Skip to content

Commit 092f407

Browse files
committed
Warn on login command when deploy token is set
1 parent b3c1452 commit 092f407

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/fastapi_cloud_cli/commands/login.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ def login() -> Any:
9393

9494
return
9595

96+
if identity.deploy_token is not None:
97+
with get_rich_toolkit() as toolkit:
98+
toolkit.print(
99+
(
100+
"You have [bold blue]FASTAPI_CLOUD_TOKEN[/] environment variable set.\n"
101+
+ "This token will take precedence over the user token for "
102+
+ "[blue]`fastapi deploy`[/] command."
103+
),
104+
tag="Warning",
105+
)
106+
96107
with get_rich_toolkit() as toolkit, APIClient() as client:
97108
toolkit.print_title("Login to FastAPI Cloud", tag="FastAPI")
98109

tests/test_cli_login.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ def test_full_login_with_deploy_token_set(
116116
assert result.exit_code == 0
117117
assert mock_open.called
118118
assert mock_open.call_args.args == ("http://test.com",)
119+
120+
# Verify the warning message is shown
121+
assert "You have FASTAPI_CLOUD_TOKEN environment variable set." in result.output
122+
assert "This token will take precedence over the user token" in result.output
123+
119124
assert "Now you are logged in!" in result.output
120125

121126
# Verify auth file was created with correct content

0 commit comments

Comments
 (0)