commit 8f377cd6136dc8f20489d3769465a293fb5faa51
Author: Georgios Gousios <gousiosg@gmail.com>
Date:   Tue Apr 12 14:38:38 2011 +0300

    Shortcut in the aai module to make tests pass
    
    Introduces a test-time runtime variable which allows REST-based (e.g.
    api) tests to pass through the authentication module

diff --git a/aai/tests.py b/aai/tests.py
index 2cf0365..b578c0d 100644
--- a/aai/tests.py
+++ b/aai/tests.py
@@ -1,7 +1,7 @@
 #
-# Unit Tests for api
+# Unit Tests for aai
 #
-# Provides automated tests for api module
+# Provides automated tests for aai module. The tests
 #
 # Copyright 2011 Greek Research and Technology Network
 #
@@ -10,7 +10,7 @@ from django.test import TestCase
 from django.test.client import Client
 from django.conf import settings
 
-from synnefo.logic.shibboleth import Tokens, NoUniqueToken
+from synnefo.aai.shibboleth import Tokens, NoUniqueToken
 from synnefo.db.models import SynnefoUser
 
 from datetime import datetime, timedelta
@@ -28,7 +28,8 @@ class AuthTestCase(TestCase):
         response = self.client.get(self.apibase + '/servers', {},
                                    **{Tokens.SIB_GIVEN_NAME: 'Jimmy',
                                       Tokens.SIB_EDU_PERSON_PRINCIPAL_NAME: 'jh@gmail.com',
-                                      Tokens.SIB_DISPLAY_NAME: 'Jimmy Hendrix'})
+                                      Tokens.SIB_DISPLAY_NAME: 'Jimmy Hendrix',
+                                      'TEST-AAI' : 'true'})
         user = None
         try:
             user = SynnefoUser.objects.get(uniq = "jh@gmail.com")
@@ -45,7 +46,8 @@ class AuthTestCase(TestCase):
         """
         response = self.client.get(self.apibase + '/servers', {},
                                     **{Tokens.SIB_GIVEN_NAME: 'Jimmy',
-                                    Tokens.SIB_DISPLAY_NAME: 'Jimmy Hendrix'})
+                                    Tokens.SIB_DISPLAY_NAME: 'Jimmy Hendrix',
+                                    'TEST-AAI' : 'true'})
         self._test_redirect(response)
 
     def test_shibboleth_wrong_from_request(self):
@@ -56,7 +58,8 @@ class AuthTestCase(TestCase):
                                       Tokens.SIB_EDU_PERSON_PRINCIPAL_NAME: 'jh@gmail.com',
                                       Tokens.SIB_DISPLAY_NAME: 'Jimmy Hendrix',
                                       'REMOTE_ADDR': '1.2.3.4',
-                                      'SERVER_NAME': 'nohost.nodomain'})
+                                      'SERVER_NAME': 'nohost.nodomain',
+                                      'TEST-AAI' : 'true'})
         self._test_redirect(response)
 
     def test_shibboleth_expired_token(self):
@@ -66,13 +69,14 @@ class AuthTestCase(TestCase):
         self.assertNotEqual(user.auth_token_created, None)
         self._update_user_ts(user)
         response = self.client.get(self.apibase + '/servers', {},
-                                   **{'X-Auth-Token': user.auth_token})
+                                   **{'X-Auth-Token': user.auth_token,
+                                      'TEST-AAI' : 'true'})
         self._test_redirect(response)
 
     def test_shibboleth_redirect(self):
         """ test redirect to Sibboleth page
         """
-        response = self.client.get(self.apibase + '/servers')
+        response = self.client.get(self.apibase + '/servers', {}, **{'TEST-AAI' : 'true'})
         self._test_redirect(response)
 
     def test_shibboleth_auth(self):
@@ -80,7 +84,8 @@ class AuthTestCase(TestCase):
         """
         user = SynnefoUser.objects.get(uniq = "test@synnefo.gr")
         response = self.client.get(self.apibase + '/servers', {},
-                                   **{'X-Auth-Token': user.auth_token})
+                                   **{'X-Auth-Token': user.auth_token,
+                                      'TEST-AAI' : 'true'})
         self.assertTrue(response.status_code, 200)
         self.assertTrue('Vary' in response)
         self.assertTrue('X-Auth-Token' in response['Vary'])
@@ -90,7 +95,8 @@ class AuthTestCase(TestCase):
         """
         response = self.client.get(self.apibase + '/servers', {},
                                    **{'X-Auth-User': 'notme',
-                                      'X-Auth-Key': '0xdeadbabe'})
+                                      'X-Auth-Key': '0xdeadbabe',
+                                      'TEST-AAI' : 'true'})
         self.assertEquals(response.status_code, 401)
 
     def test_oapi_auth(self):
@@ -98,7 +104,8 @@ class AuthTestCase(TestCase):
         """
         response = self.client.get(self.apibase + '/', {},
                                    **{'X-Auth-User': 'testdbuser',
-                                      'X-Auth-Key': 'test@synnefo.gr'})
+                                      'X-Auth-Key': 'test@synnefo.gr',
+                                      'TEST-AAI' : 'true'})
         self.assertEquals(response.status_code, 204)
         self.assertNotEqual(response['X-Auth-Token'], None)
         self.assertEquals(response['X-Server-Management-Url'], '')
@@ -114,3 +121,5 @@ class AuthTestCase(TestCase):
         user.auth_token_created = (datetime.now() -
                                    timedelta(hours = settings.AUTH_TOKEN_DURATION))
         user.save()
+
+    
\ No newline at end of file
