From b1fd6aac34a2e96d7e71f307f31f40fa3bf3fac1 Mon Sep 17 00:00:00 2001 From: Ziad Sawalha Date: Wed, 10 Aug 2011 23:42:52 -0500 Subject: Added xsd content, update static controller, and static tests Change-Id: Ibb56ac3273a5f29d5a6dc96d8f14e2e7b058c7c5 --- keystone/content/xsd/api-common.xsd | 56 +++++ keystone/content/xsd/api.xsd | 18 ++ keystone/content/xsd/atom/atom.xsd | 115 +++++++++++ keystone/content/xsd/atom/xml.xsd | 287 ++++++++++++++++++++++++++ keystone/content/xsd/endpoints.xsd | 200 ++++++++++++++++++ keystone/content/xsd/extensions.xsd | 56 +++++ keystone/content/xsd/fault.xsd | 135 ++++++++++++ keystone/content/xsd/roles.xsd | 113 ++++++++++ keystone/content/xsd/services.xsd | 59 ++++++ keystone/content/xsd/tenant.xsd | 40 ++++ keystone/content/xsd/token.xsd | 172 +++++++++++++++ keystone/content/xsd/user.xsd | 100 +++++++++ keystone/content/xsd/version.xsd | 200 ++++++++++++++++++ keystone/controllers/staticfiles.py | 21 +- keystone/routers/admin.py | 17 ++ keystone/routers/service.py | 21 +- keystone/test/functional/test_static_files.py | 10 +- 17 files changed, 1612 insertions(+), 8 deletions(-) create mode 100644 keystone/content/xsd/api-common.xsd create mode 100755 keystone/content/xsd/api.xsd create mode 100644 keystone/content/xsd/atom/atom.xsd create mode 100644 keystone/content/xsd/atom/xml.xsd create mode 100644 keystone/content/xsd/endpoints.xsd create mode 100644 keystone/content/xsd/extensions.xsd create mode 100644 keystone/content/xsd/fault.xsd create mode 100755 keystone/content/xsd/roles.xsd create mode 100644 keystone/content/xsd/services.xsd create mode 100644 keystone/content/xsd/tenant.xsd create mode 100644 keystone/content/xsd/token.xsd create mode 100755 keystone/content/xsd/user.xsd create mode 100644 keystone/content/xsd/version.xsd diff --git a/keystone/content/xsd/api-common.xsd b/keystone/content/xsd/api-common.xsd new file mode 100644 index 00000000..5e8ebeda --- /dev/null +++ b/keystone/content/xsd/api-common.xsd @@ -0,0 +1,56 @@ + + + + + + + + + + Open Stack Common API Schema Types 1.0 + + + + + +

+ This is the main index XML Schema document + for Common API Schema Types Version 1.0. +

+
+
+ + + +

+ Types related to extensions. +

+
+
+
+ + + +

+ Types related to API version details. +

+
+
+
+
diff --git a/keystone/content/xsd/api.xsd b/keystone/content/xsd/api.xsd new file mode 100755 index 00000000..e2a065a0 --- /dev/null +++ b/keystone/content/xsd/api.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/keystone/content/xsd/atom/atom.xsd b/keystone/content/xsd/atom/atom.xsd new file mode 100644 index 00000000..c515c497 --- /dev/null +++ b/keystone/content/xsd/atom/atom.xsd @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + See section 3.4 of the ATOM RFC RFC4287 + + + + + + + TODO(Jorge) + + + + + + + + TODO(Jorge) + + + + + + + + TODO(Jorge) + + + + + + + + TODO(Jorge) + + + + + + + + TODO(Jorge) + + + + + + + + diff --git a/keystone/content/xsd/atom/xml.xsd b/keystone/content/xsd/atom/xml.xsd new file mode 100644 index 00000000..aea7d0db --- /dev/null +++ b/keystone/content/xsd/atom/xml.xsd @@ -0,0 +1,287 @@ + + + + + + +
+

