summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/fakes.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-09-30 12:10:36 +0000
committerGerrit Code Review <review@openstack.org>2022-09-30 12:10:36 +0000
commit5043626c8043f35f6a044f1b0845fcd45eaa8775 (patch)
tree67deb1a3d584ab483be09831607696475e79b82b /openstackclient/tests/unit/fakes.py
parent38dda16639e409654ee45b613ddd29a866781b8e (diff)
parent62c52f5e61c009ad45fa3e8aeb049821d0b228eb (diff)
downloadpython-openstackclient-5043626c8043f35f6a044f1b0845fcd45eaa8775.tar.gz
Merge "config: Also mask non-prefix config"
Diffstat (limited to 'openstackclient/tests/unit/fakes.py')
-rw-r--r--openstackclient/tests/unit/fakes.py40
1 files changed, 18 insertions, 22 deletions
diff --git a/openstackclient/tests/unit/fakes.py b/openstackclient/tests/unit/fakes.py
index 00e0c129..086c2466 100644
--- a/openstackclient/tests/unit/fakes.py
+++ b/openstackclient/tests/unit/fakes.py
@@ -11,7 +11,6 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-#
import json
import sys
@@ -49,21 +48,6 @@ TEST_RESPONSE_DICT_V3.set_project_scope()
TEST_VERSIONS = fixture.DiscoveryList(href=AUTH_URL)
-def to_unicode_dict(catalog_dict):
- """Converts dict to unicode dict
-
- """
- if isinstance(catalog_dict, dict):
- return {to_unicode_dict(key): to_unicode_dict(value)
- for key, value in catalog_dict.items()}
- elif isinstance(catalog_dict, list):
- return [to_unicode_dict(element) for element in catalog_dict]
- elif isinstance(catalog_dict, str):
- return catalog_dict + u""
- else:
- return catalog_dict
-
-
class FakeStdout(object):
def __init__(self):
@@ -142,18 +126,30 @@ class FakeClientManager(object):
self.network_endpoint_enabled = True
self.compute_endpoint_enabled = True
self.volume_endpoint_enabled = True
+ # The source of configuration. This is either 'cloud_config' (a
+ # clouds.yaml file) or 'global_env' ('OS_'-prefixed envvars)
+ self.configuration_type = 'cloud_config'
def get_configuration(self):
- return {
- 'auth': {
- 'username': USERNAME,
- 'password': PASSWORD,
- 'token': AUTH_TOKEN,
- },
+
+ config = {
'region': REGION_NAME,
'identity_api_version': VERSION,
}
+ if self.configuration_type == 'cloud_config':
+ config['auth'] = {
+ 'username': USERNAME,
+ 'password': PASSWORD,
+ 'token': AUTH_TOKEN,
+ }
+ elif self.configuration_type == 'global_env':
+ config['username'] = USERNAME
+ config['password'] = PASSWORD
+ config['token'] = AUTH_TOKEN
+
+ return config
+
def is_network_endpoint_enabled(self):
return self.network_endpoint_enabled