Skip to content

Commit

Permalink
YDA-5664: fix delete API call that had no effect
Browse files Browse the repository at this point in the history
Also adjust integration tests to verify effect of calls to delete
API endpoint.
  • Loading branch information
stsnel committed Apr 17, 2024
1 parent b35552d commit 046de1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions yoda_eus/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def delete_user() -> Response:
if len(UserZone.query.filter_by(user_id=user.id).all()) == 0:
User.query.filter_by(username=content['username']).delete()

db.session.commit()

# Return result
response = {"status": "ok", "message": "User {} deleted from zone {}.".format(content["username"],
content["userzone"])}
Expand Down
6 changes: 6 additions & 0 deletions yoda_eus/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def test_add_and_remove_user_once(self, test_client):
assert response1.status_code == 201
response2 = c.post('/api/user/delete', json=rm_params, headers=auth_headers)
assert response2.status_code == 204
# This delete call is to verify that the user is really gone
response3 = c.post('/api/user/delete', json=rm_params, headers=auth_headers)
assert response3.status_code == 404

def test_add_and_remove_user_twice(self, test_client):
auth_headers = {'X-Yoda-External-User-Secret': 'dummy_api_secret'}
Expand All @@ -87,6 +90,9 @@ def test_add_and_remove_user_twice(self, test_client):
assert response3.status_code == 204
response4 = c.post('/api/user/delete', json=rm2_params, headers=auth_headers)
assert response4.status_code == 204
# This delete call is to verify that the user is really gone
response5 = c.post('/api/user/delete', json=rm2_params, headers=auth_headers)
assert response5.status_code == 404

def test_forgot_password_show_form(self, test_client):
with test_client as c:
Expand Down

0 comments on commit 046de1a

Please sign in to comment.