diff --git a/functional/tests/test_identity.py b/functional/tests/test_identity.py index cdb0ed341b..c5779a206d 100644 --- a/functional/tests/test_identity.py +++ b/functional/tests/test_identity.py @@ -76,6 +76,7 @@ class IdentityV3Tests(test.TestCase): DOMAIN_FIELDS = ['description', 'enabled', 'id', 'name', 'links'] GROUP_FIELDS = ['description', 'domain_id', 'id', 'name', 'links'] + TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id'] def _create_dummy_group(self): name = uuid.uuid4().hex @@ -139,3 +140,8 @@ class IdentityV3Tests(test.TestCase): raw_output = self.openstack('domain show ' + name) items = self.parse_show(raw_output) self.assert_show_fields(items, self.DOMAIN_FIELDS) + + def test_token_issue(self): + raw_output = self.openstack('token issue') + items = self.parse_show(raw_output) + self.assert_show_fields(items, self.TOKEN_FIELDS) diff --git a/openstackclient/identity/v3/token.py b/openstackclient/identity/v3/token.py index 52ed439f15..aca5c66993 100644 --- a/openstackclient/identity/v3/token.py +++ b/openstackclient/identity/v3/token.py @@ -159,9 +159,9 @@ class IssueToken(show.ShowOne): def take_action(self, parsed_args): self.log.debug('take_action(%s)', parsed_args) - identity_client = self.app.client_manager.identity + session = self.app.client_manager.identity.session - token = identity_client.service_catalog.get_token() + token = session.auth.auth_ref.service_catalog.get_token() if 'tenant_id' in token: token['project_id'] = token.pop('tenant_id') return zip(*sorted(six.iteritems(token))) diff --git a/openstackclient/tests/identity/v3/fakes.py b/openstackclient/tests/identity/v3/fakes.py index b0df16f043..1ca1c55d5d 100644 --- a/openstackclient/tests/identity/v3/fakes.py +++ b/openstackclient/tests/identity/v3/fakes.py @@ -292,7 +292,9 @@ class FakeIdentityv3Client(object): self.roles.resource_class = fakes.FakeResource(None, {}) self.services = mock.Mock() self.services.resource_class = fakes.FakeResource(None, {}) - self.service_catalog = mock.Mock() + self.session = mock.Mock() + self.session.auth.auth_ref.service_catalog.resource_class = \ + fakes.FakeResource(None, {}) self.users = mock.Mock() self.users.resource_class = fakes.FakeResource(None, {}) self.role_assignments = mock.Mock() diff --git a/openstackclient/tests/identity/v3/test_token.py b/openstackclient/tests/identity/v3/test_token.py index 8888b93186..dbe855555c 100644 --- a/openstackclient/tests/identity/v3/test_token.py +++ b/openstackclient/tests/identity/v3/test_token.py @@ -23,7 +23,8 @@ class TestToken(identity_fakes.TestIdentityv3): super(TestToken, self).setUp() # Get a shortcut to the Service Catalog Mock - self.sc_mock = self.app.client_manager.identity.service_catalog + session = self.app.client_manager.identity.session + self.sc_mock = session.auth.auth_ref.service_catalog self.sc_mock.reset_mock()