diff --git a/cumulusci/cli/org.py b/cumulusci/cli/org.py index 4dc5ed3e6f..c8ee718e6f 100644 --- a/cumulusci/cli/org.py +++ b/cumulusci/cli/org.py @@ -330,6 +330,7 @@ def org_info(runtime, org_name, print_json): "instance_url", "instance_name", "is_sandbox", + "namespace", "namespaced", "org_id", "org_type", diff --git a/cumulusci/cli/service.py b/cumulusci/cli/service.py index f9a6208c4d..e85280f2e3 100644 --- a/cumulusci/cli/service.py +++ b/cumulusci/cli/service.py @@ -204,7 +204,7 @@ def callback(*args, **kwargs): set_global_default = kwargs.pop("default", False) serv_conf = dict( - (k, v) for k, v in list(kwargs.items()) if v is not None + (k, v.strip()) for k, v in list(kwargs.items()) if v is not None ) # remove None values # A service can define a callable to validate the service config @@ -305,7 +305,7 @@ def service_update( for attr in attributes: attr_name, attr_value = attr if attr_name in service_config.config: - service_config.config[attr_name] = attr_value + service_config.config[attr_name] = attr_value.strip() attributes_were_updated = True else: available_attributes = ", ".join(service_attributes) @@ -324,7 +324,7 @@ def service_update( ) if user_input != "": attributes_were_updated = True - service_config.config[attr] = user_input + service_config.config[attr] = user_input.strip() if attributes_were_updated: runtime.keychain.set_service(service_type, service_name, service_config) diff --git a/cumulusci/cli/tests/test_org.py b/cumulusci/cli/tests/test_org.py index 01692e22a8..007e82249d 100644 --- a/cumulusci/cli/tests/test_org.py +++ b/cumulusci/cli/tests/test_org.py @@ -540,6 +540,7 @@ def test_org_info(self): "default": True, "password": None, "connected_app": "built-in", + "namespace": "test", } org_config.expires = date.today() org_config.latest_api_version = "42.0" @@ -557,6 +558,7 @@ def test_org_info(self): ["\x1b[1mconnected_app\x1b[0m", "built-in"], ["\x1b[1mdays\x1b[0m", "1"], ["\x1b[1mdefault\x1b[0m", "True"], + ["\x1b[1mnamespace\x1b[0m", "test"], ["\x1b[1mpassword\x1b[0m", "None"], ], ) diff --git a/cumulusci/cli/tests/test_service.py b/cumulusci/cli/tests/test_service.py index 774f11f532..b8d1502f1f 100644 --- a/cumulusci/cli/tests/test_service.py +++ b/cumulusci/cli/tests/test_service.py @@ -295,6 +295,28 @@ def test_service_connect_validator_failure(): run_cli_command("service", "connect", "test", "test-alias", runtime=runtime) +def test_service_connect_without_whitespaces(): + attr_value = " Sample attr value " + attr_value_without_whitespaces = "Sample attr value" + runtime = BaseCumulusCI( + config={"services": {"test": {"attributes": {"attr": {"required": False}}}}} + ) + + result = run_cli_command( + "service", + "connect", + "test", + "test-alias", + "--attr", + attr_value, + runtime=runtime, + ) + + result = runtime.keychain.get_service("test", "test-alias") + assert attr_value != result.attr + assert attr_value_without_whitespaces == result.attr + + def test_service_update__success(): # Create a new color-picker service type runtime = CliRuntime( @@ -334,6 +356,37 @@ def test_service_update__success(): assert original_color not in result.output +def test_service_update_without_whitespaces(): + # Create a new color-picker service type + runtime = CliRuntime( + config={ + "services": {"color-picker": {"attributes": {"color": {"required": False}}}} + } + ) + # Setup an existing service of type color-picker + original_color = "Turquoise" + runtime.keychain.set_service( + "color-picker", + "foo", + ServiceConfig({"color": original_color}), + ) + # Update the existing service + chosen_color = " Maroon " + chosen_color_without_whitespaces = "Maroon" + result = run_cli_command( + "service", + "update", + "color-picker", + "foo", + input=f"{chosen_color}\n", + runtime=runtime, + ) + # ensure info was written without whitespaces + result = runtime.keychain.get_service("color-picker", "foo") + assert chosen_color != result.color + assert chosen_color_without_whitespaces == result.color + + def test_service_update_headless__success(): # Create a new color-picker service type runtime = CliRuntime(