Skip to content

Commit

Permalink
♻️ Make AC subscription check optional in NRC config check
Browse files Browse the repository at this point in the history
to ensure that this utility can be reused in Open Zaak and Open Notificaties
  • Loading branch information
stevenbal committed Nov 22, 2024
1 parent de4e340 commit a1dddc2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vng_api_common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _test_ac_config() -> list:
return checks


def _test_nrc_config() -> list:
def _test_nrc_config(check_autorisaties_subscription=True) -> list:
if not apps.is_installed("notifications_api_common"):
return []

Expand Down Expand Up @@ -209,14 +209,22 @@ def _test_nrc_config() -> list:
try:
response: requests.Response = nrc_client.get("kanaal")
response.raise_for_status()
except requests.RequestException:
except requests.ConnectionError:
error = True
message = _("Could not connect with NRC")
except requests.HTTPError as exc:
error = True
message = _("Cannot retrieve kanalen: HTTP {status_code}").format(
status_code=exc.response.status_code
)
else:
message = _("Can retrieve kanalen")

checks.append((_("NRC connection and authorizations"), message, not error))

if not check_autorisaties_subscription:
return checks

# check if there's a subscription for AC notifications
has_sub = (
Subscription.objects.filter(channels__contains=["autorisaties"])
Expand Down

0 comments on commit a1dddc2

Please sign in to comment.