Skip to content

Commit

Permalink
backport permitted role change into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bengerman13 committed Mar 26, 2021
1 parent 644093f commit 39577d9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
4 changes: 2 additions & 2 deletions tests/unit/test_authn.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def test_callback_happy_path(client, simple_org_response, simple_space_response)
text=json.dumps(body),
)
m.get(
"mock://cf/v3/roles?user_guids=test_user&types=space_developer,space_manager",
"mock://cf/v3/roles?user_guids=test_user&types=space_developer,space_manager,space_auditor",
text=simple_space_response,
)
m.get(
"mock://cf/v3/roles?user_guids=test_user&types=org_manager",
"mock://cf/v3/roles?user_guids=test_user&types=organization_manager,organization_auditor",
text=simple_org_response,
)
client.get(f"/cb?code=1234&state={csrf}")
Expand Down
31 changes: 16 additions & 15 deletions tests/unit/test_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def test_gets_spaces():
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=space_developer%2Cspace_manager&user_guids=a-user-guid"
},
"last": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=space_developer%2Cspace_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=space_developer%2Cspace_manager%2Cspace_auditor&user_guids=a-user-guid"
},
"next": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=space_developer%2Cspace_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=space_developer%2Cspace_manager%2Cspace_auditor&user_guids=a-user-guid"
},
"previous": null
},
Expand Down Expand Up @@ -63,14 +63,14 @@ def test_gets_spaces():
"total_results": 2,
"total_pages": 2,
"first": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=space_developer%2Cspace_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=space_developer%2Cspace_manager%2Cspace_auditor&user_guids=a-user-guid"
},
"last": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=space_developer%2Cspace_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=space_developer%2Cspace_manager%2Cspace_auditor&user_guids=a-user-guid"
},
"next": null,
"previous": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=space_developer%2Cspace_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=space_developer%2Cspace_manager%2Cspace_auditor&user_guids=a-user-guid"
}
},
"resources": [
Expand Down Expand Up @@ -110,11 +110,11 @@ def test_gets_spaces():
}
"""
m.get(
"mock://cf/v3/roles?user_guids=a-user-id&types=space_developer,space_manager",
"mock://cf/v3/roles?user_guids=a-user-id&types=space_developer,space_manager,space_auditor",
text=response_1,
)
m.get(
"mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=space_developer%2Cspace_manager&user_guids=a-user-guid",
"mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=space_developer%2Cspace_manager%2Cspace_auditor&user_guids=a-user-guid",
text=response_2,
)
assert sorted(cf.get_spaces_for_user("a-user-id", "a_token")) == sorted(
Expand All @@ -130,13 +130,13 @@ def test_gets_roles():
"total_results": 2,
"total_pages": 2,
"first": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=org_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=organization_manager%2Corganization_auditor&user_guids=a-user-guid"
},
"last": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=org_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=organization_manager%2Corganization_auditor&user_guids=a-user-guid"
},
"next": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=org_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=organization_manager%2Corganization_auditor&user_guids=a-user-guid"
},
"previous": null
},
Expand Down Expand Up @@ -181,14 +181,14 @@ def test_gets_roles():
"total_results": 2,
"total_pages": 2,
"first": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=org_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=organization_manager,organization_auditor&user_guids=a-user-guid"
},
"last": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=org_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=organization_manager,organization_auditor&user_guids=a-user-guid"
},
"next": null,
"previous": {
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=org_manager&user_guids=a-user-guid"
"href": "mock://cf/v3/roles?order_by=%2Bcreated_at&page=1&per_page=1&types=organization_manager,organization_auditor&user_guids=a-user-guid"
}
},
"resources": [
Expand Down Expand Up @@ -228,10 +228,11 @@ def test_gets_roles():
}
"""
m.get(
"mock://cf/v3/roles?user_guids=a-user-id&types=org_manager", text=response_1
"mock://cf/v3/roles?user_guids=a-user-id&types=organization_manager,organization_auditor",
text=response_1,
)
m.get(
"mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=org_manager&user_guids=a-user-guid",
"mock://cf/v3/roles?order_by=%2Bcreated_at&page=2&per_page=1&types=organization_manager,organization_auditor&user_guids=a-user-guid",
text=response_2,
)
assert sorted(cf.get_orgs_for_user("a-user-id", "a_token")) == sorted(
Expand Down
22 changes: 18 additions & 4 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ def test_config_loads(monkeypatch):
assert config.UAA_CLIENT_SECRET == "example"
assert config.SECRET_KEY == "CHANGEME"
assert config.PERMANENT_SESSION_LIFETIME == 120
assert config.PERMITTED_SPACE_ROLES == ["space_developer", "space_manager"]
assert config.PERMITTED_ORG_ROLES == ["org_manager"]
assert config.PERMITTED_SPACE_ROLES == [
"space_developer",
"space_manager",
"space_auditor",
]
assert config.PERMITTED_ORG_ROLES == [
"organization_manager",
"organization_auditor",
]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -73,5 +80,12 @@ def test_prod_config(monkeypatch, kibana_url):
assert config.CF_URL == "https://api.example.com/"
assert config.SECRET_KEY == "changeme"
assert config.PERMANENT_SESSION_LIFETIME == 3600
assert config.PERMITTED_SPACE_ROLES == ["space_developer", "space_manager"]
assert config.PERMITTED_ORG_ROLES == ["org_manager"]
assert config.PERMITTED_SPACE_ROLES == [
"space_developer",
"space_manager",
"space_auditor",
]
assert config.PERMITTED_ORG_ROLES == [
"organization_manager",
"organization_auditor",
]

0 comments on commit 39577d9

Please sign in to comment.