|
10 | 10 | # License for the specific language governing permissions and limitations |
11 | 11 | # under the License. |
12 | 12 |
|
| 13 | +import os |
| 14 | +import uuid |
| 15 | + |
13 | 16 | from functional.common import exceptions |
14 | 17 | from functional.common import test |
15 | 18 |
|
| 19 | +BASIC_LIST_HEADERS = ['ID', 'Name'] |
| 20 | + |
16 | 21 |
|
17 | 22 | class IdentityV2Tests(test.TestCase): |
18 | 23 | """Functional tests for Identity V2 commands. """ |
19 | 24 |
|
| 25 | + USER_FIELDS = ['email', 'enabled', 'id', 'name', 'project_id', 'username'] |
| 26 | + PROJECT_FIELDS = ['enabled', 'id', 'name', 'description'] |
| 27 | + |
20 | 28 | def test_user_list(self): |
21 | | - field_names = ['ID', 'Name'] |
22 | 29 | raw_output = self.openstack('user list') |
23 | 30 | items = self.parse_listing(raw_output) |
24 | | - self.assert_table_structure(items, field_names) |
| 31 | + self.assert_table_structure(items, BASIC_LIST_HEADERS) |
25 | 32 |
|
26 | | - def test_user_get(self): |
27 | | - field_names = ['email', 'enabled', 'id', 'name', |
28 | | - 'project_id', 'username'] |
| 33 | + def test_user_show(self): |
29 | 34 | raw_output = self.openstack('user show admin') |
30 | 35 | items = self.parse_show(raw_output) |
31 | | - self.assert_show_fields(items, field_names) |
| 36 | + self.assert_show_fields(items, self.USER_FIELDS) |
| 37 | + |
| 38 | + def test_user_create(self): |
| 39 | + raw_output = self.openstack('user create mjordan --password bulls' |
| 40 | + ' --email hoops@example.com') |
| 41 | + items = self.parse_show(raw_output) |
| 42 | + self.assert_show_fields(items, self.USER_FIELDS) |
| 43 | + |
| 44 | + def test_user_delete(self): |
| 45 | + self.openstack('user create dummy') |
| 46 | + raw_output = self.openstack('user delete dummy') |
| 47 | + self.assertEqual(0, len(raw_output)) |
32 | 48 |
|
33 | 49 | def test_bad_user_command(self): |
34 | 50 | self.assertRaises(exceptions.CommandFailed, |
35 | 51 | self.openstack, 'user unlist') |
| 52 | + |
| 53 | + def test_project_list(self): |
| 54 | + raw_output = self.openstack('project list') |
| 55 | + items = self.parse_listing(raw_output) |
| 56 | + self.assert_table_structure(items, BASIC_LIST_HEADERS) |
| 57 | + |
| 58 | + def test_project_show(self): |
| 59 | + raw_output = self.openstack('project show admin') |
| 60 | + items = self.parse_show(raw_output) |
| 61 | + self.assert_show_fields(items, self.PROJECT_FIELDS) |
| 62 | + |
| 63 | + def test_project_create(self): |
| 64 | + raw_output = self.openstack('project create test-project') |
| 65 | + items = self.parse_show(raw_output) |
| 66 | + self.assert_show_fields(items, self.PROJECT_FIELDS) |
| 67 | + |
| 68 | + def test_project_delete(self): |
| 69 | + self.openstack('project create dummy-project') |
| 70 | + raw_output = self.openstack('project delete dummy-project') |
| 71 | + self.assertEqual(0, len(raw_output)) |
| 72 | + |
| 73 | + |
| 74 | +class IdentityV3Tests(test.TestCase): |
| 75 | + """Functional tests for Identity V3 commands. """ |
| 76 | + |
| 77 | + DOMAIN_FIELDS = ['description', 'enabled', 'id', 'name', 'links'] |
| 78 | + GROUP_FIELDS = ['description', 'domain_id', 'id', 'name', 'links'] |
| 79 | + |
| 80 | + def _create_dummy_group(self): |
| 81 | + name = uuid.uuid4().hex |
| 82 | + self.openstack('group create ' + name) |
| 83 | + return name |
| 84 | + |
| 85 | + def _create_dummy_domain(self): |
| 86 | + name = uuid.uuid4().hex |
| 87 | + self.openstack('domain create ' + name) |
| 88 | + return name |
| 89 | + |
| 90 | + def setUp(self): |
| 91 | + super(IdentityV3Tests, self).setUp() |
| 92 | + auth_url = os.environ.get('OS_AUTH_URL') |
| 93 | + auth_url = auth_url.replace('v2.0', 'v3') |
| 94 | + os.environ['OS_AUTH_URL'] = auth_url |
| 95 | + os.environ['OS_IDENTITY_API_VERSION'] = '3' |
| 96 | + os.environ['OS_USER_DOMAIN_ID'] = 'default' |
| 97 | + os.environ['OS_PROJECT_DOMAIN_ID'] = 'default' |
| 98 | + |
| 99 | + def test_group_create(self): |
| 100 | + raw_output = self.openstack('group create ' + uuid.uuid4().hex) |
| 101 | + items = self.parse_show(raw_output) |
| 102 | + self.assert_show_fields(items, self.GROUP_FIELDS) |
| 103 | + |
| 104 | + def test_group_list(self): |
| 105 | + self._create_dummy_group() |
| 106 | + raw_output = self.openstack('group list') |
| 107 | + items = self.parse_listing(raw_output) |
| 108 | + self.assert_table_structure(items, BASIC_LIST_HEADERS) |
| 109 | + |
| 110 | + def test_group_delete(self): |
| 111 | + name = self._create_dummy_group() |
| 112 | + raw_output = self.openstack('group delete ' + name) |
| 113 | + self.assertEqual(0, len(raw_output)) |
| 114 | + |
| 115 | + def test_group_show(self): |
| 116 | + name = self._create_dummy_group() |
| 117 | + raw_output = self.openstack('group show ' + name) |
| 118 | + items = self.parse_show(raw_output) |
| 119 | + self.assert_show_fields(items, self.GROUP_FIELDS) |
| 120 | + |
| 121 | + def test_domain_create(self): |
| 122 | + raw_output = self.openstack('domain create ' + uuid.uuid4().hex) |
| 123 | + items = self.parse_show(raw_output) |
| 124 | + self.assert_show_fields(items, self.DOMAIN_FIELDS) |
| 125 | + |
| 126 | + def test_domain_list(self): |
| 127 | + self._create_dummy_domain() |
| 128 | + raw_output = self.openstack('domain list') |
| 129 | + items = self.parse_listing(raw_output) |
| 130 | + self.assert_table_structure(items, BASIC_LIST_HEADERS) |
| 131 | + |
| 132 | + def test_domain_delete(self): |
| 133 | + name = self._create_dummy_domain() |
| 134 | + self.assertRaises(exceptions.CommandFailed, |
| 135 | + self.openstack, 'domain delete ' + name) |
| 136 | + |
| 137 | + def test_domain_show(self): |
| 138 | + name = self._create_dummy_domain() |
| 139 | + raw_output = self.openstack('domain show ' + name) |
| 140 | + items = self.parse_show(raw_output) |
| 141 | + self.assert_show_fields(items, self.DOMAIN_FIELDS) |
0 commit comments