About the XML namespace

+ +
+

+ This schema document describes the XML namespace, in a form + suitable for import by other schema documents. +

+

+ See + http://www.w3.org/XML/1998/namespace.html and + + http://www.w3.org/TR/REC-xml for information + about this namespace. +

+

+ 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. +

+

+ See further below in this document for more information about how to refer to this schema document from your own + XSD schema documents and about the + namespace-versioning policy governing this schema document. +

+
+
+
+
+ + + + +
+ +

lang (as an attribute name)

+

+ 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.

+ +
+
+

Notes

+

+ 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. +

+

+ See BCP 47 at + http://www.rfc-editor.org/rfc/bcp/bcp47.txt + and the IANA language subtag registry at + + http://www.iana.org/assignments/language-subtag-registry + for further information. +

+

+ The union allows for the 'un-declaration' of xml:lang with + the empty string. +

+
+
+
+ + + + + + + + + +
+ + + + +
+ +

space (as an attribute name)

+

+ 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.

+ +
+
+
+ + + + + + +
+ + + +
+ +

base (as an attribute name)

+

+ 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.

+ +

+ See http://www.w3.org/TR/xmlbase/ + for information about this attribute. +

+
+
+
+
+ + + + +
+ +

id (as an attribute name)

+

+ 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.

+ +

+ See http://www.w3.org/TR/xml-id/ + for information about this attribute. +

+
+
+
+
+ + + + + + + + + + +
+ +

Father (in any context at all)

+ +
+

+ 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: +

+
+

+ 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". +

+
+
+
+
+
+ + + +
+

About this schema document

+ +
+

+ This schema defines attributes and an attribute group suitable + for use by schemas wishing to allow xml:base, + xml:lang, xml:space or + xml:id attributes on elements they define. +

+

+ To enable this, such a schema must import this schema for + the XML namespace, e.g. as follows: +

+
+          <schema . . .>
+           . . .
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+     
+

+ or +

+
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+     
+

+ Subsequently, qualified reference to any of the attributes or the + group defined below will have the desired effect, e.g. +

+
+          <type . . .>
+           . . .
+           <attributeGroup ref="xml:specialAttrs"/>
+     
+

+ will define a type which will schema-validate an instance element + with any of those attributes. +

+
+
+
+
+ + + +
+

Versioning policy for this schema document

+
+

+ In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + + http://www.w3.org/2009/01/xml.xsd. +

+

+ At the date of issue it can also be found at + + http://www.w3.org/2001/xml.xsd. +

+

+ 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 + http://www.w3.org/2001/xml.xsd + + will change accordingly; the version at + + http://www.w3.org/2009/01/xml.xsd + + will not change. +

+

+ Previous dated (and unchanging) versions of this schema + document are at: +

+ +
+
+
+
+ +
+ diff --git a/keystone/content/xsd/endpoints.xsd b/keystone/content/xsd/endpoints.xsd new file mode 100644 index 00000000..7044e173 --- /dev/null +++ b/keystone/content/xsd/endpoints.xsd @@ -0,0 +1,200 @@ + + + + + + + + + +

+ A list of Endpoint Templates. +

+
+
+
+ + + + +

+ An Endpoint Template. +

+
+
+
+ + + +

+ An Endpoint. +

+
+
+
+ + + +

+ A list of Endpoints. +

+
+
+
+ + + + + + +

+ An ID uniquely identifying the Endpoint Template. +

+
+
+
+ + + +

+ The service name of Endpoint Template. +

+
+
+
+ + + +

+ The region of Endpoint Template. +

+
+
+
+ + + +

+ The public URL to access represented service. +

+
+
+
+ + + +

+ The internal version of the public URL. +

+
+
+
+ + + +

+ The admin URL. +

+
+
+
+ + + +

+ If true the Endpoint Template is automatically part of every account. +

+
+
+
+ + + +

+ True if the Endpoint Template is enabled (active). + A Endpoint Template cannot be added if it's disabled or inactive (false). +

