mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Merge pull request #63 from alphagov/require_login
Add login_required for all endpoints where it makes sense.
This commit is contained in:
@@ -1,22 +1,37 @@
|
||||
def test_should_return_list_of_all_jobs(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/jobs')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
assert 'Final reminder' in response.get_data(as_text=True)
|
||||
from tests.app.main import create_test_user
|
||||
|
||||
|
||||
def test_should_show_page_for_one_job(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/jobs/job')
|
||||
def test_should_return_list_of_all_jobs(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/jobs')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'dispatch_20151114.csv' in response.get_data(as_text=True)
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
assert response.status_code == 200
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
assert 'Final reminder' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_show_page_for_one_notification(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/jobs/job/notification/3')
|
||||
def test_should_show_page_for_one_job(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/jobs/job')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Text message' in response.get_data(as_text=True)
|
||||
assert '+44 7700 900 522' in response.get_data(as_text=True)
|
||||
assert response.status_code == 200
|
||||
assert 'dispatch_20151114.csv' in response.get_data(as_text=True)
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_show_page_for_one_notification(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/jobs/job/notification/3')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Text message' in response.get_data(as_text=True)
|
||||
assert '+44 7700 900 522' in response.get_data(as_text=True)
|
||||
|
||||
@@ -1,103 +1,165 @@
|
||||
def test_should_show_overview(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/service-settings')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Service settings' in response.get_data(as_text=True)
|
||||
from tests.app.main import create_test_user
|
||||
|
||||
|
||||
def test_should_show_service_name(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/service-settings/name')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Change your service name' in response.get_data(as_text=True)
|
||||
def test_should_show_overview(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings')
|
||||
assert response.status_code == 200
|
||||
assert 'Service settings' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_redirect_after_change_service_name(notifications_admin):
|
||||
response = notifications_admin.test_client().post('/service-settings/request-to-go-live')
|
||||
def test_should_show_service_name(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/name')
|
||||
assert response.status_code == 200
|
||||
assert 'Change your service name' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_redirect_after_change_service_name(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_service_name_confirmation(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/service-settings/name/confirm')
|
||||
def test_should_show_service_name_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/name/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Change your service name' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_redirect_after_service_name_confirmation(notifications_admin):
|
||||
response = notifications_admin.test_client().post('/service-settings/name/confirm')
|
||||
def test_should_redirect_after_service_name_confirmation(notifications_admin, notifications_admin_db,
|
||||
notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/name/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_request_to_go_live(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/service-settings/request-to-go-live')
|
||||
def test_should_show_request_to_go_live(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Request to go live' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_redirect_after_request_to_go_live(notifications_admin):
|
||||
response = notifications_admin.test_client().post('/service-settings/request-to-go-live')
|
||||
def test_should_redirect_after_request_to_go_live(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_status_page(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/service-settings/status')
|
||||
def test_should_show_status_page(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/status')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Turn off all outgoing notifications' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_show_redirect_after_status_change(notifications_admin):
|
||||
response = notifications_admin.test_client().post('/service-settings/status')
|
||||
def test_should_show_redirect_after_status_change(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/status')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings/status/confirm' == response.location
|
||||
|
||||
|
||||
def test_should_show_status_confirmation(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/service-settings/status/confirm')
|
||||
def test_should_show_status_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/status/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Turn off all outgoing notifications' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_redirect_after_status_confirmation(notifications_admin):
|
||||
response = notifications_admin.test_client().post('/service-settings/status/confirm')
|
||||
def test_should_redirect_after_status_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/status/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_delete_page(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/service-settings/delete')
|
||||
def test_should_show_delete_page(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/delete')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Delete this service from Notify' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_show_redirect_after_deleting_service(notifications_admin):
|
||||
response = notifications_admin.test_client().post('/service-settings/delete')
|
||||
def test_should_show_redirect_after_deleting_service(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/delete')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings/delete/confirm' == response.location
|
||||
|
||||
|
||||
def test_should_show_delete_confirmation(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/service-settings/delete/confirm')
|
||||
def test_should_show_delete_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/delete/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Delete this service from Notify' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_redirect_delete_confirmation(notifications_admin):
|
||||
response = notifications_admin.test_client().post('/service-settings/delete/confirm')
|
||||
def test_should_redirect_delete_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/delete/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/dashboard' == response.location
|
||||
|
||||
@@ -1,17 +1,32 @@
|
||||
def test_should_return_list_of_all_templates(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/templates')
|
||||
from tests.app.main import create_test_user
|
||||
|
||||
|
||||
def test_should_return_list_of_all_templates(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/templates')
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_should_show_page_for_one_templates(notifications_admin):
|
||||
response = notifications_admin.test_client().get('/templates/template')
|
||||
def test_should_show_page_for_one_templates(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/templates/template')
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_should_redirect_when_saving_a_template(notifications_admin):
|
||||
response = notifications_admin.test_client().post('/templates/template')
|
||||
def test_should_redirect_when_saving_a_template(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/templates/template')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == 'http://localhost/templates'
|
||||
|
||||
Reference in New Issue
Block a user