mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-30 11:19:44 -04:00
Look in organisation for whitelisted domains
At the moment we have to update a YAML file and deploy the change to get a new domain whitelisted. We already have a thing for adding new domains – the organisation stuff. This commit extends the validation to look in the `domains` table on the API if it can’t find anything in the YAML whitelist. This has the advantage of: - not having to deploy code to whitelist a new domain - forcing us to create new organisations as they come along, so that users’ services automatically get allocated to the organisation once their domain is whitelisted
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from itertools import chain
|
||||
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
@@ -8,6 +10,12 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
def get_organisations(self):
|
||||
return self.get(url='/organisations')
|
||||
|
||||
def get_domains(self):
|
||||
return set(chain.from_iterable(
|
||||
organisation['domains']
|
||||
for organisation in self.get_organisations()
|
||||
))
|
||||
|
||||
def get_organisation(self, org_id):
|
||||
return self.get(url='/organisations/{}'.format(org_id))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user