Skip to content

Commit

Permalink
feat: improve the value of "active" in endpoint output to always cont…
Browse files Browse the repository at this point in the history
…ain True or False
  • Loading branch information
pieterlukasse committed Nov 7, 2024
1 parent 95d1544 commit 7bda74a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion fence/resources/user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def get_user_info(current_session, username):
"phone_number": user.phone_number,
"email": user.email,
"is_admin": user.is_admin,
"active": user.active,
"active": False
if user.active is False
else True, # using "**is** False", since falsy None and True should both eval to True
"role": role,
"project_access": dict(user.project_access),
"certificates_uploaded": [],
Expand Down
11 changes: 8 additions & 3 deletions tests/admin/test_admin_users_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,14 @@ def test_soft_delete_user_username(
deactivated user.
"""
username = "test_user_d"
user = db_session.query(User).filter_by(username=username).one()
assert user.username == username
assert user.active is None
r = client.get(
f"/admin/users/{username}",
headers={"Authorization": "Bearer " + encoded_admin_jwt},
)
assert r.status_code == 200
assert r.json["username"] == username
assert r.json["active"] == True

# now soft-delete and assert "active" changed to False:
r = client.delete(
f"/admin/users/{username}/soft",
Expand Down

0 comments on commit 7bda74a

Please sign in to comment.