mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Add a method to guess organisation from a domain
We need this in the admin app while we still have pages that: - talk about the data sharing and financial agreement - but aren’t within a service (so can’t look at the service’s organisation) This is a get, but it deliberately won’t work if you pass it an email address, in order not to put personally identifying information in our logs.
This commit is contained in:
@@ -85,6 +85,41 @@ def test_get_organisation_by_id_returns_domains(admin_request, notify_db_session
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('domain, expected_status', (
|
||||
('foo.gov.uk', 200),
|
||||
('bar.gov.uk', 200),
|
||||
('oof.gov.uk', 404),
|
||||
pytest.param(
|
||||
'rab.gov.uk', 200,
|
||||
marks=pytest.mark.xfail(raises=AssertionError),
|
||||
),
|
||||
(None, 400),
|
||||
('personally.identifying.information@example.com', 400),
|
||||
))
|
||||
def test_get_organisation_by_domain(
|
||||
admin_request,
|
||||
notify_db_session,
|
||||
domain,
|
||||
expected_status
|
||||
):
|
||||
org = create_organisation()
|
||||
other_org = create_organisation('Other organisation')
|
||||
create_domain('foo.gov.uk', org.id)
|
||||
create_domain('bar.gov.uk', org.id)
|
||||
create_domain('rab.gov.uk', other_org.id)
|
||||
|
||||
response = admin_request.get(
|
||||
'organisation.get_organisation_by_domain',
|
||||
_expected_status=expected_status,
|
||||
domain=domain,
|
||||
)
|
||||
|
||||
if expected_status == 200:
|
||||
assert response['id'] == str(org.id)
|
||||
else:
|
||||
assert response['result'] == 'error'
|
||||
|
||||
|
||||
def test_post_create_organisation(admin_request, notify_db_session):
|
||||
data = {
|
||||
'name': 'test organisation',
|
||||
|
||||
Reference in New Issue
Block a user