mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 18:37:33 -04:00
Refactor creating a non-gov user
This commit is contained in:
@@ -2,6 +2,7 @@ from flask import url_for, session
|
|||||||
from unittest.mock import ANY
|
from unittest.mock import ANY
|
||||||
import app
|
import app
|
||||||
from app.utils import user_in_whitelist
|
from app.utils import user_in_whitelist
|
||||||
|
from tests.conftest import api_user_active as create_active_user
|
||||||
|
|
||||||
|
|
||||||
def test_get_should_render_add_service_template(app_,
|
def test_get_should_render_add_service_template(app_,
|
||||||
@@ -104,8 +105,9 @@ def test_should_return_form_errors_with_duplicate_service_name_regardless_of_cas
|
|||||||
assert not mock_create_service.called
|
assert not mock_create_service.called
|
||||||
|
|
||||||
|
|
||||||
def test_non_whitelist_user_cannot_add_service(app_, nonwhitelist_user, mocker, client):
|
def test_non_whitelist_user_cannot_add_service(app_, mocker, client, fake_uuid):
|
||||||
client.login(nonwhitelist_user, mocker)
|
non_whitelist_user = create_active_user(fake_uuid, 'someuser@notonwhitelist.com')
|
||||||
assert not user_in_whitelist(nonwhitelist_user.email_address)
|
client.login(non_whitelist_user, mocker)
|
||||||
|
assert not user_in_whitelist(non_whitelist_user.email_address)
|
||||||
response = client.get(url_for('main.add_service'))
|
response = client.get(url_for('main.add_service'))
|
||||||
assert response.status_code == 403
|
assert response.status_code == 403
|
||||||
|
|||||||
+2
-2
@@ -504,12 +504,12 @@ def nonwhitelist_user(fake_uuid):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def api_user_active(fake_uuid):
|
def api_user_active(fake_uuid, email_address='test@user.gov.uk'):
|
||||||
from app.notify_client.user_api_client import User
|
from app.notify_client.user_api_client import User
|
||||||
user_data = {'id': fake_uuid,
|
user_data = {'id': fake_uuid,
|
||||||
'name': 'Test User',
|
'name': 'Test User',
|
||||||
'password': 'somepassword',
|
'password': 'somepassword',
|
||||||
'email_address': 'test@user.gov.uk',
|
'email_address': email_address,
|
||||||
'mobile_number': '07700 900762',
|
'mobile_number': '07700 900762',
|
||||||
'state': 'active',
|
'state': 'active',
|
||||||
'failed_login_count': 0,
|
'failed_login_count': 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user