Add "token revoke" for identity v3
Change-Id: Ie631600d02942fe6ce035f31af46abe44e543631 Closes-bug: #1543226
This commit is contained in:
parent
624c39ab1b
commit
686a269738
@ -17,8 +17,6 @@ Issue new token
|
||||
token revoke
|
||||
------------
|
||||
|
||||
*Identity version 2 only.*
|
||||
|
||||
Revoke existing token
|
||||
|
||||
.. program:: token revoke
|
||||
|
@ -173,3 +173,22 @@ class IssueToken(command.ShowOne):
|
||||
if 'tenant_id' in token:
|
||||
token['project_id'] = token.pop('tenant_id')
|
||||
return zip(*sorted(six.iteritems(token)))
|
||||
|
||||
|
||||
class RevokeToken(command.Command):
|
||||
"""Revoke existing token"""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(RevokeToken, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'token',
|
||||
metavar='<token>',
|
||||
help='Token to be deleted',
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
identity_client.tokens.revoke_token(parsed_args.token)
|
||||
return
|
||||
|
@ -420,6 +420,8 @@ class FakeIdentityv3Client(object):
|
||||
self.session = mock.Mock()
|
||||
self.session.auth.auth_ref.service_catalog.resource_class = \
|
||||
fakes.FakeResource(None, {})
|
||||
self.tokens = mock.Mock()
|
||||
self.tokens.resource_class = fakes.FakeResource(None, {})
|
||||
self.trusts = mock.Mock()
|
||||
self.trusts.resource_class = fakes.FakeResource(None, {})
|
||||
self.users = mock.Mock()
|
||||
|
@ -80,3 +80,24 @@ class TestTokenIssue(TestToken):
|
||||
identity_fakes.user_id,
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
|
||||
|
||||
class TestTokenRevoke(TestToken):
|
||||
|
||||
TOKEN = 'fob'
|
||||
|
||||
def setUp(self):
|
||||
super(TestTokenRevoke, self).setUp()
|
||||
self.tokens_mock = self.app.client_manager.identity.tokens
|
||||
self.tokens_mock.reset_mock()
|
||||
self.tokens_mock.revoke_token.return_value = True
|
||||
self.cmd = token.RevokeToken(self.app, None)
|
||||
|
||||
def test_token_revoke(self):
|
||||
arglist = [self.TOKEN]
|
||||
verifylist = [('token', self.TOKEN)]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.tokens_mock.revoke_token.assert_called_with(self.TOKEN)
|
||||
|
5
releasenotes/notes/bug-1543226-7d885ecaa3715415.yaml
Normal file
5
releasenotes/notes/bug-1543226-7d885ecaa3715415.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``token revoke`` command for Identity v3
|
||||
[Bug `1543226 <https://bugs.launchpad.net/bugs/1543226>`_]
|
@ -295,6 +295,7 @@ openstack.identity.v3 =
|
||||
service_provider_show = openstackclient.identity.v3.service_provider:ShowServiceProvider
|
||||
|
||||
token_issue = openstackclient.identity.v3.token:IssueToken
|
||||
token_revoke = openstackclient.identity.v3.token:RevokeToken
|
||||
|
||||
trust_create = openstackclient.identity.v3.trust:CreateTrust
|
||||
trust_delete = openstackclient.identity.v3.trust:DeleteTrust
|
||||
|
Loading…
Reference in New Issue
Block a user