From 555e5786d7001fde519a4fcdb4f1e6b482b60f08 Mon Sep 17 00:00:00 2001 From: "Jorge L. Williams" Date: Sat, 23 Apr 2011 08:02:26 -0500 Subject: Initial getTenant. --- keystone/identity2.py | 7 +++++++ keystone/logic/service.py | 8 +++++++- test/IdentitySOAPUI.xml | 20 ++++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/keystone/identity2.py b/keystone/identity2.py index af20b363..3d811eef 100644 --- a/keystone/identity2.py +++ b/keystone/identity2.py @@ -135,4 +135,11 @@ def get_tenants(): except Exception as e: return send_error (e) +@route('/v1.0/tenants/:tenant_id', method='GET') +def get_tenant(tenant_id): + try: + return send_result(service.get_tenant(get_auth_token(), tenant_id), 200) + except Exception as e: + return send_error (e) + run(host='localhost', port=8080) diff --git a/keystone/logic/service.py b/keystone/logic/service.py index 51c9c7b7..b95a08a3 100644 --- a/keystone/logic/service.py +++ b/keystone/logic/service.py @@ -121,7 +121,13 @@ class IDMService(object): return tenants.Tenants(ts,[]) def get_tenant(self, admin_token, tenant_id): - True + self.__validate_token(admin_token) + + dtenant = db_api.tenant_get(tenant_id) + if dtenant == None: + raise fault.ItemNotFoundFault("The tenant could not be found") + + return tenants.Tenant(dtenant.id, dtenant.desc, dtenant.enabled) def update_tenant(self, admin_token, tenant): if not isinstance(tenant, tenants.Tenant): diff --git a/test/IdentitySOAPUI.xml b/test/IdentitySOAPUI.xml index b5eb5acd..ee22aabe 100644 --- a/test/IdentitySOAPUI.xml +++ b/test/IdentitySOAPUI.xml @@ -1109,7 +1109,10 @@ password="P@ssword1" username="testuser" xmlns="http://docs.openstack.org/idm/api/v1.0"/>X-Auth-TokenHEADERxs:stringtenantIdTEMPLATExs:stringapplication/xml200 203v1:tenantapplication/json200 203application/xml401v1:unauthorizedapplication/xml403v1:forbiddenapplication/xml400v1:badRequestapplication/xml404v1:itemNotFoundapplication/xml500v1:idmFaultapplication/xml503v1:serviceUnavailableapplication/json400 -401 403 404 500 503http://localhost:8080application/xmlv1:tenantapplication/jsonapplication/xml200v1:tenantapplication/json200application/xml401v1:unauthorizedapplication/xml403v1:forbiddenapplication/xml404v1:itemNotFoundapplication/xml400v1:badRequestapplication/xml500v1:idmFaultapplication/xml503v1:serviceUnavailableapplication/json401 +401 403 404 500 503<xml-fragment/>http://localhost:8080 + + +application/xmlv1:tenantapplication/jsonapplication/xml200v1:tenantapplication/json200application/xml401v1:unauthorizedapplication/xml403v1:forbiddenapplication/xml404v1:itemNotFoundapplication/xml400v1:badRequestapplication/xml500v1:idmFaultapplication/xml503v1:serviceUnavailableapplication/json401 403 404 400 500 503http://localhost:8080application/xml401v1:unauthorizedapplication/xml403v1:forbiddenapplication/xml400v1:badRequestapplication/xml404v1:itemNotFoundapplication/xml500v1:idmFaultapplication/xml503v1:serviceUnavailableapplication/json400 401 403 404 500 503http://localhost:8080markerQUERYxs:stringlimitQUERYxs:intapplication/xml200 203v1:tenantsapplication/json200 @@ -1253,4 +1256,17 @@ ns1:Response/ns1:tenant/ns1:id = "JGroup65" and ns1:Response/ns1:tenant/ns1:desc } }400falsefalsebadRequestfalsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; count(//ns1:tenant)8falsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://localhost/v1.0/tenants'; -count(//ns1:e)8falsefalse \ No newline at end of file +count(//ns1:e)8falsefalse<xml-fragment/>http://localhost:8080declare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; +ns1:tenant/@id1234falsefalsedeclare namespace ns1='http://docs.openstack.org/idm/api/v1.0'; +/ns1:tenant/@enabled and /ns1:tenant/ns1:descriptiontruefalsefalse + + +<xml-fragment/>http://localhost:8080declare namespace ns1='http://localhost/v1.0/tenants/1234'; +ns1:Response/ns1:tenant/ns1:id1234falsefalsedeclare namespace ns1='http://localhost/v1.0/tenants/1234'; +/ns1:Response/ns1:tenant/ns1:enabled and /ns1:Response/ns1:tenant/ns1:descriptiontruefalsefalse + + +<xml-fragment/>http://localhost:8080404falsefalseitemNotFoundfalsefalse + + + \ No newline at end of file -- cgit