-
Notifications
You must be signed in to change notification settings - Fork 3
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
Ops 3111/update system admin role #3117
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e43d990
refactor: update admin user role to SYSTEM_OWNER role in BE
johndeange 7110304
test: update BE unit tests and test data
johndeange b954820
test: edit FE e2e to allow system owner login
johndeange 8a7a694
test: add system owner role to initial data set
johndeange d825fed
refactor: change to is_system_owner
johndeange d4209a6
test: remove unused function
johndeange de86689
feat: use labels instead of role names
johndeange 95daf5a
Merge branch 'main' into OPS-3111/update-system-admin-role
johndeange 09eb1f4
test: fix fe unit tests
johndeange c1755ab
Merge branch 'main' into OPS-3111/update-system-admin-role
johndeange e22db28
Merge branch 'main' into OPS-3111/update-system-admin-role
johndeange a44a639
Merge branch 'main' into OPS-3111/update-system-admin-role
johndeange File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
INSERT INTO ops.division (id, name, abbreviation, created_on, updated_on) VALUES (1, 'Child Care', 'CC', current_timestamp, current_timestamp); | ||
INSERT INTO ops.division (id, name, abbreviation, created_on, updated_on) VALUES (2, 'Division of Economic Independence', 'DEI', current_timestamp, current_timestamp); | ||
INSERT INTO ops.division (id, name, abbreviation, created_on, updated_on) VALUES (3, 'Office of the Director', 'OD', current_timestamp, current_timestamp); | ||
INSERT INTO ops.division (id, name, abbreviation, created_on, updated_on) VALUES (4, 'Division of Child and Family Development', 'DFCD', current_timestamp, current_timestamp); | ||
INSERT INTO ops.division (id, name, abbreviation, created_on, updated_on) VALUES (4, 'Division of Child and Family Development', 'DCFD', current_timestamp, current_timestamp); | ||
INSERT INTO ops.division (id, name, abbreviation, created_on, updated_on) VALUES (5, 'Division of Family Strengthening', 'DFS', current_timestamp, current_timestamp); | ||
INSERT INTO ops.division (id, name, abbreviation, created_on, updated_on) VALUES (6, 'Division of Data and Improvement', 'DDI', current_timestamp, current_timestamp); | ||
INSERT INTO ops.division (id, name, abbreviation, created_on, updated_on) VALUES (7, 'Non-OPRE Division', 'OTHER', current_timestamp, current_timestamp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (1, 'admin', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,DELETE_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,GET_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,PUT_USER,POST_USER,PATCH_USER,GET_USERS,GET_HISTORY,GET_WORKFLOW,PUT_WORKFLOW,PATCH_WORKFLOW,POST_WORKFLOW,GET_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW,PATCH_CHANGE_REQUEST_REVIEW,POST_CHANGE_REQUEST_REVIEW}', current_timestamp, current_timestamp, 1, null, 0); | ||
INSERT INTO ops.role_version (id, name, permissions, created_by, updated_by, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (1, 'SYSTEM_OWNER', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,DELETE_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,DELETE_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,POST_CAN,PATCH_CAN,PUT_CAN,DELETE_CAN,GET_DIVISION,PUT_DIVISION,PATCH_DIVISION,POST_DIVISION,DELETE_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,PUT_PORTFOLIO,PATCH_PORTFOLIO,POST_PORTFOLIO,DELETE_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,PUT_USER,PATCH_USER,GET_HISTORY,GET_WORKFLOW,PUT_WORKFLOW,PATCH_WORKFLOW,POST_WORKFLOW,GET_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW,PATCH_CHANGE_REQUEST_REVIEW,POST_CHANGE_REQUEST_REVIEW,GET_UPLOAD_DOCUMENT,POST_UPLOAD_DOCUMENT,PATCH_UPLOAD_DOCUMENT}', current_timestamp, current_timestamp, 1, null, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same point as 003-role.sql about uppercase-lowercase inconsistency for role name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above |
||
INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (2, 'user', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,GET_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,GET_USERS,GET_HISTORY,GET_WORKFLOW,GET_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW}', current_timestamp, current_timestamp, 1, null, 0); | ||
INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (3, 'unassigned', '{GET_USER,POST_USER,PUT_USER,PATCH_USER}', current_timestamp, current_timestamp, 1, null, 0); | ||
INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (4, 'division-director', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,GET_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,GET_USERS,GET_HISTORY,GET_WORKFLOW,PUT_WORKFLOW,PATCH_WORKFLOW,POST_WORKFLOW,GET_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW,PATCH_CHANGE_REQUEST_REVIEW,POST_CHANGE_REQUEST_REVIEW}', current_timestamp, current_timestamp, 1, null, 0); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
@pytest.fixture() | ||
def db_with_active_user_session(loaded_db, test_user): | ||
user = loaded_db.execute(select(User).where(User.email == "admin[email protected]")).scalars().one_or_none() | ||
user = loaded_db.execute(select(User).where(User.email == "user[email protected]")).scalars().one_or_none() | ||
active_user_session_1 = UserSession( | ||
user_id=user.id, | ||
is_active=True, | ||
|
@@ -63,7 +63,7 @@ def db_with_active_user_session(loaded_db, test_user): | |
|
||
@pytest.fixture() | ||
def db_with_inactive_user_session(loaded_db, test_user): | ||
user = loaded_db.execute(select(User).where(User.email == "admin[email protected]")).scalars().one_or_none() | ||
user = loaded_db.execute(select(User).where(User.email == "user[email protected]")).scalars().one_or_none() | ||
active_user_session_1 = UserSession( | ||
user_id=user.id, | ||
is_active=False, | ||
|
@@ -118,10 +118,10 @@ def db_with_inactive_user_session(loaded_db, test_user): | |
def test_login_with_no_active_session(client, loaded_db, mocker): | ||
# setup mocks | ||
m2 = mocker.patch("ops_api.ops.auth.service._get_token_and_user_data_from_internal_auth") | ||
user = loaded_db.execute(select(User).where(User.email == "admin[email protected]")).scalars().one_or_none() | ||
user = loaded_db.execute(select(User).where(User.email == "user[email protected]")).scalars().one_or_none() | ||
m2.return_value = ("blah", "blah", user) | ||
|
||
res = client.post("/auth/login/", json={"provider": "fakeauth", "code": "admin_user"}) | ||
res = client.post("/auth/login/", json={"provider": "fakeauth", "code": "basic_user"}) | ||
assert res.status_code == 200 | ||
|
||
stmt = select(UserSession).where(UserSession.user_id == user.id) | ||
|
@@ -145,13 +145,13 @@ def test_login_with_active_session(client, db_with_active_user_session, mocker): | |
m1.return_value = False | ||
m2 = mocker.patch("ops_api.ops.auth.service._get_token_and_user_data_from_internal_auth") | ||
user = ( | ||
db_with_active_user_session.execute(select(User).where(User.email == "admin[email protected]")) | ||
db_with_active_user_session.execute(select(User).where(User.email == "user[email protected]")) | ||
.scalars() | ||
.one_or_none() | ||
) # noqa | ||
m2.return_value = ("blah", "blah", user) | ||
|
||
res = client.post("/auth/login/", json={"provider": "fakeauth", "code": "admin_user"}) | ||
res = client.post("/auth/login/", json={"provider": "fakeauth", "code": "basic_user"}) | ||
assert res.status_code == 200 | ||
|
||
stmt = select(UserSession).where(UserSession.user_id == user.id).order_by(UserSession.created_on.desc()) | ||
|
@@ -172,13 +172,13 @@ def test_login_with_inactive_session(client, db_with_inactive_user_session, mock | |
# setup mocks | ||
m2 = mocker.patch("ops_api.ops.auth.service._get_token_and_user_data_from_internal_auth") | ||
user = ( | ||
db_with_inactive_user_session.execute(select(User).where(User.email == "admin[email protected]")) | ||
db_with_inactive_user_session.execute(select(User).where(User.email == "user[email protected]")) | ||
.scalars() | ||
.one_or_none() | ||
) # noqa | ||
m2.return_value = ("blah", "blah", user) | ||
|
||
res = client.post("/auth/login/", json={"provider": "fakeauth", "code": "admin_user"}) | ||
res = client.post("/auth/login/", json={"provider": "fakeauth", "code": "basic_user"}) | ||
assert res.status_code == 200 | ||
|
||
stmt = select(UserSession).where(UserSession.user_id == user.id).order_by(UserSession.created_on.desc()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
@pytest.fixture() | ||
def db_with_active_user_session(loaded_db, test_user): | ||
user = loaded_db.execute(select(User).where(User.email == "admin[email protected]")).scalars().one_or_none() | ||
user = loaded_db.execute(select(User).where(User.email == "user[email protected]")).scalars().one_or_none() | ||
active_user_session_1 = UserSession( | ||
user_id=user.id, | ||
is_active=True, | ||
|
@@ -63,12 +63,12 @@ def db_with_active_user_session(loaded_db, test_user): | |
|
||
|
||
@pytest.mark.usefixtures("app_ctx") | ||
def test_logout(app, client, db_with_active_user_session, mocker): | ||
def test_logout(app, client, db_with_active_user_session): | ||
jwt = create_oauth_jwt( | ||
"fakeauth", | ||
app.config, | ||
payload={ | ||
"sub": "00000000-0000-1111-a111-000000000018", | ||
"sub": "00000000-0000-1111-a111-000000000019", | ||
"iat": datetime.datetime.utcnow(), | ||
"exp": datetime.datetime.utcnow() + datetime.timedelta(days=1), | ||
"iss": app.config["AUTHLIB_OAUTH_CLIENTS"]["fakeauth"]["client_id"], | ||
|
@@ -80,10 +80,10 @@ def test_logout(app, client, db_with_active_user_session, mocker): | |
|
||
res = client.post("/auth/logout/", headers={"Authorization": f"Bearer {jwt.decode('utf-8')}"}) | ||
assert res.status_code == 200 | ||
assert res.json["message"] == "User: admin[email protected] Logged out" | ||
assert res.json["message"] == "User: user[email protected] Logged out" | ||
|
||
user = ( | ||
db_with_active_user_session.execute(select(User).where(User.email == "admin[email protected]")) | ||
db_with_active_user_session.execute(select(User).where(User.email == "user[email protected]")) | ||
.scalars() | ||
.one_or_none() | ||
) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All our other roles are lowercase. Should we make the other roles upper case or should we make this one lowercase for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are currently a mix of upper and lowercase - I think they should be upper case. This PR updates the first of the roles - the other roles that are currently lowercase would be made uppercase in future PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! I'll give an approval.