Skip to content

Commit

Permalink
Updating role claims for test scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
VineetBala-AOT committed Jan 18, 2024
1 parent 8767671 commit ec2bd5f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 68 deletions.
2 changes: 0 additions & 2 deletions met-api/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ DATABASE_TEST_PORT=
# This is generated dynamically during test execution; there's no requirement to instantiate the image separately.
KEYCLOAK_TEST_BASE_URL="http://localhost:8081"

JWT_OIDC_TEST_ROLE_CLAIM=realm_access.roles # SSO schema

# Docker database settings
# If unset, uses the same settings as the main database
DATABASE_DOCKER_USERNAME=
Expand Down
1 change: 0 additions & 1 deletion met-api/src/met_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ def __init__(self) -> None:
)
self.KC['BASE_URL'] = os.getenv('KEYCLOAK_TEST_BASE_URL', self.KC['BASE_URL'])
self.KC['REALMNAME'] = os.getenv('KEYCLOAK_TEST_REALMNAME', self.KC['REALMNAME'])
self.JWT['ROLE_CLAIM'] = os.getenv('JWT_OIDC_TEST_ROLE_CLAIM', 'realm_access.roles')

# Propagate exceptions up to the test runner
TESTING = env_truthy('TESTING', default=True)
Expand Down
118 changes: 53 additions & 65 deletions met-api/tests/utilities/factory_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,8 @@ class TestJwtClaims(dict, Enum):
'firstname': fake.first_name(),
'lastname': fake.last_name(),
'preferred_username': fake.user_name(),
'realm_access': {
'roles': [
'client_roles': [
]
}
}

public_user_role = {
Expand All @@ -285,11 +283,9 @@ class TestJwtClaims(dict, Enum):
'preferred_username': fake.user_name(),
'email': fake.email(),
'tenant_id': 1,
'realm_access': {
'roles': [
'public_user'
]
}
'client_roles': [
'public_user'
]
}

met_admin_role = {
Expand All @@ -302,20 +298,18 @@ class TestJwtClaims(dict, Enum):
'tenant_id': 1,
'email': '[email protected]',
'identity_provider': LoginSource.IDIR.value,
'realm_access': {
'roles': [
'staff',
'view_engagement',
'create_survey',
'view_users',
'create_admin_user',
'edit_members',
'toggle_user_status',
'export_to_csv',
'update_user_group',
'create_tenant'
]
}
'client_roles': [
'staff',
'view_engagement',
'create_survey',
'view_users',
'create_admin_user',
'edit_members',
'toggle_user_status',
'export_to_csv',
'update_user_group',
'create_tenant'
]
}

staff_admin_role = {
Expand All @@ -328,34 +322,32 @@ class TestJwtClaims(dict, Enum):
'tenant_id': 1,
'email': '[email protected]',
'identity_provider': LoginSource.IDIR.value,
'realm_access': {
'roles': [
'staff',
'view_engagement',
'create_engagement',
'edit_engagement',
'create_survey',
'view_users',
'view_private_engagements',
'create_admin_user',
'view_all_surveys',
'view_surveys',
'edit_all_surveys',
'edit_survey',
'view_unapproved_comments',
'clone_survey',
'edit_members',
'review_comments',
'review_all_comments',
'view_all_engagements',
'toggle_user_status',
'export_all_to_csv',
'update_user_group',
'export_proponent_comment_sheet',
'export_internal_comment_sheet',
'export_cac_form_to_sheet'
]
}
'client_roles': [
'staff',
'view_engagement',
'create_engagement',
'edit_engagement',
'create_survey',
'view_users',
'view_private_engagements',
'create_admin_user',
'view_all_surveys',
'view_surveys',
'edit_all_surveys',
'edit_survey',
'view_unapproved_comments',
'clone_survey',
'edit_members',
'review_comments',
'review_all_comments',
'view_all_engagements',
'toggle_user_status',
'export_all_to_csv',
'update_user_group',
'export_proponent_comment_sheet',
'export_internal_comment_sheet',
'export_cac_form_to_sheet'
]
}
team_member_role = {
'iss': CONFIG.JWT_OIDC_TEST_ISSUER,
Expand All @@ -367,15 +359,13 @@ class TestJwtClaims(dict, Enum):
'email': '[email protected]',
'identity_provider': LoginSource.IDIR.value,
'tenant_id': 1,
'realm_access': {
'roles': [
'staff',
'view_engagement',
'view_users',
'clone_survey',
'export_proponent_comment_sheet'
]
}
'client_roles': [
'staff',
'view_engagement',
'view_users',
'clone_survey',
'export_proponent_comment_sheet'
]
}

reviewer_role = {
Expand All @@ -388,12 +378,10 @@ class TestJwtClaims(dict, Enum):
'email': '[email protected]',
'identity_provider': LoginSource.IDIR.value,
'tenant_id': 1,
'realm_access': {
'roles': [
'staff',
'view_users',
]
}
'client_roles': [
'staff',
'view_users',
]
}


Expand Down

0 comments on commit ec2bd5f

Please sign in to comment.