Imrpove test
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ca38440a Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ca38440a Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ca38440a Branch: refs/heads/trunk Commit: ca38440afb003c30b884cd6e1afb15cfb163d0d6 Parents: 15ae458 Author: micafer <[email protected]> Authored: Tue Jan 30 12:46:23 2018 +0100 Committer: micafer <[email protected]> Committed: Tue Jan 30 12:46:23 2018 +0100 ---------------------------------------------------------------------- libcloud/test/common/test_openstack_identity.py | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/ca38440a/libcloud/test/common/test_openstack_identity.py ---------------------------------------------------------------------- diff --git a/libcloud/test/common/test_openstack_identity.py b/libcloud/test/common/test_openstack_identity.py index bf0eb2b..79a129e 100644 --- a/libcloud/test/common/test_openstack_identity.py +++ b/libcloud/test/common/test_openstack_identity.py @@ -424,6 +424,30 @@ class OpenStackIdentity_3_0_ConnectionTests(unittest.TestCase): self.assertTrue(result) +class OpenStackIdentity_3_0_Connection_OIDC_access_token_federation_projectsTests( + unittest.TestCase): + def setUp(self): + mock_cls = OpenStackIdentity_3_0_federation_projects_MockHttp + mock_cls.type = None + OpenStackIdentity_3_0_Connection_OIDC_access_token.conn_class = mock_cls + + self.auth_instance = OpenStackIdentity_3_0_Connection_OIDC_access_token(auth_url='http://none', + user_id='idp', + key='token', + tenant_name='oidc', + domain_name='test_domain') + self.auth_instance.auth_token = 'mock' + + def test_authenticate(self): + auth = OpenStackIdentity_3_0_Connection_OIDC_access_token(auth_url='http://none', + user_id='idp', + key='token', + token_scope='project', + tenant_name="oidc", + domain_name='test_domain') + auth.authenticate() + + class OpenStackIdentity_3_0_Connection_OIDC_access_tokenTests( unittest.TestCase): def setUp(self): @@ -737,6 +761,22 @@ class OpenStackIdentity_3_0_MockHttp(MockHttp): raise NotImplementedError() +class OpenStackIdentity_3_0_federation_projects_MockHttp(OpenStackIdentity_3_0_MockHttp): + fixtures = ComputeFileFixtures('openstack_identity/v3') + json_content_headers = {'content-type': 'application/json; charset=UTF-8'} + + def _v3_OS_FEDERATION_projects(self, method, url, body, headers): + if method == 'GET': + # get user projects + body = json.dumps({"projects": [{"id": "project_id"}]}) + return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK]) + raise NotImplementedError() + + def _v3_auth_projects(self, method, url, body, headers): + return (httplib.INTERNAL_SERVER_ERROR, body, self.json_content_headers, + httplib.responses[httplib.INTERNAL_SERVER_ERROR]) + + class OpenStackIdentity_2_0_Connection_VOMSMockHttp(MockHttp): fixtures = ComputeFileFixtures('openstack_identity/v2') json_content_headers = {'content-type': 'application/json; charset=UTF-8'}
