agent/authentic2: fix failure when notify_agents is never called (#62480)

This commit is contained in:
Benjamin Dauvergne 2022-03-07 13:14:12 +01:00
parent e1d8af720f
commit c0780646e6
2 changed files with 13 additions and 0 deletions

View File

@ -84,6 +84,8 @@ class ApiProvisionningEngine(provisionning.Provisionning):
super().__init__()
self.service_type = service_type
self.service_url = service_url
self.leftover_audience = []
self.reached_audience = []
def get_http_services_by_url(self):
if self.service_type:

View File

@ -748,6 +748,17 @@ def test_provisionning_api(transactional_db, app_factory, tenant, settings, capl
assert resp.json['err'] == 1
assert resp.json['leftover_audience']
with patch('hobo.agent.authentic2.provisionning.requests.put') as requests_put:
role.slug = '_technical'
role.save()
resp = app.post_json(
signature.sign_url('/api/provision/?orig=%s' % orig, key), {'role_uuid': role.uuid}
)
assert requests_put.call_count == 0
assert resp.json['err'] == 0
assert not resp.json['leftover_audience']
assert not resp.json['reached_audience']
def test_provision_debug(transactional_db, tenant, caplog, settings, tmpdir):
log_path = str(tmpdir / 'debug-provisionning.log')