Skip to content

Commit c2cbcd1

Browse files
committed
Raise UnauthorisedAccessException when not logged in
1 parent 1e54a60 commit c2cbcd1

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/blueapi/client/rest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def _exception(response: requests.Response) -> Exception | None:
104104
code = response.status_code
105105
if code < 400:
106106
return None
107+
elif code == 401 or code == 403:
108+
return UnauthorisedAccessError()
107109
elif code == 404:
108110
return KeyError(str(response.json()))
109111
else:

tests/unit_tests/client/test_rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def rest_with_auth(oidc_config: OIDCConfig, tmp_path) -> BlueapiRestClient:
4040
"code,expected_exception",
4141
[
4242
(404, KeyError),
43-
(401, BlueskyRemoteControlError),
43+
(401, UnauthorisedAccessError),
4444
(450, BlueskyRemoteControlError),
4545
(500, BlueskyRemoteControlError),
4646
],

0 commit comments

Comments
 (0)