Skip to content
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

fix: #805 fix audit event type for remove user role access #857

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions server/backend/api/app/routers/router_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@router.get("", response_model=List[schemas.FamApplication], status_code=200)
def get_applications(
response: Response,
# response: Response,
db: Session = Depends(database.get_db),
access_roles: dict = Depends(jwt_validation.get_access_roles)
):
Expand All @@ -24,8 +24,15 @@ def get_applications(
"""
LOGGER.debug(f"running router ... {db}")
query_data = crud_application.get_applications_by_granted_apps(db, access_roles)
if len(query_data) == 0:
response.status_code = 204

# from fastapi v0.79.0, setting status_code to 204, 304, or any code below 200 (1xx) will remove the body from the response
# so when return response with status code 204, response will have no content return to user
# if we want to use status code 204 for empty case, we might want to apply to other methods as well
# and it will impact some test cases, casue the response cannot be conver to json in empty case

# if len(query_data) == 0:
# response.status_code = 204

MCatherine1994 marked this conversation as resolved.
Show resolved Hide resolved
return query_data


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def delete_user_role_assignment(

audit_event_log = AuditEventLog(
request=request,
event_type=AuditEventType.CREATE_USER_ROLE_ACCESS,
event_type=AuditEventType.REMOVE_USER_ROLE_ACCESS,
event_outcome=AuditEventOutcome.SUCCESS
)

Expand Down
1 change: 1 addition & 0 deletions server/backend/api/app/utils/audit_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class AuditEventType(str, Enum):
CREATE_USER_ROLE_ACCESS = "Grant User Role(S) Access"
REMOVE_USER_ROLE_ACCESS = "Remove User Role(S) Access"


class AuditEventOutcome(str, Enum):
Expand Down
3 changes: 2 additions & 1 deletion server/backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
boto3==1.28.24
botocore==1.31.24
fastapi==0.78.0
httpx==0.24.1
MCatherine1994 marked this conversation as resolved.
Show resolved Hide resolved
uvicorn[standard]==0.23.2
sqlmodel==0.0.8
email-validator==2.0.0.post2
Expand All @@ -9,4 +10,4 @@ psycopg2-binary==2.9.7
mangum==0.17.0
python-jose==3.3.0
cryptography==41.0.3
authlib==1.2.1
authlib==1.2.1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_get_application_success(

response = test_client_fixture_unit.get(f"{endPoint}", headers=headers(token))

assert response.status_code == 204
assert response.status_code == 200
data = response.json()
assert data == []

Expand Down
Loading