Skip to content

Commit 1a25cba

Browse files
author
Dean Troyer
committed
Followup for ec2 credentials command fix
Add functional tests for 'ec2 credentials' commands. Also fix tenant_id in output for create and show. Change-Id: I6ba3249b67408571624709e17f8aa2ac6d80237d
1 parent 62a2083 commit 1a25cba

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

‎functional/tests/test_identity.py‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ class IdentityV2Tests(test.TestCase):
2424

2525
USER_FIELDS = ['email', 'enabled', 'id', 'name', 'project_id', 'username']
2626
PROJECT_FIELDS = ['enabled', 'id', 'name', 'description']
27+
EC2_CREDENTIALS_FIELDS = [
28+
'access',
29+
'project_id',
30+
'secret',
31+
'trust_id',
32+
'user_id',
33+
]
34+
EC2_CREDENTIALS_LIST_HEADERS = [
35+
'Access',
36+
'Secret',
37+
'Project ID',
38+
'User ID',
39+
]
2740

2841
def test_user_list(self):
2942
raw_output = self.openstack('user list')
@@ -70,6 +83,39 @@ def test_project_delete(self):
7083
raw_output = self.openstack('project delete dummy-project')
7184
self.assertEqual(0, len(raw_output))
7285

86+
def test_ec2_credentials_create(self):
87+
create_output = self.openstack('ec2 credentials create')
88+
create_items = self.parse_show(create_output)
89+
self.openstack(
90+
'ec2 credentials delete %s' % create_items[0]['access'],
91+
)
92+
self.assert_show_fields(create_items, self.EC2_CREDENTIALS_FIELDS)
93+
94+
def test_ec2_credentials_delete(self):
95+
create_output = self.openstack('ec2 credentials create')
96+
create_items = self.parse_show(create_output)
97+
raw_output = self.openstack(
98+
'ec2 credentials delete %s' % create_items[0]['access'],
99+
)
100+
self.assertEqual(0, len(raw_output))
101+
102+
def test_ec2_credentials_list(self):
103+
raw_output = self.openstack('ec2 credentials list')
104+
items = self.parse_listing(raw_output)
105+
self.assert_table_structure(items, self.EC2_CREDENTIALS_LIST_HEADERS)
106+
107+
def test_ec2_credentials_show(self):
108+
create_output = self.openstack('ec2 credentials create')
109+
create_items = self.parse_show(create_output)
110+
show_output = self.openstack(
111+
'ec2 credentials show %s' % create_items[0]['access'],
112+
)
113+
items = self.parse_show(show_output)
114+
self.openstack(
115+
'ec2 credentials delete %s' % create_items[0]['access'],
116+
)
117+
self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS)
118+
73119

74120
class IdentityV3Tests(test.TestCase):
75121
"""Functional tests for Identity V3 commands. """

‎openstackclient/identity/v2_0/ec2creds.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ def take_action(self, parsed_args):
7171

7272
info = {}
7373
info.update(creds._info)
74+
75+
if 'tenant_id' in info:
76+
info.update(
77+
{'project_id': info.pop('tenant_id')}
78+
)
79+
7480
return zip(*sorted(six.iteritems(info)))
7581

7682

@@ -183,4 +189,10 @@ def take_action(self, parsed_args):
183189

184190
info = {}
185191
info.update(creds._info)
192+
193+
if 'tenant_id' in info:
194+
info.update(
195+
{'project_id': info.pop('tenant_id')}
196+
)
197+
186198
return zip(*sorted(six.iteritems(info)))

0 commit comments

Comments
 (0)