diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2014-12-05 12:54:19 -0600 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2014-12-05 22:21:32 -0600 |
| commit | 1a25cbaf8f2c1643181ef6233f72a57aaac5404d (patch) | |
| tree | d1db670fc2db6075e89035968977995e77e07315 | |
| parent | 62a2083a785bcfac25b2b7e409e1c7e066f9edff (diff) | |
| download | python-openstackclient-1a25cbaf8f2c1643181ef6233f72a57aaac5404d.tar.gz | |
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
| -rw-r--r-- | functional/tests/test_identity.py | 46 | ||||
| -rw-r--r-- | openstackclient/identity/v2_0/ec2creds.py | 12 |
2 files changed, 58 insertions, 0 deletions
diff --git a/functional/tests/test_identity.py b/functional/tests/test_identity.py index c5779a20..b3281154 100644 --- a/functional/tests/test_identity.py +++ b/functional/tests/test_identity.py @@ -24,6 +24,19 @@ class IdentityV2Tests(test.TestCase): USER_FIELDS = ['email', 'enabled', 'id', 'name', 'project_id', 'username'] PROJECT_FIELDS = ['enabled', 'id', 'name', 'description'] + EC2_CREDENTIALS_FIELDS = [ + 'access', + 'project_id', + 'secret', + 'trust_id', + 'user_id', + ] + EC2_CREDENTIALS_LIST_HEADERS = [ + 'Access', + 'Secret', + 'Project ID', + 'User ID', + ] def test_user_list(self): raw_output = self.openstack('user list') @@ -70,6 +83,39 @@ class IdentityV2Tests(test.TestCase): raw_output = self.openstack('project delete dummy-project') self.assertEqual(0, len(raw_output)) + def test_ec2_credentials_create(self): + create_output = self.openstack('ec2 credentials create') + create_items = self.parse_show(create_output) + self.openstack( + 'ec2 credentials delete %s' % create_items[0]['access'], + ) + self.assert_show_fields(create_items, self.EC2_CREDENTIALS_FIELDS) + + def test_ec2_credentials_delete(self): + create_output = self.openstack('ec2 credentials create') + create_items = self.parse_show(create_output) + raw_output = self.openstack( + 'ec2 credentials delete %s' % create_items[0]['access'], + ) + self.assertEqual(0, len(raw_output)) + + def test_ec2_credentials_list(self): + raw_output = self.openstack('ec2 credentials list') + items = self.parse_listing(raw_output) + self.assert_table_structure(items, self.EC2_CREDENTIALS_LIST_HEADERS) + + def test_ec2_credentials_show(self): + create_output = self.openstack('ec2 credentials create') + create_items = self.parse_show(create_output) + show_output = self.openstack( + 'ec2 credentials show %s' % create_items[0]['access'], + ) + items = self.parse_show(show_output) + self.openstack( + 'ec2 credentials delete %s' % create_items[0]['access'], + ) + self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS) + class IdentityV3Tests(test.TestCase): """Functional tests for Identity V3 commands. """ diff --git a/openstackclient/identity/v2_0/ec2creds.py b/openstackclient/identity/v2_0/ec2creds.py index 7a4dea66..a20ffd4b 100644 --- a/openstackclient/identity/v2_0/ec2creds.py +++ b/openstackclient/identity/v2_0/ec2creds.py @@ -71,6 +71,12 @@ class CreateEC2Creds(show.ShowOne): info = {} info.update(creds._info) + + if 'tenant_id' in info: + info.update( + {'project_id': info.pop('tenant_id')} + ) + return zip(*sorted(six.iteritems(info))) @@ -183,4 +189,10 @@ class ShowEC2Creds(show.ShowOne): info = {} info.update(creds._info) + + if 'tenant_id' in info: + info.update( + {'project_id': info.pop('tenant_id')} + ) + return zip(*sorted(six.iteritems(info))) |