+
+
+
+ +
+ + + + + +

+ An ID uniquely identifying the Endpoint. +

+
+
+
+ + + +

+ A hyperlink reference to the URL Endpoint Template. +

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + +
diff --git a/keystone/content/xsd/extensions.xsd b/keystone/content/xsd/extensions.xsd new file mode 100644 index 00000000..a942f0a1 --- /dev/null +++ b/keystone/content/xsd/extensions.xsd @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ There should be at least one atom link + with a describedby relation. +

+
+
+
+
+ + + + + + + +
diff --git a/keystone/content/xsd/fault.xsd b/keystone/content/xsd/fault.xsd new file mode 100644 index 00000000..6725e3a4 --- /dev/null +++ b/keystone/content/xsd/fault.xsd @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + +

+ A human readable message that is appropriate for display + to the end user. +

+
+
+
+ + + +

+ 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. +

+
+
+
+ +
+ + + +

+ The HTTP status code associated with the current fault. +

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ An optional dateTime denoting when an operation should + be retried. +

+
+
+
+
+
+
+ +
diff --git a/keystone/content/xsd/roles.xsd b/keystone/content/xsd/roles.xsd new file mode 100755 index 00000000..aad0b901 --- /dev/null +++ b/keystone/content/xsd/roles.xsd @@ -0,0 +1,113 @@ + + + + + + + + + + + +

+ A list of roles. +

+
+
+
+ + + + +

+ A role. +

+
+
+
+ + + + + +

+ A list of roles refs. +

+
+
+
+ + + + +

+ A role reference. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

+ A hyperlink refrence to the role URL. +

+
+
+
+ +
+ + + + + + + + + + +
\ No newline at end of file diff --git a/keystone/content/xsd/services.xsd b/keystone/content/xsd/services.xsd new file mode 100644 index 00000000..e9ba70e4 --- /dev/null +++ b/keystone/content/xsd/services.xsd @@ -0,0 +1,59 @@ + + + + + + + + + + + +

+ A list of services. +

+
+
+
+ + + + +

+ A service. +

+
+
+
+ + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/keystone/content/xsd/tenant.xsd b/keystone/content/xsd/tenant.xsd new file mode 100644 index 00000000..26ef15fe --- /dev/null +++ b/keystone/content/xsd/tenant.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/keystone/content/xsd/token.xsd b/keystone/content/xsd/token.xsd new file mode 100644 index 00000000..759b8de7 --- /dev/null +++ b/keystone/content/xsd/token.xsd @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ A list of services. +

+
+
+
+
+ +
+ + + + + +

+ A list of endpoints. +

+
+
+
+
+ + + +

+ The service name. +

+
+
+
+ +
+ + + + + +

+ The airport code of the region where the endpoint + lives. +

+
+
+
+ + + +

+ The publically accessible service URL. +

+
+
+
+ + + +

+ A service URL, accessible only within the + Rackspace Cloud. +

+
+
+
+ + + +

+ A service URL used for administration. This may expose + additional functionality not found in the public and + internal URL. +

+
+
+
+ +
+
+ diff --git a/keystone/content/xsd/user.xsd b/keystone/content/xsd/user.xsd new file mode 100755 index 00000000..991a1fb4 --- /dev/null +++ b/keystone/content/xsd/user.xsd @@ -0,0 +1,100 @@ + + + + + + + + + + + + + +

+ A list of Users. +

+
+
+
+ + + + +

