-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ops 441 cannot lock yourself #2678
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2fdc4ef
add code to PUT/PATCH /user to prevent user from locking themselves out
johndeange b3d2483
return 400 for some /user exceptions rather than 403 which currently …
johndeange a6dfa27
return 400 for some /user exceptions rather than 403 which currently …
johndeange eca6751
Merge branch 'main' into OPS-441-cannot-lock-yourself
johndeange a4078a9
Merge branch 'main' into OPS-441-cannot-lock-yourself
johndeange File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ def test_patch_user_unauthorized_different_user(client, loaded_db, test_non_admi | |
json={"id": test_user.id, "email": "[email protected]", "first_name": "New First Name"}, | ||
headers={"Authorization": f"Bearer {str(access_token)}"}, | ||
) | ||
assert response.status_code == 403 | ||
assert response.status_code == 400 | ||
|
||
|
||
@pytest.mark.usefixtures("app_ctx") | ||
|
@@ -121,7 +121,7 @@ def test_patch_user_must_be_user_admin_to_change_status(client, test_user, test_ | |
json={"id": test_non_admin_user.id, "status": UserStatus.ACTIVE.name}, | ||
headers={"Authorization": f"Bearer {str(access_token)}"}, | ||
) | ||
assert response.status_code == 403 | ||
assert response.status_code == 400 | ||
|
||
|
||
def test_patch_user_changing_status_deactivates_user_session(auth_client, new_user, loaded_db): | ||
|
@@ -157,3 +157,15 @@ def test_patch_user_changing_status_deactivates_user_session(auth_client, new_us | |
# cleanup | ||
loaded_db.delete(user_session) | ||
loaded_db.commit() | ||
|
||
|
||
@pytest.mark.usefixtures("app_ctx") | ||
def test_patch_user_cannot_deactivate_yourself(auth_client, new_user, loaded_db, test_admin_user): | ||
response = auth_client.patch( | ||
url_for("api.users-item", id=test_admin_user.id), | ||
json={ | ||
"id": test_admin_user.id, | ||
"status": UserStatus.INACTIVE.name, | ||
}, | ||
) | ||
assert response.status_code == 400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ def test_put_user_unauthorized_different_user(client, loaded_db, test_non_admin_ | |
json={"id": test_user.id, "email": "[email protected]", "first_name": "New First Name"}, | ||
headers={"Authorization": f"Bearer {str(access_token)}"}, | ||
) | ||
assert response.status_code == 403 | ||
assert response.status_code == 400 | ||
|
||
|
||
@pytest.mark.usefixtures("app_ctx") | ||
|
@@ -168,7 +168,7 @@ def test_put_user_wrong_user(auth_client, new_user, loaded_db, test_admin_user): | |
url_for("api.users-item", id=new_user.id), | ||
json={"id": 0, "email": "[email protected]"}, | ||
) | ||
assert response.status_code == 403 | ||
assert response.status_code == 400 | ||
|
||
|
||
def test_put_user_must_be_user_admin_to_change_status(client, test_user, test_non_admin_user): | ||
|
@@ -181,7 +181,7 @@ def test_put_user_must_be_user_admin_to_change_status(client, test_user, test_no | |
json={"id": test_non_admin_user.id, "status": UserStatus.ACTIVE.name}, | ||
headers={"Authorization": f"Bearer {str(access_token)}"}, | ||
) | ||
assert response.status_code == 403 | ||
assert response.status_code == 400 | ||
|
||
|
||
def test_put_user_changing_status_deactivates_user_session(auth_client, new_user, loaded_db): | ||
|
@@ -222,3 +222,12 @@ def test_put_user_changing_status_deactivates_user_session(auth_client, new_user | |
# cleanup | ||
loaded_db.delete(user_session) | ||
loaded_db.commit() | ||
|
||
|
||
@pytest.mark.usefixtures("app_ctx") | ||
def test_put_user__cannot_deactivate_yourself(auth_client, new_user, loaded_db, test_admin_user): | ||
response = auth_client.put( | ||
url_for("api.users-item", id=test_admin_user.id), | ||
json={"email": "[email protected]", "status": UserStatus.INACTIVE.name}, | ||
) | ||
assert response.status_code == 400 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there it is!