commit 17fc7729dd05af39127294f00c452a0e7ee61278
Author: Georgios Gousios <gousiosg@gmail.com>
Date:   Fri Apr 1 09:52:03 2011 +0300

    Move authentication tests and code to logic

diff --git a/auth/fixtures/auth_test_data.json b/auth/fixtures/auth_test_data.json
deleted file mode 100644
index 4581808..0000000
--- a/auth/fixtures/auth_test_data.json
+++ /dev/null
@@ -1,10 +0,0 @@
-[
-    {
-        "model": "db.SynnefoUser",
-        "pk": 1,
-        "fields": {
-            "name": 1,
-            "credit": 1024
-        }
-    }
-]
\ No newline at end of file
diff --git a/auth/tests.py b/auth/tests.py
index 79b48e0..e69de29 100644
--- a/auth/tests.py
+++ b/auth/tests.py
@@ -1,43 +0,0 @@
-#
-# Unit Tests for auth api
-#
-# Provides automated tests for api module
-#
-# Copyright 2011 Greek Research and Technology Network
-#
-
-from django.test import TestCase
-from django.test.client import Client
-
-class AuthTestCase(TestCase):
-    fixtures = ['api_test_data', 'auth_test_data']
-    apibase = '/api/v1.0'
-
-    def setUp(self):
-        self.client = Client()
-
-
-    def test_auth_headers(self):
-        """ test whether the authentication mechanism sets the correct headers
-        """
-        #Check with non-existing user
-        response = self.client.get( self.apibase + '/servers', {},
-                                   **{'X-Auth-User':'notme',
-                                      'X-Auth-Key':'0xdeadbabe'})
-        self.assertEquals(response.status_code, 401)
-
-        #Check with existing user
-        response = self.client.get( self.apibase + '/', {},
-                                   **{'X-Auth-User':'testuser',
-                                      'X-Auth-Key':'testuserpasswd'})
-        self.assertEquals(response.status_code, 204)
-        self.assertNotEqual(response['X-Auth-Token'], None)
-        self.assertEquals(response['X-Server-Management-Url'], '')
-        self.assertEquals(response['X-Storage-Url'], '')
-        self.assertEquals(response['X-CDN-Management-Url'], '')
-
-        #Check access now that we do have an auth token
-        token = response['X-Auth-Token']
-        response = self.client.get (self.apibase + '/servers/detail', {},
-                                   **{'X-Auth-Token': token})
-        self.assertEquals(response.status_code, 200)
\ No newline at end of file
diff --git a/logic/fixtures/auth_test_data.json b/logic/fixtures/auth_test_data.json
new file mode 100644
index 0000000..4581808
--- /dev/null
+++ b/logic/fixtures/auth_test_data.json
@@ -0,0 +1,10 @@
+[
+    {
+        "model": "db.SynnefoUser",
+        "pk": 1,
+        "fields": {
+            "name": 1,
+            "credit": 1024
+        }
+    }
+]
\ No newline at end of file
diff --git a/logic/tests.py b/logic/tests.py
index e465534..f47abda 100644
--- a/logic/tests.py
+++ b/logic/tests.py
@@ -99,3 +99,35 @@ class DebitAccountTestCase(TestCase):
         s_user = SynnefoUser.objects.get(pk=30000)
 
         self.assertEqual(0, s_user.credit, 'SynnefoUser (pk=30000) should have zero credits (%d)' % ( s_user.credit, ))
+
+class AuthTestCase(TestCase):
+    fixtures = ['api_test_data', 'auth_test_data']
+    apibase = '/api/v1.0'
+
+    def setUp(self):
+        self.client = Client()
+
+    def test_auth_headers(self):
+        """ test whether the authentication mechanism sets the correct headers
+        """
+        #Check with non-existing user
+        response = self.client.get( self.apibase + '/servers', {},
+                                   **{'X-Auth-User':'notme',
+                                      'X-Auth-Key':'0xdeadbabe'})
+        self.assertEquals(response.status_code, 401)
+
+        #Check with existing user
+        response = self.client.get( self.apibase + '/', {},
+                                   **{'X-Auth-User':'testuser',
+                                      'X-Auth-Key':'testuserpasswd'})
+        self.assertEquals(response.status_code, 204)
+        self.assertNotEqual(response['X-Auth-Token'], None)
+        self.assertEquals(response['X-Server-Management-Url'], '')
+        self.assertEquals(response['X-Storage-Url'], '')
+        self.assertEquals(response['X-CDN-Management-Url'], '')
+
+        #Check access now that we do have an auth token
+        token = response['X-Auth-Token']
+        response = self.client.get (self.apibase + '/servers/detail', {},
+                                   **{'X-Auth-Token': token})
+        self.assertEquals(response.status_code, 200)
