mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-01 14:41:25 -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
|
||||
import app
|
||||
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_,
|
||||
@@ -104,8 +105,9 @@ def test_should_return_form_errors_with_duplicate_service_name_regardless_of_cas
|
||||
assert not mock_create_service.called
|
||||
|
||||
|
||||
def test_non_whitelist_user_cannot_add_service(app_, nonwhitelist_user, mocker, client):
|
||||
client.login(nonwhitelist_user, mocker)
|
||||
assert not user_in_whitelist(nonwhitelist_user.email_address)
|
||||
def test_non_whitelist_user_cannot_add_service(app_, mocker, client, fake_uuid):
|
||||
non_whitelist_user = create_active_user(fake_uuid, 'someuser@notonwhitelist.com')
|
||||
client.login(non_whitelist_user, mocker)
|
||||
assert not user_in_whitelist(non_whitelist_user.email_address)
|
||||
response = client.get(url_for('main.add_service'))
|
||||
assert response.status_code == 403
|
||||
|
||||
@@ -504,12 +504,12 @@ def nonwhitelist_user(fake_uuid):
|
||||
|
||||
|
||||
@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
|
||||
user_data = {'id': fake_uuid,
|
||||
'name': 'Test User',
|
||||
'password': 'somepassword',
|
||||
'email_address': 'test@user.gov.uk',
|
||||
'email_address': email_address,
|
||||
'mobile_number': '07700 900762',
|
||||
'state': 'active',
|
||||
'failed_login_count': 0,
|
||||
|
||||
Reference in New Issue
Block a user