Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion server/wsi_viewer/desktop_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from .domain import SlideState
from .evidence_contract import load_trusted_signers, parse_evidence, validate_evidence
from .evidence_set_contract import validate_evidence_set
from .identity import is_default_legacy_owner
from .identity import DEFAULT_ORGANIZATION_ID, is_default_legacy_owner
from .models import (
AnalysisRun,
Annotation,
Expand Down Expand Up @@ -683,6 +683,9 @@ def credential_status(
authenticated: DesktopCredential = Depends(credential),
) -> dict[str, Any]:
return {
"organizationId": DEFAULT_ORGANIZATION_ID,
"userId": authenticated.user_id,
"credentialId": authenticated.id,
"deviceName": authenticated.device_name,
"scopes": authenticated.scopes,
"expiresAt": as_utc(authenticated.expires_at).isoformat(),
Expand Down
13 changes: 11 additions & 2 deletions tests/backend/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from wsi_viewer.config import Settings
from wsi_viewer.database import create_schema, session_factory
from wsi_viewer.domain import SlideState
from wsi_viewer.identity import ensure_default_owner_membership
from wsi_viewer.identity import DEFAULT_ORGANIZATION_ID, ensure_default_owner_membership
from wsi_viewer.main import create_app
from wsi_viewer.models import (
AnalysisRun,
Expand Down Expand Up @@ -497,7 +497,16 @@ def test_desktop_pairing_is_short_lived_one_time_and_revocable(tmp_path: Path) -
"persistedSha256": True,
}
]
assert client.get("/api/v1/desktop/credential", headers=authorization).status_code == 200
credential_status = client.get("/api/v1/desktop/credential", headers=authorization)
assert credential_status.status_code == 200
status_body = credential_status.json()
assert status_body["organizationId"] == DEFAULT_ORGANIZATION_ID
with session_factory(client.app.state.settings)() as database:
stored = database.scalar(select(DesktopCredential))
assert stored is not None
assert status_body["userId"] == stored.user_id
assert status_body["credentialId"] == stored.id
assert "accessToken" not in status_body
assert (
client.post("/api/v1/desktop/credential/revoke", headers=authorization).status_code
== 204
Expand Down