60
60
expect = (DEFAULT_AUTH_URL, DEFAULT_PASSWORD, DEFAULT_TENANT_ID,
61
61
DEFAULT_TENANT_NAME, DEFAULT_USERNAME, '')
62
62
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
63
65
shell('--os_auth_url http://0.0.0.0:5000/ --os_password xyzpdq '
64
66
'--os_tenant_id 1234 --os_tenant_name fred '
65
67
'--os_username barney '
73
75
'fred', 'barney', '2.0')
74
76
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
79
shell('--os-auth-url http://1.1.1.1:5000/ --os-password xyzpdq '
80
'--os-tenant-id 4321 --os-tenant-name wilma '
81
'--os-username betty '
82
'--os-identity-api-version 2.0 user-list')
83
assert do_tenant_mock.called
84
((a, b), c) = do_tenant_mock.call_args
85
actual = (b.os_auth_url, b.os_password, b.os_tenant_id,
86
b.os_tenant_name, b.os_username,
87
b.os_identity_api_version)
88
expect = ('http://1.1.1.1:5000/', 'xyzpdq', '4321',
89
'wilma', 'betty', '2.0')
90
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
76
92
def test_shell_user_create_args(self):
77
93
"""Test user-create args"""
78
94
do_uc_mock = mock.MagicMock()
82
98
with mock.patch('keystoneclient.v2_0.shell.do_user_create',
85
102
# Test case with one --tenant_id args present: ec2 creds
86
103
shell('user-create --name=FOO '
87
104
'--pass=secrete --tenant_id=barrr --enabled=true')
97
114
expect = ('barrr', 'FOO', 'secrete', 'true')
98
115
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
118
# Test case with one --tenant-id args present: ec2 creds
119
shell('user-create --name=foo '
120
'--pass=secrete --tenant-id=BARRR --enabled=true')
121
assert do_uc_mock.called
122
((a, b), c) = do_uc_mock.call_args
123
actual = (b.os_auth_url, b.os_password, b.os_tenant_id,
124
b.os_tenant_name, b.os_username,
125
b.os_identity_api_version)
126
expect = (DEFAULT_AUTH_URL, DEFAULT_PASSWORD, DEFAULT_TENANT_ID,
127
DEFAULT_TENANT_NAME, DEFAULT_USERNAME, '')
128
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
129
actual = (b.tenant_id, b.name, b.passwd, b.enabled)
130
expect = ('BARRR', 'foo', 'secrete', 'true')
131
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
100
134
# Test case with --os_tenant_id and --tenant_id args present
101
135
shell('--os_tenant_id=os-tenant user-create --name=FOO '
102
136
'--pass=secrete --tenant_id=barrr --enabled=true')
112
146
expect = ('barrr', 'FOO', 'secrete', 'true')
113
147
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
150
# Test case with --os-tenant-id and --tenant-id args present
151
shell('--os-tenant-id=ostenant user-create --name=foo '
152
'--pass=secrete --tenant-id=BARRR --enabled=true')
153
assert do_uc_mock.called
154
((a, b), c) = do_uc_mock.call_args
155
actual = (b.os_auth_url, b.os_password, b.os_tenant_id,
156
b.os_tenant_name, b.os_username,
157
b.os_identity_api_version)
158
expect = (DEFAULT_AUTH_URL, DEFAULT_PASSWORD, 'ostenant',
159
DEFAULT_TENANT_NAME, DEFAULT_USERNAME, '')
160
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
161
actual = (b.tenant_id, b.name, b.passwd, b.enabled)
162
expect = ('BARRR', 'foo', 'secrete', 'true')
163
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
115
165
def test_do_tenant_create(self):
116
166
do_tenant_mock = mock.MagicMock()
117
167
with mock.patch('keystoneclient.v2_0.shell.do_tenant_create',
140
190
with mock.patch('keystoneclient.v2_0.shell.do_ec2_credentials_create',
143
194
# Test case with one --tenant_id args present: ec2 creds
144
195
shell('ec2-credentials-create '
145
196
'--tenant_id=ec2-tenant --user_id=ec2-user')
155
206
expect = ('ec2-tenant', 'ec2-user')
156
207
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
210
# Test case with one --tenant-id args present: ec2 creds
211
shell('ec2-credentials-create '
212
'--tenant-id=dash-tenant --user-id=dash-user')
213
assert do_ec2_mock.called
214
((a, b), c) = do_ec2_mock.call_args
215
actual = (b.os_auth_url, b.os_password, b.os_tenant_id,
216
b.os_tenant_name, b.os_username,
217
b.os_identity_api_version)
218
expect = (DEFAULT_AUTH_URL, DEFAULT_PASSWORD, DEFAULT_TENANT_ID,
219
DEFAULT_TENANT_NAME, DEFAULT_USERNAME, '')
220
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
221
actual = (b.tenant_id, b.user_id)
222
expect = ('dash-tenant', 'dash-user')
223
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
158
226
# Test case with two --tenant_id args present
159
227
shell('--os_tenant_id=os-tenant ec2-credentials-create '
160
228
'--tenant_id=ec2-tenant --user_id=ec2-user')
170
238
expect = ('ec2-tenant', 'ec2-user')
171
239
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
242
# Test case with two --tenant-id args present
243
shell('--os-tenant-id=ostenant ec2-credentials-create '
244
'--tenant-id=dash-tenant --user-id=dash-user')
245
assert do_ec2_mock.called
246
((a, b), c) = do_ec2_mock.call_args
247
actual = (b.os_auth_url, b.os_password, b.os_tenant_id,
248
b.os_tenant_name, b.os_username,
249
b.os_identity_api_version)
250
expect = (DEFAULT_AUTH_URL, DEFAULT_PASSWORD, 'ostenant',
251
DEFAULT_TENANT_NAME, DEFAULT_USERNAME, '')
252
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
253
actual = (b.tenant_id, b.user_id)
254
expect = ('dash-tenant', 'dash-user')
255
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
173
257
def test_do_ec2_get(self):
174
258
do_shell_mock = mock.MagicMock()
218
303
'http://example.com:1234/go',
219
304
'http://example.com:9876/adm')
220
305
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
309
shell('endpoint-create '
310
'--service-id=3 --publicurl=http://example.com:4321/go '
311
'--adminurl=http://example.com:9876/adm')
312
assert do_shell_mock.called
313
((a, b), c) = do_shell_mock.call_args
314
actual = (b.os_auth_url, b.os_password, b.os_tenant_id,
315
b.os_tenant_name, b.os_username,
316
b.os_identity_api_version)
317
expect = (DEFAULT_AUTH_URL, DEFAULT_PASSWORD, DEFAULT_TENANT_ID,
318
DEFAULT_TENANT_NAME, DEFAULT_USERNAME, '')
319
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
320
actual = (b.service_id, b.publicurl, b.adminurl)
322
'http://example.com:4321/go',
323
'http://example.com:9876/adm')
324
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))