commit 8cb96389486348d0403667229d365ac54779cfc5
Author: Sofia Papagiannaki <spapagian@grnet.gr>
Date:   Mon Jun 3 15:47:10 2013 +0300

    astakos: modifications in authenticate keystone api call
    
    * change the call to utilize the updated db models
    * update tests
    * update docs

diff --git a/snf-astakos-app/astakos/im/tests/api.py b/snf-astakos-app/astakos/im/tests/api.py
index 540919e..1461854 100644
--- a/snf-astakos-app/astakos/im/tests/api.py
+++ b/snf-astakos-app/astakos/im/tests/api.py
@@ -34,10 +34,12 @@
 from astakos.im.tests.common import *
 
 from django.test import TestCase
+from django.core.urlresolvers import reverse
+
 
 from urllib import quote
 from urlparse import urlparse, parse_qs
-from xml.dom import minidom
+#from xml.dom import minidom
 
 import json
 
@@ -391,31 +393,46 @@ class TokensApiTest(TestCase):
         backend.activate_user(self.user2)
         assert self.user2.is_active is True
 
-        Service(name='service1', url='http://localhost/service1',
-                api_url='http://localhost/api/service1',
-                type='service1').save()
-        Service(name='service2', url='http://localhost/service2',
-                api_url='http://localhost/api/service2',
-                type='service2').save()
-        Service(name='service3', url='http://localhost/service3',
-                api_url='http://localhost/api/service3',
-                type='service3').save()
+        c1 = Component(name='component1', url='http://localhost/component1')
+        c1.save()
+        s1 = Service(component=c1, type='type1', name='service1')
+        s1.save()
+        e1 = Endpoint(service=s1)
+        e1.save()
+        e1.data.create(key='versionId', value='v1.0')
+        e1.data.create(key='publicURL', value='http://localhost:8000/s1/v1.0')
+
+        s2 = Service(component=c1, type='type2', name='service2')
+        s2.save()
+        e2 = Endpoint(service=s2)
+        e2.save()
+        e2.data.create(key='versionId', value='v1.0')
+        e2.data.create(key='publicURL', value='http://localhost:8000/s2/v1.0')
+
+        c2 = Component(name='component2', url='http://localhost/component2')
+        c2.save()
+        s3 = Service(component=c2, type='type3', name='service3')
+        s3.save()
+        e3 = Endpoint(service=s3)
+        e3.save()
+        e3.data.create(key='versionId', value='v2.0')
+        e3.data.create(key='publicURL', value='http://localhost:8000/s3/v2.0')
 
     def test_authenticate(self):
         client = Client()
 
         # Check not allowed method
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         r = client.get(url, post_data={})
         self.assertEqual(r.status_code, 400)
 
         # Malformed request
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         r = client.post(url, post_data={})
         self.assertEqual(r.status_code, 400)
 
         # Check unsupported xml input
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         post_data = """
             <?xml version="1.0" encoding="UTF-8"?>
                 <auth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -431,7 +448,7 @@ class TokensApiTest(TestCase):
                          "Unsupported Content-type: 'application/xml'")
 
         # Check malformed request: missing password
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         post_data = """{"auth":{"passwordCredentials":{"username":"%s"},
                                 "tenantName":"%s"}}""" % (
             self.user1.uuid, self.user1.uuid)
@@ -442,7 +459,7 @@ class TokensApiTest(TestCase):
                          'Malformed request')
 
         # Check malformed request: missing username
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         post_data = """{"auth":{"passwordCredentials":{"password":"%s"},
                                 "tenantName":"%s"}}""" % (
             self.user1.auth_token, self.user1.uuid)
@@ -453,7 +470,7 @@ class TokensApiTest(TestCase):
                          'Malformed request')
 
         # Check invalid pass
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         post_data = """{"auth":{"passwordCredentials":{"username":"%s",
                                                        "password":"%s"},
                                 "tenantName":"%s"}}""" % (
@@ -465,7 +482,7 @@ class TokensApiTest(TestCase):
                          'Invalid token')
 
         # Check inconsistent pass
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         post_data = """{"auth":{"passwordCredentials":{"username":"%s",
                                                        "password":"%s"},
                                 "tenantName":"%s"}}""" % (
@@ -477,14 +494,14 @@ class TokensApiTest(TestCase):
                          'Invalid credentials')
 
         # Check invalid json data
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         r = client.post(url, "not json", content_type='application/json')
         self.assertEqual(r.status_code, 400)
         body = json.loads(r.content)
         self.assertEqual(body['badRequest']['message'], 'Invalid JSON data')
 
         # Check auth with token
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         post_data = """{"auth":{"token": {"id":"%s"},
                         "tenantName":"%s"}}""" % (
             self.user1.auth_token, self.user1.uuid)
@@ -497,7 +514,7 @@ class TokensApiTest(TestCase):
             self.fail(e)
 
         # Check successful json response
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         post_data = """{"auth":{"passwordCredentials":{"username":"%s",
                                                        "password":"%s"},
                                 "tenantName":"%s"}}""" % (
@@ -511,9 +528,9 @@ class TokensApiTest(TestCase):
             self.fail(e)
 
         try:
-            token = body['token']['id']
-            user = body['user']['id']
-            service_catalog = body['serviceCatalog']
+            token = body['access']['token']['id']
+            user = body['access']['user']['id']
+            service_catalog = body['access']['serviceCatalog']
         except KeyError:
             self.fail('Invalid response')
 
@@ -522,7 +539,7 @@ class TokensApiTest(TestCase):
         self.assertEqual(len(service_catalog), 3)
 
         # Check successful xml response
-        url = '/astakos/api/tokens'
+        url = reverse('astakos.api.tokens.authenticate')
         headers = {'HTTP_ACCEPT': 'application/xml'}
         post_data = """{"auth":{"passwordCredentials":{"username":"%s",
                                                        "password":"%s"},
