|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | +# not use this file except in compliance with the License. You may obtain |
| 3 | +# a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | + |
| 13 | +import json |
| 14 | + |
| 15 | +from openstackclient.tests.functional import base |
| 16 | + |
| 17 | + |
| 18 | +class ArgumentTests(base.TestCase): |
| 19 | + """Functional tests for command line arguments""" |
| 20 | + |
| 21 | + def test_default_auth_type(self): |
| 22 | + cmd_output = json.loads(self.openstack( |
| 23 | + 'configuration show -f json', |
| 24 | + cloud='', |
| 25 | + )) |
| 26 | + self.assertIsNotNone(cmd_output) |
| 27 | + self.assertIn( |
| 28 | + 'auth_type', |
| 29 | + cmd_output.keys(), |
| 30 | + ) |
| 31 | + self.assertEqual( |
| 32 | + 'password', |
| 33 | + cmd_output['auth_type'], |
| 34 | + ) |
| 35 | + |
| 36 | + def test_auth_type_none(self): |
| 37 | + cmd_output = json.loads(self.openstack( |
| 38 | + 'configuration show -f json', |
| 39 | + cloud=None, |
| 40 | + )) |
| 41 | + self.assertIsNotNone(cmd_output) |
| 42 | + self.assertIn( |
| 43 | + 'auth_type', |
| 44 | + cmd_output.keys(), |
| 45 | + ) |
| 46 | + self.assertEqual( |
| 47 | + 'none', |
| 48 | + cmd_output['auth_type'], |
| 49 | + ) |
| 50 | + |
| 51 | + def test_auth_type_token_endpoint_opt(self): |
| 52 | + cmd_output = json.loads(self.openstack( |
| 53 | + 'configuration show -f json --os-auth-type token_endpoint', |
| 54 | + cloud=None, |
| 55 | + )) |
| 56 | + self.assertIsNotNone(cmd_output) |
| 57 | + self.assertIn( |
| 58 | + 'auth_type', |
| 59 | + cmd_output.keys(), |
| 60 | + ) |
| 61 | + self.assertEqual( |
| 62 | + 'token_endpoint', |
| 63 | + cmd_output['auth_type'], |
| 64 | + ) |
| 65 | + |
| 66 | + def test_auth_type_password_opt(self): |
| 67 | + cmd_output = json.loads(self.openstack( |
| 68 | + 'configuration show -f json --os-auth-type password', |
| 69 | + cloud=None, |
| 70 | + )) |
| 71 | + self.assertIsNotNone(cmd_output) |
| 72 | + self.assertIn( |
| 73 | + 'auth_type', |
| 74 | + cmd_output.keys(), |
| 75 | + ) |
| 76 | + self.assertEqual( |
| 77 | + 'password', |
| 78 | + cmd_output['auth_type'], |
| 79 | + ) |
0 commit comments