softmax-cli 0.26.9__tar.gz → 0.26.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {softmax_cli-0.26.9/src/softmax_cli.egg-info → softmax_cli-0.26.10}/PKG-INFO +1 -1
  2. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax/cli.py +7 -1
  3. {softmax_cli-0.26.9 → softmax_cli-0.26.10/src/softmax_cli.egg-info}/PKG-INFO +1 -1
  4. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/tests/test_auth_login.py +57 -0
  5. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/BUILD.bazel +0 -0
  6. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/pyproject.toml +0 -0
  7. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/setup.cfg +0 -0
  8. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax/__init__.py +0 -0
  9. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax/_console.py +0 -0
  10. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax/auth.py +0 -0
  11. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax/cogames.py +0 -0
  12. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax/perform_login.py +0 -0
  13. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax/token_storage.py +0 -0
  14. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax_cli.egg-info/SOURCES.txt +0 -0
  15. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax_cli.egg-info/dependency_links.txt +0 -0
  16. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax_cli.egg-info/entry_points.txt +0 -0
  17. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax_cli.egg-info/requires.txt +0 -0
  18. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/src/softmax_cli.egg-info/top_level.txt +0 -0
  19. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/tests/BUILD.bazel +0 -0
  20. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/tests/test_cli_plugins.py +0 -0
  21. {softmax_cli-0.26.9 → softmax_cli-0.26.10}/tests/test_python_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: softmax-cli
3
- Version: 0.26.9
3
+ Version: 0.26.10
4
4
  Summary: Softmax CLI — authentication and account tools
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.11
@@ -101,7 +101,10 @@ def login_cmd(
101
101
  if user_token is not None:
102
102
  api_server = None if is_default_server else login_server
103
103
  try:
104
- fetch_cogames_whoami(api_server=api_server, token=user_token)
104
+ whoami = fetch_cogames_whoami(api_server=api_server, token=user_token)
105
+ if whoami.subject_type == "anonymous":
106
+ console.print("Saved token is no longer valid. Re-authenticating...", style="yellow")
107
+ user_token = None
105
108
  except httpx.HTTPStatusError as exc:
106
109
  if exc.response.status_code == 401:
107
110
  console.print("Saved token is no longer valid. Re-authenticating...", style="yellow")
@@ -195,6 +198,9 @@ def status_cmd(
195
198
  raise typer.Exit(1)
196
199
 
197
200
  session = fetch_cogames_whoami(api_server=server, token=token)
201
+ if session.subject_type == "anonymous":
202
+ console.print("[red]Token is invalid or expired.[/red] Run [cyan]softmax login[/cyan] to re-authenticate.")
203
+ raise typer.Exit(1)
198
204
  console.print("[green]Authenticated[/green]")
199
205
  console.print(f"user_email: {session.user_email}")
200
206
  console.print(f"subject_type: {session.subject_type}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: softmax-cli
3
- Version: 0.26.9
3
+ Version: 0.26.10
4
4
  Summary: Softmax CLI — authentication and account tools
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.11
@@ -290,3 +290,60 @@ def test_save_token_raises_for_malformed_storage_section(
290
290
  server="https://softmax.com/api",
291
291
  token="abc",
292
292
  )
293
+
294
+
295
+ def test_status_fails_for_anonymous_session(
296
+ monkeypatch: pytest.MonkeyPatch,
297
+ tmp_path,
298
+ ) -> None:
299
+ monkeypatch.setenv("HOME", str(tmp_path))
300
+ save_token(token_kind=TokenKind.COGAMES, server="https://softmax.com/api", token="bad-token")
301
+
302
+ class FakeResponse:
303
+ def raise_for_status(self) -> None:
304
+ return None
305
+
306
+ def json(self) -> dict[str, object]:
307
+ return {
308
+ "user_email": "unknown",
309
+ "is_softmax_team_member": False,
310
+ "is_softmax_admin": False,
311
+ "subject_type": "anonymous",
312
+ "subject_id": None,
313
+ "owner_user_id": None,
314
+ "scopes": [],
315
+ }
316
+
317
+ monkeypatch.setattr("softmax.auth.httpx.get", lambda *args, **kwargs: FakeResponse())
318
+
319
+ result = runner.invoke(app, ["status"])
320
+ assert result.exit_code == 1
321
+ assert "invalid or expired" in result.stdout
322
+
323
+
324
+ def test_login_detects_anonymous_whoami_as_invalid_token(
325
+ monkeypatch: pytest.MonkeyPatch,
326
+ tmp_path,
327
+ ) -> None:
328
+ monkeypatch.setenv("HOME", str(tmp_path))
329
+ save_token(token_kind=TokenKind.COGAMES_USER, server="https://softmax.com/api", token="stale-token")
330
+
331
+ class FakeResponse:
332
+ def raise_for_status(self) -> None:
333
+ return None
334
+
335
+ def json(self) -> dict[str, object]:
336
+ return {
337
+ "user_email": "unknown",
338
+ "is_softmax_team_member": False,
339
+ "is_softmax_admin": False,
340
+ "subject_type": "anonymous",
341
+ "subject_id": None,
342
+ "owner_user_id": None,
343
+ "scopes": [],
344
+ }
345
+
346
+ monkeypatch.setattr("softmax.auth.httpx.get", lambda *args, **kwargs: FakeResponse())
347
+
348
+ result = runner.invoke(app, ["login", "--no-browser"])
349
+ assert "no longer valid" in result.stdout
File without changes
File without changes