diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-06-13 13:23:29 -0500 |
|---|---|---|
| committer | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-06-13 13:23:29 -0500 |
| commit | f0567818f3e86357dca815fa2cc0d7a7647d5e4d (patch) | |
| tree | 6035d1bef00b912de4f73276bb25320efe6ec991 /test | |
| parent | 59d9bb49649a3c2de6122e0461ad5d9298b1fd85 (diff) | |
| parent | ef2033be3411ade4e43225de0995fa27baa378fc (diff) | |
Merge branch 'master' of git://github.com/rackspace/keystone
Conflicts:
keystone/test/functional/test_tokens.py
Diffstat (limited to 'test')
28 files changed, 0 insertions, 10551 deletions
diff --git a/test/EchoSOAPUI.xml b/test/EchoSOAPUI.xml deleted file mode 100644 index 8a74eee0..00000000 --- a/test/EchoSOAPUI.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<con:soapui-project name="Echo" resourceRoot="" soapui-version="3.6.1" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings/><con:interface xsi:type="con:RestService" wadlVersion="http://wadl.dev.java.net/2009/02" name="Echo" type="rest" basePath="" definitionUrl="file:/Users/jorgew/projects/keystone/echo/echo.wadl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache/><con:endpoints><con:endpoint>http://localhost:8090</con:endpoint></con:endpoints><con:resource name="/" path="/"><con:settings/><con:parameters><con:parameter required="true"><con:name>X-Auth-Token</con:name><con:value xsi:nil="true"/><con:style>HEADER</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type><con:default xsi:nil="true"/></con:parameter></con:parameters><con:method name="GET - get" method="GET"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>*/*</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/echo/api/v1.0">v1:echo</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="*/*"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8090</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:request></con:method><con:method name="PUT - put" method="PUT"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>*/*</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/echo/api/v1.0">v1:echo</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1"><con:settings/><con:endpoint>http://localhost:8090</con:endpoint><con:parameters/></con:request></con:method><con:method name="POST - post" method="POST"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>*/*</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/echo/api/v1.0">v1:echo</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1"><con:settings/><con:endpoint>http://localhost:8090</con:endpoint><con:parameters/></con:request></con:method><con:method name="DELETE - delete" method="DELETE"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>*/*</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/echo/api/v1.0">v1:echo</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1"><con:settings/><con:endpoint>http://localhost:8090</con:endpoint><con:parameters/></con:request></con:method><con:method name="HEAD - head" method="HEAD"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>*/*</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/echo/api/v1.0">v1:echo</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1"><con:settings/><con:endpoint>http://localhost:8090</con:endpoint><con:parameters/></con:request></con:method><con:method name="OPTIONS - options" method="OPTIONS"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>*/*</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/echo/api/v1.0">v1:echo</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1"><con:settings/><con:endpoint>http://localhost:8090</con:endpoint><con:parameters/></con:request></con:method></con:resource></con:interface><con:properties/><con:wssContainer/><con:databaseConnectionContainer/><con:reporting><con:xmlTemplates/><con:parameters/></con:reporting></con:soapui-project>
\ No newline at end of file diff --git a/test/IdentitySOAPUI.xml b/test/IdentitySOAPUI.xml deleted file mode 100644 index 3cf2984e..00000000 --- a/test/IdentitySOAPUI.xml +++ /dev/null @@ -1,1355 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<con:soapui-project name="Keystone" resourceRoot="" soapui-version="3.6.1" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.actions.iface.tools.soapui.TestRunnerAction@values-local"><![CDATA[<xml-fragment xmlns:con="http://eviware.com/soapui/config"> - <con:entry key="Global Properties" value=""/> - <con:entry key="TestSuite" value="Keystone Tests"/> - <con:entry key="Report to Generate" value=""/> - <con:entry key="Password" value=""/> - <con:entry key="soapui-setings.xml Password" value=""/> - <con:entry key="TestRunner Path" value=""/> - <con:entry key="Tool Args" value=""/> - <con:entry key="Ignore Errors" value="false"/> - <con:entry key="Host:Port" value=""/> - <con:entry key="WSS Password Type" value=""/> - <con:entry key="Save Project" value="false"/> - <con:entry key="Enable UI" value="true"/> - <con:entry key="System Properties" value=""/> - <con:entry key="Domain" value=""/> - <con:entry key="Coverage Report" value="false"/> - <con:entry key="Export JUnit Results" value="false"/> - <con:entry key="Open Report" value="false"/> - <con:entry key="Project Properties" value=""/> - <con:entry key="Project Password" value=""/> - <con:entry key="Export All" value="false"/> - <con:entry key="Report Format(s)" value=""/> - <con:entry key="TestCase" value="<all>"/> - <con:entry key="Print Report" value="false"/> - <con:entry key="Username" value=""/> - <con:entry key="Root Folder" value=""/> - <con:entry key="Save After" value="false"/> - <con:entry key="Add Settings" value="false"/> - <con:entry key="Endpoint" value=""/> -</xml-fragment>]]></con:setting></con:settings><con:interface xsi:type="con:RestService" wadlVersion="http://wadl.dev.java.net/2009/02" name="Keystone" type="rest" basePath="" definitionUrl="file:/Users/jorgew/projects/keystone/keystone/identity.wadl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="file:/Users/jorgew/projects/keystone/keystone/identity.wadl"><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/identity.wadl</con:url><con:content><![CDATA[<application xsi:schemaLocation="http://docs.openstack.org/identity/api/v2.0 xsd/api.xsd http://docs.openstack.org/common/api/v1.0 xsd/api-common.xsd " xmlns="http://wadl.dev.java.net/2009/02" xmlns:identity="http://docs.openstack.org/identity/api/v2.0" xmlns:capi="http://docs.openstack.org/common/api/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <grammars> - <include href="xsd/api.xsd"/> - <include href="xsd/api-common.xsd"/> - </grammars> - <!--We should use SSL in production--> - <resources base="http://localhost:8080"> - <resource id="version" path="v1.0"> - <method href="#getVersionInfo"/> - <resource id="extensions" path="extensions"> - <method href="#getExtensions"/> - <resource id="alias" path="{alias}"> - <param name="alias" style="template" type="xsd:string"/> - <method href="#getExtension"/> - </resource> - </resource> - <resource id="token" path="token"> - <method href="#authenticate"/> - <resource id="tokenId" path="{tokenId}"> - <param name="X-Auth-Token" style="header" type="xsd:string" required="true"/> - <param name="tokenId" style="template" type="xsd:string"/> - <method href="#validateToken"/> - <method href="#revokeToken"/> - </resource> - </resource> - <resource id="tenants" path="tenants"> - <param name="X-Auth-Token" style="header" type="xsd:string" required="true"/> - <method href="#getTenants"/> - <method href="#createTenant"/> - <resource id="tenantId" path="{tenantId}"> - <param name="tenantId" style="template" type="xsd:string"/> - <method href="#getTenant"/> - <method href="#updateTenant"/> - <method href="#deleteTenant"/> - </resource> - </resource> - </resource> - </resources> - <!--Extensions--> - <method name="GET" id="getExtensions"> - <response status="200 203"> - <representation mediaType="application/xml" element="capi:extensions"/> - <representation mediaType="application/json"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="400 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <method name="GET" id="getExtension"> - <response status="200 203"> - <representation mediaType="application/xml" element="capi:extension"/> - <representation mediaType="application/json"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="404"> - <representation mediaType="application/xml" element="identity:itemNotFound"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="400 404 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <!--Version Info--> - <method name="GET" id="getVersionInfo"> - <response status="200 203"> - <representation mediaType="application/xml" element="capi:version"/> - <representation mediaType="application/json"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="400 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <!--Token Operations--> - <method name="POST" id="authenticate"> - <request> - <representation mediaType="application/xml" element="identity:passwordCredentials"/> - <representation mediaType="application/json"/> - </request> - <response status="200 203"> - <representation mediaType="application/xml" element="identity:auth"/> - <representation mediaType="application/json"/> - </response> - <response status="401"> - <representation mediaType="application/xml" element="identity:unauthorized"/> - </response> - <response status="403"> - <representation mediaType="application/xml" element="identity:userDisabled"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="401 403 400 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <method name="GET" id="validateToken"> - <request> - <param name="belongsTo" style="query" required="false" type="xsd:string"/> - </request> - <response status="200 203"> - <representation mediaType="application/xml" element="identity:auth"/> - <representation mediaType="application/json"/> - </response> - <response status="401"> - <representation mediaType="application/xml" element="identity:unauthorized"/> - </response> - <response status="403"> - <representation mediaType="application/xml" element="identity:forbidden"/> - <representation mediaType="application/xml" element="identity:userDisabled"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="404"> - <representation mediaType="application/xml" element="identity:itemNotFound"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="400 401 403 404 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <method name="DELETE" id="revokeToken"> - <response status="204"/> - <response status="401"> - <representation mediaType="application/xml" element="identity:unauthorized"/> - </response> - <response status="403"> - <representation mediaType="application/xml" element="identity:forbidden"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="404"> - <representation mediaType="application/xml" element="identity:itemNotFound"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="400 401 403 404 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <!--Tenant Operations--> - <method name="GET" id="getTenants"> - <request> - <param name="marker" style="query" required="false" type="xsd:string"/> - <param name="limit" style="query" required="false" type="xsd:int"/> - </request> - <response status="200 203"> - <representation mediaType="application/xml" element="identity:tenants"/> - <representation mediaType="application/json"/> - </response> - <response status="401"> - <representation mediaType="application/xml" element="identity:unauthorized"/> - </response> - <response status="403"> - <representation mediaType="application/xml" element="identity:forbidden"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="404"> - <representation mediaType="application/xml" element="identity:itemNotFound"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="400 401 403 404 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <method name="POST" id="createTenant"> - <request> - <representation mediaType="application/xml" element="identity:tenant"/> - <representation mediaType="application/json"/> - </request> - <response status="201"> - <representation mediaType="application/xml" element="identity:tenant"/> - <representation mediaType="application/json"/> - </response> - <response status="401"> - <representation mediaType="application/xml" element="identity:unauthorized"/> - </response> - <response status="403"> - <representation mediaType="application/xml" element="identity:forbidden"/> - </response> - <response status="409"> - <representation mediaType="application/xml" element="identity:tenantConflict"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="401 403 400 409 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <method name="GET" id="getTenant"> - <response status="200 203"> - <representation mediaType="application/xml" element="identity:tenant"/> - <representation mediaType="application/json"/> - </response> - <response status="401"> - <representation mediaType="application/xml" element="identity:unauthorized"/> - </response> - <response status="403"> - <representation mediaType="application/xml" element="identity:forbidden"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="404"> - <representation mediaType="application/xml" element="identity:itemNotFound"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="400 401 403 404 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <method name="PUT" id="updateTenant"> - <request> - <representation mediaType="application/xml" element="identity:tenant"/> - <representation mediaType="application/json"/> - </request> - <response status="200"> - <representation mediaType="application/xml" element="identity:tenant"/> - <representation mediaType="application/json"/> - </response> - <response status="401"> - <representation mediaType="application/xml" element="identity:unauthorized"/> - </response> - <response status="403"> - <representation mediaType="application/xml" element="identity:forbidden"/> - </response> - <response status="404"> - <representation mediaType="application/xml" element="identity:itemNotFound"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="401 403 404 400 500 503"> - <representation mediaType="application/json"/> - </response> - </method> - <method name="DELETE" id="deleteTenant"> - <response status="204"/> - <response status="401"> - <representation mediaType="application/xml" element="identity:unauthorized"/> - </response> - <response status="403"> - <representation mediaType="application/xml" element="identity:forbidden"/> - </response> - <response status="400"> - <representation mediaType="application/xml" element="identity:badRequest"/> - </response> - <response status="404"> - <representation mediaType="application/xml" element="identity:itemNotFound"/> - </response> - <response status="500"> - <representation mediaType="application/xml" element="identity:identityFault"/> - </response> - <response status="503"> - <representation mediaType="application/xml" element="identity:serviceUnavailable"/> - </response> - <response status="400 401 403 404 500 503"> - <representation mediaType="application/json"/> - </response> - </method> -</application>]]></con:content><con:type>http://wadl.dev.java.net/2009/02</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/api.xsd</con:url><con:content><schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://docs.openstack.org/identity/api/v2.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:identity="http://docs.openstack.org/identity/api/v2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <include schemaLocation="token.xsd"/> - <include schemaLocation="tenant.xsd"/> - <include schemaLocation="fault.xsd"/> -</schema></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/token.xsd</con:url><con:content><![CDATA[<schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://docs.openstack.org/identity/api/v2.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:identity="http://docs.openstack.org/identity/api/v2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <!--Elements--> - <element name="passwordCredentials" type="identity:PasswordCredentials"/> - <element name="auth" type="identity:AuthData"/> - <!--Complex Types--> - <complexType name="Credentials" abstract="true"/> - <complexType name="PasswordCredentials"> - <complexContent> - <extension base="identity:Credentials"> - <sequence> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="password" type="xsd:string" use="required"/> - <attribute name="username" type="xsd:string" use="required"/> - <attribute name="tenantId" type="xsd:string" use="optional"/> - <anyAttribute namespace="##other" processContents="lax"/> - </extension> - </complexContent> - </complexType> - <complexType name="AuthData"> - <sequence> - <element name="token" type="identity:Token"/> - <element name="user" type="identity:User"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <anyAttribute namespace="##other" processContents="lax"/> - </complexType> - <complexType name="Token"> - <sequence> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="expires" type="xsd:dateTime" use="required"/> - <attribute name="id" type="xsd:string" use="required"/> - <anyAttribute namespace="##other" processContents="lax"/> - </complexType> - <complexType name="User"> - <sequence> - <element name="groups" type="identity:Groups"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="tenantId" type="xsd:string"/> - <attribute name="username" type="xsd:string"/> - <anyAttribute namespace="##other" processContents="lax"/> - </complexType> - <complexType name="Groups"> - <sequence> - <element name="group" type="identity:Group" maxOccurs="1000"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <anyAttribute namespace="##other" processContents="lax"/> - </complexType> - <complexType name="Group"> - <attribute name="id" type="xsd:string" use="required"/> - <attribute name="tenantId" type="xsd:string" use="optional"/> - <anyAttribute namespace="##other" processContents="lax"/> - </complexType> -</schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/tenant.xsd</con:url><con:content><![CDATA[<schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://docs.openstack.org/identity/api/v2.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:identity="http://docs.openstack.org/identity/api/v2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" xmlns:atom="http://www.w3.org/2005/Atom"> - <!--Import ATOM specific schema definitions--> - <import vc:minVersion="1.1" namespace="http://www.w3.org/2005/Atom" schemaLocation="./atom/atom.xsd"/> - <!--Elements--> - <element name="tenant" type="identity:Tenant"/> - <element name="tenants" type="identity:Tenants"/> - <!--Complex Types--> - <complexType name="Tenants"> - <sequence> - <element name="tenant" type="identity:Tenant" maxOccurs="1000"/> - <element vc:minVersion="1.1" ref="atom:link" minOccurs="0" maxOccurs="unbounded"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <anyAttribute namespace="##other" processContents="lax"/> - </complexType> - <complexType name="Tenant"> - <sequence> - <element name="description" type="xsd:string"/> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="enabled" type="xsd:boolean" use="optional" default="true"/> - <attribute name="id" type="xsd:string" use="optional"/> - <anyAttribute namespace="##other" processContents="lax"/> - </complexType> -</schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/atom/atom.xsd</con:url><con:content><![CDATA[<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.w3.org/2005/Atom" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/> - <xs:simpleType name="relation"> - <xs:restriction base="xs:string"> - <xs:enumeration value="alternate"/> - <xs:enumeration value="appendix"/> - <xs:enumeration value="archives"/> - <xs:enumeration value="author"/> - <xs:enumeration value="bookmark"/> - <xs:enumeration value="chapter"/> - <xs:enumeration value="contents"/> - <xs:enumeration value="copyright"/> - <xs:enumeration value="current"/> - <xs:enumeration value="describedby"/> - <xs:enumeration value="edit"/> - <xs:enumeration value="edit-media"/> - <xs:enumeration value="first"/> - <xs:enumeration value="glossary"/> - <xs:enumeration value="help"/> - <xs:enumeration value="hub"/> - <xs:enumeration value="icon"/> - <xs:enumeration value="index"/> - <xs:enumeration value="last"/> - <xs:enumeration value="latest-version"/> - <xs:enumeration value="license"/> - <xs:enumeration value="monitor"/> - <xs:enumeration value="monitor-group"/> - <xs:enumeration value="next"/> - <xs:enumeration value="next-arvhice"/> - <xs:enumeration value="nofollow"/> - <xs:enumeration value="payment"/> - <xs:enumeration value="predecessor-version"/> - <xs:enumeration value="prefetch"/> - <xs:enumeration value="prev"/> - <xs:enumeration value="previous"/> - <xs:enumeration value="prev-archive"/> - <xs:enumeration value="replies"/> - <xs:enumeration value="search"/> - <xs:enumeration value="section"/> - <xs:enumeration value="self"/> - <xs:enumeration value="service"/> - <xs:enumeration value="start"/> - <xs:enumeration value="stylesheet"/> - <xs:enumeration value="subsection"/> - <xs:enumeration value="successor-version"/> - <xs:enumeration value="up"/> - <xs:enumeration value="version-history"/> - <xs:enumeration value="via"/> - <xs:enumeration value="working-copy"/> - <xs:enumeration value="working-copy-of"/> - </xs:restriction> - </xs:simpleType> - <xs:element name="link" type="atom:link"/> - <xs:complexType name="link"> - <xs:annotation> - <xs:documentation> - <html:p> - See section 3.4 of the ATOM RFC - <html:a href="http://tools.ietf.org/html/rfc4287">RFC4287</html:a> - </html:p> - </xs:documentation> - </xs:annotation> - <xs:attribute name="rel" use="required" type="atom:relation"> - <xs:annotation> - <xs:documentation> - <html:p>TODO</html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="type" use="optional" type="xs:string"> - <xs:annotation> - <xs:documentation> - <html:p>TODO</html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="href" use="required" type="xs:anyURI"> - <xs:annotation> - <xs:documentation> - <html:p>TODO</html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="hreflang" use="optional" type="xs:NMTOKEN"> - <xs:annotation> - <xs:documentation> - <html:p>TODO</html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="title" use="optional" type="xs:string"> - <xs:annotation> - <xs:documentation> - <html:p>TODO</html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute ref="xml:base"/> - <xs:attribute ref="xml:lang"/> - </xs:complexType> -</xs:schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/atom/xml.xsd</con:url><con:content><![CDATA[<?xml-stylesheet href="../2008/09/xsd.xsl" type="text/xsl"?> -<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xml:lang="en" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/1999/xhtml"> - <xs:annotation> - <xs:documentation> - <div> - <h1>About the XML namespace</h1> - <div class="bodytext"> - <p>This schema document describes the XML namespace, in a form - suitable for import by other schema documents.</p> - <p> - See - <a href="http://www.w3.org/XML/1998/namespace.html">http://www.w3.org/XML/1998/namespace.html</a> - and - <a href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</a> - for information - about this namespace. - </p> - <p>Note that local names in this namespace are intended to be - defined only by the World Wide Web Consortium or its subgroups. - The names currently defined in this namespace are listed below. - They should not be used with conflicting semantics by any Working - Group, specification, or document instance.</p> - <p> - See further below in this document for more information about - <a href="#usage">how to refer to this schema document from your own - XSD schema documents</a> - and about - <a href="#nsversioning">the - namespace-versioning policy governing this schema document</a> - . - </p> - </div> - </div> - </xs:documentation> - </xs:annotation> - <xs:attribute name="lang"> - <xs:annotation> - <xs:documentation> - <div> - <h3>lang (as an attribute name)</h3> - <p>denotes an attribute whose value - is a language code for the natural language of the content of - any element; its value is inherited. This name is reserved - by virtue of its definition in the XML specification.</p> - </div> - <div> - <h4>Notes</h4> - <p>Attempting to install the relevant ISO 2- and 3-letter - codes as the enumerated possible values is probably never - going to be a realistic possibility.</p> - <p> - See BCP 47 at - <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">http://www.rfc-editor.org/rfc/bcp/bcp47.txt</a> - and the IANA language subtag registry at - <a href="http://www.iana.org/assignments/language-subtag-registry">http://www.iana.org/assignments/language-subtag-registry</a> - for further information. - </p> - <p>The union allows for the 'un-declaration' of xml:lang with - the empty string.</p> - </div> - </xs:documentation> - </xs:annotation> - <xs:simpleType> - <xs:union memberTypes="xs:language"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value=""/> - </xs:restriction> - </xs:simpleType> - </xs:union> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="space"> - <xs:annotation> - <xs:documentation> - <div> - <h3>space (as an attribute name)</h3> - <p>denotes an attribute whose - value is a keyword indicating what whitespace processing - discipline is intended for the content of the element; its - value is inherited. This name is reserved by virtue of its - definition in the XML specification.</p> - </div> - </xs:documentation> - </xs:annotation> - <xs:simpleType> - <xs:restriction base="xs:NCName"> - <xs:enumeration value="default"/> - <xs:enumeration value="preserve"/> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="base" type="xs:anyURI"> - <xs:annotation> - <xs:documentation> - <div> - <h3>base (as an attribute name)</h3> - <p>denotes an attribute whose value - provides a URI to be used as the base for interpreting any - relative URIs in the scope of the element on which it - appears; its value is inherited. This name is reserved - by virtue of its definition in the XML Base specification.</p> - <p> - See - <a href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/</a> - for information about this attribute. - </p> - </div> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="id" type="xs:ID"> - <xs:annotation> - <xs:documentation> - <div> - <h3>id (as an attribute name)</h3> - <p>denotes an attribute whose value - should be interpreted as if declared to be of type ID. - This name is reserved by virtue of its definition in the - xml:id specification.</p> - <p> - See - <a href="http://www.w3.org/TR/xml-id/">http://www.w3.org/TR/xml-id/</a> - for information about this attribute. - </p> - </div> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attributeGroup name="specialAttrs"> - <xs:attribute ref="xml:base"/> - <xs:attribute ref="xml:lang"/> - <xs:attribute ref="xml:space"/> - <xs:attribute ref="xml:id"/> - </xs:attributeGroup> - <xs:annotation> - <xs:documentation> - <div> - <h3>Father (in any context at all)</h3> - <div class="bodytext"> - <p>denotes Jon Bosak, the chair of - the original XML Working Group. This name is reserved by - the following decision of the W3C XML Plenary and - XML Coordination groups:</p> - <blockquote> - <p>In appreciation for his vision, leadership and - dedication the W3C XML Plenary on this 10th day of - February, 2000, reserves for Jon Bosak in perpetuity - the XML name "xml:Father".</p> - </blockquote> - </div> - </div> - </xs:documentation> - </xs:annotation> - <xs:annotation> - <xs:documentation> - <div xml:id="usage" id="usage"> - <h2> - <a name="usage">About this schema document</a> - </h2> - <div class="bodytext"> - <p> - This schema defines attributes and an attribute group suitable - for use by schemas wishing to allow - <code>xml:base</code> - , - <code>xml:lang</code> - , - <code>xml:space</code> - or - <code>xml:id</code> - attributes on elements they define. - </p> - <p>To enable this, such a schema must import this schema for - the XML namespace, e.g. as follows:</p> - <pre><schema . . .> - . . . - <import namespace="http://www.w3.org/XML/1998/namespace" - schemaLocation="http://www.w3.org/2001/xml.xsd"/></pre> - <p>or</p> - <pre><import namespace="http://www.w3.org/XML/1998/namespace" - schemaLocation="http://www.w3.org/2009/01/xml.xsd"/></pre> - <p>Subsequently, qualified reference to any of the attributes or the - group defined below will have the desired effect, e.g.</p> - <pre><type . . .> - . . . - <attributeGroup ref="xml:specialAttrs"/></pre> - <p>will define a type which will schema-validate an instance element - with any of those attributes.</p> - </div> - </div> - </xs:documentation> - </xs:annotation> - <xs:annotation> - <xs:documentation> - <div id="nsversioning" xml:id="nsversioning"> - <h2> - <a name="nsversioning">Versioning policy for this schema document</a> - </h2> - <div class="bodytext"> - <p> - In keeping with the XML Schema WG's standard versioning - policy, this schema document will persist at - <a href="http://www.w3.org/2009/01/xml.xsd">http://www.w3.org/2009/01/xml.xsd</a> - . - </p> - <p> - At the date of issue it can also be found at - <a href="http://www.w3.org/2001/xml.xsd">http://www.w3.org/2001/xml.xsd</a> - . - </p> - <p> - The schema document at that URI may however change in the future, - in order to remain compatible with the latest version of XML - Schema itself, or with the XML namespace itself. In other words, - if the XML Schema or XML namespaces change, the version of this - document at - <a href="http://www.w3.org/2001/xml.xsd">http://www.w3.org/2001/xml.xsd</a> - will change accordingly; the version at - <a href="http://www.w3.org/2009/01/xml.xsd">http://www.w3.org/2009/01/xml.xsd</a> - will not change. - </p> - <p>Previous dated (and unchanging) versions of this schema - document are at:</p> - <ul> - <li> - <a href="http://www.w3.org/2009/01/xml.xsd">http://www.w3.org/2009/01/xml.xsd</a> - </li> - <li> - <a href="http://www.w3.org/2007/08/xml.xsd">http://www.w3.org/2007/08/xml.xsd</a> - </li> - <li> - <a href="http://www.w3.org/2004/10/xml.xsd">http://www.w3.org/2004/10/xml.xsd</a> - </li> - <li> - <a href="http://www.w3.org/2001/03/xml.xsd">http://www.w3.org/2001/03/xml.xsd</a> - </li> - </ul> - </div> - </div> - </xs:documentation> - </xs:annotation> -</xs:schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/fault.xsd</con:url><con:content><![CDATA[<schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://docs.openstack.org/identity/api/v2.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:identity="http://docs.openstack.org/identity/api/v2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <!--Fault Elements--> - <element name="identityFault" type="identity:IdentityFault"/> - <element name="serviceUnavailable" type="identity:ServiceUnavailableFault"/> - <element name="badRequest" type="identity:BadRequestFault"/> - <element name="unauthorized" type="identity:UnauthorizedFault"/> - <element name="overLimit" type="identity:OverLimitFault"/> - <element name="userDisabled" type="identity:UserDisabledFault"/> - <element name="forbidden" type="identity:ForbiddenFault"/> - <element name="itemNotFound" type="identity:ItemNotFoundFault"/> - <element name="tenantConflict" type="identity:TenantConflictFault"/> - <!--Fault Types--> - <complexType name="IdentityFault"> - <sequence> - <element name="message" type="xsd:string"> - <annotation> - <xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <p>A human readable message that is appropriate for display - to the end user.</p> - </xsd:documentation> - </annotation> - </element> - <element name="details" type="xsd:string" minOccurs="0"> - <annotation> - <xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <p>The optional <details> element may contain useful - information for tracking down errors (e.g a stack - trace). This information may or may not be appropriate - for display to an end user.</p> - </xsd:documentation> - </annotation> - </element> - <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </sequence> - <attribute name="code" type="xsd:int" use="required"> - <annotation> - <xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <p>The HTTP status code associated with the current fault.</p> - </xsd:documentation> - </annotation> - </attribute> - <anyAttribute namespace="##other" processContents="lax"/> - </complexType> - <complexType name="ServiceUnavailableFault"> - <complexContent> - <extension base="identity:IdentityFault"></extension> - </complexContent> - </complexType> - <complexType name="BadRequestFault"> - <complexContent> - <extension base="identity:IdentityFault"></extension> - </complexContent> - </complexType> - <complexType name="UnauthorizedFault"> - <complexContent> - <extension base="identity:IdentityFault"></extension> - </complexContent> - </complexType> - <complexType name="UserDisabledFault"> - <complexContent> - <extension base="identity:IdentityFault"></extension> - </complexContent> - </complexType> - <complexType name="ForbiddenFault"> - <complexContent> - <extension base="identity:IdentityFault"></extension> - </complexContent> - </complexType> - <complexType name="ItemNotFoundFault"> - <complexContent> - <extension base="identity:IdentityFault"></extension> - </complexContent> - </complexType> - <complexType name="TenantConflictFault"> - <complexContent> - <extension base="identity:IdentityFault"></extension> - </complexContent> - </complexType> - <complexType name="OverLimitFault"> - <complexContent> - <extension base="identity:IdentityFault"> - <attribute name="retryAt" type="xsd:dateTime" use="optional"> - <annotation> - <xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <p>An optional dateTime denoting when an operation should - be retried.</p> - </xsd:documentation> - </annotation> - </attribute> - </extension> - </complexContent> - </complexType> -</schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/api-common.xsd</con:url><con:content><![CDATA[<?xml-stylesheet type="text/xsl" href="../xslt/schema.xslt"?> -<!--(C) 2009-2011 Rackspace Hosting, All Rights Reserved--> -<schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://docs.openstack.org/common/api/v1.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:capi="http://docs.openstack.org/common/api/v1.0" xmlns:xsdxt="http://docs.rackspacecloud.com/xsd-ext/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <annotation> - <xsd:appinfo xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <xsdxt:title>Open Stack Common API Schema Types 1.0</xsdxt:title> - <xsdxt:link rev="index" href="extensions.xsd"/> - <xsdxt:link rev="index" href="limits.xsd"/> - <xsdxt:link rev="index" href="version.xsd"/> - </xsd:appinfo> - <xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <p>This is the main index XML Schema document - for Common API Schema Types Version 1.0.</p> - </xsd:documentation> - </annotation> - <include schemaLocation="extensions.xsd"> - <annotation> - <xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <p>Types related to extensions.</p> - </xsd:documentation> - </annotation> - </include> - <include schemaLocation="version.xsd"> - <annotation> - <xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <p>Types related to API version details.</p> - </xsd:documentation> - </annotation> - </include> -</schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/extensions.xsd</con:url><con:content><![CDATA[<xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://docs.openstack.org/common/api/v1.0" xmlns:ext="http://docs.openstack.org/common/api/v1.0" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <!--Import ATOM specific schema definitions--> - <xsd:import namespace="http://www.w3.org/2005/Atom" schemaLocation="./atom/atom.xsd"/> - <xsd:element name="extensions" type="ext:Extensions"/> - <xsd:element name="extension" type="ext:Extension"/> - <xsd:complexType name="Extensions"> - <xsd:sequence> - <xsd:element name="extension" type="ext:Extension" minOccurs="0" maxOccurs="unbounded"/> - <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:anyAttribute namespace="##other" processContents="lax"/> - </xsd:complexType> - <xsd:complexType name="Extension"> - <xsd:sequence> - <xsd:element name="description" type="xsd:string" minOccurs="1"/> - <xsd:element vc:minVersion="1.1" ref="atom:link" minOccurs="0" maxOccurs="unbounded"/> - <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" use="required"/> - <xsd:attribute name="namespace" type="xsd:anyURI" use="required"/> - <xsd:attribute name="alias" type="ext:Alias" use="required"/> - <xsd:attribute name="updated" type="xsd:dateTime" use="optional"/> - <xsd:anyAttribute namespace="##other" processContents="lax"/> - <xsd:assert vc:minVersion="1.1" test="atom:link[@rel='describedby']"> - <xsd:annotation> - <xsd:documentation xml:lang="EN" xmlns="http://www.w3.org/1999/xhtml"> - <p>There should be at least one atom link - with a describedby relation.</p> - </xsd:documentation> - </xsd:annotation> - </xsd:assert> - </xsd:complexType> - <xsd:simpleType name="Alias"> - <xsd:restriction base="xsd:string"> - <xsd:pattern value="\w+\-\w+"/> - </xsd:restriction> - </xsd:simpleType> -</xsd:schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>file:/Users/jorgew/projects/keystone/keystone/xsd/version.xsd</con:url><con:content><![CDATA[<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://docs.openstack.org/common/api/v1.0" xmlns:vers="http://docs.openstack.org/common/api/v1.0" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <!--Import ATOM specific schema definitions--> - <xs:import namespace="http://www.w3.org/2005/Atom" schemaLocation="./atom/atom.xsd"/> - <!--Multiple choices--> - <xs:element name="choices" type="vers:VersionChoiceList"/> - <!--Versioning--> - <xs:element name="versions" type="vers:VersionChoiceList"/> - <xs:element name="version" type="vers:VersionChoice" vc:minVersion="1.0" vc:maxVersion="1.1"/> - <xs:element name="version" type="vers:VersionChoiceRoot" vc:minVersion="1.1"/> - <!--Types--> - <xs:simpleType name="VersionStatus"> - <xs:annotation> - <xs:documentation> - <html:p>The VersionStatus type describes a service's operational status.</html:p> - </xs:documentation> - </xs:annotation> - <xs:restriction base="xs:string"> - <xs:enumeration value="DEPRECATED"/> - <xs:enumeration value="ALPHA"/> - <xs:enumeration value="BETA"/> - <xs:enumeration value="CURRENT"/> - </xs:restriction> - </xs:simpleType> - <xs:complexType name="VersionChoiceList"> - <xs:annotation> - <xs:documentation> - <html:p>A version choice list outlines a collection of service version choices.</html:p> - </xs:documentation> - </xs:annotation> - <xs:sequence> - <xs:element name="version" type="vers:VersionChoice" minOccurs="1" maxOccurs="unbounded"/> - <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </xs:sequence> - <xs:anyAttribute namespace="##other" processContents="lax"/> - <xs:assert vc:minVersion="1.1" test="every $v in vers:version satisfies $v/atom:link[@rel='self']"> - <xs:annotation> - <xs:documentation> - <html:p>In version lists, every single version must - contain at least one self link.</html:p> - </xs:documentation> - </xs:annotation> - </xs:assert> - </xs:complexType> - <xs:complexType name="VersionChoiceRoot" vc:minVersion="1.1"> - <xs:complexContent> - <xs:extension base="vers:VersionChoice"> - <xs:assert test="atom:link[@rel='describedby']"> - <xs:annotation> - <xs:documentation> - <html:p>When used as a root element, a version choice - must contain at least one describedby link.</html:p> - </xs:documentation> - </xs:annotation> - </xs:assert> - </xs:extension> - </xs:complexContent> - </xs:complexType> - <xs:complexType name="VersionChoice"> - <xs:annotation> - <xs:documentation> - <html:p>A version choice contains relevant information about an available service - that a user can then use to target a specific version of the service. Note - that both the descriptive media types and the atom link references are - not manditory and are offered as message enrichment elements rather - than message requirements.</html:p> - </xs:documentation> - </xs:annotation> - <xs:sequence> - <xs:element name="media-types" type="vers:MediaTypeList" minOccurs="0" maxOccurs="1"/> - <xs:element vc:minVersion="1.1" ref="atom:link" minOccurs="0" maxOccurs="unbounded"/> - <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </xs:sequence> - <xs:attribute name="id" type="xs:string" use="required"> - <xs:annotation> - <xs:documentation> - <html:p>The ID of a version choice represents the service version's unique - identifier. This ID is guaranteed to be unique only among the - service version choices outlined in the VersionChoiceList.</html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="status" type="vers:VersionStatus" use="required"> - <xs:annotation> - <xs:documentation> - <html:p>A version choice's status describes the current operational state of - the given service version. The operational status is captured in a - simple type enumeration called VersionStatus.</html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="updated" type="xs:dateTime" use="optional"> - <xs:annotation> - <xs:documentation> - <html:p> - A version choice's updated attribute describes - the time when the version was updated. The - time should be updated anytime - <html:strong>anything</html:strong> - in the - version has changed: documentation, - extensions, bug fixes. - </html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:anyAttribute namespace="##other" processContents="lax"/> - </xs:complexType> - <xs:complexType name="MediaTypeList"> - <xs:annotation> - <xs:documentation> - <html:p>A MediaTypeList outlines a collection of valid media types for a given - service version.</html:p> - </xs:documentation> - </xs:annotation> - <xs:sequence> - <xs:element name="media-type" type="vers:MediaType" minOccurs="1" maxOccurs="unbounded"/> - <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </xs:sequence> - <xs:anyAttribute namespace="##other" processContents="lax"/> - </xs:complexType> - <xs:complexType name="MediaType"> - <xs:annotation> - <xs:documentation> - <html:p>A MediaType describes what content types the service version understands.</html:p> - </xs:documentation> - </xs:annotation> - <xs:sequence> - <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> - </xs:sequence> - <xs:attribute name="base" type="xs:string" use="optional" default=""> - <xs:annotation> - <xs:documentation> - <html:p>The base of a given media type describes the simple MIME type - that then a more complicated media type can be derived from. These - types are basic and provide no namespace or version specific - data are are only provided as a convenience. Because of this the - base attribute is declared as optional.</html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="type" type="xs:string" use="required"> - <xs:annotation> - <xs:documentation> - <html:p> - The type attribute of a MediaType describes the MIME specific - identifier of the media type in question. This identifier should include - a vendor namespace ( - <html:a href="http://tools.ietf.org/html/rfc2048">See RFC 2048</html:a> - ) - as well as a version suffix. - </html:p> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:anyAttribute namespace="##other" processContents="lax"/> - </xs:complexType> -</xs:schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part></con:definitionCache><con:endpoints><con:endpoint>http://localhost:8080</con:endpoint></con:endpoints><con:resource name="v1.0" path="v1.0"><con:settings/><con:parameters/><con:resource name="extensions" path="extensions"><con:settings/><con:parameters/><con:resource name="{alias}" path="{alias}"><con:settings/><con:parameters><con:parameter><con:name>alias</con:name><con:value xsi:nil="true"/><con:style>TEMPLATE</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type><con:default xsi:nil="true"/></con:parameter></con:parameters><con:method name="GET - getExtension" method="GET"><con:settings/><con:parameters/><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200 203</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/common/api/v1.0">v1:extension</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200 203</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>404</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:itemNotFound</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>400 404 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="alias" value="RAX-TEST" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:request></con:method></con:resource><con:method name="GET - getExtensions" method="GET"><con:settings/><con:parameters/><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200 203</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/common/api/v1.0">v1:extensions</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200 203</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>400 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:request></con:method></con:resource><con:resource name="token" path="token"><con:settings/><con:parameters/><con:resource name="{tokenId}" path="{tokenId}"><con:settings/><con:parameters><con:parameter required="true"><con:name>X-Auth-Token</con:name><con:value xsi:nil="true"/><con:style>HEADER</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type><con:default xsi:nil="true"/></con:parameter><con:parameter><con:name>tokenId</con:name><con:value xsi:nil="true"/><con:style>TEMPLATE</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type><con:default xsi:nil="true"/></con:parameter></con:parameters><con:method name="GET - validateToken" method="GET"><con:settings/><con:parameters><con:parameter><con:name>belongsTo</con:name><con:value xsi:nil="true"/><con:style>QUERY</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type><con:default xsi:nil="true"/></con:parameter></con:parameters><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200 203</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:auth</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200 203</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>401</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:unauthorized</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:forbidden</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:userDisabled</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>404</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:itemNotFound</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>400 401 403 404 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="887665443383838"/> - <con:entry key="X-Auth-Token" value="999888777666"/> - <con:entry key="belongsTo" value="1234"/> -</con:parameters></con:request></con:method><con:method name="DELETE - revokeToken" method="DELETE"><con:settings/><con:parameters/><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>401</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:unauthorized</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:forbidden</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>404</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:itemNotFound</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>400 401 403 404 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="3u37737"/> - <con:entry key="X-Auth-Token" value="3838737726"/> -</con:parameters></con:request></con:method></con:resource><con:method name="POST - authenticate" method="POST"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>application/xml</con:mediaType><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:passwordCredentials</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="REQUEST" id=""><con:mediaType>application/json</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200 -203</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:auth</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200 -203</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>401</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:unauthorized</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:userDisabled</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>401 -403 400 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><passwordCredentials -password="secrete" username="joeuser" -xmlns="http://docs.openstack.org/identity/api/v2.0"/></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:request></con:method></con:resource><con:resource name="tenants" path="tenants"><con:settings/><con:parameters><con:parameter required="true"><con:name>X-Auth-Token</con:name><con:value xsi:nil="true"/><con:style>HEADER</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type><con:default xsi:nil="true"/></con:parameter></con:parameters><con:resource name="{tenantId}" path="{tenantId}"><con:settings/><con:parameters><con:parameter><con:name>tenantId</con:name><con:value xsi:nil="true"/><con:style>TEMPLATE</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type><con:default xsi:nil="true"/></con:parameter></con:parameters><con:method name="GET - getTenant" method="GET"><con:settings/><con:parameters/><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200 -203</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:tenant</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200 -203</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>401</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:unauthorized</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:forbidden</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>404</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:itemNotFound</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>400 -401 403 404 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="1234"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:request></con:method><con:method name="PUT - updateTenant" method="PUT"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>application/xml</con:mediaType><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:tenant</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="REQUEST" id=""><con:mediaType>application/json</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:tenant</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>401</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:unauthorized</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:forbidden</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>404</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:itemNotFound</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>401 -403 404 400 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml" postQueryString="false"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"> - <v1:description>New Description</v1:description> -</v1:tenant></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="1234"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:request></con:method><con:method name="DELETE - deleteTenant" method="DELETE"><con:settings/><con:parameters/><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>401</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:unauthorized</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:forbidden</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>404</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:itemNotFound</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>400 -401 403 404 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="0000"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:request></con:method></con:resource><con:method name="GET - getTenants" method="GET"><con:settings/><con:parameters><con:parameter><con:name>marker</con:name><con:value xsi:nil="true"/><con:style>QUERY</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type><con:default xsi:nil="true"/></con:parameter><con:parameter><con:name>limit</con:name><con:value xsi:nil="true"/><con:style>QUERY</con:style><con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:int</con:type><con:default xsi:nil="true"/></con:parameter></con:parameters><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200 -203</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:tenants</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200 -203</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>401</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:unauthorized</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:forbidden</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>404</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:itemNotFound</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>400 -401 403 404 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:request></con:method><con:method name="POST - createTenant" method="POST"><con:settings/><con:parameters/><con:representation type="REQUEST" id=""><con:mediaType>application/xml</con:mediaType><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:tenant</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="REQUEST" id=""><con:mediaType>application/json</con:mediaType><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>201</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:tenant</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>201</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>401</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:unauthorized</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>403</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:forbidden</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType> -<con:status>409</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:tenantConflict</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType> -<con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>401 -403 400 409 500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant -enabled="true" id="my_new_tenant" -xmlns:v1="http://docs.openstack.org/identity/api/v2.0"><v1:description>This -is a description of my tenant. Thank you very -much.</v1:description></v1:tenant></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:request></con:method></con:resource><con:method name="GET - getVersionInfo" method="GET"><con:settings/><con:parameters/><con:representation type="RESPONSE" id=""><con:mediaType>application/xml</con:mediaType><con:status>200 -203</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/common/api/v1.0">v1:version</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="RESPONSE" id=""><con:mediaType>application/json</con:mediaType><con:status>200 -203</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>400</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:badRequest</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>500</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:identityFault</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/xml</con:mediaType><con:status>503</con:status><con:params/><con:element xmlns:v1="http://docs.openstack.org/identity/api/v2.0">v1:serviceUnavailable</con:element><con:description xsi:nil="true"/></con:representation><con:representation type="FAULT" id=""><con:mediaType>application/json</con:mediaType><con:status>400 -500 503</con:status><con:params/><con:element xsi:nil="true"/><con:description xsi:nil="true"/></con:representation><con:request name="Request 1" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:request></con:method></con:resource></con:interface><con:testSuite name="Keystone Tests"><con:settings/><con:runType>SEQUENTIAL</con:runType><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Admin Credential Check" searchProperties="true" id="29b2fa4b-e1c3-49c4-a7e6-334724e74bb9"><con:settings/><con:testStep type="restrequest" name="GET - validateToken - Valid Token"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Valid Token" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>auth</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="887665443383838"/> - <con:entry key="X-Auth-Token" value="999888777666"/> - <con:entry key="belongsTo" value="1234"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Expired Admin Token"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Expired Admin Token" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>unauthorized</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>401</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="377372"/> - <con:entry key="X-Auth-Token" value="000999"/> - <con:entry key="belongsTo" value="3334"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Missing Admin Token"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Missing Admin Token" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>unauthorized</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>401</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="377372"/> - <con:entry key="X-Auth-Token" value=" "/> - <con:entry key="belongsTo" value="3334"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Bad Admin Token"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Bad Admin Token" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>unauthorized</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>401</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="377372"/> - <con:entry key="X-Auth-Token" value="976BAD"/> - <con:entry key="belongsTo" value="3334"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Joe User Makes Admin Call"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Joe User Makes Admin Call" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>forbidden</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>403</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="377372"/> - <con:entry key="X-Auth-Token" value="887665443383838"/> - <con:entry key="belongsTo" value="3334"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Disabled User Makes Admin Call"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Disabled User Makes Admin Call" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>userDisabled</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>403</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="377372"/> - <con:entry key="X-Auth-Token" value="999888777"/> - <con:entry key="belongsTo" value="3334"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:properties/><con:reportParameters/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Validate Token" searchProperties="true" id="e4d9f6ba-f392-4c78-bddc-47fca1fc9b0e"><con:settings/><con:testStep type="restrequest" name="GET - validateToken - Valid Token"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Valid Token" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>auth</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="887665443383838"/> - <con:entry key="X-Auth-Token" value="999888777666"/> - <con:entry key="belongsTo" value="1234"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Valid Token no belongsTo"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Valid Token no belongsTo" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>auth</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="887665443383838"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Valid Token bad belongsTo"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Valid Token bad belongsTo" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="887665443383838"/> - <con:entry key="X-Auth-Token" value="999888777666"/> - <con:entry key="belongsTo" value="998877665"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Bad Token"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Bad Token" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="0009991919"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - Expired Token"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - Expired Token" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="000999"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:properties/><con:reportParameters/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Authenticate" searchProperties="true" id="6daa3ca5-8855-4181-afd4-151833f786ff"><con:settings/><con:testStep type="restrequest" name="POST - authenticate - Bad Credentials, user doesn't exist"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Bad Credentials, user doesn't exist" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><passwordCredentials password="P@ssword1" username="testuser" xmlns="http://docs.openstack.org/identity/api/v2.0"/></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>401</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>unauthorized</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Disabled User"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Disabled User" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><passwordCredentials password="1234" username="disabled" xmlns="http://docs.openstack.org/identity/api/v2.0"/></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>403</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>userDisabled</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Bad Credentials, bad password"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Bad Credentials, bad password" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><passwordCredentials password="123774" username="joeuser" xmlns="http://docs.openstack.org/identity/api/v2.0"/></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>401</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>unauthorized</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Valid Credentials - Admin"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Valid Credentials - Admin" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><passwordCredentials password="secrete" username="admin" xmlns="http://docs.openstack.org/identity/api/v2.0"/></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>Admin</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace auth='http://docs.openstack.org/identity/api/v2.0'; -/auth:auth/auth:user/auth:groups/auth:group/@id='Admin'</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Valid Credentials - Joe User"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Valid Credentials - Joe User" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><passwordCredentials password="secrete" username="joeuser" xmlns="http://docs.openstack.org/identity/api/v2.0"/></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple NotContains"><con:configuration><token>Admin</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace auth='http://docs.openstack.org/identity/api/v2.0'; -/auth:auth/auth:user/auth:groups/auth:group/@id='Admin'</path><content>false</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:properties/><con:reportParameters/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Authenticate (JSON)" searchProperties="true" id="686eabb3-4d04-4f63-a46c-fab41cd1ea62"><con:settings/><con:testStep type="restrequest" name="POST - authenticate - Bad Credentials, user doesn't exist"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Bad Credentials, user doesn't exist" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{ - "passwordCredentials" : { - "username" : "testuser", - "password" : "P@ssword1" - } -}</con:request><con:assertion type="Simple Contains"><con:configuration><token>401</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>unauthorized</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Disabled User"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Disabled User" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{ - "passwordCredentials" : { - "username" : "disabled", - "password" : "1234" - } -}</con:request><con:assertion type="Simple Contains"><con:configuration><token>403</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>userDisabled</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Bad Credentials, bad password"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Bad Credentials, bad password" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{ - "passwordCredentials" : { - "username" : "joeuser", - "password" : "123774" - } -}</con:request><con:assertion type="Simple Contains"><con:configuration><token>401</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>unauthorized</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Valid Credentials - Admin"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Valid Credentials - Admin" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{ - "passwordCredentials" : { - "username" : "admin", - "password" : "secrete" - } -}</con:request><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>Admin</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Valid Credentials - Joe User"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Valid Credentials - Joe User" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{ - "passwordCredentials" : { - "username" : "joeuser", - "password" : "secrete" - } -}</con:request><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple NotContains"><con:configuration><token>Admin</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:properties/><con:reportParameters/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Revoke Token" searchProperties="true" id="f10219b1-055a-4cf4-aeb3-4172bd596979"><con:settings/><con:testStep type="restrequest" name="DELETE - revokeToken - token doesn't exist"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="DELETE - revokeToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="DELETE - revokeToken - token doesn't exist" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="3u37737"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Valid Credentials - Joe User, old Token?"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Valid Credentials - Joe User, old Token?" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><passwordCredentials password="secrete" username="joeuser" xmlns="http://docs.openstack.org/identity/api/v2.0"/></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple NotContains"><con:configuration><token>Admin</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace auth='http://docs.openstack.org/identity/api/v2.0'; -/auth:auth/auth:user/auth:groups/auth:group/@id='Admin'</path><content>false</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace auth='http://docs.openstack.org/identity/api/v2.0'; -/auth:auth/auth:token/@id</path><content>887665443383838</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="DELETE - revokeToken - Joe User"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="DELETE - revokeToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="DELETE - revokeToken - Joe User" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="GroovyScriptAssertion"><con:configuration><scriptText>assert(context.response==null)</scriptText></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="887665443383838"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - validateToken - old Token, Bad?"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens/{tokenId}" methodName="GET - validateToken" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - validateToken - old Token, Bad?" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tokenId" value="887665443383838"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - authenticate - Valid Credentials - Joe User, new Token?"><con:settings/><con:config service="Keystone" resourcePath="/v2.0/tokens" methodName="POST - authenticate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - authenticate - Valid Credentials - Joe User, new Token?" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><passwordCredentials password="secrete" username="joeuser" xmlns="http://docs.openstack.org/identity/api/v2.0"/></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>user</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>token</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple NotContains"><con:configuration><token>Admin</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace auth='http://docs.openstack.org/identity/api/v2.0'; -/auth:auth/auth:user/auth:groups/auth:group/@id='Admin'</path><content>false</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace auth='http://docs.openstack.org/identity/api/v2.0'; -/auth:auth/auth:token/@id="887665443383838"</path><content>false</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:properties/><con:reportParameters/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Tenant Create" searchProperties="true" id="ec537986-d739-4ade-a2f6-f0fca19b876e"><con:settings/><con:testStep type="restrequest" name="POST - createTenant - New Tenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" id="my_new_tenant" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"><v1:description>This is a description of my tenant. Thank you very much.</v1:description></v1:tenant></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@enabled = "true" and /ns1:tenant/@id="my_new_tenant" and /ns1:tenant/ns1:description = "This is a description of my tenant. Thank you very much."</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant, same id"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant, same id" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" id="my_new_tenant" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"><v1:description>This is a description of my tenant. Thank you very much.</v1:description></v1:tenant></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>tenantConflict</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>409</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Disabled Tenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Disabled Tenant" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="false" id="mt2" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"><v1:description>New Disabled Tenant</v1:description></v1:tenant></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@enabled = "false" and /ns1:tenant/@id="mt2" and /ns1:tenant/ns1:description = "New Disabled Tenant"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant No Enable"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant No Enable" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant id="mt3" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"><v1:description>New Tenant 3</v1:description></v1:tenant></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="mt3" and /ns1:tenant/ns1:description = "New Tenant 3"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant No ID"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant No ID" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"><v1:description>New Tenant No ID</v1:description></v1:tenant></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>400</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>badRequest</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant no Description"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant no Description" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" id="my_new_tenant" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"></v1:tenant></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>400</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>badRequest</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:properties/><con:reportParameters/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Tenant Create (JSON)" searchProperties="true" id="8e95cb90-ef1b-4f0e-a882-09a4a43dd01f"><con:settings/><con:testStep type="restrequest" name="POST - createTenant - New Tenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{"tenant": - { - "id": "JGroup", - "description": "A description ...", - "enabled": true - } -} -</con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://localhost/v1.0/tenants'; -ns1:Response/ns1:tenant/ns1:id="JGroup" and ns1:Response/ns1:tenant/ns1:enabled="true" and ns1:Response/ns1:tenant/ns1:description="A description ..."</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant, same id"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant, same id" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{"tenant": - { - "id": "JGroup", - "description": "A description ...", - "enabled": true - } -}</con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>tenantConflict</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>409</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Disabled Tenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Disabled Tenant" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{"tenant": - { - "id": "JGroup33", - "description": "A description...", - "enabled": false - } -}</con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://localhost/v1.0/tenants'; -ns1:Response/ns1:tenant/ns1:id = "JGroup33" and ns1:Response/ns1:tenant/ns1:enabled="false" and ns1:Response/ns1:tenant/ns1:description="A description..."</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant No Enable"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant No Enable" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{"tenant": - { - "id": "JGroup65", - "description": "A description..." - } -}</con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://localhost/v1.0/tenants'; -ns1:Response/ns1:tenant/ns1:id = "JGroup65" and ns1:Response/ns1:tenant/ns1:description = "A description..."</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant No ID"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant No ID" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{"tenant": - { - "description": "A description...", - "enabled" : true - } -}</con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>400</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>badRequest</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant no Description"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant no Description" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{"tenant": - { - "id": "JGroup95", - "enabled": true - } -}</con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>400</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>badRequest</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="POST - createTenant - New Tenant Bad Enabled"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant Bad Enabled" mediaType="application/json" postQueryString="false" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request>{"tenant": - { - "id": "JGroup95", - "description" : "A description...", - "enabled": "true" - } -}</con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>400</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains"><con:configuration><token>badRequest</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:properties/><con:reportParameters/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Get Tenants" searchProperties="true" id="3465716c-ff9c-4dea-8444-ae70e8144571"><con:settings/><con:testStep type="restrequest" name="GET - getTenants"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="GET - getTenants" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenants" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -count(//ns1:tenant)</path><content>8</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenants (JSON)"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="GET - getTenants" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenants (JSON)" mediaType="application/xml" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://localhost/v1.0/tenants'; -count(//ns1:e)</path><content>8</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:properties/><con:reportParameters/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Get Tenant" searchProperties="true" id="e66665ad-46b4-45d2-a8e4-761dbb12fd1c"><con:settings/><con:testStep type="restrequest" name="GET - getTenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenant - Request 1" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -ns1:tenant/@id</path><content>1234</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath (enabled and description)"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@enabled and /ns1:tenant/ns1:description</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="1234"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant (JSON)"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenant (JSON)" mediaType="application/xml" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://localhost/v1.0/tenants/1234'; -ns1:Response/ns1:tenant/ns1:id</path><content>1234</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath (enabled and description)"><con:configuration><path>declare namespace ns1='http://localhost/v1.0/tenants/1234'; -/ns1:Response/ns1:tenant/ns1:enabled and /ns1:Response/ns1:tenant/ns1:description</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="1234"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant, Not Found"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenant, Not Found" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains itemNotFound"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="88273666219200"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:properties/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Delete Tenant" searchProperties="true" id="65633524-fcae-4006-b838-e02a1077e3f7"><con:settings/><con:testStep type="restrequest" name="POST - createTenant - New Tenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" id="to_delete" - xmlns:v1="http://docs.openstack.org/identity/api/v2.0"> - <v1:description>To Be Deleted</v1:description> -</v1:tenant></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@enabled = "true" and /ns1:tenant/@id="to_delete" and /ns1:tenant/ns1:description = "To Be Deleted"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="Copy of GET - getTenant" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -ns1:tenant/@id</path><content>to_delete</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath (enabled and description)"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@enabled and /ns1:tenant/ns1:description</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_delete"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="DELETE - deleteTenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="DELETE - deleteTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="DELETE - deleteTenant - Request 1" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="GroovyScriptAssertion" name="Script Assertion"><con:configuration><scriptText>assert(context.response == null)</scriptText></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_delete"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant, Not Found"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="Copy of GET - getTenant, Not Found" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains itemNotFound"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_delete"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="DELETE - deleteTenant, not empty - user"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="DELETE - deleteTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="DELETE - deleteTenant, not empty - user" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains" name="Contains - forbidden"><con:configuration><token>forbidden</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains - 403"><con:configuration><token>403</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="1234"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="DELETE - deleteTenant, not empty - group"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="DELETE - deleteTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="DELETE - deleteTenant, not empty - group" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Simple Contains" name="Contains - forbidden"><con:configuration><token>forbidden</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains - 403"><con:configuration><token>403</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="0000"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:properties/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Update Tenant" searchProperties="true" id="60b728bc-d3d5-46f0-84bf-a12d6a443d1a"><con:settings/><con:testStep type="restrequest" name="POST - createTenant - New Tenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants" methodName="POST - createTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="POST - createTenant - New Tenant" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" id="to_update" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"> - <v1:description>ToUpdate</v1:description> -</v1:tenant></con:request><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@enabled = "true" and /ns1:tenant/@id="to_update" and /ns1:tenant/ns1:description = "ToUpdate"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="X-Auth-Token" value="999888777666" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenant" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "true" and /ns1:tenant/@id="to_update" and /ns1:tenant/ns1:description = "ToUpdate"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="PUT - updateTenant - Description"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="PUT - updateTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="PUT - updateTenant - Description" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"> - <v1:description>ToUpdate2</v1:description> -</v1:tenant></con:request><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "true" and /ns1:tenant/ns1:description = "ToUpdate2"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant - New Description?"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenant - New Description?" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "true" and /ns1:tenant/@id="to_update" and /ns1:tenant/ns1:description = "ToUpdate2"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="PUT - updateTenant - Enabled"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="PUT - updateTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="PUT - updateTenant - Enabled" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="false" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"> - <v1:description>ToUpdate2</v1:description> -</v1:tenant></con:request><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "false" and /ns1:tenant/ns1:description = "ToUpdate2"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant - New Enable?"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenant - New Enable?" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "false" and /ns1:tenant/@id="to_update" and /ns1:tenant/ns1:description = "ToUpdate2"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="PUT - updateTenant - ID, should ignore"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="PUT - updateTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="PUT - updateTenant - ID, should ignore" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant id="boogabooga" enabled="false" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"> - <v1:description>ToUpdate2</v1:description> -</v1:tenant></con:request><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "false" and /ns1:tenant/ns1:description = "ToUpdate2"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant - New ID ignored?"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenant - New ID ignored?" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "false" and /ns1:tenant/@id="to_update" and /ns1:tenant/ns1:description = "ToUpdate2"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="PUT - updateTenant - Enabled and Description"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="PUT - updateTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="PUT - updateTenant - Enabled and Description" mediaType="application/xml" postQueryString="false" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request><v1:tenant enabled="true" xmlns:v1="http://docs.openstack.org/identity/api/v2.0"> - <v1:description>ToUpdate3</v1:description> -</v1:tenant></con:request><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "true" and /ns1:tenant/ns1:description = "ToUpdate3"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getTenant - New Changes?"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="GET - getTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getTenant - New Changes?" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/identity/api/v2.0'; -/ns1:tenant/@id="to_update" and /ns1:tenant/@enabled = "true" and /ns1:tenant/@id="to_update" and /ns1:tenant/ns1:description = "ToUpdate3"</path><content>true</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="DELETE - deleteTenant"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/tenants/{tenantId}" methodName="DELETE - deleteTenant" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="DELETE - deleteTenant" mediaType="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Accept" value="application/xml" xmlns="http://eviware.com/soapui/config"/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="GroovyScriptAssertion" name="Script Assertion"><con:configuration><scriptText>assert(context.response == null)</scriptText></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters> - <con:entry key="tenantId" value="to_update"/> - <con:entry key="X-Auth-Token" value="999888777666"/> -</con:parameters></con:restRequest></con:config></con:testStep><con:properties/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Extensions" searchProperties="true" id="038f320e-bf1f-42e6-a953-33c166d7619e"><con:settings/><con:testStep type="restrequest" name="GET - getExtensions"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/extensions" methodName="GET - getExtensions" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getExtensions" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/common/api/v1.0'; -count(/ns1:extensions)</path><content>1</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getExtensions (JSON)"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/extensions" methodName="GET - getExtensions" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getExtensions (JSON)" mediaType="application/xml" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://localhost/v1.0/extensions'; -count(//ns1:extensions)</path><content>1</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getExtension"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/extensions/{alias}" methodName="GET - getExtension" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getExtension - Request 1" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains itemNotFound"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="alias" value="RAX-TEST" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getExtension (JSON)"><con:settings/><con:config service="Keystone" resourcePath="/v1.0/extensions/{alias}" methodName="GET - getExtension" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getExtension (JSON)" mediaType="application/xml" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains"><con:configuration><token>404</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:assertion type="Simple Contains" name="Contains itemNotFound"><con:configuration><token>itemNotFound</token><ignoreCase>false</ignoreCase><useRegEx>false</useRegEx></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><entry key="alias" value="RAX-TEST" xmlns="http://eviware.com/soapui/config"/></con:parameters></con:restRequest></con:config></con:testStep><con:properties/></con:testCase><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Version Info" searchProperties="true" id="99db3dab-53de-44f5-93cd-099c8850fd97"><con:settings/><con:testStep type="restrequest" name="GET - getVersionInfo"><con:settings/><con:config service="Keystone" resourcePath="/v1.0" methodName="GET - getVersionInfo" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getVersionInfo - Request 1" mediaType="application/xml" accept="application/xml"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://docs.openstack.org/common/api/v1.0'; -count(//ns1:version)</path><content>1</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:testStep type="restrequest" name="GET - getVersionInfo (JSON)"><con:settings/><con:config service="Keystone" resourcePath="/v1.0" methodName="GET - getVersionInfo" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:restRequest name="GET - getVersionInfo (JSON)" mediaType="application/xml" accept="application/json"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting></con:settings><con:endpoint>http://localhost:8080</con:endpoint><con:request/><con:assertion type="Schema Compliance" name="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XPath Match" name="XPath Match"><con:configuration><path>declare namespace ns1='http://localhost/v1.0'; -count(//ns1:version)</path><content>1</content><allowWildcards>false</allowWildcards><ignoreNamspaceDifferences>false</ignoreNamspaceDifferences></con:configuration></con:assertion><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters/></con:restRequest></con:config></con:testStep><con:properties/></con:testCase><con:properties/><con:reportParameters/></con:testSuite><con:requirements/><con:properties/><con:wssContainer/><con:databaseConnectionContainer/><con:reporting><con:xmlTemplates/><con:parameters/></con:reporting></con:soapui-project>
\ No newline at end of file diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/test/__init__.py +++ /dev/null diff --git a/test/functional/base.py b/test/functional/base.py deleted file mode 100644 index 2baffc4a..00000000 --- a/test/functional/base.py +++ /dev/null @@ -1,101 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import dtest - -import ksapi -import simplerest - - -options = None - - -def _get_ksapi(url): - """Get an instance of KeystoneAPI20.""" - - # If debug mode has been enabled, let's select a debug stream - dbstream = None - if options.debug: - dbstream = dtest.status - - # Build and return the API object - return ksapi.KeystoneAPI20(url, dbstream) - - -class BaseKeystoneTest(dtest.DTestCase): - """Base class for Keystone tests.""" - - def setUp(self): - """Initialize tests by setting up a KeystoneAPI20 to call.""" - - # Build the API objects - self.ks = _get_ksapi(options.keystone) - self.ks_admin = _get_ksapi(options.keystone_admin) - - -class KeystoneTest(BaseKeystoneTest): - """Base class for Keystone tests.""" - - user_tok = None - user_expire = None - admin_tok = None - admin_expire = None - - @classmethod - def setUpClass(cls): - """Initialize tests by setting up a keystone token.""" - - # Get an API object - ks = _get_ksapi(options.keystone) - - # Next, let's authenticate and get a user token - resp = ks.authenticate(options.username, options.password) - - # Save the authentication token and other data - cls.user_tok = resp.obj['auth']['token']['id'] - cls.user_expire = resp.obj['auth']['token']['expires'] - - # Now, let's get an admin token - resp = ks.authenticate(options.adminuser, options.adminpass) - - # Save the authentication token and other data - cls.admin_tok = resp.obj['auth']['token']['id'] - cls.admin_expire = resp.obj['auth']['token']['expires'] - - @classmethod - def tearDownClass(cls): - """Revoke the authentication token.""" - - # Get an API object - ks = _get_ksapi(options.keystone_admin) - - try: - # First, let's revoke the user token - resp = ks.revoke_token(cls.admin_tok, cls.user_tok) - except simplerest.RESTException: - # Ignore errors revoking the token - pass - - try: - # Now, let's revoke the admin token - resp = ks.revoke_token(cls.admin_tok, cls.admin_tok) - except simplerest.RESTException: - # Ignore errors revoking the token - pass - - # For completeness sake... - cls.token = None diff --git a/test/functional/ksapi.py b/test/functional/ksapi.py deleted file mode 100644 index 9c426109..00000000 --- a/test/functional/ksapi.py +++ /dev/null @@ -1,146 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import simplerest - - -class KeystoneAPI20(simplerest.RESTAPI): - get_version_info = simplerest.RESTMethod('get_version_info', 'GET', '/') - - get_extensions = simplerest.RESTMethod('get_extensions', 'GET', - '/extensions') - get_extension = simplerest.RESTMethod('get_extension', 'GET', - '/extensions/{alias}', ['alias']) - - authenticate = simplerest.RESTMethod('authenticate', 'POST', - '/tokens', - ['username', 'password', 'tenantId'], - 'passwordCredentials', - username='req', password='req', - tenantId=('req', False)) - validate_token = simplerest.RESTMethod('validate_token', 'GET', - '/tokens/{tokenId}', - ['x_auth_token', - 'tokenId', 'belongsTo'], - x_auth_token='header', - belongsTo='query') - revoke_token = simplerest.RESTMethod('revoke_token', 'DELETE', - '/tokens/{tokenId}', - ['x_auth_token', 'tokenId'], - x_auth_token='header') - - create_tenant = simplerest.RESTMethod('create_tenant', 'POST', '/tenants', - ['x_auth_token', 'id', - 'description', 'enabled'], - 'tenant', - x_auth_token='header', - id='req', description='req', - enabled='req') - get_tenants = simplerest.RESTMethod('get_tenants', 'GET', '/tenants', - ['x_auth_token'], - x_auth_token='header') - get_tenant = simplerest.RESTMethod('get_tenant', 'GET', - '/tenants/{tenantId}', - ['x_auth_token', 'tenantId'], - x_auth_token='header') - update_tenant = simplerest.RESTMethod('update_tenant', 'PUT', - '/tenants/{tenantId}', - ['x_auth_token', 'tenantId', - 'description'], - 'tenant', - x_auth_token='header', - description='req') - delete_tenant = simplerest.RESTMethod('delete_tenant', 'DELETE', - '/tenants/{tenantId}', - ['x_auth_token', 'tenantId'], - x_auth_token='header') - - get_base_urls = simplerest.RESTMethod('get_base_urls', 'GET', - '/baseURLs', - ['x_auth_token', 'serviceName'], - x_auth_token='header', - serviceName='query') - get_enabled_base_urls = simplerest.RESTMethod('get_enabled_base_urls', - 'GET', '/baseURLs/enabled', - ['x_auth_token', - 'serviceName'], - x_auth_token='header', - serviceName='query') - get_base_url = simplerest.RESTMethod('get_base_url', 'GET', - '/baseURLs/{baseURLId}', - ['x_auth_token', 'baseURLId'], - x_auth_token='header') - get_base_url_refs = simplerest.RESTMethod('get_base_url_refs', 'GET', - '/tenants/{tenantId}/' - 'baseURLRefs', - ['x_auth_token', 'tenantId'], - x_auth_token='header') - add_base_url_ref = simplerest.RESTMethod('add_base_url_ref', 'POST', - '/tenants/{tenantId}/' - 'baseURLRefs', - ['x_auth_token', - 'tenantId', 'id', 'region', - 'default', 'serviceName', - 'publicURL', 'internalURL', - 'enabled'], 'baseURL', - x_auth_token='header', - id='req', region='req', - default='req', - serviceName='req', - publicURL='req', - internalURL='req', enabled='req') - get_base_url_ref = simplerest.RESTMethod('get_base_url_ref', 'GET', - '/tenants/{tenantId}/' - 'baseURLRefs/{baseURLId}', - ['x_auth_token', 'tenantId', - 'baseURLId'], - x_auth_token='header') - delete_base_url_ref = simplerest.RESTMethod('delete_base_url_ref', - 'DELETE', - '/tenants/{tenantId}/' - 'baseURLRefs/{baseURLId}', - ['x_auth_token', 'tenantId', - 'baseURLId'], - x_auth_token='header') - - get_roles = simplerest.RESTMethod('get_roles', 'GET', '/roles', - ['x_auth_token', 'serviceName'], - x_auth_token='header', - serviceName='query') - get_role = simplerest.RESTMethod('get_role', 'GET', '/roles/{roleId}', - ['x_auth_token', 'roleId'], - x_auth_token='header') - get_role_refs = simplerest.RESTMethod('get_role_refs', 'GET', - '/users/{userId}/roleRefs', - ['x_auth_token', 'userId'], - x_auth_token='header') - add_role_ref = simplerest.RESTMethod('add_role_ref', 'POST', - '/users/{userId}/roleRefs', - ['x_auth_token', 'userId', 'id', - 'href', 'tenantId'], - 'roleRef', x_auth_token='header', - id='req', href='req', tenantId='req') - get_role_ref = simplerest.RESTMethod('get_role_ref', 'GET', - '/users/{userId}/roleRefs/{roleId}', - ['x_auth_token', 'userId', 'roleId'], - x_auth_token='header') - delete_role_ref = simplerest.RESTMethod('delete_role_ref', 'DELETE', - '/users/{userId}/roleRefs/' - '{roleId}', - ['x_auth_token', 'userId', - 'roleId'], - x_auth_token='header') diff --git a/test/functional/run_tests.py b/test/functional/run_tests.py deleted file mode 100755 index 86b9ec92..00000000 --- a/test/functional/run_tests.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/python -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -try: - import dtest -except: - print "DTest framework needed. Try running 'pip install dtest'" - exit() - -import sys - -import base - - -def add_opts(opts): - """Adds options specific to this test suite.""" - - opts.add_option("-u", "--username", - action="store", type="string", dest="username", - help="The username to use to access Keystone.") - opts.add_option("-p", "--password", - action="store", type="string", dest="password", - help="The password to use to access Keystone.") - - opts.add_option("-U", "--adminuser", - action="store", type="string", dest="adminuser", - help="The admin username to use to access Keystone.") - opts.add_option("-P", "--adminpass", - action="store", type="string", dest="adminpass", - help="The admin password to use to access Keystone.") - - opts.add_option("-k", "--keystone", - action="store", type="string", dest="keystone", - help="The URL to use to access the Keystone service.") - opts.add_option("-K", "--keystone-admin", - action="store", type="string", dest="keystone_admin", - help="The URL to use to access the Keystone admin " - "service.") - - return opts - - -if __name__ == '__main__': - # Obtain the options - opts = add_opts(dtest.optparser(usage="%prog [options]")) - - # Process command-line arguments, saving them so tests can get to - # them - (base.options, args) = opts.parse_args() - - # Ensure required options are present - if (not base.options.username or not base.options.password or - not base.options.keystone): - print >>sys.stderr, "Missing required options" - print >>sys.stderr, ("At a minimum, --username, --password, and " - "--keystone must be specified.") - opts.print_help(sys.stderr) - sys.exit(1) - - # How about the admin stuff? - if not base.options.adminuser: - base.options.adminuser = base.options.username - if not base.options.adminpass: - base.options.adminpass = base.options.password - if not base.options.keystone_admin: - base.options.keystone_admin = base.options.keystone - - # Execute the test suite - sys.exit(dtest.main(**dtest.opts_to_args(base.options))) diff --git a/test/functional/sample_test.py b/test/functional/sample_test.py deleted file mode 100644 index ef8ee27a..00000000 --- a/test/functional/sample_test.py +++ /dev/null @@ -1,86 +0,0 @@ -## Lines beginning with '##' are for explaining the contents of this -## file, and should be removed if you copy the file to create a new -## (set of) tests. Also note that the file must be named to match the -## scheme "test_[...].py", i.e., "test_tokens.py". -## -## I don't think I need to explain the copyright notice :) -## -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -## This test suite uses the DTest framework, which can be found on -## PyPi ("pip install dtest"). DTest uses threading to perform tests -## in parallel; the threading can be limited by using dependencies, -## but the purpose of dependencies is really to say that some test -## must pass before other actions can be performed. Within dtest, the -## util module contains a number of useful "assert_*()" functions, but -## if you want, you can just use the "assert" statement. -## -## Also note that names are important. Modules should be named -## "test_[...].py", as mentioned above. Classes must extend -## base.KeystoneTest (a subclass of dtest.DTestCase), and test methods -## should have names like "test_[...]" (or be decorated with the -## @dtest.istest decorator). Adhere to these rules, and DTest can -## discover and run the tests without you having to do anything other -## than create them. -import dtest -from dtest import util - -## The "base" module contains KeystoneTest, which ensures that there's -## a Keystone authentication token in self.token and API accessors in -## self.ks and self.ks_admin. See ksapi.py for a list of what methods -## are available on self.ks/self.ks_admin. -import base - - -## Tests should be gathered together in classes, not too dissimilar -## from how unittest works. Extend base.KeystoneTest, so you get -## self.user_tok, self.ks, self.admin_tok, and self.ks_admin. If you -## override setUp(), make sure you call the superclass's setUp() -## method (it's responsible for setting self.ks and self.ks_admin). -## Try to avoid overriding setUpClass() or tearDownClass() if you can -## help it (they're responsible for setting up and destroying -## self.admin_tok and self.user_tok). -class SampleTest(base.KeystoneTest): - def test_sample(self): - """Test that we can do sample.""" - ## You don't *have* to declare a doc string, but it's good - ## practice. - - ## Here we're making a "sample_call()", passing self.token as - ## the authentication token. For available calls and the - ## order of arguments, check out ksapi.py. The return value - ## will be an httplib.HTTPResponse object with additional - ## 'body' (str) and 'obj' (dict) attributes. If a status code - ## greater than or equal to 400 is returned from the other - ## end, an exception will be raised; the response will be - ## attached to the 'response' attribute of the exception, and - ## the status will be on the 'status' attribute of the - ## exception. Note that redirects are followed. - resp = self.ks.sample_call(self.user_tok, 'argument 1', 'argument 2') - - # Verify that resp is correct - util.assert_equal(resp.status, 200) - util.assert_in('sample', resp.obj) - ## Place your various assertions about the response here. - - ## Rinse, lather, repeat. You should perform only a single - ## test per test method, but if you're doing creation tests, - ## it makes sense to include the deletion test in the same - ## test method. Remember, the only control you have over test - ## ordering is by setting up dependencies (@dtest.depends()). - ## No return value is necessary. diff --git a/test/functional/simplerest.py b/test/functional/simplerest.py deleted file mode 100644 index fd5e0882..00000000 --- a/test/functional/simplerest.py +++ /dev/null @@ -1,641 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib -import json -import re -import string -import urllib -import urlparse - - -class HTTPRequest(object): - """Represent an HTTP request. - - Represents an HTTP request. Headers can be manipulated using - standard dictionary access (i.e., req["accept"] will be the - contents of the "Accept" header), and the body can be fed in using - write(). Note that headers are manipulated in a case-insensitive - fashion; that is, the "accept" header is the same thing as the - "ACCEPT" header or the "aCcEpT" header. - - """ - - def __init__(self, method, uri, body=None, headers=None): - """Initialize an HTTP request. - - :param method: The HTTP method, i.e., "GET". - :param uri: The full path of the resource. - :param body: A string giving the body of the request. - :param headers: A dictionary of headers. - """ - - # Save the relevant data - self.method = method.upper() - self.uri = uri - self.body = body or '' - self.headers = {} - - # Set the headers... - if headers: - for hdr, value in headers.items(): - # Allows appropriate case mapping - self[hdr] = value - - def write(self, data): - """Write data to the request body. - - :param data: Data to be appended to the request body. - """ - - # Add the written data to our body - self.body += data - - def flush(self): - """Flush data to the request body. - - Does nothing. Provided just in case something tries to call - flush(). - """ - - # Do-nothing to allow stream compatibility - pass - - def __getitem__(self, item): - """Allow access to headers.""" - - # Headers are done by item access - return self.headers[item.title()] - - def __setitem__(self, item, value): - """Allow access to headers.""" - - # Headers are done by item access - self.headers[item.title()] = value - - def __delitem__(self, item): - """Allow access to headers.""" - - # Headers are done by item access - del self.headers[item.title()] - - def __contains__(self, item): - """Allow access to headers.""" - - # Headers are done by item access - return item.title() in self.headers - - def __len__(self): - """Allow access to headers.""" - - # Headers are done by item access - return len(self.headers) - - -class RESTClient(object): - """Represent a REST client connection. - - Represents a REST client connection. All calls will be made - relative to the base URL defined when the class is instantiated. - Note that 301, 302, 303, and 307 redirects are honored. By - default, redirects are limited to a maximum of 10; this may be - modified by setting the max_redirects class attribute. - - """ - - # Maximum number of redirects we'll follow - max_redirects = 10 - - def __init__(self, baseurl, debug_stream=None): - """Initialize a REST client. - - :param baseurl: The base URL for the client connection. - :param debug_stream: An optional stream for receiving debug. - """ - - # Save the base URL and debug stream - self._baseurl = baseurl - self._debug_stream = debug_stream - - # Pull it apart, also... - parsed = urlparse.urlparse(baseurl) - - # Make sure the scheme makes sense - if parsed.scheme not in ('http', 'https'): - raise httplib.InvalidURL("invalid scheme: '%s'" % parsed.scheme) - - # We're only concerned with the scheme, netloc, and path... - self._scheme = parsed.scheme - self._netloc = parsed.netloc - self._path = parsed.path or '/' - - # We'll keep a cached HTTPConnection for our baseurl around... - self._connect = None - - @classmethod - def _open(cls, scheme, netloc, cache=None): - """Open an HTTPConnection. - - Opens an HTTPConnection or returns an open one from the cache, - if given. If the scheme is "https", returns an - HTTPSConnection. - - :param scheme: The URI scheme; one of 'http' or 'https'. - :param netloc: The network location. - :param cache: Optional dictionary caching connections. - """ - - # If cache is present, look up the scheme and netloc in it... - if cache and (scheme, netloc) in cache: - # Return the pre-existing connection - return cache[(scheme, netloc)] - - # Open a connection for the given scheme and netloc - if scheme == 'http': - connect = httplib.HTTPConnection(netloc) - elif scheme == 'https': - connect = httplib.HTTPSConnection(netloc) - - # Make sure to cache it... - if cache is not None: - cache[(scheme, netloc)] = connect - - return connect - - def _debug(self, msg, *args, **kwargs): - """Generate debugging output.""" - - # If we have a declared debug stream, output to it - if self._debug_stream: - print >>self._debug_stream, msg % (kwargs if kwargs else args) - - def make_req(self, method, reluri, query=None, obj=None, headers=None): - """Makes an HTTPRequest. - - Generates an instance of HTTPRequest and returns it. - - :param method: The HTTP method, i.e., "GET". - :param reluri: The resource URI, relative to the base URL. - :param query: Optional dictionary to convert into a query. - :param obj: Optional object to serialize as a JSON object. - :param headers: Optional dictionary of headers. - """ - - # First, let's compose the path with the reluri - joincond = (self._path[-1:], reluri[:1]) - if joincond == ('/', '/'): - fulluri = self._path + reluri[1:] - elif '/' in joincond: - fulluri = self._path + reluri - else: - fulluri = self._path + '/' + reluri - - # Add the query, if there is one - if query: - fulluri += '?%s' % urllib.urlencode(query) - - self._debug("Creating %s request for %s", method, fulluri) - - # Set up a default for the accept header - if headers is None: - headers = {} - headers.setdefault('accept', 'application/json') - - # Build a request - req = HTTPRequest(method, fulluri, headers=headers) - - # If there's an object, jsonify it - if obj is not None: - json.dump(obj, req) - req['content-type'] = 'application/json' - self._debug(" Request body: %r" % req.body) - - # Now, return the request - return req - - def send(self, req): - """Send request. - - Sends a request, which must have been generated using - make_req() (assumes URL is relative to the base URL). Honors - redirects (even to URLs not relative to base URL). If the - status code of the response is >= 400, raises an appropriate - exception derived from HTTPException (of this module). - Returns an HTTPResponse (defined by httplib). If a JSON - object is available in the body, the obj attribute of the - response will be set to it; otherwise, obj is None. - """ - - self._debug("Sending request on client %s: (%r, %r, %r, %r)", - self._baseurl, req.method, req.uri, req.body, req.headers) - - # First, get a connection - if self._connect is None: - self._connect = self._open(self._scheme, self._netloc) - - # Pre-initialize the cache... - cache = {(self._scheme, self._netloc): self._connect} - - # Get the initial connection we'll be using... - connect = self._connect - - # Also get the initial URI we're using... - uri = req.uri - - # Need the full URL, with e.g., netloc - fullurl = urlparse.urlunparse((self._scheme, self._netloc, uri, - None, None, None)) - - # Loop for redirection handling - seen = set([fullurl]) - for i in range(self.max_redirects): - # Make the request - self._debug(" Issuing request to %s (%s)", fullurl, uri) - connect.request(req.method, uri, req.body, req.headers) - - # Get the response - resp = connect.getresponse() - - # Now, is the response a redirection? - newurl = None - if resp.status in (301, 302, 303, 307): - # Find the forwarding header... - if 'location' in resp.msg: - newurl = resp.getheader('location') - elif 'uri' in resp.msg: - newurl = resp.getheader('uri') - - # If we have a newurl, process the redirection - if newurl is not None: - # Canonicalize it; it could be relative - fullurl = urlparse.urljoin(fullurl, newurl) - - self._debug(" Got redirected to %s" % fullurl) - - # Make sure we haven't seen it before... - if fullurl in seen: - self._debug(" Redirected URL already seen!") - break - - seen.add(fullurl) - - # Now, split it back up - tmp = urlparse.urlparse(newurl) - - # Get the path part of the URL - uri = urlparse.urlunparse((None, None, tmp.path, tmp.params, - tmp.query, tmp.fragment)) - - # Finally, get a connection - connect = self._open(tmp.scheme, tmp.netloc, cache) - - # And we try again - continue - - # We have a response and it's not a redirection; let's - # interpret the JSON in the response (safely)... - self._debug(" Received %s response (%s)", resp.status, - resp.reason) - resp.body = resp.read() - try: - resp.obj = json.loads(resp.body) - self._debug(" Received entity: %r", resp.obj) - except ValueError: - resp.obj = None - self._debug(" No received entity; body %r", resp.body) - - # If this is an error response, let's raise an appropriate - # exception - if resp.status >= 400: - exc = exceptions.get(resp.status, HTTPException) - self._debug(" Response was a fault, raising %s", - exc.__name__) - raise exc(resp) - - # Return the response - return resp - - # Exceeded the maximum number of redirects - self._debug(" Redirect loop detected") - raise RESTException("Redirect loop detected") - - def get(self, reluri, query=None, headers=None): - """Send a GET request. - - :param reluri: The resource URI, relative to the base URL. - :param query: Optional dictionary to convert into a query. - :param headers: Optional dictionary of headers. - """ - - # Make a GET request... - req = self.make_req('GET', reluri, query=query, headers=headers) - - # And issue it - return self.send(req) - - def put(self, reluri, query=None, obj=None, headers=None): - """Send a PUT request. - - :param reluri: The resource URI, relative to the base URL. - :param query: Optional dictionary to convert into a query. - :param obj: Optional object to serialize as a JSON object. - :param headers: Optional dictionary of headers. - """ - - # Make a PUT request... - req = self.make_req('PUT', reluri, query=query, obj=obj, - headers=headers) - - # And issue it - return self.send(req) - - def post(self, reluri, query=None, obj=None, headers=None): - """Send a POST request. - - :param reluri: The resource URI, relative to the base URL. - :param query: Optional dictionary to convert into a query. - :param obj: Optional object to serialize as a JSON object. - :param headers: Optional dictionary of headers. - """ - - # Make a POST request... - req = self.make_req('POST', reluri, query=query, obj=obj, - headers=headers) - - # And issue it - return self.send(req) - - def delete(self, reluri, query=None, headers=None): - """Send a DELETE request. - - :param reluri: The resource URI, relative to the base URL. - :param query: Optional dictionary to convert into a query. - :param headers: Optional dictionary of headers. - """ - - # Make a DELETE request... - req = self.make_req('DELETE', reluri, query=query, headers=headers) - - # And issue it - return self.send(req) - - -class RESTException(Exception): - """Superclass for exceptions from this module.""" - - pass - - -class HTTPException(RESTException): - """Superclass of exceptions raised if an error status is returned.""" - - def __init__(self, response): - """Initializes exception, attaching response.""" - - # Formulate a message from the response - msg = response.reason - - # Initialize superclass - super(RESTException, self).__init__(msg) - - # Also attach status code and the response - self.status = response.status - self.response = response - - -# Set up more specific exceptions -exceptions = {} -for _status, _name in httplib.responses.items(): - # Skip non-error codes - if _status < 400: - continue - - # Make a valid name - _exname = re.sub(r'\W+', '', _name) + 'Exception' - - # Make a class - _cls = type(_exname, (HTTPException,), {'__doc__': _name}) - - # Now, put it in the right places - vars()[_exname] = _cls - exceptions[_status] = _cls - - -class RESTMethod(object): - """Represent a REST method. - - Represents a class method which should be translated into a - request to a REST server. - - """ - - def __init__(self, name, method, uri, argorder=None, reqwrapper=None, - **kwargs): - """Initialize a REST method. - - Creates a method that will use the defined HTTP method to - access the defined resource. Extra keyword arguments specify - the names and dispositions of arguments not derived from the - uri format string. The values of those extra arguments may be - 'query', 'req', or 'header', to indicate that the argument - goes in the query string, the request object, or the request - headers. (Note that header names have '_' mapped to '-' for - convenience.) If a value is a tuple, the first element of the - tuple must be the type ('query', 'req', or 'header'), and the - second element must be either True or False, to indicate that - the argument is required. By default, all query arguments are - optional, and all other arguments are required. - - :param name: The method name. - :param method: The corresponding HTTP method. - :param uri: A relative URI for the resource. A format string. - :param reqwrapper: Key for the wrapping dictionary of the request. - :param argorder: Order arguments may be specified in. - """ - - # Save our name and method - self.name = name - self.method = method.upper() - - # Need to save the various construction information - self.uri = uri - self.reqwrapper = reqwrapper - self.argorder = argorder or [] - - # Need to determine what keys are required and where they - # go... - self.kwargs = {} - - # Start by parsing the uri format string - for text, field, fmt, conv in string.Formatter().parse(uri): - # Add field as a required kw argument - if field is not None: - self.kwargs[field] = ('uri', True) - - # Now consider other mentioned arguments... - for field, type_ in kwargs.items(): - # Don't allow duplicate fields - if field in self.kwargs: - raise RESTException("Field %r of %s() already defined as %r" % - (field, name, self.kwargs[field][0])) - - # If type_ is a tuple, first element is type and second is - # required or not - required = None - if isinstance(type_, (tuple, list)): - required = type_[1] - type_ = type_[0] - - # Ensure valid type... - if (type_ not in ('query', 'req', 'header') or - (type_ == 'req' and reqwrapper is None)): - raise RESTException("Invalid type %r for field %r of %s()" % - (type_, field, name)) - - # For query arguments, required defaults to False - if required is None: - if type_ == 'query': - required = False - else: - required = True - - # Add the field - self.kwargs[field] = (type_, required) - - def __get__(self, obj, owner): - """Retrieve a wrapper to call this REST method.""" - - # If access via class, return ourself - if obj is None: - return self - - # OK, construct a wrapper to call the method with the - # appropriate RESTClient - def wrapper(*args, **kwargs): - # Build a dictionary from zipping together argorder and - # args - newkw = dict(zip(self.argorder, args)) - - # Make kwargs override - newkw.update(kwargs) - - return self(obj._rc, newkw) - - # Copy over the name for prettiness sake - wrapper.__name__ = self.name - wrapper.func_name = self.name - - return wrapper - - def __call__(self, rc, kwargs): - """Call this REST method. - - :param rc: A RESTClient instance. - :param kwargs: A dictionary of arguments to this REST method. - """ - - rc._debug("Called %s(%r)", self.name, kwargs) - - # We're going to build an object, a query, and headers - headers = {} - query = {} - if self.reqwrapper is None: - obj = None - reqobj = None - else: - obj = {} - reqobj = {self.reqwrapper: obj} - - # Let's walk through kwargs and make sure our required - # arguments are present - seen = set() - for field, (type_, required) in self.kwargs.items(): - # Is the field present? - if field not in kwargs: - # Is it required? - if required: - rc._debug(" Required %r argument %r missing", - type_, field) - raise RESTException("Missing required argument " - "%r of %s()" % - (field, self.name)) - - # Not required, don't worry about it - rc._debug(" Optional %r argument %r missing", - type_, field) - continue - - # Send it to the right place - if type_ == 'query': - rc._debug(" Query argument %r: %r", field, kwargs[field]) - query[field] = kwargs[field] - elif type_ == 'req': - rc._debug(" Request object argument %r: %r", field, - kwargs[field]) - obj[field] = kwargs[field] - elif type_ == 'header': - # Reformulate the name - hdr = '-'.join(field.split('_')).title() - rc._debug(" Header %r argument %r: %r", hdr, field, - kwargs[field]) - headers[hdr] = kwargs[field] - - # Keep track of arguments we've used - seen.add(field) - - # Deal with unprocessed arguments - if obj is not None: - for arg in set(kwargs.keys()) - seen: - rc._debug(" Extra request object argument %r: %r", - arg, kwargs[arg]) - obj[arg] = kwargs[arg] - - # Format the URI - uri = self.uri.format(**kwargs) - rc._debug(" Request URI: %s", uri) - - # We now have all the pieces we need; create a request... - req = rc.make_req(self.method, uri, query, reqobj, headers) - - # And send it - return rc.send(req) - - -class RESTAPI(object): - """Represent a REST API. - - A convenient superclass for defining REST APIs using this toolkit. - Methods should be defined by assigning instances of RESTMethod to - class variables. - - """ - - def __init__(self, baseurl, debug_stream=None): - """Initialize a REST API. - - Creates a RESTClient instance from the baseurl and attaches it - where RESTMethod expects to find it. - """ - - # Create and save a RESTClient for our use - self._rc = RESTClient(baseurl, debug_stream) - - @property - def rc(self): - """Retrieve the RESTClient instance.""" - - return self._rc diff --git a/test/functional/test_tokens.py b/test/functional/test_tokens.py deleted file mode 100644 index a30c4c9a..00000000 --- a/test/functional/test_tokens.py +++ /dev/null @@ -1,94 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import dtest -from dtest import util - -import base -import simplerest - - -class AuthenticateTest(base.BaseKeystoneTest): - def test_authenticate(self): - """Test that we can authenticate using Keystone.""" - - # Issue the authentication request - resp = self.ks.authenticate(base.options.adminuser, - base.options.adminpass) - - # Verify that resp is correct - util.assert_equal(resp.status, 200) - util.assert_in('auth', resp.obj) - util.assert_in('token', resp.obj['auth']) - util.assert_in('expires', resp.obj['auth']['token']) - util.assert_in('id', resp.obj['auth']['token']) - - # Squirrel away the admin token ID - admin_tok = resp.obj['auth']['token']['id'] - - # Now ensure we can revoke an authentication token - resp = self.ks_admin.revoke_token(admin_tok, admin_tok) - util.assert_equal(resp.status, 204) - - @dtest.depends(test_authenticate) - def test_adminauth(self): - """Test that we can authenticate using Keystone Admin API.""" - - # Issue the authentication request - resp = self.ks_admin.authenticate(base.options.adminuser, - base.options.adminpass) - - # Verify that resp is correct - util.assert_equal(resp.status, 200) - util.assert_in('auth', resp.obj) - util.assert_in('token', resp.obj['auth']) - util.assert_in('expires', resp.obj['auth']['token']) - util.assert_in('id', resp.obj['auth']['token']) - - # Squirrel away the admin token ID - admin_tok = resp.obj['auth']['token']['id'] - - # Now ensure we can revoke an authentication token - resp = self.ks_admin.revoke_token(admin_tok, admin_tok) - util.assert_equal(resp.status, 204) - - -# Ensure that all remaining tests wait for test_authenticate -dtest.depends(AuthenticateTest.test_authenticate, - AuthenticateTest.test_adminauth)(base.KeystoneTest.setUpClass) - - -class ValidateTest(base.KeystoneTest): - def test_validate(self): - """Test that we can validate tokens using Keystone.""" - - # Issue the validation request - resp = self.ks_admin.validate_token(self.admin_tok, self.user_tok) - - # Verify that resp is correct - util.assert_equal(resp.status, 200) - util.assert_in('auth', resp.obj) - util.assert_in('token', resp.obj['auth']) - util.assert_in('expires', resp.obj['auth']['token']) - util.assert_equal(resp.obj['auth']['token']['expires'], - self.user_expire) - util.assert_in('id', resp.obj['auth']['token']) - util.assert_equal(resp.obj['auth']['token']['id'], self.user_tok) - util.assert_in('user', resp.obj['auth']) - util.assert_in('username', resp.obj['auth']['user']) - util.assert_equal(resp.obj['auth']['user']['username'], - base.options.username) diff --git a/test/kill.sql b/test/kill.sql deleted file mode 100644 index 66e3733f..00000000 --- a/test/kill.sql +++ /dev/null @@ -1,10 +0,0 @@ --- --- Clean up the DB --- - -delete from users; -delete from tenants; -delete from groups; -delete from user_group_association; -delete from user_tenant_association; -delete from token; diff --git a/test/unit/__init__.py b/test/unit/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/test/unit/__init__.py +++ /dev/null diff --git a/test/unit/base.py b/test/unit/base.py deleted file mode 100644 index 0d59bba1..00000000 --- a/test/unit/base.py +++ /dev/null @@ -1,282 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Base test case classes for the unit tests""" - -import datetime -import functools -import json -import httplib -import logging -import pprint -import unittest - -from lxml import etree, objectify -import webob - -from keystone import server -from keystone.db.sqlalchemy import api as db_api - -logger = logging.getLogger('test.unit.base') - - -class ServiceAPITest(unittest.TestCase): - - """ - Base test case class for any unit test that tests the main service API. - """ - - """ - The `api` attribute for this base class is the `server.KeystoneAPI` - controller. - """ - api_class = server.KeystoneAPI - - """ - Dict of configuration options to pass to the API controller - """ - options = {'sql_connection': 'sqlite:///', # in-memory db - 'verbose': False, - 'debug': False} - - """ - Set of dicts of tenant attributes we start each test case with - """ - tenant_fixtures = [ - {'id': 'tenant1', - 'enabled': True, - 'desc': 'tenant1'} - ] - - """ - Attributes of the user the test creates for each test case that - will authenticate against the API. The `auth_user` attribute - will contain the created user with the following attributes. - """ - auth_user_attrs = {'id': 'auth_user', - 'password': 'auth_pass', - 'email': 'auth_user@example.com', - 'enabled': True, - 'tenant_id': 'tenant1'} - """ - Special attribute that is the identifier of the token we use in - authenticating. Makes it easy to test the authentication process. - """ - auth_token_id = 'SPECIALAUTHTOKEN' - - """ - Content-type of requests. Generally, you don't need to manually - change this. Instead, :see test.unit.decorators - """ - content_type = 'json' - - """ - Version of the API to test - """ - api_version = '2.0' - - def setUp(self): - self.api = self.api_class(self.options) - - self.expires = datetime.datetime.utcnow() - self.clear_all_data() - - # Create all our base tenants - for tenant in self.tenant_fixtures: - self.fixture_create_tenant(**tenant) - - # Create the user we will authenticate with - self.auth_user = self.fixture_create_user(**self.auth_user_attrs) - self.auth_token = self.fixture_create_token( - user_id=self.auth_user['id'], - tenant_id=self.auth_user['tenant_id'], - expires=self.expires, - token_id=self.auth_token_id) - - self.add_verify_status_helpers() - - def tearDown(self): - self.clear_all_data() - setattr(self, 'req', None) - setattr(self, 'res', None) - - def clear_all_data(self): - """ - Purges the database of all data - """ - db_api.unregister_models() - logger.debug("Cleared all data from database") - db_api.register_models() - - def fixture_create_tenant(self, **kwargs): - """ - Creates a tenant fixture. - - :params **kwargs: Attributes of the tenant to create - """ - values = kwargs.copy() - tenant = db_api.tenant_create(values) - logger.debug("Created tenant fixture %s", values['id']) - return tenant - - def fixture_create_user(self, **kwargs): - """ - Creates a user fixture. If the user's tenant ID is set, and the tenant - does not exist in the database, the tenant is created. - - :params **kwargs: Attributes of the user to create - """ - values = kwargs.copy() - tenant_id = values.get('tenant_id') - if tenant_id: - if not db_api.tenant_get(tenant_id): - db_api.tenant_create({'id': tenant_id, - 'enabled': True, - 'desc': tenant_id}) - user = db_api.user_create(values) - logger.debug("Created user fixture %s", values['id']) - return user - - def fixture_create_token(self, **kwargs): - """ - Creates a token fixture. - - :params **kwargs: Attributes of the token to create - """ - values = kwargs.copy() - token = db_api.token_create(values) - logger.debug("Created token fixture %s", values['token_id']) - return token - - def get_request(self, method, url, headers=None): - """ - Sets the `req` attribute to a `webob.Request` object that - is constructed with the supplied method and url. Supplied - headers are added to appropriate Content-type headers. - """ - headers = headers or {} - self.req = webob.Request.blank('/v%s/%s' % (self.api_version, - url.lstrip('/'))) - self.req.method = method - self.req.headers = headers - if 'content-type' not in headers: - ct = 'application/%s' % self.content_type - self.req.headers['content-type'] = ct - self.req.headers['accept'] = ct - return self.req - - def get_response(self): - """ - Sets the appropriate headers for the `req` attribute for - the current content type, then calls `req.get_response()` and - sets the `res` attribute to the returned `webob.Response` object - """ - self.res = self.req.get_response(self.api) - logger.debug("%s %s returned %s", self.req.method, self.req.path_qs, - self.res.status) - if self.res.status_int != httplib.OK: - logger.debug("Response Body:") - for line in self.res.body.split("\n"): - logger.debug(line) - return self.res - - def verify_status(self, status_code): - """ - Simple convenience wrapper for validating a response's status - code. - """ - if not getattr(self, 'res'): - raise RuntimeError("Called verify_status() before calling " - "get_response()!") - - self.assertEqual(status_code, self.res.status_int, - "Incorrect status code %d. Expected %d" % - (self.res.status_int, status_code)) - - def add_verify_status_helpers(self): - """ - Adds some convenience helpers using partials... - """ - self.status_ok = functools.partial(self.verify_status, - httplib.OK) - self.status_not_found = functools.partial(self.verify_status, - httplib.NOT_FOUND) - self.status_unauthorized = functools.partial(self.verify_status, - httplib.UNAUTHORIZED) - self.status_bad_request = functools.partial(self.verify_status, - httplib.BAD_REQUEST) - - def assert_dict_equal(self, expected, got): - """ - Compares two dicts for equality and prints the dictionaries - nicely formatted for easy comparison if there is a failure. - """ - self.assertEqual(expected, got, "Mappings are not equal.\n" - "Got:\n%s\nExpected:\n%s" % - (pprint.pformat(got), - pprint.pformat(expected))) - - def assert_xml_strings_equal(self, expected, got): - """ - Compares two XML strings for equality by parsing them both - into DOMs. Prints the DOMs nicely formatted for easy comparison - if there is a failure. - """ - # This is a nice little trick... objectify.fromstring() returns - # a DOM different from etree.fromstring(). The objectify version - # removes any different whitespacing... - got = objectify.fromstring(got) - expected = objectify.fromstring(expected) - self.assertEqual(etree.tostring(expected), - etree.tostring(got), "DOMs are not equal.\n" - "Got:\n%s\nExpected:\n%s" % - (etree.tostring(got, pretty_print=True), - etree.tostring(expected, pretty_print=True))) - - -class AdminAPITest(ServiceAPITest): - - """ - Base test case class for any unit test that tests the admin API. The - """ - - """ - The `api` attribute for this base class is the `server.KeystoneAdminAPI` - controller. - """ - api_class = server.KeystoneAdminAPI - - """ - Set of dicts of tenant attributes we start each test case with - """ - tenant_fixtures = [ - {'id': 'tenant1', - 'enabled': True, - 'desc': 'tenant1'}, - {'id': 'tenant2', - 'enabled': True, - 'desc': 'tenant2'} - ] - - """ - Attributes of the user the test creates for each test case that - will authenticate against the API. - """ - auth_user_attrs = {'id': 'admin_user', - 'password': 'admin_pass', - 'email': 'admin_user@example.com', - 'enabled': True, - 'tenant_id': 'tenant2'} diff --git a/test/unit/decorators.py b/test/unit/decorators.py deleted file mode 100644 index 17a7d432..00000000 --- a/test/unit/decorators.py +++ /dev/null @@ -1,49 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Decorators useful in unit tests""" - -import functools - - -def content_type(func, content_type='json'): - """ - Decorator for a test case method that sets the test case's - content_type to 'json' or 'xml' and resets it afterwards to - the original setting. This also asserts that if there is a - value for the test object's `res` attribute, that the content-type - header of the response is correct. - """ - @functools.wraps(func) - def wrapped(*a, **kwargs): - test_obj = a[0] - orig_content_type = test_obj.content_type - try: - test_obj.content_type = content_type - func(*a, **kwargs) - if getattr(test_obj, 'res'): - expected = 'application/%s' % content_type - got = test_obj.res.headers['content-type'].split(';')[0] - test_obj.assertEqual(expected, got, - "Bad content type: %s. Expected: %s" % - (got, expected)) - finally: - test_obj.content_type = orig_content_type - return wrapped - - -jsonify = functools.partial(content_type, content_type='json') -xmlify = functools.partial(content_type, content_type='xml') diff --git a/test/unit/test_BaseURLs.py b/test/unit/test_BaseURLs.py deleted file mode 100644 index fa352f93..00000000 --- a/test/unit/test_BaseURLs.py +++ /dev/null @@ -1,667 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import json -from lxml import etree -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest - -import test_common as utils -from test_common import URL - -class BaseURLsTest(unittest.TestCase): - def setUp(self): - self.tenant = utils.get_tenant() - self.password = utils.get_password() - self.email = utils.get_email() - self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - self.missing_token = utils.get_none_token() - self.invalid_token = utils.get_non_existing_token() - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.create_user(self.tenant, self.user, self.auth_token) - self.token = utils.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - utils.delete_user(self.tenant, self.user, self.auth_token) - utils.delete_tenant(self.tenant, self.auth_token) - utils.delete_all_baseurls_ref(self.tenant, self.auth_token) - -class GetBaseURLsTest(BaseURLsTest): - def test_get_baseURLs(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - #verify content - obj = json.loads(content) - if not "baseURLs" in obj: - raise self.fail("Expecting BaseURLs") - - def test_get_baseURLs_using_expired_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403 , int(resp['status'])) - - def test_get_baseURLs_using_disabled_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.disabled_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403 , int(resp['status'])) - - def test_get_baseURLs_using_missing_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.missing_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401 , int(resp['status'])) - - def test_get_baseURLs_using_invalid_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.invalid_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404 , int(resp['status'])) - - def test_get_baseURLs_xml(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - #verify content - dom = etree.Element("root") - dom.append(etree.fromstring(content)) - baseURLs = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "baseURLs") - if baseURLs == None: - self.fail("Expecting BaseURLs") - - def test_get_baseURLs_xml_expired_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_baseURLs_xml_disabled_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.disabled_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_baseURLs_xml_missing_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.missing_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_baseURLs_xml_invalid_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.invalid_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - -class GetBaseURLTest(BaseURLsTest): - def test_get_baseURL(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs/%s' % (utils.URL, '1') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - #verify content - obj = json.loads(content) - if not "baseURL" in obj: - raise self.fail("Expecting BaseURL") - - def test_get_baseURL_using_expired_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs/%s' % (utils.URL, '1') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_baseURL_using_disabled_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs/%s' % (utils.URL, '1') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.disabled_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_baseURL_using_missing_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs/%s' % (utils.URL, '1') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.missing_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - - def test_get_baseURL_using_invalid_auth_token(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs/%s' % (utils.URL, '1') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.invalid_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_baseURL_xml(self): - header = httplib2.Http(".cache") - url = '%sbaseURLs/%s' % (utils.URL,'1') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - #verify content - dom = etree.Element("root") - dom.append(etree.fromstring(content)) - baseURL = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "baseURL") - if baseURL == None: - self.fail("Expecting BaseURL") - - -class CreateBaseURLRefsTest(BaseURLsTest): - def test_baseurls_ref_create_json(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - - def test_baseurls_ref_create_json_using_expired_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.exp_auth_token)) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_baseurls_ref_create_json_using_disabled_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.disabled_token)) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_baseurls_ref_create_json_using_missing_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.missing_token)) - resp_val = int(resp['status']) - self.assertEqual(401, resp_val) - - def test_baseurls_ref_create_json_using_invalid_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.invalid_token)) - resp_val = int(resp['status']) - self.assertEqual(404, resp_val) - - def test_baseurls_ref_create_xml(self): - header = httplib2.Http(".cache") - - resp, content = utils.create_baseurls_ref_xml(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, '1') - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.auth_token)}) - resp_val = int(resp['status']) - self.assertEqual(204, resp_val) - - def test_baseurls_ref_create_xml_using_expired_token(self): - header = httplib2.Http(".cache") - - resp, content = utils.create_baseurls_ref_xml(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, '1') - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.exp_auth_token)}) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_baseurls_ref_create_xml_using_disabled_token(self): - header = httplib2.Http(".cache") - - resp, content = utils.create_baseurls_ref_xml(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, '1') - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.disabled_token)}) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_baseurls_ref_create_xml_using_missing_token(self): - header = httplib2.Http(".cache") - - resp, content = utils.create_baseurls_ref_xml(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, '1') - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.missing_token)}) - resp_val = int(resp['status']) - self.assertEqual(401, resp_val) - - def test_baseurls_ref_create_xml_using_invalid_token(self): - header = httplib2.Http(".cache") - - resp, content = utils.create_baseurls_ref_xml(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, '1') - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.invalid_token)}) - resp_val = int(resp['status']) - self.assertEqual(404, resp_val) - -class GetBaseURLRefsTest(BaseURLsTest): - def test_get_baseurls_ref_xml(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.auth_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_baseurls_ref_xml_using_expired_auth_token(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.exp_auth_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_baseurls_ref_xml_using_disabled_auth_token(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.disabled_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_baseurls_ref_xml_using_missing_auth_token(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.missing_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_baseurls_ref_xml_using_invalid_auth_token(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.invalid_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_baseurls_ref_json(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.auth_token), - "ACCEPT": "application/json"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - obj = json.loads(content) - if not "baseURLRefs" in obj: - raise self.fail("Expecting BaseURLRefs") - - def test_get_baseurls_ref_json_using_expired_auth_token(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.exp_auth_token), - "ACCEPT": "application/json"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - obj = json.loads(content) - - def test_get_baseurls_ref_json_using_disabled_auth_token(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.disabled_token), - "ACCEPT": "application/json"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - obj = json.loads(content) - - def test_get_baseurls_ref_json_using_missing_auth_token(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.missing_token), - "ACCEPT": "application/json"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - obj = json.loads(content) - - def test_get_baseurls_ref_json_using_invalid_auth_token(self): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.invalid_token), - "ACCEPT": "application/json"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - obj = json.loads(content) - -class DeleteBaseURLRefsTest(BaseURLsTest): - def test_delete_baseurlref(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "baseURLRef" in obj: - raise fault.BadRequestFault("Expecting baseURLRef") - base_url_ref = obj["baseURLRef"] - if not "id" in base_url_ref: - base_url_ref_id = None - else: - base_url_ref_id = base_url_ref["id"] - if base_url_ref_id is None: - raise fault.BadRequestFault("Expecting baseURLRefID") - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, base_url_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.auth_token)}) - resp_val = int(resp['status']) - self.assertEqual(204, resp_val) - - def test_delete_baseurlref_using_expired_auth_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "baseURLRef" in obj: - raise fault.BadRequestFault("Expecting baseURLRef") - base_url_ref = obj["baseURLRef"] - if not "id" in base_url_ref: - base_url_ref_id = None - else: - base_url_ref_id = base_url_ref["id"] - if base_url_ref_id is None: - raise fault.BadRequestFault("Expecting baseURLRefID") - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, base_url_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.exp_auth_token)}) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_delete_baseurlref_using_disabled_auth_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "baseURLRef" in obj: - raise fault.BadRequestFault("Expecting baseURLRef") - base_url_ref = obj["baseURLRef"] - if not "id" in base_url_ref: - base_url_ref_id = None - else: - base_url_ref_id = base_url_ref["id"] - if base_url_ref_id is None: - raise fault.BadRequestFault("Expecting baseURLRefID") - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, base_url_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.disabled_token)}) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_delete_baseurlref_using_missing_auth_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "baseURLRef" in obj: - raise fault.BadRequestFault("Expecting baseURLRef") - base_url_ref = obj["baseURLRef"] - if not "id" in base_url_ref: - base_url_ref_id = None - else: - base_url_ref_id = base_url_ref["id"] - if base_url_ref_id is None: - raise fault.BadRequestFault("Expecting baseURLRefID") - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, base_url_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.missing_token)}) - resp_val = int(resp['status']) - self.assertEqual(401, resp_val) - - def test_delete_baseurlref_using_invalid_auth_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_baseurls_ref(self.tenant,"1", - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "baseURLRef" in obj: - raise fault.BadRequestFault("Expecting baseURLRef") - base_url_ref = obj["baseURLRef"] - if not "id" in base_url_ref: - base_url_ref_id = None - else: - base_url_ref_id = base_url_ref["id"] - if base_url_ref_id is None: - raise fault.BadRequestFault("Expecting baseURLRefID") - url = '%stenants/%s/baseURLRefs/%s' % (URL, self.tenant, base_url_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.invalid_token)}) - resp_val = int(resp['status']) - self.assertEqual(404, resp_val) - -if __name__ == '__main__': - unittest.main()
\ No newline at end of file diff --git a/test/unit/test_auth.py b/test/unit/test_auth.py deleted file mode 100644 index e51cbbb6..00000000 --- a/test/unit/test_auth.py +++ /dev/null @@ -1,34 +0,0 @@ -import unittest -import os -import sys -import json - -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) - -from keystone import server -import keystone.logic.types.auth as auth -import keystone.logic.types.fault as fault - -from StringIO import StringIO -from datetime import date -from lxml import etree - - -class TestAuth(unittest.TestCase): - '''Unit tests for auth.py.''' - - pwd_xml = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="secret" username="disabled" \ - />' - - def test_pwd_cred_marshall(self): - creds = auth.PasswordCredentials.from_xml(self.pwd_xml) - self.assertTrue(creds.password,"secret") - self.assertTrue(creds.username,"username") - - -if __name__ == '__main__': - unittest.main()
\ No newline at end of file diff --git a/test/unit/test_authentication.py b/test/unit/test_authentication.py deleted file mode 100644 index 16160d48..00000000 --- a/test/unit/test_authentication.py +++ /dev/null @@ -1,186 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import json -from lxml import etree -import os -import sys -# Need to access identity module -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest -from webtest import TestApp - -import test_common as utils - - -class AuthenticationTest(unittest.TestCase): - - def setUp(self): - self.tenant = utils.get_tenant() - self.token = utils.get_token('joeuser', 'secrete', self.tenant, - 'token') - #self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - #self.exp_auth_token = utils.get_exp_auth_token() - #self.disabled_token = utils.get_disabled_token() - - def tearDown(self): - utils.delete_token(self.token, self.auth_token) - - def test_a_authorize(self): - resp, content = utils.get_token('joeuser', 'secrete', self.tenant) - self.assertEqual(200, int(resp['status'])) - self.assertEqual('application/json', utils.content_type(resp)) - - def test_a_authorize_xml(self): - resp, content = utils.get_token_xml('joeuser', 'secrete', - self.tenant) - self.assertEqual(200, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_authorize_legacy(self): - resp, content = utils.get_token_legacy('joeuser', 'secrete') - self.assertEqual(204, int(resp['status'])) - self.assertTrue(resp['x-auth-token']) - - def test_a_authorize_user_disabled(self): - header = httplib2.Http(".cache") - url = '%stokens' % utils.URL - body = {"passwordCredentials": {"username": self.userdisabled, - "password": "secrete", - "tenantId": self.tenant}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json"}) - - content = json.loads(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - self.assertEqual('application/json', utils.content_type(resp)) - - def test_a_authorize_user_disabled_xml(self): - header = httplib2.Http(".cache") - url = '%stokens' % utils.URL - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="secrete" username="%s" \ - tenantId="%s"/>' % (self.userdisabled, self.tenant) - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "ACCEPT": "application/xml"}) - - content = etree.fromstring(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_authorize_user_wrong(self): - header = httplib2.Http(".cache") - url = '%stokens' % utils.URL - body = {"passwordCredentials": {"username-w": "disabled", - "password": "secrete", - "tenantId": self.tenant}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json"}) - content = json.loads(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(400, int(resp['status'])) - self.assertEqual('application/json', utils.content_type(resp)) - - def test_a_authorize_user_wrong_xml(self): - header = httplib2.Http(".cache") - url = '%stokens' % utils.URL - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="secrete" username-w="disabled" \ - tenantId="%s"/>' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "ACCEPT": "application/xml"}) - content = etree.fromstring(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(400, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - -class MultiToken(unittest.TestCase): - - def setUp(self): - self.auth_token = utils.get_auth_token() - self.userdisabled = utils.get_userdisabled() - resp1, content1 = utils.create_tenant('test_tenant1', self.auth_token) - #create tenant2 - resp2, content2 = utils.create_tenant('test_tenant2', self.auth_token) - #create user1 with tenant1 - resp3, content3 = utils.create_user('test_tenant1', 'test_user1', - self.auth_token) - resp3, content3 = utils.create_user('test_tenant1', 'test_user2', - self.auth_token) - #add user1 to tenant2 - resp4, content4 = utils.add_user_json('test_tenant2', 'test_user1', - self.auth_token) - #self.exp_auth_token = utils.get_exp_auth_token() - #self.disabled_token = utils.get_disabled_token() - - def tearDown(self): - utils.delete_user('test_tenant1', 'test_user1', self.auth_token) - utils.delete_user('test_tenant1', 'test_user2', self.auth_token) - utils.delete_user('test_tenant2', 'test_user1', self.auth_token) - utils.delete_tenant('test_tenant1', self.auth_token) - utils.delete_tenant('test_tenant2', self.auth_token) - - """ INVALID TEST - we're changing how we delegate access to second tenant - def test_multi_token(self): - #get token for user1 with tenant1 - token1 = utils.get_token('test_user1', 'secrete', 'test_tenant1',\ - 'token') - #get token for user 1 with tenant2 - token2 = utils.get_token('test_user1', 'secrete', 'test_tenant2',\ - 'token') - #test result :: both token should be different - self.assertNotEqual(token1, None) - self.assertNotEqual(token2, None) - self.assertNotEqual(token1, token2) - - resp = utils.delete_token(token1, self.auth_token) - resp = utils.delete_token(token2, self.auth_token) - """ - - def test_unassigned_user(self): - resp, content = utils.get_token('test_user2', 'secrete', \ - 'test_tenant') - - self.assertEqual(401, int(resp['status'])) - -if __name__ == '__main__': - unittest.main() diff --git a/test/unit/test_authn_v2.py b/test/unit/test_authn_v2.py deleted file mode 100644 index af9d725b..00000000 --- a/test/unit/test_authn_v2.py +++ /dev/null @@ -1,463 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import logging - -from keystone import server -from test.unit import base -from test.unit.decorators import jsonify, xmlify - -logger = logging.getLogger('test.unit.test_authn_v2') - - -class AuthnMethods(object): - - def test_authn_get_fails(self): - """ - Test for GH issue #5. GET /tokens works when it should not - """ - url = "/tokens" - req = self.get_request('GET', url) - body = { - "passwordCredentials": { - "username": self.auth_user['id'], - "password": self.auth_user['password'], - "tenantId": self.auth_user['tenant_id'] - } - } - req.body = json.dumps(body) - self.get_response() - self.status_not_found() - - @jsonify - def test_authn_success_json(self): - """ - Test that good password credentials returns a 200 OK - """ - url = "/tokens" - req = self.get_request('POST', url) - body = { - "passwordCredentials": { - "username": self.auth_user['id'], - "password": self.auth_user['password'], - "tenantId": self.auth_user['tenant_id'] - } - } - req.body = json.dumps(body) - self.get_response() - self.status_ok() - - expected = { - u'auth': { - u'token': { - u'expires': self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - u'id': self.auth_token_id - } - } - } - self.assert_dict_equal(expected, json.loads(self.res.body)) - - @jsonify - def test_authn_success_missing_tenant_json(self): - """ - Test that supplying an existing user/pass, with a missing tenant ID - in the password credentials results in a 200 OK but a token not - matching the token with a tenant attached to it. - """ - # Create a special token for user with no tenant - auth_token = self.fixture_create_token( - user_id=self.auth_user['id'], - tenant_id=None, - expires=self.expires, - token_id='NOTENANTTOKEN') - - url = "/tokens" - req = self.get_request('POST', url) - body = { - "passwordCredentials": { - "username": self.auth_user['id'], - "password": self.auth_user['password'] - } - } - req.body = json.dumps(body) - self.get_response() - self.status_ok() - - expected = { - u'auth': { - u'token': { - u'expires': self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - u'id': 'NOTENANTTOKEN' - } - } - } - self.assert_dict_equal(expected, json.loads(self.res.body)) - - @jsonify - def test_authn_success_none_tenant_json(self): - """ - Test that supplying an existing user/pass, with a tenant ID of None - in the password credentials results in a 200 OK but a token not - matching the token with a tenant attached to it. - """ - # Create a special token for user with no tenant - auth_token = self.fixture_create_token( - user_id=self.auth_user['id'], - tenant_id=None, - expires=self.expires, - token_id='NOTENANTTOKEN') - - url = "/tokens" - req = self.get_request('POST', url) - body = { - "passwordCredentials": { - "username": self.auth_user['id'], - "password": self.auth_user['password'], - "tenantId": None - } - } - req.body = json.dumps(body) - self.get_response() - self.status_ok() - - expected = { - u'auth': { - u'token': { - u'expires': self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - u'id': 'NOTENANTTOKEN' - } - } - } - self.assert_dict_equal(expected, json.loads(self.res.body)) - - @jsonify - def test_authn_malformed_creds_json(self): - """ - Test that supplying a malformed password credentials - results in a 400 Bad Request - """ - url = "/tokens" - req = self.get_request('POST', url) - body = { - "passwordCredMisspelled": { - "username": 'unknown', - "password": 'badpass', - "tenantId": None - } - } - req.body = json.dumps(body) - self.get_response() - self.status_bad_request() - - @jsonify - def test_authn_user_not_found_json(self): - """ - Test that supplying a non-existing user in the password credentials - results in a 401 Unauthorized - """ - url = "/tokens" - req = self.get_request('POST', url) - body = { - "passwordCredentials": { - "username": 'unknown', - "password": 'badpass', - "tenantId": None - } - } - req.body = json.dumps(body) - self.get_response() - self.status_unauthorized() - - @jsonify - def test_authn_user_missing_json(self): - """ - Test that supplying a missing user in the password credentials - results in a 401 Unauthorized - """ - url = "/tokens" - req = self.get_request('POST', url) - body = { - "passwordCredentials": { - "username": None, - "password": self.auth_user['password'], - "tenantId": self.auth_user['tenant_id'] - } - } - req.body = json.dumps(body) - self.get_response() - self.status_unauthorized() - - @jsonify - def test_authn_bad_pass_json(self): - """ - Test that supplying an existing user and a bad password - in the password credentials results in a 401 Unauthorized - """ - url = "/tokens" - req = self.get_request('POST', url) - body = { - "passwordCredentials": { - "username": self.auth_user['id'], - "password": 'badpass', - "tenantId": None - } - } - req.body = json.dumps(body) - self.get_response() - self.status_unauthorized() - - @jsonify - def test_authn_bad_tenant_json(self): - """ - Test that supplying an existing user/pass, with a bad tenant ID - in the password credentials results in a 401 Unauthorized - """ - url = "/tokens" - req = self.get_request('POST', url) - body = { - "passwordCredentials": { - "username": self.auth_user['id'], - "password": self.auth_user['password'], - "tenantId": 'badtenant' - } - } - req.body = json.dumps(body) - self.get_response() - self.status_unauthorized() - - @xmlify - def test_authn_success_xml(self): - """ - Test that good password credentials returns a 200 OK - """ - url = "/tokens" - req = self.get_request('POST', url) - req.body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" \ - tenantId="%s"/> ' % (self.auth_user['password'], - self.auth_user['id'], - self.auth_user['tenant_id']) - self.get_response() - self.status_ok() - - expected = """ - <auth xmlns="http://docs.openstack.org/identity/api/v2.0"> - <token expires="%s" id="%s" /> - </auth> - """ % (self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - self.auth_token_id) - self.assert_xml_strings_equal(expected, self.res.body) - - @xmlify - def test_authn_success_missing_tenant_xml(self): - """ - Test that supplying an existing user/pass, with a missing tenant ID - in the password credentials results in a 200 OK but a token not - matching the token with a tenant attached to it. - """ - # Create a special token for user with no tenant - auth_token = self.fixture_create_token( - user_id=self.auth_user['id'], - tenant_id=None, - expires=self.expires, - token_id='NOTENANTTOKEN') - - url = "/tokens" - req = self.get_request('POST', url) - req.body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" /> ' % ( - self.auth_user['password'], - self.auth_user['id']) - self.get_response() - self.status_ok() - - expected = """ - <auth xmlns="http://docs.openstack.org/identity/api/v2.0"> - <token expires="%s" id="%s" /> - </auth> - """ % (self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - 'NOTENANTTOKEN') - self.assert_xml_strings_equal(expected, self.res.body) - - @xmlify - def test_authn_malformed_creds_xml(self): - """ - Test that supplying a malformed password credentials - results in a 400 Bad Request - """ - url = "/tokens" - req = self.get_request('POST', url) - req.body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredMispelled \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" \ - tenantId="%s"/> ' % (self.auth_user['password'], - self.auth_user['id'], - self.auth_user['tenant_id']) - self.get_response() - self.status_bad_request() - - @xmlify - def test_authn_user_not_found_xml(self): - """ - Test that supplying a non-existing user in the password credentials - results in a 401 Unauthorized - """ - url = "/tokens" - req = self.get_request('POST', url) - req.body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" \ - tenantId="%s"/> ' % (self.auth_user['password'], - 'missinguser', - self.auth_user['tenant_id']) - self.get_response() - self.status_unauthorized() - - @xmlify - def test_authn_user_missing_xml(self): - """ - Test that supplying a missing user in the password credentials - results in a 400 Bad Request - """ - url = "/tokens" - req = self.get_request('POST', url) - req.body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" \ - tenantId="%s"/> ' % (self.auth_user['password'], - self.auth_user['tenant_id']) - self.get_response() - self.status_bad_request() - - @xmlify - def test_authn_bad_pass_xml(self): - """ - Test that supplying a bad password in the password credentials - results in a 401 Unauthorized - """ - url = "/tokens" - req = self.get_request('POST', url) - req.body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" \ - tenantId="%s"/> ' % ('badpass', - self.auth_user['id'], - self.auth_user['tenant_id']) - self.get_response() - self.status_unauthorized() - - @xmlify - def test_authn_bad_tenant_xml(self): - """ - Test that supplying a bad tenant in the password credentials - results in a 401 Unauthorized - """ - url = "/tokens" - req = self.get_request('POST', url) - req.body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" \ - tenantId="%s"/> ' % (self.auth_user['password'], - self.auth_user['id'], - 'badtenant') - self.get_response() - self.status_unauthorized() - - -class TestAuthnV2(base.ServiceAPITest, AuthnMethods): - - """ - Tests for the /v2.0/tokens auth endpoint with main service API - """ - - -class TestAdminAuthnV2(base.AdminAPITest, AuthnMethods): - - """ - Tests for the /v2.0/tokens auth endpoint with admin API - """ - - @jsonify - def test_validate_token_json(self): - """ - Test successful validation of the token we use in authn - """ - url = "/tokens/%s" % self.auth_token_id - headers = {"X-Auth-Token": self.auth_token_id} - req = self.get_request('GET', url, headers) - self.get_response() - self.status_ok() - - expected = { - "auth": { - "token": { - u'expires': self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - u'id': self.auth_token_id, - "tenantId": self.auth_user['tenant_id'] - }, - "user": { - "username": self.auth_user['id'], - "tenantId": self.auth_user['tenant_id'], - "roleRefs": [] - } - } - } - for user_role in self.auth_user['roles']: - expected["auth"]["user"]["roleRefs"].append( - {"roleId": user_role['role_id'], "id": user_role['id']}) - self.assert_dict_equal(expected, json.loads(self.res.body)) - - @xmlify - def test_validate_token_xml(self): - """ - Test successful validation of the token we use in authn - """ - url = "/tokens/%s" % self.auth_token_id - headers = {"X-Auth-Token": self.auth_token_id} - req = self.get_request('GET', url, headers) - self.get_response() - self.status_ok() - - expected = """<auth xmlns="http://docs.openstack.org/identity/api/v2.0"> - <token expires="%s" id="%s" tenantId="%s"/> - <user username="%s" tenantId="%s"> - <roleRefs xmlns="http://docs.openstack.org/identity/api/v2.0"> - """ % ( - self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - self.auth_token_id, - self.auth_user['tenant_id'], - self.auth_user['id'], - self.auth_user['tenant_id']) - - for user_role in self.auth_user['roles']: - expected = expected + """ - <roleRef xmlns="http://docs.openstack.org/identity/api/v2.0" - id="%s" roleId="%s"/>""" % (user_role['id'], - user_role['role_id']) - expected = expected + """</roleRefs> - </user> - </auth>""" - self.assert_xml_strings_equal(expected, self.res.body) diff --git a/test/unit/test_common.py b/test/unit/test_common.py deleted file mode 100644 index e77f7fc8..00000000 --- a/test/unit/test_common.py +++ /dev/null @@ -1,809 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import json -from lxml import etree -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest - -URL = 'http://localhost:8081/v2.0/' -URLv1 = 'http://localhost:8081/v1.0/' - -def get_token(user, pswd, tenant_id, kind=''): - header = httplib2.Http(".cache") - url = '%stokens' % URL - - if not tenant_id: - body = {"passwordCredentials": {"username": user, - "password": pswd}} - else: - body = {"passwordCredentials": {"username": user, - "password": pswd, - "tenantId": tenant_id}} - - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json"}) - - if int(resp['status']) == 200: - content = json.loads(content) - token = str(content['auth']['token']['id']) - else: - token = None - if kind == 'token': - return token - else: - return (resp, content) - - -def get_token_legacy(user, pswd, kind=''): - header = httplib2.Http(".cache") - url = URLv1 - resp, content = header.request(url, "GET", '', - headers={"Content-Type": "application/json", - "X-Auth-User": user, - "X-Auth-Key": pswd}) - - if int(resp['status']) == 204: - token = resp['x-auth-token'] - else: - token = None - if kind == 'token': - return token - else: - return (resp, content) - - -def delete_token(token, auth_token): - header = httplib2.Http(".cache") - url = '%stoken/%s' % (URL, token) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def create_tenant(tenantid, auth_token): - header = httplib2.Http(".cache") - - url = '%stenants' % (URL) - body = {"tenant": {"id": tenantid, - "description": "A description ...", - "enabled": True}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def create_tenant_group(groupid, tenantid, auth_token): - header = httplib2.Http(".cache") - - url = '%stenants/%s/groups' % (URL, tenantid) - body = {"group": {"id": groupid, - "description": "A description ..."}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def delete_tenant(tenantid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s' % (URL, tenantid) - resp, content = header.request(url, "DELETE", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return resp - - -def delete_tenant_group(groupid, tenantid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/groups/%s' % (URL, tenantid, groupid) - resp, content = header.request(url, "DELETE", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def create_global_group(groupid, auth_token): - header = httplib2.Http(".cache") - - url = '%sgroups' % (URL) - body = {"group": {"id": groupid, - "description": "A description ..."}} - resp, content = header.request(url, "POST", body=json.dumps(body), - - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def create_global_group_xml(groupid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups' % (URL) - body = '<?xml version="1.0" encoding="UTF-8"?>\ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"><description>A Description of the group</description>\ - </group>' % groupid - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def delete_global_group(groupid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups/%s' % (URL, groupid) - resp, content = header.request(url, "DELETE", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def delete_global_group_xml(groupid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups/%s' % (URL, groupid) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def get_token_xml(user, pswd, tenant_id, type=''): - header = httplib2.Http(".cache") - url = '%stokens' % URL - # to test multi token, removing below code - """if tenant_id: - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" \ - tenantId="%s"/> ' % (pswd, user, tenant_id) - else: - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" /> ' % (pswd, user)""" - # adding code ie., body - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="%s" username="%s" \ - tenantId="%s"/> ' % (pswd, user, tenant_id) - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "ACCEPT": "application/xml"}) - if int(resp['status']) == 200: - dom = etree.fromstring(content) - root = dom.find("{http://docs.openstack.org/" \ - "identity/api/v2.0}token") - token_root = root.attrib - token = str(token_root['id']) - else: - token = None - - if type == 'token': - return token - else: - return (resp, content) - - -def delete_token_xml(token, auth_token): - header = httplib2.Http(".cache") - url = '%stoken/%s' % (URL, token) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def create_tenant_xml(tenantid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants' % (URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true" id="%s"> \ - <description>A description...</description> \ - </tenant>' % tenantid - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def create_tenant_group_xml(groupid, tenantid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/groups' % (URL, tenantid) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"> \ - <description>A description...</description> \ - </group>' % groupid - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def delete_tenant_xml(tenantid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s' % (URL, tenantid) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - - return resp - - -def delete_tenant_group_xml(groupid, tenantid, auth_token): - header = httplib2.Http(".cache") - url = '%stenant/%s/groups/%s' % (URL, tenantid, groupid) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def create_user(tenantid, userid, auth_token, email=None): - header = httplib2.Http(".cache") - url = '%stenants/%s/users' % (URL, tenantid) - if email is not None: - email_id = email - else: - email_id = "%s@rackspace.com" % userid - body = {"user": {"password": "secrete", - "id": userid, - "tenantId": tenantid, - "email": "%s" % email_id, - "enabled": True}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def delete_user(tenant, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/users/%s' % (URL, tenant, userid) - resp, content = header.request(url, "DELETE", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return resp - - -def create_user_xml(tenantid, userid, auth_token, email=None): - header = httplib2.Http(".cache") - url = '%stenants/%s/users' % (URL, tenantid) - if email is not None: - email_id = email - else: - email_id = userid - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <user xmlns="http://docs.openstack.org/identity/api/v2.0" \ - email="%s" \ - tenantId="%s" id="%s" \ - enabled="true" password="secrete"/>' % (email_id, tenantid, userid) - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -"""def delete_user(tenant, userid, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s' % (URL, tenant, userid) - - resp, content = h.request(url, "DELETE", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return resp""" - - -def delete_user_xml(tenantid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/users/%s' % (URL, tenantid, userid) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return resp - - -def add_user_json(tenantid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/add' % (URL, tenantid, userid) - resp, content = header.request(url, "PUT", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - -def add_user_xml(tenantid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/add' % (URL, tenantid, userid) - resp, content = header.request(url, "PUT", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - -def add_user_json(tenantid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/users/' % (URL, tenantid) - resp, content = header.request(url, "POST", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def add_user_xml(tenantid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/add' % (URL, tenantid, userid) - resp, content = header.request(url, "PUT", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def user_update_json(tenant_id, user_id, auth_token, email=None): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s' % (URL, tenant_id, user_id) - if email is None: - new_email = "updatedjoeuser@rackspace.com" - else: - new_email = email - data = '{"user": { "email": "%s"}}' % (new_email) - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def user_update_xml(tenant_id, user_id, auth_token, email=None): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s' % (URL, tenant_id, user_id) - if email is None: - new_email = "updatedjoeuser@rackspace.com" - else: - new_email = email - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <user xmlns="http://docs.openstack.org/identity/api/v2.0" \ - email="%s" />' % (new_email) - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def user_get_json(tenant_id, user_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s' % (URL, tenant_id, user_id) - #test for Content-Type = application/json - resp, content = h.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def user_password_json(tenant_id, user_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/password' % (URL, tenant_id, user_id) - data = '{"user": { "password": "p@ssword"}}' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def user_password_xml(tenant_id, user_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/password' % (URL, tenant_id, user_id) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <user xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="p@ssword" />' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def user_enabled_json(tenant_id, user_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/enabled' % (URL, tenant_id, user_id) - data = {"user": {"enabled": True}} - resp, content = h.request(url, "PUT", body=json.dumps(data), - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def user_enabled_xml(tenant_id, user_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/enabled' % (URL, tenant_id, user_id) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <user xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true" />' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def user_get_xml(tenant_id, user_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s' % (URL, tenant_id, user_id) - resp, content = h.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def users_get_json(tenant_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users' % (URL, tenant_id) - resp, content = h.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def users_get_xml(tenant_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users' % (URL, tenant_id) - resp, content = h.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def users_group_get_json(tenant_id, user_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/groups' % (URL, tenant_id, user_id) - resp, content = h.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def users_group_get_xml(tenant_id, user_id, auth_token): - h = httplib2.Http(".cache") - url = '%stenants/%s/users/%s/groups' % (URL, tenant_id, user_id) - resp, content = h.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def add_user_tenant_group(tenantid, groupid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/groups/%s/users/%s' % (URL, tenantid, groupid, userid) - - resp, content = header.request(url, "PUT", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def add_user_tenant_group_xml(tenantid, groupid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/groups/%s/users/%s' % (URL, tenantid, groupid, userid) - - resp, content = header.request(url, "PUT", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def delete_user_tenant_group(tenantid, groupid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/groups/%s/users/%s' % (URL, tenantid, groupid, userid) - - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def delete_user_tenant_group_xml(tenantid, groupid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/groups/%s/users/%s' % (URL, tenantid, groupid, userid) - - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def get_user_tenant_group(tenantid, groupid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/groups/%s/users' % (URL, tenantid, groupid) - - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def get_user_tenant_group_xml(tenantid, groupid, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/groups/%s/users' % (URL, tenantid, groupid) - - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def add_user_global_group(groupid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups/%s/users/%s' % (URL, groupid, userid) - - resp, content = header.request(url, "PUT", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def add_user_global_group_xml(groupid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups/%s/users/%s' % (URL, groupid, userid) - - resp, content = header.request(url, "PUT", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def delete_user_global_group(groupid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups/%s/users/%s' % (URL, groupid, userid) - - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - - -def delete_user_global_group_xml(groupid, userid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups/%s/users/%s' % (URL, groupid, userid) - - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def get_user_global_group(groupid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups/%s/users' % (URL, groupid) - - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - - return (resp, content) - - -def get_userid(): - return 'test_user11' - - -def get_password(): - return 'secrete' - - -def get_email(): - return 'joetest@rackspace.com' - - -def get_user_global_group_xml(groupid, auth_token): - header = httplib2.Http(".cache") - url = '%sgroups/%s/users' % (URL, groupid) - - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - - -def get_tenant(): - return '1234' - - -def get_another_tenant(): - return '4321' - - -def get_user(): - return 'test_user' - - -def get_userdisabled(): - return 'disabled' - - -def get_auth_token(): - return '999888777666' - - -def get_exp_auth_token(): - return '000999' - - -def get_none_token(): - return '' - - -def get_non_existing_token(): - return 'invalid_token' - - -def get_disabled_token(): - return '999888777' - - -def content_type(resp): - return resp['content-type'].split(';')[0] - - -def get_global_tenant(): - return 'GlobalTenant' - - -def handle_user_resp(self, content, respvalue, resptype): - if respvalue == 200: - if resptype == 'application/json': - content = json.loads(content) - if 'tenantId' in content['user']: - self.tenant = content['user']['tenantId'] - self.userid = content['user']['id'] - if resptype == 'application/xml': - content = etree.fromstring(content) - self.tenant = content.get("tenantId") - self.id = content.get("id") - if respvalue == 500: - self.fail('Identity Fault') - elif respvalue == 503: - self.fail('Service Not Available') - -def create_role(roleid, auth_token): - header = httplib2.Http(".cache") - - url = '%sroles' % (URL) - body = {"role": {"id": roleid, - "description": "A description ..."}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - -def create_role_ref(user_id, role_id, tenant_id, auth_token): - header = httplib2.Http(".cache") - - url = '%susers/%s/roleRefs' % (URL, user_id) - body = {"roleRef": {"tenantId": tenant_id, - "roleId": role_id}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - -def create_role_ref_xml(user_id, role_id, tenant_id, auth_token): - header = httplib2.Http(".cache") - url = '%susers/%s/roleRefs' % (URL, user_id) - body = '<?xml version="1.0" encoding="UTF-8"?>\ - <roleRef xmlns="http://docs.openstack.org/identity/api/v2.0" \ - tenantId="%s" roleId="%s"/>\ - ' % (tenant_id, role_id) - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - -def delete_role_ref(user, role_ref_id, auth_token): - header = httplib2.Http(".cache") - url = '%susers/%s/roleRefs/%s' % (URL, user, role_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(auth_token)}) - return (resp, content) - -def create_role_xml(role_id, auth_token): - header = httplib2.Http(".cache") - url = '%sroles' % (URL) - body = '<?xml version="1.0" encoding="UTF-8"?>\ - <role xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s" description="A Description of the group"/>\ - ' % role_id - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - -def create_baseurls_ref(tenant_id, baseurl_id, auth_token): - header = httplib2.Http(".cache") - - url = '%stenants/%s/baseURLRefs' % (URL, tenant_id) - body = {"baseURL": {"id": baseurl_id}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - return (resp, content) - -def create_baseurls_ref_xml(tenant_id, baseurl_id, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, tenant_id) - body = '<?xml version="1.0" encoding="UTF-8"?>\ - <baseURL xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"/>\ - ' % (baseurl_id) - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": auth_token, - "ACCEPT": "application/xml"}) - return (resp, content) - -def delete_all_baseurls_ref(tenant_id, auth_token): - header = httplib2.Http(".cache") - url = '%stenants/%s/baseURLRefs' % (URL, tenant_id) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - - #verify content - obj = json.loads(content) - base_url_refs = obj["baseURLRefs"]["values"] - for base_url_ref in base_url_refs: - url = '%stenants/%s/baseURLRefs/%s' % (URL, tenant_id, base_url_ref["id"]) - header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(auth_token)}) - -if __name__ == '__main__': - unittest.main()
\ No newline at end of file diff --git a/test/unit/test_exthandler.py b/test/unit/test_exthandler.py deleted file mode 100644 index 4379e03f..00000000 --- a/test/unit/test_exthandler.py +++ /dev/null @@ -1,65 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import sys -# Need to access identity module -sys.path.append(os.path.abspath(os.path.join( - os.getcwd(), '..', '..', 'keystone'))) -from queryext.exthandler import UrlExtensionFilter -import unittest - - -class MockWsgiApp(object): - - def __init__(self): - pass - - def __call__(self, env, start_response): - pass - - -def _start_response(): - pass - - -class UrlExtensionFilterTest(unittest.TestCase): - - def setUp(self): - self.filter = UrlExtensionFilter(MockWsgiApp(), {}) - - def test_xml_extension(self): - env = {'PATH_INFO': '/v2.0/someresource.xml'} - self.filter(env, _start_response) - self.assertEqual('/v2.0/someresource', env['PATH_INFO']) - self.assertEqual('application/xml', env['HTTP_ACCEPT']) - - def test_json_extension(self): - env = {'PATH_INFO': '/v2.0/someresource.json'} - self.filter(env, _start_response) - self.assertEqual('/v2.0/someresource', env['PATH_INFO']) - self.assertEqual('application/json', env['HTTP_ACCEPT']) - - def test_extension_overrides_header(self): - env = {'PATH_INFO': '/v2.0/someresource.json', - 'HTTP_ACCEPT': 'application/xml'} - self.filter(env, _start_response) - self.assertEqual('/v2.0/someresource', env['PATH_INFO']) - self.assertEqual('application/json', env['HTTP_ACCEPT']) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/unit/test_groups.py b/test/unit/test_groups.py deleted file mode 100644 index 2d7a7e00..00000000 --- a/test/unit/test_groups.py +++ /dev/null @@ -1,966 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import json -from lxml import etree -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest -from webtest import TestApp - -import test_common as utils - - -## -## Global Group Tests -## - - -class GlobalGroupTest(unittest.TestCase): - - def setUp(self): - self.globaltenant = utils.get_global_tenant() - self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - self.global_group = 'test_global_group_add' - utils.create_tenant(self.globaltenant, str(self.auth_token)) - utils.create_user(self.globaltenant, self.user, self.auth_token) - utils.add_user_json(self.globaltenant, self.user, self.auth_token) - self.token = utils.get_token(self.user, 'secrete', self.globaltenant, - 'token') - - def tearDown(self): - utils.delete_user(self.globaltenant, self.user, str(self.auth_token)) - utils.delete_global_group(self.global_group, self.auth_token) - utils.delete_tenant(self.globaltenant, self.auth_token) - - -class CreateGlobalGroupTest(GlobalGroupTest): - - def test_global_group_create(self): - utils.delete_global_group(self.global_group, str(self.auth_token)) - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - - if int(resp_new['status']) == 500: - self.fail('Identity fault') - elif int(resp_new['status']) == 503: - self.fail('Service Not Available') - if int(resp_new['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp_new['status'])) - - def test_global_group_create_xml(self): - utils.delete_global_group_xml(self.global_group, str(self.auth_token)) - resp_new, content_new = utils.create_global_group_xml(\ - self.global_group, - str(self.auth_token)) - - if int(resp_new['status']) == 500: - self.fail('Identity fault') - elif int(resp_new['status']) == 503: - self.fail('Service Not Available') - - if int(resp_new['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp_new['status'])) - - def test_global_group_create_again(self): - utils.create_global_group(self.global_group, str(self.auth_token)) - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - if int(resp_new['status']) == 500: - self.fail('Identity fault') - elif int(resp_new['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp_new['status'])) - - def test_global_group_create_again_xml(self): - utils.create_global_group_xml(self.global_group, str(self.auth_token)) - resp_new, content_new = utils.create_global_group_xml(\ - self.global_group, - str(self.auth_token)) - content_new = etree.fromstring(content_new) - if int(resp_new['status']) == 500: - self.fail('Identity fault') - elif int(resp_new['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp_new['status'])) - - def test_global_group_create_unauthorized_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_global_group(\ - self.global_group, - str(self.token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_global_group_create_unauthorized_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_global_group_xml(\ - self.global_group, - str(self.token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_global_group_create_expired_token(self): - header = httplib2.Http(".cache") - url = '%sgroups' % (utils.URL) - body = {"group": {"id": self.global_group, - "description": "A description ..."}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": \ - self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_global_group_create_expired_token_xml(self): - header = httplib2.Http(".cache") - url = '%sgroups' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"><description>A description...</description> \ - </group>' % self.globaltenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_global_group_create_missing_token(self): - header = httplib2.Http(".cache") - url = '%sgroups' % (utils.URL) - body = {"group": {"id": self.global_group, - "description": "A description ..."}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_global_group_create_missing_token_xml(self): - header = httplib2.Http(".cache") - url = '%sgroups' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"><description>A description...</description> \ - </group>' % self.global_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_global_group_create_disabled_token(self): - header = httplib2.Http(".cache") - url = '%sgroups' % (utils.URL) - body = '{"group": { "id": "%s", \ - "description": "A description ..." } }' % self.global_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/json", - "X-Auth-Token": \ - self.disabled_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_global_group_create_disabled_token_xml(self): - header = httplib2.Http(".cache") - url = '%sgroups' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"><description>A description...</description> \ - </group>' % self.global_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.disabled_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_global_group_create_invalid_token(self): - header = httplib2.Http(".cache") - url = '%sgroups' % (utils.URL) - body = '{"group": { "id": "%s", \ - "description": "A description ..." } }' % self.globaltenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/json", - "X-Auth-Token": 'nonexsitingtoken'}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_global_group_create_invalid_token_xml(self): - header = httplib2.Http(".cache") - url = '%sgroups' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"><description>A description...</description> \ - </group>' % self.global_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": 'nonexsitingtoken', - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class GetGlobalGroupsTest(GlobalGroupTest): - - def test_get_global_groups(self): - header = httplib2.Http(".cache") - utils.delete_global_group(self.global_group, str(self.auth_token)) - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - - url = '%sgroups' % (utils.URL) - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_global_groups_xml(self): - header = httplib2.Http(".cache") - utils.create_global_group_xml(self.global_group, str(self.auth_token)) - url = '%sgroups' % (utils.URL) - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_global_groups_unauthorized_token(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - url = '%sgroups' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_global_groups_unauthorized_token_xml(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group_xml(\ - self.global_group, - str(self.auth_token)) - url = '%sgroups' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_global_groups_exp_token(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - url = '%sgroups' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": \ - self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_global_groups_exp_token_xml(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group_xml(\ - self.global_group, - str(self.auth_token)) - url = '%sgroups' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - -class GetGlobalGroupTest(GlobalGroupTest): - - def test_get_global_group(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - url = '%sgroups/%s' % (utils.URL, self.global_group) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_global_group_xml(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group_xml(\ - self.global_group, - str(self.auth_token)) - url = '%sgroups/%s' % (utils.URL, self.global_group) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_global_group_bad(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - url = '%sgroups/%s' % (utils.URL, 'global_group_bad') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_global_group_bad_xml(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group_xml(\ - self.global_group, - str(self.auth_token)) - url = '%sgroups/%s' % (utils.URL, 'global_group_bad') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class UpdateGlobalGroupsTest(GlobalGroupTest): - - def test_update_global_group(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - url = '%sgroups/%s' % (utils.URL, self.global_group) - resp, content = header.request(url, "PUT", body='{"group":{\ - "id" : "%s","description" :\ - "A New description of the group..."}}' % self.global_group, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - body = json.loads(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - self.assertEqual(self.global_group, body['group']['id']) - self.assertEqual('A New description of the group...', - str(body['group']['description'])) - - def test_update_global_group_xml(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - - url = '%sgroups/%s' % (utils.URL, self.global_group) - data = u'<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"><description>A NEW description...</description> \ - </group>' % (self.global_group) - #test for Content-Type = application/json - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - - body = etree.fromstring(content) - desc = body.find("{http://docs.openstack.org/identity/api/v2.0}description") - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - self.assertEqual(str(self.global_group), str(body.get('id'))) - self.assertEqual('A NEW description...', desc.text) - - def test_update_global_group_bad(self): - header = httplib2.Http(".cache") - resp_new, content_new = utils.create_global_group(self.global_group, - str(self.auth_token)) - url = '%sgroups/%s' % (utils.URL, self.global_group) - data = '{"group": { "description_bad": "A NEW description...", \ - "id":"%s" }}'\ - % (self.global_group) - #test for Content-Type = application/json - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(400, int(resp['status'])) - - def test_update_global_group_bad_xml(self): - header = httplib2.Http(".cache") - utils.create_global_group_xml(self.global_group, str(self.auth_token)) - url = '%sgroups/%s' % (utils.URL, self.global_group) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"><description_bad>A NEW description...</description> \ - </group>' % (self.global_group) - #test for Content-Type = application/json - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - - self.assertEqual(400, int(resp['status'])) - - def test_update_global_group_not_found(self): - header = httplib2.Http(".cache") - utils.create_global_group(self.global_group, str(self.auth_token)) - url = '%sgroups/NonexistingID' % (utils.URL) - data = '{"group": { "description": "A NEW description...", \ - "id":"NonexistingID"}}' - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - self.assertEqual(404, int(resp['status'])) - - def test_update_global_group_not_found_xml(self): - header = httplib2.Http(".cache") - utils.create_tenant_xml(self.globaltenant, str(self.auth_token)) - url = '%sgroups/NonexistingID' % (utils.URL) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="NonexistingID"> \ - <description_bad>A NEW description...</description> \ - </group>' - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class DeleteGlobalGroupTest(GlobalGroupTest): - - def test_delete_global_group_not_found(self): - resp, content = utils.delete_global_group("test_global_group_1", - str(self.auth_token)) - self.assertEqual(404, int(resp['status'])) - - def test_delete_global_group_not_found_xml(self): - resp, content = utils.delete_global_group_xml("test_global_group_1", - str(self.auth_token)) - self.assertEqual(404, int(resp['status'])) - - def test_delete_global_group(self): - utils.create_tenant(self.globaltenant, str(self.auth_token)) - utils.create_tenant_group('test_global_group_delete', - self.globaltenant, str(self.auth_token)) - resp_new, content_new = utils.delete_global_group(\ - 'test_global_group_delete', - str(self.auth_token)) - resp = utils.delete_tenant(self.globaltenant, str(self.auth_token)) - self.assertEqual(204, int(resp_new['status'])) - - def test_delete_global_group_xml(self): - - utils.create_tenant_xml(self.globaltenant, str(self.auth_token)) - - utils.create_tenant_group_xml('test_global_group_delete', - self.globaltenant, str(self.auth_token)) - - resp_new, content_new = utils.delete_global_group_xml(\ - 'test_global_group_delete', - str(self.auth_token)) - utils.delete_tenant_xml(self.globaltenant, str(self.auth_token)) - - self.assertEqual(204, int(resp_new['status'])) - - -class AddUserGlobalGroupTest(unittest.TestCase): - - def setUp(self): - self.tenant = utils.get_global_tenant() - self.auth_token = utils.get_auth_token() - self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - self.global_group = 'test_global_group' - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.create_user(self.tenant, self.user, self.auth_token) - utils.add_user_json(self.tenant, self.user, self.auth_token) - self.token = utils.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - utils.delete_user_global_group(self.global_group, self.user, - str(self.auth_token)) - - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - utils.delete_user(self.tenant, self.user, self.auth_token) - utils.delete_global_group(self.global_group, self.auth_token) - - def test_add_user_global_group(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp_new, content_new = utils.add_user_global_group(self.global_group, - self.user, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - if int(resp_new['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp_new['status'])) - - def test_add_user_global_group_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp_new, content_new = utils.add_user_global_group_xml(\ - self.global_group, - self.user, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - if int(resp_new['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp_new['status'])) - - def test_add_user_global_group_conflict(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.add_user_global_group(self.global_group, - self.user, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp_new['status'])) - - def test_add_user_global_group_conflict_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group_xml(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.add_user_global_group_xml(\ - self.global_group, - self.user, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp_new['status'])) - - def test_add_user_global_group_unauthorized(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - - utils.create_user(self.tenant, self.user, str(self.auth_token)) - - resp_new, content_new = utils.add_user_global_group(self.global_group, - self.user, - str(self.token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp_new['status'])) - - def test_add_user_global_group_unauthorized_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp_new, content_new = utils.add_user_global_group_xml(\ - self.global_group, - self.user, - str(self.token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp_new['status'])) - - def test_add_user_global_group_forbidden(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp_new, content_new = utils.add_user_global_group(\ - self.global_group, - self.user, - str(self.disabled_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp_new['status'])) - - def test_add_user_global_group_forbidden_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp_new, content_new = utils.add_user_global_group_xml(\ - self.global_group, - self.user, - str(self.disabled_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp_new['status'])) - - -class GetUsersTenantGroupTest(unittest.TestCase): - - def setUp(self): - self.tenant = utils.get_global_tenant() - self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - self.global_group = 'test_global_group' - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.create_user(self.tenant, self.user, self.auth_token) - utils.add_user_json(self.tenant, self.user, self.auth_token) - self.token = utils.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - utils.delete_user_global_group(self.global_group, self.user, - str(self.auth_token)) - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - utils.delete_global_group(self.global_group, self.auth_token) - - def test_get_users_global_group(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.get_user_global_group(\ - self.global_group, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp_new['status'])) - - def test_get_users_global_group_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group_xml(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.get_user_global_group_xml(\ - self.global_group, - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp_new['status'])) - - def test_get_users_global_group_unauthorized(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - - resp_new, content_new = utils.get_user_global_group(\ - self.global_group, - str(self.token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp_new['status'])) - - def test_get_users_global_group_unauthorized_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.get_user_global_group_xml(\ - self.global_group, - str(self.token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp_new['status'])) - - def test_get_users_global_group_forbidden(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.get_user_global_group(\ - self.global_group, - str(self.disabled_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp_new['status'])) - - def test_get_users_global_group_forbidden_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.get_user_global_group_xml(\ - self.global_group, - str(self.disabled_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp_new['status'])) - - def test_get_users_global_group_expired(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.get_user_global_group(\ - self.global_group, - str(self.exp_auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp_new['status'])) - - def test_get_users_global_group_expired_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.get_user_global_group_xml(\ - self.global_group, - str(self.exp_auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp_new['status'])) - - -class DeleteUsersGlobalGroupTest(unittest.TestCase): - - def setUp(self): - self.tenant = utils.get_global_tenant() - self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - self.global_group = 'test_global_group' - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.create_user(self.tenant, self.user, self.auth_token) - utils.add_user_json(self.tenant, self.user, self.auth_token) - self.token = utils.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - utils.delete_user_global_group(self.global_group, self.user, - str(self.auth_token)) - - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - utils.delete_global_group(self.global_group, self.auth_token) - - def test_delete_user_global_group(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - - resp_new, content_new = utils.delete_user_global_group(\ - self.global_group, - self.user, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(204, int(resp_new['status'])) - - def test_delete_user_global_group_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.delete_user_global_group_xml(\ - self.global_group, - self.user, - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(204, int(resp_new['status'])) - - def test_delete_user_global_group_notfound(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.disabled_token)) - utils.delete_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.delete_user_global_group( - self.global_group, - self.user, - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp_new['status'])) - - def test_delete_user_global_group_notfound_xml(self): - resp, content = utils.create_global_group(self.global_group, - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - utils.create_user(self.tenant, self.user, str(self.auth_token)) - utils.add_user_global_group(self.global_group, self.user, - str(self.disabled_token)) - utils.delete_user_global_group(self.global_group, self.user, - str(self.auth_token)) - resp_new, content_new = utils.delete_user_global_group_xml(\ - self.global_group, self.user, - str(self.auth_token)) - self.assertEqual(404, int(resp_new['status'])) - -if __name__ == '__main__': - unittest.main() diff --git a/test/unit/test_keystone.py b/test/unit/test_keystone.py deleted file mode 100644 index 3b17d9b2..00000000 --- a/test/unit/test_keystone.py +++ /dev/null @@ -1,60 +0,0 @@ -import logging -from lxml import etree -import os -import unittest - -MODULE_EXTENSIONS = set('.py'.split()) -TEST_FILES = ['test_authentication.py', 'test_keystone.py', 'test_tenants.py', - 'test_common.py', 'test_users.py', 'test_tenant_groups.py', - 'test_token.py', 'test_version.py', 'test_groups.py'] - - -def unit_test_extractor(tup, path, filenames): - """Pull ``unittest.TestSuite``s from modules in path - if the path represents a valid Python package. Accumulate - results in `tup[1]`. - """ - package_path, suites = tup - logging.debug('Path: %s', path) - logging.debug('Filenames: %s', filenames) - relpath = os.path.relpath(path, package_path) - relpath_pieces = relpath.split(os.sep) - - if relpath_pieces[0] == '.': # Base directory. - relpath_pieces.pop(0) # Otherwise, screws up module name. - elif not any(os.path.exists(os.path.join(path, '__init__' + ext)) - for ext in MODULE_EXTENSIONS): - return # Not a package directory and not the base directory, reject. - - logging.info('Base: %s', '.'.join(relpath_pieces)) - for filename in filenames: - if filename not in TEST_FILES: - continue - base, ext = os.path.splitext(filename) - #if ext not in MODULE_EXTENSIONS : # Not a Python module. - # continue - logging.info('Module: %s', base) - module_name = '.'.join(relpath_pieces + [base]) - logging.info('Importing from %s', module_name) - module = __import__(module_name) - module_suites = unittest.defaultTestLoader.loadTestsFromModule(module) - logging.info('Got suites: %s', module_suites) - suites += module_suites - - -def get_test_suites(path): - """:return: Iterable of suites for the packages/modules - present under :param:`path`. - """ - logging.info('Base path: %s', package_path) - suites = [] - os.path.walk(package_path, unit_test_extractor, (package_path, suites)) - logging.info('Got suites: %s', suites) - return suites - -if __name__ == '__main__': - logging.basicConfig(level=logging.WARN) - package_path = os.path.dirname(os.path.abspath(__file__)) - suites = get_test_suites(package_path) - for suite in suites: - unittest.TextTestRunner(verbosity=1).run(suite) diff --git a/test/unit/test_roles.py b/test/unit/test_roles.py deleted file mode 100644 index 10b16d27..00000000 --- a/test/unit/test_roles.py +++ /dev/null @@ -1,682 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import json -from lxml import etree -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest - -import test_common as utils -from test_common import URL - -class RolesTest(unittest.TestCase): - def setUp(self): - self.tenant = utils.get_tenant() - self.password = utils.get_password() - self.email = utils.get_email() - self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - self.missing_token = utils.get_none_token() - self.invalid_token = utils.get_non_existing_token() - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.create_user(self.tenant, self.user, self.auth_token) - self.token = utils.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - utils.delete_user(self.tenant, self.user, self.auth_token) - utils.delete_tenant(self.tenant, self.auth_token) - -class GetRolesTest(RolesTest): - def test_get_roles(self): - header = httplib2.Http(".cache") - url = '%sroles' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - #verify content - obj = json.loads(content) - if not "roles" in obj: - raise self.fail("Expecting Roles") - roles = obj["roles"]["values"] - if len(roles) != 1: - self.fail("Roles not of required length.") - - role = roles[0] - if not "id" in role: - role_id = None - else: - role_id = role["id"] - if role_id != 'Admin': - self.fail("Not the expected Role") - - - def test_get_roles_xml(self): - header = httplib2.Http(".cache") - url = '%sroles' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - # Validate Returned Content - dom = etree.Element("root") - dom.append(etree.fromstring(content)) - roles = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "roles") - if roles == None: - self.fail("Expecting Roles") - roles = roles.findall("{http://docs.openstack.org/identity/api/v2.0}" \ - "role") - if len(roles) != 1: - self.fail("Not the expected Role count") - for role in roles: - if role.get("id") != 'Admin': - self.fail("Not the expected Role") - - - def test_get_roles_exp_token(self): - header = httplib2.Http(".cache") - url = '%sroles' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_roles_exp_token_xml(self): - header = httplib2.Http(".cache") - url = '%stenants' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - -class GetRoleTest(RolesTest): - - def test_get_role(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - #verify content - obj = json.loads(content) - if not "role" in obj: - raise fault.BadRequestFault("Expecting Role") - role = obj["role"] - if not "id" in role: - role_id = None - else: - role_id = role["id"] - if role_id != 'Admin': - self.fail("Not the expected Role") - - def test_get_role_xml(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - #verify content - dom = etree.Element("root") - dom.append(etree.fromstring(content)) - role = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "role") - if role == None: - self.fail("Expecting Role") - role_id = role.get("id") - if role_id != 'Admin': - self.fail("Not the expected Role") - - def test_get_role_bad(self): - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, 'tenant_bad') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_role_xml_bad(self): - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, 'tenant_bad') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_role_expired_token(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_role_xml_using_expired_token(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_role_using_disabled_token(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.disabled_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_role_xml_using_disabled_token(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.disabled_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_role_using_missing_token(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.missing_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_role_xml_using_missing_token(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.missing_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_role_using_invalid_token(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.invalid_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_role_xml_using_invalid_token(self): - self.role = 'Admin' - header = httplib2.Http(".cache") - url = '%sroles/%s' % (utils.URL, self.role) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.invalid_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class CreateRoleRefTest(RolesTest): - def test_role_ref_create_json(self): - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - - def test_role_ref_create_xml(self): - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref_xml(self.user, 'Admin', self.tenant, - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - - def test_role_ref_create_json_using_expired_token(self): - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_role_ref_create_json_using_disabled_token(self): - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.disabled_token)) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_role_ref_create_json_using_missing_token(self): - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.missing_token)) - resp_val = int(resp['status']) - self.assertEqual(401, resp_val) - - def test_role_ref_create_json_using_invalid_token(self): - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.invalid_token)) - resp_val = int(resp['status']) - self.assertEqual(404, resp_val) - - -class GetRoleRefsTest(RolesTest): - def test_get_rolerefs(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.auth_token)}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - #verify content - obj = json.loads(content) - if not "roleRefs" in obj: - raise self.fail("Expecting RoleRefs") - - def test_get_rolerefs_xml(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.auth_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - #verify content - dom = etree.Element("root") - dom.append(etree.fromstring(content)) - roles = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "roleRefs") - if roles == None: - self.fail("Expecting Role Refs") - - def test_get_rolerefs_using_expired_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.exp_auth_token)}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_rolerefs_xml_using_expired_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.exp_auth_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_rolerefs_using_disabled_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.disabled_token)}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_rolerefs_xml_using_disabled_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.disabled_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_rolerefs_using_missing_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.missing_token)}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_rolerefs_xml_using_missing_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.missing_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_rolerefs_using_invalid_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.invalid_token)}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_rolerefs_xml_using_missing_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - url = '%susers/%s/roleRefs' % (URL, self.user) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/xml", - "X-Auth-Token": str(self.invalid_token), - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class DeleteRoleRefTest(RolesTest): - def test_delete_roleref(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "roleRef" in obj: - raise fault.BadRequestFault("Expecting RoleRef") - roleRef = obj["roleRef"] - if not "id" in roleRef: - role_ref_id = None - else: - role_ref_id = roleRef["id"] - if role_ref_id is None: - raise fault.BadRequestFault("Expecting RoleRefId") - url = '%susers/%s/roleRefs/%s' % (URL, self.user, role_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.auth_token)}) - resp_val = int(resp['status']) - self.assertEqual(204, resp_val) - - def test_delete_roleref_using_expired_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "roleRef" in obj: - raise fault.BadRequestFault("Expecting RoleRef") - roleRef = obj["roleRef"] - if not "id" in roleRef: - role_ref_id = None - else: - role_ref_id = roleRef["id"] - if role_ref_id is None: - raise fault.BadRequestFault("Expecting RoleRefId") - url = '%susers/%s/roleRefs/%s' % (URL, self.user, role_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.exp_auth_token)}) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_delete_roleref_using_disabled_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "roleRef" in obj: - raise fault.BadRequestFault("Expecting RoleRef") - roleRef = obj["roleRef"] - if not "id" in roleRef: - role_ref_id = None - else: - role_ref_id = roleRef["id"] - if role_ref_id is None: - raise fault.BadRequestFault("Expecting RoleRefId") - url = '%susers/%s/roleRefs/%s' % (URL, self.user, role_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.disabled_token)}) - resp_val = int(resp['status']) - self.assertEqual(403, resp_val) - - def test_delete_roleref_using_missing_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "roleRef" in obj: - raise fault.BadRequestFault("Expecting RoleRef") - roleRef = obj["roleRef"] - if not "id" in roleRef: - role_ref_id = None - else: - role_ref_id = roleRef["id"] - if role_ref_id is None: - raise fault.BadRequestFault("Expecting RoleRefId") - url = '%susers/%s/roleRefs/%s' % (URL, self.user, role_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.missing_token)}) - resp_val = int(resp['status']) - self.assertEqual(401, resp_val) - - def test_delete_roleref_using_invalid_token(self): - header = httplib2.Http(".cache") - utils.add_user_json(self.tenant, self.user, self.auth_token) - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, - str(self.auth_token)) - resp_val = int(resp['status']) - self.assertEqual(201, resp_val) - obj = json.loads(content) - if not "roleRef" in obj: - raise fault.BadRequestFault("Expecting RoleRef") - roleRef = obj["roleRef"] - if not "id" in roleRef: - role_ref_id = None - else: - role_ref_id = roleRef["id"] - if role_ref_id is None: - raise fault.BadRequestFault("Expecting RoleRefId") - url = '%susers/%s/roleRefs/%s' % (URL, self.user, role_ref_id) - resp, content = header.request(url, "DELETE", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": str(self.invalid_token)}) - resp_val = int(resp['status']) - self.assertEqual(404, resp_val) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/unit/test_server.py b/test/unit/test_server.py deleted file mode 100644 index 294b1e54..00000000 --- a/test/unit/test_server.py +++ /dev/null @@ -1,86 +0,0 @@ -import unittest -import os -import sys -import json - -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) - -from keystone import server -import keystone.logic.types.auth as auth -import keystone.logic.types.fault as fault - -from StringIO import StringIO -from datetime import date -from lxml import etree -from webob import Request -from webob import Response - -class TestServer(unittest.TestCase): - '''Unit tests for server.py.''' - - request = None - auth_data = None - - def setUp(self): - environ = {'wsgi.url_scheme': 'http'} - self.request = Request(environ) - self.auth_data = auth.AuthData(auth.Token(date.today(),"2231312"), auth.User("username","12345",auth.Groups([],[]))) - - #def tearDown(self): - - def test_is_xml_response(self): - self.assertFalse(server.is_xml_response(self.request)) - self.request.headers["Accept"] = "application/xml" - self.request.content_type="application/json" - self.assertTrue(server.is_xml_response(self.request)) - - def test_send_result_xml(self): - self.request.headers["Accept"] = "application/xml" - response = server.send_result(200,self.request,self.auth_data); - - self.assertTrue(response.headers['content-type'] == "application/xml; charset=UTF-8") - xml = etree.fromstring(response.unicode_body) - - user = xml.find("{http://docs.openstack.org/identity/api/v2.0}user") - token = xml.find("{http://docs.openstack.org/identity/api/v2.0}token") - - self.assertTrue(user.get("username"),"username") - self.assertTrue(user.get("tenantId"),'12345'); - self.assertTrue(token.get("id"),'2231312'); - self.assertTrue(token.get("expires"),date.today()); - - def test_send_result_json(self): - self.request.headers["Accept"] = "application/json" - response = server.send_result(200,self.request,self.auth_data); - self.assertTrue(response.headers['content-type'] == "application/json; charset=UTF-8") - dict = json.loads(response.unicode_body) - self.assertTrue(dict['auth']['user']['username'],'username'); - self.assertTrue(dict['auth']['user']['tenantId'],'12345'); - self.assertTrue(dict['auth']['token']['id'],'2231312'); - self.assertTrue(dict['auth']['token']['expires'],date.today()); - - def test_get_auth_token(self): - self.request.headers["X-Auth-Token"]="Test token" - self.assertTrue(server.get_auth_token(self.request),"Test Token") - - def test_get_normalized_request_content_exception(self): - self.assertRaises(fault.IdentityFault,server.get_normalized_request_content,None,self.request) - - def test_get_normalized_request_content_xml(self): - self.request.environ["CONTENT_TYPE"]="application/xml" - pwd_cred = auth.PasswordCredentials("username","password","1") - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <passwordCredentials \ - xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="secret" username="disabled" \ - />' - str=StringIO() - str.write(body) - self.request.environ["wsgi.input"]=str - self.request.environ["CONTENT_LENGTH"] = str.len - #TODO: I THINK THIS belongs in a test for auth.py. - - -if __name__ == '__main__': - unittest.main()
\ No newline at end of file diff --git a/test/unit/test_tenant_groups.py b/test/unit/test_tenant_groups.py deleted file mode 100644 index 21bb9221..00000000 --- a/test/unit/test_tenant_groups.py +++ /dev/null @@ -1,1217 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import json -from lxml import etree -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest - -import test_common as util - - -class TenantGroupTest(unittest.TestCase): - - def setUp(self): - self.tenant = util.get_another_tenant() - self.user = util.get_user() - self.userdisabled = util.get_userdisabled() - self.auth_token = util.get_auth_token() - self.exp_auth_token = util.get_exp_auth_token() - self.disabled_token = util.get_disabled_token() - self.tenant_group = 'test_tenant_group_new' - util.create_tenant(self.tenant, str(self.auth_token)) - util.create_user(self.tenant, self.user, self.auth_token) - util.add_user_json(self.tenant, self.user, self.auth_token) - self.token = util.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - resp = util.delete_user(self.tenant, self.user, - str(self.auth_token)) - - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - self.auth_token) - resp = util.delete_tenant(self.tenant, self.auth_token) - - -class CreateTenantGroupTest(TenantGroupTest): - - def test_tenant_group_create(self): - util.delete_user(self.tenant, self.user, - str(self.auth_token)) - resp = util.delete_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - - if int(resp['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp['status'])) - - def test_tenant_group_create_xml(self): - util.delete_user(self.tenant, self.user, - str(self.auth_token)) - resp = util.delete_tenant_xml(self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_xml(self.tenant, - str(self.auth_token)) - resp, content = util.delete_tenant_group_xml(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_group_xml(self.tenant_group, - self.tenant, - str(self.auth_token)) - - content = etree.fromstring(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - if int(resp['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp['status'])) - - def test_tenant_group_create_again(self): - resp, content = util.create_tenant(self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - self.tenant_group = content['group']['id'] - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp['status'])) - - def test_tenant_group_create_again_xml(self): - resp, content = util.create_tenant_xml("test_tenant", - str(self.auth_token)) - resp, content = util.create_tenant_group_xml(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp_new, content_new = util.create_tenant_group_xml(self.tenant_group, - self.tenant, - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp['status'])) - - def test_tenant_group_create_unauthorized_token(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - resp, content = util.create_tenant_group_xml(self.tenant_group, - self.tenant, - str(self.auth_token)) - - if int(resp['status']) == 200: - self.tenant_group = resp['group']['id'] - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = {"group": {"id": self.tenant_group, - "description": "A description ..."}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": self.token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_tenant_group_create_unauthorized_token_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"><description>A description...</description> \ - </group>' % self.tenant_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_tenant_group_create_expired_token(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = {"group": {"id": self.tenant_group, - "description": "A description ..."}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_tenant_group_create_expired_token_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"> \ - <description>A description...</description> \ - </group>' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_tenant_group_create_missing_token(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = {"group": {"id": self.tenant_group, - "description": "A description ..."}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_tenant_group_create_missing_token_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"> \ - <description>A description...</description> \ - </group>' % self.tenant_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_tenant_group_create_disabled_token(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = '{"group": { "id": "%s", \ - "description": "A description ..." } }' % self.tenant_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.disabled_token}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_tenant_group_create_disabled_token_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"> \ - <description>A description...</description> \ - </group>' % self.tenant_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.disabled_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_tenant_group_create_invalid_token(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = '{"group": { "id": "%s", \ - "description": "A description ..." } }' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/json", - "X-Auth-Token": 'nonexsitingtoken'}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_tenant_group_create_invalid_token_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - - url = '%stenants/%s/groups' % (util.URL, self.tenant) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="%s"> \ - <description>A description...</description> \ - </group>' % self.tenant_group - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": 'nonexsitingtoken', - "ACCEPT": "application/xml"}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class GetTenantGroupsTest(TenantGroupTest): - - def test_get_tenant_groups(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - - url = '%stenants/%s/groups' % (util.URL, self.tenant) - - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenant_groups_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - - resp, content = util.create_tenant_group_xml(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups' % (util.URL, self.tenant) - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenant_groups_unauthorized_token(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups' % (util.URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_tenant_groups_unauthorized_token_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups' % (util.URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_get_tenant_groups_exp_token(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups' % (util.URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_tenant_groups_exp_token_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups' % (util.URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - -class GetTenantGroupTest(TenantGroupTest): - - def test_get_tenant_group(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, self.tenant, - self.tenant_group) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenant_group_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, self.tenant, - self.tenant_group) - #test for Content-Type = application/xml - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenant_group_bad(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, 'tenant_bad', - self.tenant_group) - - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_tenant_group_bad_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, 'tenant_bad', - self.tenant_group) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_tenant_group_not_found(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, self.tenant, - 'nonexistinggroup') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_tenant_group_not_found_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, self.tenant, - 'nonexistinggroup') - - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class UpdateTenantGroupTest(TenantGroupTest): - - def test_update_tenant_group(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, self.tenant, - self.tenant_group) - - data = '{"group": { "id":"%s","description": "A NEW description..." ,\ - "tenantId":"%s" }}' % (self.tenant_group, self.tenant) - #test for Content-Type = application/json - - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - - body = json.loads(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - self.assertEqual(self.tenant_group, body['group']['id']) - self.assertEqual('A NEW description...', body['group']['description']) - - def test_update_tenant_group_xml(self): - header = httplib2.Http(".cache") - resp = util.delete_tenant(self.tenant, str(self.auth_token)) - - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - - url = '%stenants/%s/groups/%s' % (util.URL, self.tenant, - self.tenant_group) - - data = '<group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - tenantId="%s" id="%s"> \ - <description>A NEW description...</description> \ - </group>' % (self.tenant, self.tenant_group) - - #test for Content-Type = application/json - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - - body = etree.fromstring(content) - desc = body.find("{http://docs.openstack.org/identity/api/v2.0}description") - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - - self.assertEqual(200, int(resp['status'])) - self.assertEqual(str(self.tenant_group), str(body.get('id'))) - self.assertEqual('A NEW description...', desc.text) - - def test_update_tenant_group_bad(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, self.tenant, - self.tenant_group) - data = '{"group": { "description_bad": "A NEW description...",\ - "id":"%s","tenantId":"%s" }}' % (self.tenant_group, self.tenant) - #test for Content-Type = application/json - - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(400, int(resp['status'])) - - def test_update_tenant_group_bad_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/%s' % (util.URL, self.tenant, - self.tenant_group) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - tenantId="%s" id="%s"> \ - <description_bad>A NEW description...</description> \ - </group>' % (self.tenant, self.tenant_group) - #test for Content-Type = application/json - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(400, int(resp['status'])) - - def test_update_tenant_group_not_found(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - url = '%stenants/%s/groups/NonexistingID' % (util.URL, self.tenant) - - data = '{"group": { "description": "A NEW description...",\ - "id":"NonexistingID", "tenantId"="test_tenant" }}' - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_update_tenant_group_not_found_xml(self): - header = httplib2.Http(".cache") - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/%s/groups/NonexistingID' % (util.URL, self.tenant) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ - id="NonexistingID", "tenant_id"="test_tenant"> \ - <description_bad>A NEW description...</description> \ - </group>' - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class DeleteTenantGroupTest(TenantGroupTest): - - def test_delete_tenant_group_not_found(self): - resp, content = util.delete_tenant_group("test_tenant_delete111", - self.tenant, - str(self.auth_token)) - self.assertEqual(404, int(resp['status'])) - - def test_delete_tenant_group_not_found_xml(self): - resp, content = util.delete_tenant_group_xml("test_tenant_delete111", - self.tenant, - str(self.auth_token)) - self.assertEqual(404, int(resp['status'])) - - def test_delete_tenant_group(self): - resp, content = util.create_tenant("test_tenant_delete", - str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - 'test_tenant_delete', - str(self.auth_token)) - resp, content = util.delete_tenant_group(self.tenant_group, - 'test_tenant_delete', - str(self.auth_token)) - self.assertEqual(204, int(resp['status'])) - resp = util.delete_tenant("test_tenant_delete", - str(self.auth_token)) - self.assertEqual(204, int(resp['status'])) - - -class AddUserTenantGroupTest(TenantGroupTest): - - def setUp(self): - self.tenant = 'test_tenant' - self.user = util.get_user() - self.userdisabled = util.get_userdisabled() - self.auth_token = util.get_auth_token() - self.exp_auth_token = util.get_exp_auth_token() - self.disabled_token = util.get_disabled_token() - self.tenant_group = 'test_tenant_group_add' - util.create_tenant(self.tenant, str(self.auth_token)) - util.create_user(self.tenant, self.user, self.auth_token) - util.add_user_json(self.tenant, self.user, self.auth_token) - self.token = util.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - resp, content = util.delete_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - - resp = util.delete_user(self.tenant, self.user, - str(self.auth_token)) - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - self.auth_token) - resp = util.delete_tenant(self.tenant, self.auth_token) - - def test_add_user_tenant_group(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - - resp, content = util.create_user(self.tenant, self.user, - str(self.auth_token)) - resp, content = util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - if int(resp['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp['status'])) - - def test_add_user_tenant_group_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_user(self.tenant, self.user, - str(self.auth_token)) - resp, content = util.add_user_tenant_group_xml(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - if int(resp['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp['status'])) - - def test_add_user_tenant_group_conflict(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_user(self.tenant, self.user, - str(self.auth_token)) - resp, content = util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - resp, content = util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp['status'])) - - def test_add_user_tenant_group_conflict_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_user(self.tenant, self.user, - str(self.auth_token)) - resp, content = util.add_user_tenant_group_xml(self.tenant, - self.tenant_group, - self.user, str(self.auth_token)) - resp, content = util.add_user_tenant_group_xml(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp['status'])) - - def test_add_user_tenant_group_unauthorized(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_user(self.tenant, self.user, - str(self.auth_token)) - - resp, content = util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, self.token) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_add_user_tenant_group_unauthorized_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_user(self.tenant, self.user, - str(self.auth_token)) - - resp, content = util.add_user_tenant_group_xml(self.tenant, - self.tenant_group, - self.user, self.token) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_add_user_tenant_group_forbidden(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_user(self.tenant, self.user, - str(self.auth_token)) - - resp, content = util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - self.disabled_token) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_add_user_tenant_group_forbidden_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - resp, content = util.create_user(self.tenant, self.user, - str(self.auth_token)) - - resp, content = util.add_user_tenant_group_xml(self.tenant, - self.tenant_group, - self.user, - self.disabled_token) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - -class GetUsersTenantGroupTest(TenantGroupTest): - - def setUp(self): - self.tenant = 'test_tenant' - self.user = util.get_user() - self.userdisabled = util.get_userdisabled() - self.auth_token = util.get_auth_token() - self.exp_auth_token = util.get_exp_auth_token() - self.disabled_token = util.get_disabled_token() - self.tenant_group = 'test_tenant_group_add' - util.create_tenant(self.tenant, str(self.auth_token)) - util.create_user(self.tenant, self.user, self.auth_token) - util.add_user_json(self.tenant, self.user, self.auth_token) - self.token = util.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - resp, content = util.delete_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - - resp = util.delete_user(self.tenant, self.user, - str(self.auth_token)) - resp, content = util.delete_tenant_group(self.tenant_group, - self.tenant, - self.auth_token) - util.delete_tenant(self.tenant, self.auth_token) - - def test_get_users_tenant_group(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - resp, content = util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - - util.create_user(self.tenant, self.user, - str(self.auth_token)) - util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - resp, content = util.get_user_tenant_group(self.tenant, - self.tenant_group, - str(self.auth_token)) - - self.assertEqual(200, int(resp['status'])) - - def test_get_users_tenant_group_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - util.add_user_tenant_group_xml(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - resp, content = util.get_user_tenant_group_xml(self.tenant, - self.tenant_group, - str(self.auth_token)) - - self.assertEqual(200, int(resp['status'])) - - def test_get_users_tenant_group_unauthorized(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - - util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - self.auth_token) - - resp, content = util.get_user_tenant_group(self.tenant, - self.tenant_group, - str(self.token)) - self.assertEqual(401, int(resp['status'])) - - def test_get_users_tenant_group_unauthorized_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - - util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, self.auth_token) - resp, content = util.get_user_tenant_group_xml(self.tenant, - self.tenant_group, - str(self.token)) - self.assertEqual(401, int(resp['status'])) - - def test_get_users_tenant_group_forbidden(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - - util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, self.auth_token) - resp, content = util.get_user_tenant_group(self.tenant, - self.tenant_group, - str(self.disabled_token)) - - self.assertEqual(403, int(resp['status'])) - - def test_get_users_tenant_group_forbidden_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - - util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, self.auth_token) - resp, content = util.get_user_tenant_group_xml(self.tenant, - self.tenant_group, - str(self.disabled_token)) - - self.assertEqual(403, int(resp['status'])) - - def test_get_users_tenant_group_expired(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - - util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, self.auth_token) - resp, content = util.get_user_tenant_group(self.tenant, - self.tenant_group, - str(self.exp_auth_token)) - self.assertEqual(403, int(resp['status'])) - - def test_get_users_tenant_group_expired_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - - util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, self.auth_token) - resp, content = util.get_user_tenant_group_xml(self.tenant, - self.tenant_group, - str(self.exp_auth_token)) - - self.assertEqual(403, int(resp['status'])) - - -class DeleteUsersTenantGroupTest(TenantGroupTest): - - def test_delete_user_tenant_group(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - util.add_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - resp, content = util.delete_user_tenant_group(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - - self.assertEqual(204, int(resp['status'])) - - def test_delete_user_tenant_group_xml(self): - resp, content = util.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - util.create_tenant_group(self.tenant_group, - self.tenant, - str(self.auth_token)) - util.create_user(self.tenant, self.user, - str(self.auth_token)) - util.add_user_tenant_group_xml(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - resp, content = util.delete_user_tenant_group_xml(self.tenant, - self.tenant_group, - self.user, - str(self.auth_token)) - - self.assertEqual(204, int(resp['status'])) - - def test_delete_user_tenant_group_notfound(self): - resp, content = util.delete_user_tenant_group(self.tenant, - self.tenant_group, - 'NonExistinguser', - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_delete_user_tenant_group_notfound_xml(self): - resp, content = util.delete_user_tenant_group_xml(self.tenant, - self.tenant_group, - 'NonExistinguser', - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - -if __name__ == '__main__': - unittest.main() diff --git a/test/unit/test_tenants.py b/test/unit/test_tenants.py deleted file mode 100644 index bc639904..00000000 --- a/test/unit/test_tenants.py +++ /dev/null @@ -1,661 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import json -from lxml import etree -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest - -import test_common as utils - - -class TenantTest(unittest.TestCase): - - def setUp(self): - self.tenant = 'test_tenant' - self.auth_token = utils.get_auth_token() - self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.create_user(self.tenant, self.user, self.auth_token) - utils.add_user_json(self.tenant, self.user, self.auth_token) - self.token = utils.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - utils.delete_user(self.tenant, self.user, self.auth_token) - utils.delete_tenant(self.tenant, self.auth_token) - - -class CreateTenantTest(TenantTest): - - def test_tenant_create(self): - utils.delete_user(self.tenant, self.user, self.auth_token) - utils.delete_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - - if int(resp['status']) not in (200, 201): - - self.fail('Failed due to %d' % int(resp['status'])) - - def test_tenant_create_xml(self): - utils.delete_user(self.tenant, self.user, self.auth_token) - utils.delete_tenant_xml(self.tenant, - str(self.auth_token)) - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - if int(resp['status']) not in (200, 201): - self.fail('Failed due to %d' % int(resp['status'])) - - def test_tenant_create_again(self): - - resp, content = utils.create_tenant(self.tenant, - str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - resp, content = utils.create_tenant(self.tenant, - str(self.auth_token)) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp['status'])) - - def test_tenant_create_again_xml(self): - - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(409, int(resp['status'])) - - def test_tenant_create_forbidden_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - - url = '%stenants' % (utils.URL) - body = {"tenant": {"id": self.tenant, - "description": "A description ...", - "enabled": True}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": self.token}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_tenant_create_forbidden_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - - url = '%stenants' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true" id="%s"> \ - <description>A description...</description> \ - </tenant>' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.token, - "ACCEPT": "application/xml"}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_tenant_create_expired_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, - str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - url = '%stenants' % (utils.URL) - body = {"tenant": {"id": self.tenant, - "description": "A description ...", - "enabled": True}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_tenant_create_expired_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - - url = '%stenants' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true" id="%s"> \ - <description>A description...</description> \ - </tenant>' % self.tenant - - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_tenant_create_missing_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, - str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - - url = '%stenants' % (utils.URL) - body = {"tenant": {"id": self.tenant, - "description": "A description ...", - "enabled": True}} - resp, content = header.request(url, "POST", body=json.dumps(body), - headers={"Content-Type": "application/json"}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_tenant_create_missing_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - url = '%stenants' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true" id="%s"> \ - <description>A description...</description> \ - </tenant>' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - - def test_tenant_create_disabled_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, - str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - - url = '%stenants' % (utils.URL) - body = '{"tenant": { "id": "%s", \ - "description": "A description ...", "enabled"\ - :true } }' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.disabled_token}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_tenant_create_disabled_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - url = '%stenants' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true" id="%s"> \ - <description>A description...</description> \ - </tenant>' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.disabled_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_tenant_create_invalid_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, - str(self.auth_token)) - if int(resp['status']) == 200: - self.tenant = content['tenant']['id'] - - url = '%stenants' % (utils.URL) - body = '{"tenant": { "id": "%s", \ - "description": "A description ...", "enabled"\ - :true } }' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/json", - "X-Auth-Token": 'nonexsitingtoken'}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_tenant_create_invalid_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - content = etree.fromstring(content) - if int(resp['status']) == 200: - self.tenant = content.get('id') - - url = '%stenants' % (utils.URL) - body = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true" id="%s"> \ - <description>A description...</description> \ - </tenant>' % self.tenant - resp, content = header.request(url, "POST", body=body, - headers={"Content-Type": "application/xml", - "X-Auth-Token": 'nonexsitingtoken', - "ACCEPT": "application/xml"}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class GetTenantsTest(TenantTest): - - def test_get_tenants_using_admin_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenants_using_admin_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenants_using_user_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenants_using_user_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenants_exp_token(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - def test_get_tenants_exp_token_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - - -class GetTenantTest(TenantTest): - - def test_get_tenant(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/%s' % (utils.URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenant_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/%s' % (utils.URL, self.tenant) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - - def test_get_tenant_bad(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/%s' % (utils.URL, 'tenant_bad') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_tenant_bad_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/%s' % (utils.URL, 'tenant_bad') - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_tenant_not_found(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/NonexistingID' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='{}', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_get_tenant_not_found_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/NonexistingID' % (utils.URL) - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class UpdateTenantTest(TenantTest): - - def test_update_tenant(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/%s' % (utils.URL, self.tenant) - data = '{"tenant": { "description": "A NEW description..." ,\ - "enabled":true }}' - #test for Content-Type = application/json - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - body = json.loads(content) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - self.assertEqual(self.tenant, body['tenant']['id']) - self.assertEqual('A NEW description...', body['tenant']['description']) - - def test_update_tenant_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant_xml(self.tenant, - str(self.auth_token)) - url = '%stenants/%s' % (utils.URL, self.tenant) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true"> \ - <description>A NEW description...</description> \ - </tenant>' - - #test for Content-Type = application/json - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - body = etree.fromstring(content) - desc = body.find("{http://docs.openstack.org/identity/api/v2.0}description") - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - self.assertEqual(self.tenant, body.get('id')) - self.assertEqual('A NEW description...', desc.text) - - def test_update_tenant_bad(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/%s' % (utils.URL, self.tenant) - data = '{"tenant": { "description_bad": "A NEW description...",\ - "enabled":true }}' - #test for Content-Type = application/json - - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(400, int(resp['status'])) - - def test_update_tenant_bad_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/%s' % (utils.URL, self.tenant) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true"> \ - <description_bad>A NEW description...</description> \ - </tenant>' - #test for Content-Type = application/json - resp, content = header.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(400, int(resp['status'])) - - def test_update_tenant_not_found(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/NonexistingID' % (utils.URL) - data = '{"tenant": { "description": "A NEW description...",\ - "enabled":true }}' - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - def test_update_tenant_not_found_xml(self): - header = httplib2.Http(".cache") - resp, content = utils.create_tenant(self.tenant, str(self.auth_token)) - url = '%stenants/NonexistingID' % (utils.URL) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - <tenant xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true"> \ - <description_bad>A NEW description...</description> \ - </tenant>' - #test for Content-Type = application/json - resp, content = header.request(url, "GET", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(404, int(resp['status'])) - - -class DeleteTenantTest(TenantTest): - - def test_delete_tenant_not_found(self): - #resp,content=utils.create_tenant("test_tenant_delete", - # str(self.auth_token)) - resp = utils.delete_tenant("test_tenant_delete111", - str(self.auth_token)) - self.assertEqual(404, int(resp['status'])) - - def test_delete_tenant_not_found_xml(self): - #resp,content=utils.create_tenant("test_tenant_delete", - # str(self.auth_token)) - resp = utils.delete_tenant_xml("test_tenant_delete111", - str(self.auth_token)) - self.assertEqual(404, int(resp['status'])) - - def test_delete_tenant(self): - resp, content = utils.create_tenant("test_tenant_delete", - str(self.auth_token)) - resp = utils.delete_tenant("test_tenant_delete", - str(self.auth_token)) - self.assertEqual(204, int(resp['status'])) - - def test_delete_tenant_xml(self): - resp, content = utils.create_tenant_xml("test_tenant_delete", - str(self.auth_token)) - resp = utils.delete_tenant_xml("test_tenant_delete", - str(self.auth_token)) - self.assertEqual(204, int(resp['status'])) - -if __name__ == '__main__': - unittest.main() diff --git a/test/unit/test_token.py b/test/unit/test_token.py deleted file mode 100644 index 0754f777..00000000 --- a/test/unit/test_token.py +++ /dev/null @@ -1,173 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest -import test_common as utils -import json -import keystone.logic.types.fault as fault -from lxml import etree - -class ValidateToken(unittest.TestCase): - - def setUp(self): - self.tenant = utils.get_tenant() - self.user = 'joeuser' - self.token = utils.get_token('joeuser', 'secrete', self.tenant, - 'token') - #self.user = utils.get_user() - #self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - self.exp_auth_token = utils.get_exp_auth_token() - #self.disabled_token = utils.get_disabled_token() - resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, str(self.auth_token)) - obj = json.loads(content) - if not "roleRef" in obj: - raise fault.BadRequestFault("Expecting RoleRef") - roleRef = obj["roleRef"] - if not "id" in roleRef: - self.role_ref_id = None - else: - self.role_ref_id = roleRef["id"] - - - def tearDown(self): - resp, content = utils.delete_role_ref(self.user, self.role_ref_id, self.auth_token) - utils.delete_token(self.token, self.auth_token) - - def test_validate_token_true(self): - header = httplib2.Http(".cache") - - url = '%stokens/%s?belongsTo=%s' % (utils.URL, self.token, self.tenant) - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - self.assertEqual('application/json', utils.content_type(resp)) - #verify content - obj = json.loads(content) - if not "auth" in obj: - raise self.fail("Expecting Auth") - role_refs = obj["auth"]["user"]["roleRefs"] - role_ref = role_refs[0] - role_ref_id = role_ref["id"] - self.assertEqual(self.role_ref_id, role_ref_id) - - def test_validate_token_true_xml(self): - header = httplib2.Http(".cache") - url = '%stokens/%s?belongsTo=%s' % (utils.URL, self.token, self.tenant) - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(200, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - #verify content - dom = etree.Element("root") - dom.append(etree.fromstring(content)) - auth = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "auth") - if auth == None: - self.fail("Expecting Auth") - - user = auth.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "user") - if user == None: - self.fail("Expecting User") - roleRefs = user.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "roleRefs") - if roleRefs == None: - self.fail("Expecting Role Refs") - roleRef = roleRefs.find("{http://docs.openstack.org/identity/api/v2.0}" \ - "roleRef") - if roleRef == None: - self.fail("Expecting Role Refs") - self.assertEqual(str(self.role_ref_id), roleRef.get("id")) - - def test_validate_token_expired(self): - header = httplib2.Http(".cache") - url = '%stokens/%s?belongsTo=%s' % (utils.URL, self.exp_auth_token, - self.tenant) - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.exp_auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - self.assertEqual('application/json', utils.content_type(resp)) - - def test_validate_token_expired_xml(self): - header = httplib2.Http(".cache") - - url = '%stokens/%s?belongsTo=%s' % (utils.URL, self.exp_auth_token, - self.tenant) - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.exp_auth_token, - "ACCEPT": "application/xml"}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(403, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_validate_token_invalid(self): - header = httplib2.Http(".cache") - url = '%stokens/%s?belongsTo=%s' % (utils.URL, 'NonExistingToken', - self.tenant) - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - self.assertEqual('application/json', utils.content_type(resp)) - - def test_validate_token_invalid_xml(self): - header = httplib2.Http(".cache") - url = '%stokens/%s?belongsTo=%s' % (utils.URL, 'NonExistingToken', - self.tenant) - resp, content = header.request(url, "GET", body='', - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - if int(resp['status']) == 500: - self.fail('Identity Fault') - elif int(resp['status']) == 503: - self.fail('Service Not Available') - self.assertEqual(401, int(resp['status'])) - self.assertEqual('application/json', utils.content_type(resp)) - -if __name__ == '__main__': - unittest.main() diff --git a/test/unit/test_users.py b/test/unit/test_users.py deleted file mode 100644 index 083da21f..00000000 --- a/test/unit/test_users.py +++ /dev/null @@ -1,1584 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import json -from lxml import etree -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest - -import test_common as utils -from test_common import URL - - -class UserTest(unittest.TestCase): - - def setUp(self): - self.tenant = utils.get_tenant() - self.password = utils.get_password() - self.email = utils.get_email() - self.user = utils.get_user() - self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - self.missing_token = utils.get_none_token() - self.invalid_token = utils.get_non_existing_token() - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.add_user_json(self.tenant, self.user, self.auth_token) - self.token = utils.get_token(self.user, 'secrete', self.tenant, - 'token') - - def tearDown(self): - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - - -class CreateUserTest(UserTest): - - def test_a_user_create_json(self): - - resp = utils.delete_user(self.tenant, self.user, str(self.auth_token)) - - resp, content = utils.create_user(self.tenant, 'test_user1', - str(self.auth_token)) - self.user = 'test_user1' - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(201, resp_val) - - def test_a_user_create_xml(self): - utils.delete_user_xml(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.create_user_xml(self.tenant, 'test_user1', - str(self.auth_token)) - self.user = 'test_user1' - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(201, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_create_json_disabled_tenant(self): - resp, content = utils.create_user('0000', self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - - def test_a_user_create_json_disabled_tenant_xml(self): - resp, content = utils.create_user_xml('0000', self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_create_again_json(self): - resp, content = utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - resp, content = utils.create_user(self.tenant, self.user, - str(self.auth_token)) - self.assertEqual(409, int(resp['status'])) - - def test_a_user_create_again_xml(self): - utils.create_user_xml(self.tenant, self.user, - str(self.auth_token)) - resp, content = utils.create_user_xml(self.tenant, self.user, - str(self.auth_token)) - content = etree.fromstring(content) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(409, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_create_email_conflict(self): - utils.create_user(self.tenant, self.user, str(self.auth_token), - self.email) - resp, content = utils.create_user(self.tenant, self.user, - str(self.auth_token), - self.email) - self.assertEqual(409, int(resp['status'])) - - def test_a_user_create_email_conflict_xml(self): - utils.create_user_xml(self.tenant, - self.user, - str(self.auth_token), - self.email) - resp, content = utils.create_user_xml(self.tenant, self.user, - str(self.auth_token), - self.email) - content = etree.fromstring(content) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(409, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_create_expired_token(self): - resp, content = utils.create_user(self.tenant, self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, int(resp['status'])) - - def test_a_user_create_expired_token_xml(self): - resp, content = utils.create_user_xml(self.tenant, self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_create_disabled_token(self): - resp, content = utils.create_user(self.tenant, self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, int(resp['status'])) - - def test_a_user_create_disabled_token_xml(self): - resp, content = utils.create_user_xml(self.tenant, self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_create_missing_token(self): - resp, content = utils.create_user(self.tenant, self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(401, int(resp['status'])) - - def test_a_user_create_missing_token_xml(self): - resp, content = utils.create_user_xml(self.tenant, self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(401, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_create_invalid_token(self): - resp, content = utils.create_user(self.tenant, self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(404, int(resp['status'])) - - def test_a_user_create_invalid_token_xml(self): - resp, content = utils.create_user_xml(self.tenant, self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(404, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - - -class GetUserTest(UserTest): - - def test_a_user_get(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_json(self.tenant, self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(200, resp_val) - - def test_a_user_get_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_xml(self.tenant, self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(200, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_get_expired_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_json(self.tenant, self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - - def test_a_user_get_expired_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_xml(self.tenant, self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_get_disabled_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_json(self.tenant, - self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - - def test_a_user_get_disabled_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_xml(self.tenant, - self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_get_missing_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_json(self.tenant, - self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(401, resp_val) - - def test_a_user_get_missing_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_xml(self.tenant, self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(401, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_get_invalid_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_json(self.tenant, self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(404, resp_val) - - def test_a_user_get_invalid_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_xml(self.tenant, self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(404, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_get_disabled_user(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_json(self.tenant, - self.userdisabled, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - - def test_a_user_get_disabled_user_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_xml(self.tenant, self.userdisabled, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_get_disabled_tenant(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_json('0000', self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - - def test_a_user_get_disabled_tenant_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_get_xml('0000', self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - utils.handle_user_resp(self, content, resp_val, - utils.content_type(resp)) - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', - utils.content_type(resp)) - - -class DeleteUserTest(UserTest): - - def test_a_user_delete(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user(self.tenant, self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(204, resp_val) - - def test_a_user_delete_xml(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user_xml(self.tenant, self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(204, resp_val) - - def test_a_user_delete_expired_token(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user(self.tenant, self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_a_user_delete_expired_token_xml(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user_xml(self.tenant, self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_delete_missing_token(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user(self.tenant, self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - - def test_a_user_delete_missing_token_xml(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user_xml(self.tenant, self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_delete_invalid_token(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user(self.tenant, self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - - def test_a_user_delete_invalid_token_xml(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user_xml(self.tenant, self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_a_user_delete_disabled_tenant(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user("0000", self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_a_user_delete_disabled_tenant_xml(self): - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - resp = utils.delete_user_xml("0000", self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - -class GetUsersTest(UserTest): - - def test_users_get(self): - resp, content = utils.users_get_json(self.tenant, self.auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(200, resp_val) - - def test_users_get_xml(self): - resp, content = utils.users_get_xml(self.tenant, self.auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(200, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_get_expired_token(self): - resp, content = utils.users_get_json(self.tenant, self.exp_auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_users_get_expired_token_xml(self): - resp, content = utils.users_get_xml(self.tenant, self.exp_auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_get_disabled_token(self): - resp, content = utils.users_get_json(self.tenant, self.disabled_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_users_get_disabled_token_xml(self): - resp, content = utils.users_get_xml(self.tenant, self.disabled_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_get_missing_token(self): - resp, content = utils.users_get_json(self.tenant, self.missing_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - - def test_users_get_missing_token_xml(self): - resp, content = utils.users_get_xml(self.tenant, self.missing_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_get_invalid_token(self): - resp, content = utils.users_get_json(self.tenant, self.invalid_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - - def test_users_get_invalid_token_xml(self): - resp, content = utils.users_get_xml(self.tenant, self.invalid_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_get_disabled_tenant(self): - resp, content = utils.users_get_json('0000', self.auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_users_get_disabled_tenant_xml(self): - resp, content = utils.users_get_xml('0000', self.auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - -class GetUsersGroupTest(UserTest): - - def test_users_group_get(self): - resp, content = utils.users_group_get_json(self.tenant, - self.user, - self.auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(200, resp_val) - - def test_users_group_get_xml(self): - resp, content = utils.users_group_get_xml(self.tenant, - self.user, - self.auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(200, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_group_get_expired_token(self): - resp, content = utils.users_group_get_json(self.tenant, - self.user, - self.exp_auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_users_group_get_expired_token_xml(self): - resp, content = utils.users_group_get_xml(self.tenant, - self.user, - self.exp_auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_group_get_disabled_token(self): - resp, content = utils.users_group_get_json(self.tenant, - self.user, - self.disabled_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_users_group_get_disabled_token_xml(self): - resp, content = utils.users_group_get_xml(self.tenant, - self.user, - self.disabled_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_group_get_missing_token(self): - resp, content = utils.users_group_get_json(self.tenant, - self.user, - self.missing_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - - def test_users_group_get_missing_token_xml(self): - resp, content = utils.users_group_get_xml(self.tenant, - self.user, - self.missing_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_group_get_invalid_token(self): - resp, content = utils.users_group_get_json(self.tenant, - self.user, - self.invalid_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - - def test_users_group_get_invalid_token_xml(self): - resp, content = utils.users_group_get_xml(self.tenant, - self.user, - self.invalid_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_users_group_get_disabled_tenant(self): - resp, content = utils.users_group_get_json('0000', - self.user, - self.auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_users_group_get_disabled_tenant_xml(self): - resp, content = utils.users_group_get_xml('0000', - self.user, - self.auth_token) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - -class UpdateUserTest(UserTest): - - def test_user_update(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_json(self.tenant, self.user, - self.auth_token) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(200, resp_val) - self.assertEqual('updatedjoeuser@rackspace.com', - content['user']['email']) - - def test_user_update_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_xml(self.tenant, self.user, - self.auth_token) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(200, resp_val) - self.assertEqual('updatedjoeuser@rackspace.com', - content.get("email")) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_update_user_disabled(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_json(self.tenant, - self.userdisabled, - self.auth_token) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_update_user_disabled_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_xml(self.tenant, - self.userdisabled, - self.auth_token) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_update_email_conflict(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_json(self.tenant, - "joeuser", - self.auth_token, - "test_user@rackspace.com") - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(409, resp_val) - - def test_user_update_email_conflict_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_xml(self.tenant, - "joeuser", - self.auth_token, - "test_user@rackspace.com") - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(409, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_update_bad_request_json(self): - h = httplib2.Http(".cache") - resp, content = utils.create_user(self.tenant, self.user, - str(self.auth_token)) - url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user) - data = '{"user_bad": { "bad": "updatedjoeuser@rackspace.com"}}' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(400, resp_val) - - def test_user_update_bad_request_xml(self): - h = httplib2.Http(".cache") - resp, content = utils.create_user_xml(self.tenant, self.user, - str(self.auth_token)) - url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - user xmlns="http://docs.openstack.org/identity/api/v2.0" \ - email="updatedjoeuser@rackspace.com" />' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(400, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_update_expired_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_json(self.tenant, - self.user, - self.exp_auth_token) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_update_expired_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_xml(self.tenant, - self.user, - self.exp_auth_token) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_update_disabled_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_json(self.tenant, - self.user, - self.disabled_token) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_update_disabled_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_xml(self.tenant, - self.user, - self.disabled_token) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_update_invalid_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_json(self.tenant, - self.user, - self.invalid_token) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - - def test_user_update_invalid_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_xml(self.tenant, - self.user, - self.invalid_token) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_update_missing_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_json(self.tenant, - self.user, - self.missing_token) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - - def test_user_update_missing_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_update_xml(self.tenant, - self.user, - self.missing_token) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - -class SetPasswordTest(UserTest): - - def test_user_password(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_json(self.tenant, - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(200, resp_val) - self.assertEqual('p@ssword', content['user']['password']) - - def test_user_password_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_xml(self.tenant, - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(200, resp_val) - self.assertEqual('p@ssword', content.get("password")) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_password_user_disabled(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_json(self.tenant, - self.userdisabled, - str(self.auth_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_password_user_disabled_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_xml(self.tenant, - self.userdisabled, - str(self.auth_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_password_bad_request_json(self): - h = httplib2.Http(".cache") - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user) - data = '{"user_bad": { "password": "p@ssword"}}' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(400, resp_val) - - def test_user_password_bad_request_xml(self): - h = httplib2.Http(".cache") - utils.create_user_xml(self.tenant, self.user, str(self.auth_token)) - url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - user xmlns="http://docs.openstack.org/identity/api/v2.0" \ - password="p@ssword" />' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(400, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_password_expired_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_json(self.tenant, - self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_password_expired_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_xml(self.tenant, - self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_password_disabled_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_json(self.tenant, - self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_password_disabled_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_xml(self.tenant, - self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_password_invalid_token(self): - utils.create_user(self.tenant, - self.user, - str(self.auth_token)) - resp, content = utils.user_password_json(self.tenant, - self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - - def test_user_password_invalid_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_xml(self.tenant, - self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_password_missing_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_json(self.tenant, - self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - - def test_user_password_missing_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_password_xml(self.tenant, - self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - -class SetEnabledTest(UserTest): - - def test_user_enabled(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_json(self.tenant, - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(200, resp_val) - self.assertEqual(True, content['user']['enabled']) - - def test_user_enabled_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_xml(self.tenant, - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(200, resp_val) - self.assertEqual('true', content.get("enabled")) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_enabled_bad_request_json(self): - h = httplib2.Http(".cache") - utils.create_user(self.tenant, self.user, - str(self.auth_token)) - url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user) - data = '{"user_bad": { "enabled": true}}' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/json", - "X-Auth-Token": self.auth_token}) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(400, resp_val) - - def test_user_enabled_bad_request_xml(self): - h = httplib2.Http(".cache") - utils.create_user_xml(self.tenant, self.user, - str(self.auth_token)) - url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user) - data = '<?xml version="1.0" encoding="UTF-8"?> \ - user xmlns="http://docs.openstack.org/identity/api/v2.0" \ - enabled="true" />' - resp, content = h.request(url, "PUT", body=data, - headers={"Content-Type": "application/xml", - "X-Auth-Token": self.auth_token, - "ACCEPT": "application/xml"}) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - self.assertEqual(400, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_enabled_disabled_tenant(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_json('0000', - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_enabled_disabled_tenant_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_xml('0000', - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_enabled_expired_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_json(self.tenant, - self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_enabled_expired_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_xml(self.tenant, - self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_enabled_disabled_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_json(self.tenant, - self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_user_enabled_disabled_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_xml(self.tenant, - self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_enabled_invalid_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_json(self.tenant, - self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - - def test_user_enabled_invalid_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_xml(self.tenant, - self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - def test_user_enabled_missing_token(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_json(self.tenant, - self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - content = json.loads(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - - def test_user_enabled_missing_token_xml(self): - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.user_enabled_xml(self.tenant, - self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - content = etree.fromstring(content) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - self.assertEqual('application/xml', utils.content_type(resp)) - - -class AddUserTest(UserTest): - - def setUp(self): - self.token = utils.get_token('joeuser1', 'secrete', '1234') - self.tenant = utils.get_another_tenant() - self.password = utils.get_password() - self.email = utils.get_email() - self.user = 'joeuser1' - self.userdisabled = utils.get_userdisabled() - self.auth_token = utils.get_auth_token() - self.exp_auth_token = utils.get_exp_auth_token() - self.disabled_token = utils.get_disabled_token() - self.missing_token = utils.get_none_token() - self.invalid_token = utils.get_non_existing_token() - - def tearDown(self): - utils.delete_user(self.tenant, self.user, str(self.auth_token)) - utils.delete_tenant(self.tenant, str(self.auth_token)) - - def test_add_user_tenant(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user(self.tenant, - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(201, resp_val) - - def test_add_user_tenant_xml(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user_xml(self.tenant, - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(201, resp_val) - - def test_add_user_tenant_conflict(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.create_user(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.create_user(self.tenant, - self.user, - str(self.auth_token)) - - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(409, resp_val) - - def test_add_user_tenant_conflict_xml(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - utils.create_user_xml(self.tenant, self.user, str(self.auth_token)) - resp, content = utils.create_user_xml(self.tenant, - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(409, resp_val) - - - def test_add_user_tenant_expired_token(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user(self.tenant, - self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_add_user_tenant_expired_token_xml(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user_xml(self.tenant, - self.user, - str(self.exp_auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_add_user_tenant_disabled_token(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user(self.tenant, - self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_add_user_tenant_disabled_token_xml(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user_xml(self.tenant, - self.user, - str(self.disabled_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_add_user_tenant_invalid_token(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user(self.tenant, - self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - - def test_add_user_tenant_invalid_token_xml(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user_xml(self.tenant, - self.user, - str(self.invalid_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(404, resp_val) - - def test_add_user_tenant_missing_token(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user(self.tenant, - self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - - def test_add_user_tenant_missing_token_xml(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user_xml(self.tenant, - self.user, - str(self.missing_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(401, resp_val) - - def test_add_user_tenant_disabled_tenant(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user('0000', - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - - def test_add_user_tenant_disabled_tenant_xml(self): - utils.create_tenant(self.tenant, str(self.auth_token)) - resp, content = utils.create_user_xml('0000', - self.user, - str(self.auth_token)) - resp_val = int(resp['status']) - if resp_val == 500: - self.fail('Identity Fault') - elif resp_val == 503: - self.fail('Service Not Available') - self.assertEqual(403, resp_val) - -if __name__ == '__main__': - unittest.main() diff --git a/test/unit/test_version.py b/test/unit/test_version.py deleted file mode 100644 index 3e98935e..00000000 --- a/test/unit/test_version.py +++ /dev/null @@ -1,49 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import httplib2 -import os -import sys -sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', '..', '..', 'keystone'))) -import unittest - -import test_common as utils - - -class VersionTest(unittest.TestCase): - - #Given _a_ to make inherited test cases in an order. - #here to call below method will call as last test case - - def test_a_get_version_json(self): - header = httplib2.Http(".cache") - resp, content = header.request(utils.URL, "GET", body="", - headers={"Content-Type": "application/json"}) - self.assertEqual(200, int(resp['status'])) - self.assertEqual('application/json', utils.content_type(resp)) - - def test_a_get_version_xml(self): - header = httplib2.Http(".cache") - resp, content = header.request(utils.URL, "GET", body="", - headers={"Content-Type": "application/xml", - "ACCEPT": "application/xml"}) - self.assertEqual(200, int(resp['status'])) - self.assertEqual('application/xml', utils.content_type(resp)) - -if __name__ == '__main__': - unittest.main() |
