Skip to content
Snippets Groups Projects
Commit c04ba60a authored by lass's avatar lass
Browse files

Merge branch 'GREG-350-uit-idconfig' into 'master'

Greg 350 uit idconfig

See merge request !400
parents c492e1b9 89388fc4
No related branches found
No related tags found
1 merge request!400Greg 350 uit idconfig
Pipeline #190325 passed
...@@ -119,10 +119,7 @@ class Person(BaseModel): ...@@ -119,10 +119,7 @@ class Person(BaseModel):
@staticmethod @staticmethod
def get_verified_identities_query(): def get_verified_identities_query():
return Q( return Q(
identities__type__in=[ identities__type__in=settings.ALLOWED_VERIFIED_ID_TYPES,
Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER,
Identity.IdentityType.PASSPORT_NUMBER,
],
identities__verified_at__isnull=False, identities__verified_at__isnull=False,
identities__verified_at__lte=timezone.now(), identities__verified_at__lte=timezone.now(),
) )
...@@ -155,10 +152,7 @@ class Person(BaseModel): ...@@ -155,10 +152,7 @@ class Person(BaseModel):
""" """
return ( return (
self.identities.filter( self.identities.filter(
type__in=[ type__in=settings.ALLOWED_VERIFIED_ID_TYPES,
Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER,
Identity.IdentityType.PASSPORT_NUMBER,
],
verified_at__isnull=False, verified_at__isnull=False,
verified_at__lte=timezone.now(), verified_at__lte=timezone.now(),
).count() ).count()
......
...@@ -3,6 +3,7 @@ from functools import partial ...@@ -3,6 +3,7 @@ from functools import partial
import pytest import pytest
from django.utils import timezone from django.utils import timezone
from django.test import override_settings
from greg.models import ( from greg.models import (
Consent, Consent,
...@@ -80,6 +81,22 @@ def unverified_passport() -> Identity: ...@@ -80,6 +81,22 @@ def unverified_passport() -> Identity:
return Identity(type=Identity.IdentityType.PASSPORT_NUMBER) return Identity(type=Identity.IdentityType.PASSPORT_NUMBER)
@pytest.fixture
def migration_id() -> Identity:
return Identity(
type=Identity.IdentityType.MIGRATION_ID,
verified_at=_a_year_ago,
)
@pytest.fixture
def national_id_card() -> Identity:
return Identity(
type=Identity.IdentityType.NATIONAL_ID_CARD_NUMBER,
verified_at=_a_year_ago,
)
@pytest.fixture @pytest.fixture
def future_identity() -> Identity: def future_identity() -> Identity:
return Identity( return Identity(
...@@ -180,6 +197,32 @@ def test_is_verified_mixed_verified_and_unverified_identities( ...@@ -180,6 +197,32 @@ def test_is_verified_mixed_verified_and_unverified_identities(
assert person.is_verified assert person.is_verified
@pytest.mark.django_db
def test_is_verified_extra_id_types(
person,
person_foo,
person_bar,
national_id_card,
verified_national_id_number,
migration_id,
):
person.identities.add(migration_id, bulk=False)
person_foo.identities.add(national_id_card, bulk=False)
person_bar.identities.add(verified_national_id_number, bulk=False)
with override_settings(
ALLOWED_VERIFIED_ID_TYPES=[
"migration_id",
"national_id_card_number",
]
):
assert person.is_verified
assert person_foo.is_verified
assert not person_bar.is_verified
assert not person.is_verified
assert not person_foo.is_verified
assert person_bar.is_verified
@pytest.mark.django_db @pytest.mark.django_db
def test_is_verified_in_future(person, future_identity): def test_is_verified_in_future(person, future_identity):
person.identities.add(future_identity, bulk=False) person.identities.add(future_identity, bulk=False)
......
...@@ -356,3 +356,6 @@ IGA_CLIENT = { ...@@ -356,3 +356,6 @@ IGA_CLIENT = {
} }
ALLOW_SO_NUMBERS = False ALLOW_SO_NUMBERS = False
# Which id-types need to be verified for a guest to appear under "Confirmed guests"
ALLOWED_VERIFIED_ID_TYPES = ["norwegian_national_id_number", "passport_number"]
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