remove mock_has_permissions from logged_in_client

mock_has_permissions blindly returns True - this is useful for the
decorators on most endpoints checking if the user has permission to
access endpoints about the provided service, but is not useful when
it returns true to such checks as "if user is platform admin, show
secret stuff", despite the logged in user being
"active_user_with_permissions" rather than a platform admin.

So remove this, and add "logged_in_platform_admin_client" for when we
want to explicitly check platform admin functionality.

This has the advantage of the actual permissions code being checked
in tests, so the test environment is more consistent with the real
world.

Several tests will have to change now though - active_user_with_perms
has permissions for service_one, so most tests should now call
client.get(url_for(..., service_id=service_one['id']) or they'll 403
This commit is contained in:
Leo Hemsted
2017-02-13 15:05:41 +00:00
parent af1befe248
commit 61cbdac09d

View File

@@ -1366,12 +1366,23 @@ def logged_in_client(
mocker,
service_one,
mock_login,
mock_has_permissions
):
client.login(active_user_with_permissions, mocker, service_one)
yield client
@pytest.fixture(scope='function')
def logged_in_platform_admin_client(
client,
platform_admin_user,
mocker,
service_one,
mock_login,
):
client.login(platform_admin_user, mocker, service_one)
yield client
@pytest.fixture
def os_environ():
"""