|
| 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 | + |
| 14 | +from openstackclient.common import configuration |
| 15 | +from openstackclient.tests import fakes |
| 16 | +from openstackclient.tests import utils |
| 17 | + |
| 18 | + |
| 19 | +class TestConfiguration(utils.TestCommand): |
| 20 | + |
| 21 | + def test_show(self): |
| 22 | + arglist = [] |
| 23 | + verifylist = [('mask', True)] |
| 24 | + cmd = configuration.ShowConfiguration(self.app, None) |
| 25 | + parsed_args = self.check_parser(cmd, arglist, verifylist) |
| 26 | + |
| 27 | + columns, data = cmd.take_action(parsed_args) |
| 28 | + |
| 29 | + collist = ('auth.password', 'auth.token', 'auth.username', |
| 30 | + 'identity_api_version', 'region') |
| 31 | + self.assertEqual(collist, columns) |
| 32 | + datalist = ( |
| 33 | + configuration.REDACTED, |
| 34 | + configuration.REDACTED, |
| 35 | + fakes.USERNAME, |
| 36 | + fakes.VERSION, |
| 37 | + fakes.REGION_NAME, |
| 38 | + ) |
| 39 | + self.assertEqual(datalist, tuple(data)) |
| 40 | + |
| 41 | + def test_show_unmask(self): |
| 42 | + arglist = ['--unmask'] |
| 43 | + verifylist = [('mask', False)] |
| 44 | + cmd = configuration.ShowConfiguration(self.app, None) |
| 45 | + parsed_args = self.check_parser(cmd, arglist, verifylist) |
| 46 | + |
| 47 | + columns, data = cmd.take_action(parsed_args) |
| 48 | + |
| 49 | + collist = ('auth.password', 'auth.token', 'auth.username', |
| 50 | + 'identity_api_version', 'region') |
| 51 | + self.assertEqual(collist, columns) |
| 52 | + datalist = ( |
| 53 | + fakes.PASSWORD, |
| 54 | + fakes.AUTH_TOKEN, |
| 55 | + fakes.USERNAME, |
| 56 | + fakes.VERSION, |
| 57 | + fakes.REGION_NAME, |
| 58 | + ) |
| 59 | + self.assertEqual(datalist, tuple(data)) |
| 60 | + |
| 61 | + def test_show_mask(self): |
| 62 | + arglist = ['--mask'] |
| 63 | + verifylist = [('mask', True)] |
| 64 | + cmd = configuration.ShowConfiguration(self.app, None) |
| 65 | + parsed_args = self.check_parser(cmd, arglist, verifylist) |
| 66 | + |
| 67 | + columns, data = cmd.take_action(parsed_args) |
| 68 | + |
| 69 | + collist = ('auth.password', 'auth.token', 'auth.username', |
| 70 | + 'identity_api_version', 'region') |
| 71 | + self.assertEqual(collist, columns) |
| 72 | + datalist = ( |
| 73 | + configuration.REDACTED, |
| 74 | + configuration.REDACTED, |
| 75 | + fakes.USERNAME, |
| 76 | + fakes.VERSION, |
| 77 | + fakes.REGION_NAME, |
| 78 | + ) |
| 79 | + self.assertEqual(datalist, tuple(data)) |
0 commit comments