Fix get_current_user and auth_is_admin creating their own db session instead of getting from get_session
This commit is contained in:
@@ -117,7 +117,7 @@ def test_auth_is_admin(db_session, admin_user, regular_user):
|
||||
admin_token = create_access_token(data={"sub": admin_user.name})
|
||||
|
||||
# Admin should pass
|
||||
result = auth_is_admin(token=admin_token)
|
||||
result = auth_is_admin(token=admin_token, db=db_session)
|
||||
assert result is True
|
||||
|
||||
# Create token for regular user
|
||||
@@ -125,7 +125,7 @@ def test_auth_is_admin(db_session, admin_user, regular_user):
|
||||
|
||||
# Regular user should fail
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
auth_is_admin(token=user_token)
|
||||
auth_is_admin(token=user_token, db=db_session)
|
||||
assert exc_info.value.status_code == status.HTTP_403_FORBIDDEN
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user