+ A Keystone User. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/keystone/content/xsd/version.xsd b/keystone/content/xsd/version.xsd new file mode 100644 index 00000000..6b2403bd --- /dev/null +++ b/keystone/content/xsd/version.xsd @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + The VersionStatus type describes a service's operational status. + + + + + + + + + + + + + + + + + A version choice list outlines a collection of service version choices. + + + + + + + + + + + + + + In version lists, every single version must + contain at least one self link. + + + + + + + + + + + + + + When used as a root element, a version choice + must contain at least one describedby link. + + + + + + + + + + + + + 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. + + + + + + + + + + + + + + + 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. + + + + + + + + + + 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. + + + + + + + + + + A version choice's updated attribute describes + the time when the version was updated. The + time should be updated anytime + anything in the + version has changed: documentation, + extensions, bug fixes. + + + + + + + + + + + + A MediaTypeList outlines a collection of valid media types for a given + service version. + + + + + + + + + + + + + + + + A MediaType describes what content types the service version understands. + + + + + + + + + + + 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. + + + + + + + + + + The type attribute of a MediaType describes the MIME specific + identifier of the media type in question. This identifier should include + a vendor namespace ( + See RFC 2048) + as well as a version suffix. + + + + + + + diff --git a/keystone/controllers/staticfiles.py b/keystone/controllers/staticfiles.py index a311e450..4057956c 100644 --- a/keystone/controllers/staticfiles.py +++ b/keystone/controllers/staticfiles.py @@ -1,3 +1,20 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 OpenStack LLC. +# All Rights Reserved. +# +# 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. + from webob import Response from keystone import utils @@ -25,11 +42,11 @@ class StaticFilesController(wsgi.Controller): @utils.wrap_error def get_xsd_contract(self, req, xsd): resp = Response() - return template.static_file(resp, req, "/xsd/" + xsd, + return template.static_file(resp, req, "content/xsd/" + xsd, root=utils.get_app_root(), mimetype="application/xml") @utils.wrap_error def get_xsd_atom_contract(self, req, xsd): resp = Response() - return template.static_file(resp, req, "/xsd/atom/" + xsd, + return template.static_file(resp, req, "content/xsd/atom/" + xsd, root=utils.get_app_root(), mimetype="application/xml") diff --git a/keystone/routers/admin.py b/keystone/routers/admin.py index 293b38fc..c1a02455 100755 --- a/keystone/routers/admin.py +++ b/keystone/routers/admin.py @@ -1,3 +1,20 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 OpenStack LLC. +# All Rights Reserved. +# +# 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 routes from keystone.common import wsgi diff --git a/keystone/routers/service.py b/keystone/routers/service.py index ea4865d0..2a9e4182 100644 --- a/keystone/routers/service.py +++ b/keystone/routers/service.py @@ -1,3 +1,20 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 OpenStack LLC. +# All Rights Reserved. +# +# 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 routes from keystone.common import wsgi @@ -49,11 +66,11 @@ class ServiceApi(wsgi.Router): conditions=dict(method=["GET"])) mapper.connect("/xsd/{xsd}", controller=static_files_controller, - action="get_pdf_contract", + action="get_xsd_contract", conditions=dict(method=["GET"])) mapper.connect("/xsd/atom/{xsd}", controller=static_files_controller, - action="get_pdf_contract", + action="get_xsd_atom_contract", conditions=dict(method=["GET"])) super(ServiceApi, self).__init__(mapper) diff --git a/keystone/test/functional/test_static_files.py b/keystone/test/functional/test_static_files.py index 1765e33e..092fd85a 100644 --- a/keystone/test/functional/test_static_files.py +++ b/keystone/test/functional/test_static_files.py @@ -11,11 +11,13 @@ class TestStaticFiles(KeystoneTestCase): r = self.admin_request(path='/identity.wadl') self.assertTrue('xml' in r.getheader('Content-Type')) -# def test_xsd_contract(self): -# self.admin_request(path='/xsd/something') + def test_xsd_contract(self): + r = self.admin_request(path='/xsd/api.xsd') + self.assertTrue('xml' in r.getheader('Content-Type')) -# def test_xsd_atom_contract(self): -# self.admin_request(path='/xsd/atom/something') + def test_xsd_atom_contract(self): + r = self.admin_request(path='/xsd/atom/atom.xsd') + self.assertTrue('xml' in r.getheader('Content-Type')) if __name__ == '__main__': -- cgit