mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 14:48:25 -04:00
Add tests to ensure non gov user cannot see, access or create service
This commit is contained in:
@@ -3,7 +3,7 @@ from flask import url_for
|
||||
from bs4 import BeautifulSoup
|
||||
import app
|
||||
from app.notify_client.models import InvitedUser
|
||||
from app.utils import user_in_whitelist
|
||||
from app.utils import is_gov_user
|
||||
from tests.conftest import service_one as create_sample_service
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ def test_should_show_page_for_inviting_user(
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.parametrize('email_address, whitelist_user', [
|
||||
@pytest.mark.parametrize('email_address, gov_user', [
|
||||
('test@example.gov.uk', True),
|
||||
('test@nonwhitelist.com', False)
|
||||
])
|
||||
@@ -141,7 +141,7 @@ def test_invite_user(
|
||||
mocker,
|
||||
sample_invite,
|
||||
email_address,
|
||||
whitelist_user
|
||||
gov_user
|
||||
):
|
||||
service = create_sample_service(active_user_with_permissions)
|
||||
sample_invite['email_address'] = 'test@example.gov.uk'
|
||||
@@ -150,7 +150,7 @@ def test_invite_user(
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user_with_permissions, mocker, service)
|
||||
assert user_in_whitelist(email_address) == whitelist_user
|
||||
assert is_gov_user(email_address) == gov_user
|
||||
mocker.patch('app.invite_api_client.get_invites_for_service', return_value=data)
|
||||
mocker.patch('app.user_api_client.get_users_for_service', return_value=[active_user_with_permissions])
|
||||
mocker.patch('app.invite_api_client.create_invite', return_value=InvitedUser(**sample_invite))
|
||||
|
||||
Reference in New Issue
Block a user