From 61cbdac09ddbce352b0c4dadd37b1a0de4a18697 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Mon, 13 Feb 2017 15:05:41 +0000 Subject: [PATCH] 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 --- tests/conftest.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 53a9ca0b5..9a83fadfe 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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(): """