|
10 | 10 |
|
11 | 11 | from unittest import mock as mock
|
12 | 12 |
|
| 13 | +from SoftLayer.fixtures import SoftLayer_User_Customer |
13 | 14 | from SoftLayer import testing
|
14 | 15 |
|
15 | 16 |
|
@@ -387,3 +388,31 @@ def test_remove_without_password(self):
|
387 | 388 | result = self.run_command(['user', 'vpn-password', '123456'])
|
388 | 389 | self.assertEqual(2, result.exit_code)
|
389 | 390 | self.assertIn("Missing option '--password'", result.output)
|
| 391 | + |
| 392 | + def test_api_key_without_option(self): |
| 393 | + result = self.run_command(['user', 'apikey', '123456']) |
| 394 | + self.assertEqual(2, result.exit_code) |
| 395 | + self.assertIn('At least one option is required', result.exception.message) |
| 396 | + |
| 397 | + def test_api_key_with_all_option(self): |
| 398 | + result = self.run_command(['user', 'apikey', '123456', '--add', '--remove', '--refresh']) |
| 399 | + self.assertEqual(2, result.exit_code) |
| 400 | + self.assertIn('Can only specify one option', result.exception.message) |
| 401 | + |
| 402 | + def test_remove_api_authentication_key_without_api_key(self): |
| 403 | + mock = self.set_mock('SoftLayer_User_Customer', 'getApiAuthenticationKeys') |
| 404 | + mock.return_value = SoftLayer_User_Customer.getEmptyApiAuthenticationKeys |
| 405 | + result = self.run_command(['user', 'apikey', '123456', '--remove']) |
| 406 | + self.assert_no_fail(result) |
| 407 | + |
| 408 | + def test_add_api_authentication_key(self): |
| 409 | + result = self.run_command(['user', 'apikey', '123456', '--add']) |
| 410 | + self.assert_no_fail(result) |
| 411 | + |
| 412 | + def test_remove_api_authentication_key(self): |
| 413 | + result = self.run_command(['user', 'apikey', '123456', '--remove']) |
| 414 | + self.assert_no_fail(result) |
| 415 | + |
| 416 | + def test_refresh_api_authentication_key(self): |
| 417 | + result = self.run_command(['user', 'apikey', '123456', '--refresh']) |
| 418 | + self.assert_no_fail(result) |
0 commit comments