-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3117 from HHS/OPS-3111/update-system-admin-role
Ops 3111/update system admin role
- Loading branch information
Showing
52 changed files
with
181 additions
and
163 deletions.
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
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.