Skip to content

Commit 1b151c2

Browse files
authored
Small tweak for Account-Id or business identifier undefined (bcgov#3605)
1 parent 8c1e07a commit 1b151c2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

auth-api/src/auth_api/services/authorization.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def check_auth(**kwargs):
239239
else:
240240
business_identifier = kwargs.get("business_identifier", None)
241241
org_identifier = kwargs.get("org_id", None) or user_from_context.account_id
242+
auth = None
242243
if business_identifier:
243244
auth = Authorization.get_user_authorizations_for_entity(business_identifier)
244245
elif org_identifier:

auth-api/tests/unit/services/test_authorization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ def test_check_auth(session, monkeypatch): # pylint:disable=unused-argument
258258
("Test OK when STAFF in one_of_roles.", does_not_raise(), {"one_of_roles": {"STAFF"}}, False),
259259
("Test OK when STAFF IS equals_role.", does_not_raise(), {"equals_role": "STAFF"}, False),
260260
(
261-
"Test UnboundLocalError when system_required set to true -- auth variable not set.",
262-
pytest.raises(UnboundLocalError),
261+
"Test (403) when system_required set to true with no org id provided.",
262+
pytest.raises(Forbidden),
263263
{"equals_role": "STAFF", "system_required": True},
264264
False,
265265
),
@@ -405,8 +405,8 @@ def test_check_auth_system_path(
405405
"test_desc,test_expect,additional_kwargs,is_org_member,is_entity_affiliated",
406406
[
407407
(
408-
"Test UnboundLocalError (403) when no role checks provided in kwargs.",
409-
pytest.raises(UnboundLocalError),
408+
"Test (403) when no role checks provided in kwargs.",
409+
pytest.raises(Forbidden),
410410
{},
411411
False,
412412
False,

0 commit comments

Comments
 (0)