mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-06 00:48:46 -04:00
Look at service’s organisation on agreement page
Usually the service’s organisation and the user’s current organisation will be the same. But this won’t be the case when: - someone with a non-government email address is looking at the page - someone from our team, as a platform admin user, is looking at the page (it will show Cabinet Office instead) This commit fixes these problems by explicitly looking at the service’s organisation. We couldn’t do this previously because when this page wasn’t service-specific `current_service` was not guaranteed to be set.
This commit is contained in:
@@ -4,7 +4,11 @@ from io import BytesIO
|
||||
import pytest
|
||||
from flask import url_for
|
||||
|
||||
from tests.conftest import SERVICE_ONE_ID, mock_get_organisation_by_domain
|
||||
from tests.conftest import (
|
||||
SERVICE_ONE_ID,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_service_organisation,
|
||||
)
|
||||
|
||||
|
||||
class _MockS3Object():
|
||||
@@ -16,16 +20,18 @@ class _MockS3Object():
|
||||
return {'Body': BytesIO(self.data)}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('endpoint, extra_args, link_selector, expected_back_links', [
|
||||
@pytest.mark.parametrize('endpoint, extra_args, organisation_mock, link_selector, expected_back_links', [
|
||||
(
|
||||
'main.agreement',
|
||||
{},
|
||||
mock_get_organisation_by_domain,
|
||||
'main .column-two-thirds a',
|
||||
[]
|
||||
),
|
||||
(
|
||||
'main.service_agreement',
|
||||
{'service_id': SERVICE_ONE_ID},
|
||||
mock_get_service_organisation,
|
||||
'main .column-five-sixths a',
|
||||
[
|
||||
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID)
|
||||
@@ -66,10 +72,11 @@ def test_show_agreement_page(
|
||||
expected_links,
|
||||
endpoint,
|
||||
extra_args,
|
||||
organisation_mock,
|
||||
link_selector,
|
||||
expected_back_links,
|
||||
):
|
||||
mock_get_organisation_by_domain(
|
||||
organisation_mock(
|
||||
mocker,
|
||||
crown=crown,
|
||||
agreement_signed=agreement_signed,
|
||||
|
||||
Reference in New Issue
Block a user