mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-05 14:11:41 -04:00
Go straight into org if no trial mode services
You might still belong to some services, but because they’re live they’re all in your organisation.
This commit is contained in:
@@ -16,7 +16,12 @@ def user_with_orgs_and_services(num_orgs, num_services, platform_admin=False):
|
||||
@pytest.mark.parametrize('num_orgs,num_services,endpoint,endpoint_kwargs', [
|
||||
(0, 0, '.choose_account', {}),
|
||||
(0, 2, '.choose_account', {}),
|
||||
(1, 1, '.choose_account', {}),
|
||||
|
||||
# assumption is that live service is part of user’s organisation
|
||||
# – real users shouldn’t have orphaned live services, or access to
|
||||
# services belonging to other organisations
|
||||
(1, 1, '.organisation_dashboard', {'org_id': 'org1'}),
|
||||
|
||||
(2, 0, '.choose_account', {}),
|
||||
(0, 1, '.service_dashboard', {'service_id': 'service1'}),
|
||||
(1, 0, '.organisation_dashboard', {'org_id': 'org1'}),
|
||||
@@ -24,6 +29,7 @@ def user_with_orgs_and_services(num_orgs, num_services, platform_admin=False):
|
||||
def test_show_accounts_or_dashboard_redirects_to_choose_account_or_service_dashboard(
|
||||
client,
|
||||
mocker,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
num_orgs,
|
||||
num_services,
|
||||
endpoint,
|
||||
@@ -72,6 +78,7 @@ def test_show_accounts_or_dashboard_redirects_if_org_in_session(client, mocker):
|
||||
def test_show_accounts_or_dashboard_doesnt_redirect_to_service_dashboard_if_user_not_part_of_service_in_session(
|
||||
client,
|
||||
mocker,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_service
|
||||
):
|
||||
client.login(user_with_orgs_and_services(num_orgs=1, num_services=1), mocker=mocker)
|
||||
@@ -82,12 +89,13 @@ def test_show_accounts_or_dashboard_doesnt_redirect_to_service_dashboard_if_user
|
||||
response = client.get(url_for('.show_accounts_or_dashboard'))
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.choose_account', _external=True)
|
||||
assert response.location == url_for('main.organisation_dashboard', org_id='org1', _external=True)
|
||||
|
||||
|
||||
def test_show_accounts_or_dashboard_doesnt_redirect_to_org_dashboard_if_user_not_part_of_org_in_session(
|
||||
client,
|
||||
mocker
|
||||
mocker,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
):
|
||||
client.login(user_with_orgs_and_services(num_orgs=1, num_services=1), mocker=mocker)
|
||||
with client.session_transaction() as session:
|
||||
@@ -97,7 +105,7 @@ def test_show_accounts_or_dashboard_doesnt_redirect_to_org_dashboard_if_user_not
|
||||
response = client.get(url_for('.show_accounts_or_dashboard'))
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.choose_account', _external=True)
|
||||
assert response.location == url_for('main.organisation_dashboard', org_id='org1', _external=True)
|
||||
|
||||
|
||||
def test_show_accounts_or_dashboard_redirects_if_not_logged_in(
|
||||
|
||||
@@ -3355,6 +3355,7 @@ def mock_get_non_empty_organisations_and_services_for_user(mocker, organisation_
|
||||
return [{
|
||||
'name': '{} {}'.format(name, i),
|
||||
'id': SERVICE_TWO_ID,
|
||||
'restricted': False,
|
||||
} for i in range(1, 3)]
|
||||
|
||||
def _get_orgs_and_services(user_id):
|
||||
|
||||
Reference in New Issue
Block a user