Skip to content

Commit

Permalink
test: can't launch NSC test assert 404 instead of 403 (#9197)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasBlaskey authored Apr 18, 2024
1 parent 4b1c937 commit 5f312ed
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions e2e_tests/tests/cluster/test_rbac_ntsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,9 @@ def can_access_logs(sess: api.Session, ntsc_id: str) -> bool:
assert "access denied" in fe.value.message
# user 1 should be able to launch tensorboards but not NSCs in workspace 0.
only_tensorboard_can_launch(creds[1], workspaces[0].id, typ, experiment_id)
# tensorboard requires workspace access so returns workspace not found if
# the user does not have access to the workspace.
if typ == api.NTSC_Kind.tensorboard:
with pytest.raises(errors.NotFoundException):
api_utils.launch_ntsc(creds[1], workspaces[1].id, typ, experiment_id)
else:
with pytest.raises(errors.ForbiddenException):
api_utils.launch_ntsc(creds[1], workspaces[1].id, typ, experiment_id)
# Don't leak workspace information to a user without access.
with pytest.raises(errors.NotFoundException):
api_utils.launch_ntsc(creds[1], workspaces[1].id, typ, experiment_id)

# user 2
assert not can_access_logs(
Expand All @@ -211,12 +206,8 @@ def can_access_logs(sess: api.Session, ntsc_id: str) -> bool:
# user 2 should not be able to set priority or know it exists.
api_utils.set_prio_ntsc(creds[2], typ, created_id, 1)
assert e.value.status_code == 404, f"user 2 should not be able to set priority {typ}"
if typ == api.NTSC_Kind.tensorboard:
with pytest.raises(errors.NotFoundException):
api_utils.launch_ntsc(creds[2], workspaces[0].id, typ, experiment_id)
else:
with pytest.raises(errors.ForbiddenException):
api_utils.launch_ntsc(creds[2], workspaces[0].id, typ, experiment_id)
with pytest.raises(errors.NotFoundException):
api_utils.launch_ntsc(creds[2], workspaces[0].id, typ, experiment_id)
# user 2 has view access to workspace 1 so gets forbidden instead of not found.
with pytest.raises(errors.ForbiddenException):
api_utils.launch_ntsc(creds[2], workspaces[1].id, typ, experiment_id)
Expand Down

0 comments on commit 5f312ed

Please sign in to comment.