mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 15:08:25 -04:00
Revert config changes so it doesn't break local dev builds.
Update tests
This commit is contained in:
@@ -39,9 +39,9 @@ class Config(object):
|
|||||||
ADMIN_CLIENT_SECRET = os.getenv('ADMIN_CLIENT_SECRET')
|
ADMIN_CLIENT_SECRET = os.getenv('ADMIN_CLIENT_SECRET')
|
||||||
|
|
||||||
WTF_CSRF_ENABLED = True
|
WTF_CSRF_ENABLED = True
|
||||||
SECRET_KEY = 'dev-notify-secret-key'
|
SECRET_KEY = 'secret-key'
|
||||||
HTTP_PROTOCOL = 'http'
|
HTTP_PROTOCOL = 'http'
|
||||||
DANGEROUS_SALT = 'dev-notify-salt'
|
DANGEROUS_SALT = 'itsdangeroussalt'
|
||||||
TOKEN_MAX_AGE_SECONDS = 3600
|
TOKEN_MAX_AGE_SECONDS = 3600
|
||||||
|
|
||||||
MAX_CONTENT_LENGTH = 10 * 1024 * 1024 # 10mb
|
MAX_CONTENT_LENGTH = 10 * 1024 * 1024 # 10mb
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from flask import url_for
|
from flask import url_for
|
||||||
|
|
||||||
|
import app
|
||||||
|
|
||||||
|
|
||||||
def test_should_render_forgot_password(app_):
|
def test_should_render_forgot_password(app_):
|
||||||
with app_.test_request_context():
|
with app_.test_request_context():
|
||||||
@@ -12,8 +14,9 @@ def test_should_render_forgot_password(app_):
|
|||||||
def test_should_redirect_to_password_reset_sent_for_valid_email(
|
def test_should_redirect_to_password_reset_sent_for_valid_email(
|
||||||
app_,
|
app_,
|
||||||
api_user_active,
|
api_user_active,
|
||||||
mock_reset_user_password):
|
mocker):
|
||||||
with app_.test_request_context():
|
with app_.test_request_context():
|
||||||
|
mocker.patch('app.user_api_client.send_reset_password_url', return_value=None)
|
||||||
response = app_.test_client().post(
|
response = app_.test_client().post(
|
||||||
url_for('.forgot_password'),
|
url_for('.forgot_password'),
|
||||||
data={'email_address': api_user_active.email_address})
|
data={'email_address': api_user_active.email_address})
|
||||||
@@ -21,4 +24,4 @@ def test_should_redirect_to_password_reset_sent_for_valid_email(
|
|||||||
assert (
|
assert (
|
||||||
'You have been sent an email containing a link'
|
'You have been sent an email containing a link'
|
||||||
' to reset your password.') in response.get_data(as_text=True)
|
' to reset your password.') in response.get_data(as_text=True)
|
||||||
mock_reset_user_password.assert_called_once_with(api_user_active.email_address)
|
app.user_api_client.send_reset_password_url.assert_called_once_with(api_user_active.email_address)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from flask import url_for
|
from flask import url_for
|
||||||
|
from tests.conftest import SERVICE_ONE_ID
|
||||||
|
|
||||||
|
|
||||||
def test_should_render_two_factor_page(app_,
|
def test_should_render_two_factor_page(app_,
|
||||||
@@ -31,11 +32,10 @@ def test_should_login_user_and_redirect_to_service_dashboard(app_,
|
|||||||
'email': api_user_active.email_address}
|
'email': api_user_active.email_address}
|
||||||
response = client.post(url_for('main.two_factor'),
|
response = client.post(url_for('main.two_factor'),
|
||||||
data={'sms_code': '12345'})
|
data={'sms_code': '12345'})
|
||||||
|
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert response.location == url_for(
|
assert response.location == url_for(
|
||||||
'main.service_dashboard',
|
'main.service_dashboard',
|
||||||
service_id="596364a0-858e-42c8-9062-a8fe822260eb",
|
service_id=SERVICE_ONE_ID,
|
||||||
_external=True
|
_external=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -125,11 +125,10 @@ def test_two_factor_should_set_password_when_new_password_exists_in_session(app_
|
|||||||
|
|
||||||
response = client.post(url_for('main.two_factor'),
|
response = client.post(url_for('main.two_factor'),
|
||||||
data={'sms_code': '12345'})
|
data={'sms_code': '12345'})
|
||||||
|
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert response.location == url_for(
|
assert response.location == url_for(
|
||||||
'main.service_dashboard',
|
'main.service_dashboard',
|
||||||
service_id="596364a0-858e-42c8-9062-a8fe822260eb",
|
service_id=SERVICE_ONE_ID,
|
||||||
_external=True
|
_external=True
|
||||||
)
|
)
|
||||||
api_user_active.password = 'changedpassword'
|
api_user_active.password = 'changedpassword'
|
||||||
|
|||||||
@@ -90,17 +90,20 @@ def mock_update_service(mocker):
|
|||||||
'app.notifications_api_client.update_service', side_effect=_update)
|
'app.notifications_api_client.update_service', side_effect=_update)
|
||||||
|
|
||||||
|
|
||||||
|
SERVICE_ONE_ID = "596364a0-858e-42c8-9062-a8fe822260eb"
|
||||||
|
SERVICE_TWO_ID = "147ad62a-2951-4fa1-9ca0-093cd1a52c52"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_get_services(mocker, user=None):
|
def mock_get_services(mocker, user=None):
|
||||||
if user is None:
|
if user is None:
|
||||||
user = api_user_active()
|
user = api_user_active()
|
||||||
|
|
||||||
def _create(user_id=None):
|
def _create(user_id=None):
|
||||||
import uuid
|
|
||||||
service_one = service_json(
|
service_one = service_json(
|
||||||
"596364a0-858e-42c8-9062-a8fe822260eb", "service_one", [user.id], 1000, True, False)
|
SERVICE_ONE_ID, "service_one", [user.id], 1000, True, False)
|
||||||
service_two = service_json(
|
service_two = service_json(
|
||||||
"147ad62a-2951-4fa1-9ca0-093cd1a52c52", "service_two", [user.id], 1000, True, False)
|
SERVICE_TWO_ID, "service_two", [user.id], 1000, True, False)
|
||||||
return {'data': [service_one, service_two]}
|
return {'data': [service_one, service_two]}
|
||||||
|
|
||||||
return mocker.patch(
|
return mocker.patch(
|
||||||
@@ -113,9 +116,8 @@ def mock_get_services_with_one_service(mocker, user=None):
|
|||||||
user = api_user_active()
|
user = api_user_active()
|
||||||
|
|
||||||
def _create(user_id=None):
|
def _create(user_id=None):
|
||||||
import uuid
|
|
||||||
return {'data': [service_json(
|
return {'data': [service_json(
|
||||||
"596364a0-858e-42c8-9062-a8fe822260eb", "service_one", [user.id], 1000, True, False
|
SERVICE_ONE_ID, "service_one", [user.id], 1000, True, False
|
||||||
)]}
|
)]}
|
||||||
|
|
||||||
return mocker.patch(
|
return mocker.patch(
|
||||||
@@ -669,8 +671,3 @@ def mock_add_user_to_service(mocker, service_one, api_user_active):
|
|||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_set_user_permissions(mocker):
|
def mock_set_user_permissions(mocker):
|
||||||
return mocker.patch('app.user_api_client.set_user_permissions', return_value=None)
|
return mocker.patch('app.user_api_client.set_user_permissions', return_value=None)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
|
||||||
def mock_reset_user_password(mocker):
|
|
||||||
return mocker.patch('app.user_api_client.send_reset_password_url', return_value=None)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user