diff --git a/plugins/tokenauth_context_condition_tokenauth.inc b/plugins/tokenauth_context_condition_tokenauth.inc
index 119c2f9..06043e1 100644
--- a/plugins/tokenauth_context_condition_tokenauth.inc
+++ b/plugins/tokenauth_context_condition_tokenauth.inc
@@ -7,8 +7,8 @@
 class tokenauth_context_condition_tokenauth extends context_condition {
   function condition_values() {
     return array(
-      1 => t('Did not use Token Authentication to log in'),
-      2 => t('Used Token Authentication to log in'),
+      TOKENAUTH_CONTEXT_NORMAL_LOGIN => t('Did not use Token Authentication to log in'),
+      TOKENAUTH_CONTEXT_TOKEN_LOGIN => t('Used Token Authentication to log in'),
     );
   }
 
diff --git a/tests/tokenauth.context.test b/tests/tokenauth.context.test
new file mode 100644
index 0000000..e659191
--- /dev/null
+++ b/tests/tokenauth.context.test
@@ -0,0 +1,47 @@
+<?php
+/**
+ * @file
+ * Test the Context.module integration for Token Authentication.
+ */
+
+class TokenauthContextTest extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Context integration',
+      'description' => 'Test context condition.',
+      'group' => 'Token Authentication',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('context', 'ctools', 'tokenauth');
+    $this->user = $this->drupalCreateUser(array('access tokenauth'));
+    $this->user->tokenauth_token = tokenauth_get_token($this->user->uid);
+
+    // Create test context.
+    ctools_include('export');
+    $this->context = ctools_export_new_object('context');
+    $this->context->name = 'testcontext';
+    $this->context->conditions = array('tokenauth' => array('values' => TOKENAUTH_CONTEXT_TOKEN_LOGIN);
+    $this->context->reactions = array('debug' => array('debug' => TRUE));
+    $saved = context_save($this->context);
+    $this->assertTrue($saved, "Context 'testcontext' saved.");
+
+    // Configure allowed paths for a context-testable location.
+    $this->tokenauth_pages = variable_get('tokenauth_pages', "rss.xml\n*/feed\n*/opml");
+    variable_set('tokenauth_pages', '<front>');
+  }
+
+  function tearDown() {
+    parent::tearDown();
+    context_delete($this->context);
+    user_delete($this->user->uid);
+    variable_set('tokenauth_pages', $this->tokenauth_pages);
+  }
+
+  function test() {
+    $this->drupalGet('<front>', array('query' => array('token' => $this->user->tokenauth_token)));
+    $this->assertText('Active context: testcontext');
+  }
+}
+
diff --git a/tokenauth.module b/tokenauth.module
index 1719cea..fa39f10 100644
--- a/tokenauth.module
+++ b/tokenauth.module
@@ -5,6 +5,9 @@
  * Provides URL variable-based authentication to allowed pages.
  */
 
+define ('TOKENAUTH_CONTEXT_NORMAL_LOGIN', 1);
+define ('TOKENAUTH_CONTEXT_TOKEN_LOGIN', 2);
+
 include_once('tokenauth.inc');
 
 /**
