Merge "Add OS-SIMPLE-CERT support for v3."
This commit is contained in:
40
keystoneclient/tests/unit/v3/test_simple_cert.py
Normal file
40
keystoneclient/tests/unit/v3/test_simple_cert.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Copyright 2014 IBM Corp.
|
||||||
|
# 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 testresources
|
||||||
|
|
||||||
|
from keystoneclient.tests.unit import client_fixtures
|
||||||
|
from keystoneclient.tests.unit.v3 import utils
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleCertTests(utils.TestCase, testresources.ResourcedTestCase):
|
||||||
|
|
||||||
|
resources = [('examples', client_fixtures.EXAMPLES_RESOURCE)]
|
||||||
|
|
||||||
|
def test_get_ca_certificate(self):
|
||||||
|
self.stub_url('GET', ['OS-SIMPLE-CERT', 'ca'],
|
||||||
|
headers={'Content-Type': 'application/x-pem-file'},
|
||||||
|
text=self.examples.SIGNING_CA)
|
||||||
|
res = self.client.simple_cert.get_ca_certificates()
|
||||||
|
self.assertEqual(self.examples.SIGNING_CA, res)
|
||||||
|
|
||||||
|
def test_get_certificates(self):
|
||||||
|
self.stub_url('GET', ['OS-SIMPLE-CERT', 'certificates'],
|
||||||
|
headers={'Content-Type': 'application/x-pem-file'},
|
||||||
|
text=self.examples.SIGNING_CERT)
|
||||||
|
res = self.client.simple_cert.get_certificates()
|
||||||
|
self.assertEqual(self.examples.SIGNING_CERT, res)
|
||||||
|
|
||||||
|
|
||||||
|
def load_tests(loader, tests, pattern):
|
||||||
|
return testresources.OptimisingTestSuite(tests)
|
@@ -25,6 +25,7 @@ from keystoneclient.v3.contrib import endpoint_filter
|
|||||||
from keystoneclient.v3.contrib import endpoint_policy
|
from keystoneclient.v3.contrib import endpoint_policy
|
||||||
from keystoneclient.v3.contrib import federation
|
from keystoneclient.v3.contrib import federation
|
||||||
from keystoneclient.v3.contrib import oauth1
|
from keystoneclient.v3.contrib import oauth1
|
||||||
|
from keystoneclient.v3.contrib import simple_cert
|
||||||
from keystoneclient.v3.contrib import trusts
|
from keystoneclient.v3.contrib import trusts
|
||||||
from keystoneclient.v3 import credentials
|
from keystoneclient.v3 import credentials
|
||||||
from keystoneclient.v3 import domains
|
from keystoneclient.v3 import domains
|
||||||
@@ -145,6 +146,10 @@ EndpointPolicyManager`
|
|||||||
|
|
||||||
:py:class:`keystoneclient.v3.roles.RoleManager`
|
:py:class:`keystoneclient.v3.roles.RoleManager`
|
||||||
|
|
||||||
|
.. py:attribute:: simple_cert
|
||||||
|
|
||||||
|
:py:class:`keystoneclient.v3.contrib.simple_cert.SimpleCertManager`
|
||||||
|
|
||||||
.. py:attribute:: services
|
.. py:attribute:: services
|
||||||
|
|
||||||
:py:class:`keystoneclient.v3.services.ServiceManager`
|
:py:class:`keystoneclient.v3.services.ServiceManager`
|
||||||
@@ -186,6 +191,7 @@ EndpointPolicyManager`
|
|||||||
role_assignments.RoleAssignmentManager(self._adapter))
|
role_assignments.RoleAssignmentManager(self._adapter))
|
||||||
self.roles = roles.RoleManager(self._adapter)
|
self.roles = roles.RoleManager(self._adapter)
|
||||||
self.services = services.ServiceManager(self._adapter)
|
self.services = services.ServiceManager(self._adapter)
|
||||||
|
self.simple_cert = simple_cert.SimpleCertManager(self._adapter)
|
||||||
self.tokens = tokens.TokenManager(self._adapter)
|
self.tokens = tokens.TokenManager(self._adapter)
|
||||||
self.trusts = trusts.TrustManager(self._adapter)
|
self.trusts = trusts.TrustManager(self._adapter)
|
||||||
self.users = users.UserManager(self._adapter)
|
self.users = users.UserManager(self._adapter)
|
||||||
|
43
keystoneclient/v3/contrib/simple_cert.py
Normal file
43
keystoneclient/v3/contrib/simple_cert.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Copyright 2014 IBM Corp.
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleCertManager(object):
|
||||||
|
"""Manager for the OS-SIMPLE-CERT extension."""
|
||||||
|
|
||||||
|
def __init__(self, client):
|
||||||
|
self._client = client
|
||||||
|
|
||||||
|
def get_ca_certificates(self):
|
||||||
|
"""Get CA certificates.
|
||||||
|
|
||||||
|
:returns: PEM-formatted string.
|
||||||
|
:rtype: str
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
resp, body = self._client.get('/OS-SIMPLE-CERT/ca',
|
||||||
|
authenticated=False)
|
||||||
|
return resp.text
|
||||||
|
|
||||||
|
def get_certificates(self):
|
||||||
|
"""Get signing certificates.
|
||||||
|
|
||||||
|
:returns: PEM-formatted string.
|
||||||
|
:rtype: str
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
resp, body = self._client.get('/OS-SIMPLE-CERT/certificates',
|
||||||
|
authenticated=False)
|
||||||
|
return resp.text
|
Reference in New Issue
Block a user