diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9767d7e..29073e3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1 @@ -## Bug Fixes -- Custom `base_image` values are now explicitly rejected with an error rather than silently ignored, providing clearer feedback when unsupported configuration options are supplied. - -## Other Changes -- Updated CLI documentation to remove references to non-existent commands and add documentation for previously undocumented ones. \ No newline at end of file +Add improvements/clarity to user facing CLI output. \ No newline at end of file diff --git a/dispatch_cli/auth_login.py b/dispatch_cli/auth_login.py index 9b67ad4..886a7e9 100644 --- a/dispatch_cli/auth_login.py +++ b/dispatch_cli/auth_login.py @@ -363,7 +363,7 @@ def _fetch_organizations(self, access_token: str) -> list[AuthOrganization]: def _select_organization(self, organizations: list[AuthOrganization]) -> str: choices = [ questionary.Choice( - title=f"{organization.display_name} ({organization.id})", + title=organization.display_name, value=organization.id, ) for organization in organizations diff --git a/dispatch_cli/main.py b/dispatch_cli/main.py index 27bac32..fa013fc 100644 --- a/dispatch_cli/main.py +++ b/dispatch_cli/main.py @@ -112,10 +112,8 @@ def login( logger.success("Logged in with browser auth") if session.user_email: logger.info(f"User: {session.user_email}") - if session.org_display_name and session.org_id: - logger.info(f"Organization: {session.org_display_name} ({session.org_id})") - elif session.org_id: - logger.info(f"Organization: {session.org_id}") + if session.org_display_name: + logger.info(f"Organization: {session.org_display_name}") @app.command() @@ -169,12 +167,8 @@ def whoami(): if credential.user_email: logger.info(f"User: {credential.user_email}") - if credential.org_display_name and credential.org_id: - logger.info( - f"Organization: {credential.org_display_name} ({credential.org_id})" - ) - elif credential.org_id: - logger.info(f"Organization: {credential.org_id}") + if credential.org_display_name: + logger.info(f"Organization: {credential.org_display_name}") try: session = default_auth_session_store().load() diff --git a/pyproject.toml b/pyproject.toml index 82e4008..0c2093b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "dispatch-cli" -version = "0.9.12" +version = "0.9.13" description = "" authors = [ {name = "Diamond Bishop", email = "diamond.bishop@datadoghq.com"}, diff --git a/tests/test_auth_commands.py b/tests/test_auth_commands.py index d90a55a..32b3aa8 100644 --- a/tests/test_auth_commands.py +++ b/tests/test_auth_commands.py @@ -43,6 +43,8 @@ def test_login_runs_oauth_flow_and_persists_session(self, runner): assert stored is not None assert stored.user_email == "user@example.com" assert "Logged in with browser auth" in result.output + assert "Organization: Example Org" in result.output + assert "org_123" not in result.output def test_login_surfaces_oauth_flow_failure(self, runner): login_flow = Mock() @@ -170,7 +172,8 @@ def test_whoami_shows_oauth_identity(self, runner): assert result.exit_code == 0 assert "Auth mode: oauth" in result.output assert "User: user@example.com" in result.output - assert "Organization: Example Org (org_123)" in result.output + assert "Organization: Example Org" in result.output + assert "org_123" not in result.output def test_whoami_shows_api_key_mode(self, runner): provider = StaticCredentialProvider( diff --git a/tests/test_auth_login.py b/tests/test_auth_login.py index 83447f3..23bf593 100644 --- a/tests/test_auth_login.py +++ b/tests/test_auth_login.py @@ -267,6 +267,34 @@ def test_prompts_for_org_when_multiple_orgs_are_available(self): assert session.org_id == "org_456" flow._select_organization.assert_called_once() + def test_org_prompt_choices_hide_auth0_ids(self): + flow = BrowserLoginFlow( + AuthClientConfig( + domain="tenant.auth0.com", + client_id="client_123", + audience="aud", + ) + ) + + with patch("dispatch_cli.auth_login.questionary.select") as select: + select.return_value.ask.return_value = "org_456" + + selected = flow._select_organization( + [ + AuthOrganization( + id="org_123", name="first", display_name="First Org" + ), + AuthOrganization( + id="org_456", name="chosen", display_name="Chosen Org" + ), + ] + ) + + assert selected == "org_456" + choices = select.call_args.kwargs["choices"] + assert [choice.title for choice in choices] == ["First Org", "Chosen Org"] + assert [choice.value for choice in choices] == ["org_123", "org_456"] + def test_raises_when_user_has_no_organizations(self): flow = BrowserLoginFlow( AuthClientConfig( diff --git a/uv.lock b/uv.lock index 3751799..2b6f7db 100644 --- a/uv.lock +++ b/uv.lock @@ -565,7 +565,7 @@ wheels = [ [[package]] name = "dispatch-cli" -version = "0.9.12" +version = "0.9.13" source = { editable = "." } dependencies = [ { name = "aiohttp" },