Skip to content
Snippets Groups Projects
Verified Commit dd9b0369 authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Add a toggle for the iga identity check

Since we may not want to enable the identity check, it must be
togglable. This commit adds environment variable
REACT_APP_ENABLE_IGA_CHECK for toggling the check in the frontend, and
django settings variable IGA_CHECK for toggling the check in the
backend.
parent 0a5ec39b
No related branches found
No related tags found
1 merge request!301Add a toggle for the iga identity check
Pipeline #120659 passed
This commit is part of merge request !301. Comments created here will be created in the context of that merge request.
......@@ -35,6 +35,9 @@ export const availableInSearchEnabled: boolean =
export const disableNinVerification: boolean =
env.REACT_APP_DISABLE_NIN_VERIFICATION === 'true'
/* Should iga be checked when verifying identificators? */
export const enableIgaCheck: boolean = env.REACT_APP_ENABLE_IGA_CHECK === 'true'
/* Footer content */
export const responsibleOrganization: string =
env.REACT_APP_RESPONSIBLE_ORGANIZATION as string
......
......@@ -6,7 +6,7 @@ import { fetchJsonOpts, submitJsonOpts } from 'utils'
import CheckIcon from '@mui/icons-material/Check'
import { Trans, useTranslation } from 'react-i18next'
import { TableCell } from 'components/table'
import { appInst, disableNinVerification } from 'appConfig'
import { appInst, disableNinVerification, enableIgaCheck } from 'appConfig'
interface IdentityLineProps {
text: string
......@@ -85,7 +85,7 @@ const IdentityLine = ({
}
useEffect(() => {
if (confirmOpen && identityCheckText === null) {
if (enableIgaCheck && confirmOpen && identityCheckText === null) {
fetchIdentityCheckText(identity.id)
}
}, [confirmOpen])
......
......@@ -343,6 +343,8 @@ DEFAULT_IDENTITY_SOURCE = "greg"
DISABLE_NIN_VERIFY = False
# Iga client config used by identity checking view when checking iga
# Take care to also set the check parameter to True if you use this
IGA_CHECK = False
IGA_CLIENT = {
"url": "http://example.com/cerebrum/",
"headers": {"X-Gravitee-Api-Key": "<KEY>"},
......
......@@ -41,6 +41,8 @@ class IdentityCheckView(APIView):
permission_classes = [IsAuthenticated, IsSponsor]
def get(self, request, *args, **kwargs):
if not settings.IGA_CHECK:
return Response({"match": None})
client = get_iga_client(settings.INSTANCE_NAME, settings.IGA_CLIENT)
try:
ident: Identity = Identity.objects.get(pk=kwargs["id"])
......@@ -50,4 +52,4 @@ class IdentityCheckView(APIView):
status=status.HTTP_404_NOT_FOUND,
)
match = client.extid_search(ident.type, ident.value)
return Response({"match": match.dict() if match else match})
return Response({"match": match.dict() if match else None})
import pytest
from django.conf import settings
from rest_framework.reverse import reverse
from greg.models import Identity
......@@ -37,6 +38,7 @@ def test_identity_check_nonexisting_fnr(
requests_mock, client, log_in, user_sponsor, person_foo
):
"""Verify that identitycheck endpoint checks iga when queried"""
settings.IGA_CHECK = True
requests_mock.get(
"http://example.com/cerebrum/v1/search/persons/external-ids?id_type=NO_BIRTHNO&external_id=12345612345",
json={"external_ids": []},
......@@ -52,6 +54,7 @@ def test_identity_check_existing_fnr(
requests_mock, client, log_in, user_sponsor, person_foo
):
"""Verify that identitycheck endpoint checks iga when queried"""
settings.IGA_CHECK = True
requests_mock.get(
"http://example.com/cerebrum/v1/search/persons/external-ids?id_type=NO_BIRTHNO&external_id=12345612345",
json={
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment