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:
Chris Hill-Scott
2019-06-07 13:06:53 +01:00
parent 71dc650db6
commit 1b395c04f3
3 changed files with 14 additions and 5 deletions

View File

@@ -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 users organisation
# real users shouldnt 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(

View File

@@ -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):