Skip to content

Commit

Permalink
Fix for #1674
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Feb 4, 2025
1 parent 38eeb23 commit 48a106b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/scim/user_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from server.scim import EXTERNAL_ID_POST_FIX
from server.scim.schema_template import \
SCIM_SCHEMA_CORE_USER, SCIM_SCHEMA_SRAM_USER, SCIM_API_MESSAGES
from server.tools import dt_now
from server.tools import dt_now, inactivity


def replace_none_values(d: dict):
Expand Down Expand Up @@ -36,7 +36,7 @@ def _meta_info(user: User):

def inactive_days(date_at):
delta = dt_now().date() - date_at.date()
return delta.days
return inactivity(delta.days)


def create_user_template(user: User):
Expand Down
6 changes: 5 additions & 1 deletion server/test/scim/test_user_template.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import uuid
from unittest import TestCase

Expand All @@ -10,9 +11,12 @@ class TestUserTemplate(TestCase):

def test_find_user_by_id_template(self):
now = dt_now()
days = 365 * 2
last_login_date = now - datetime.timedelta(days=(days), weeks=3)
user = User(external_id=uuid.uuid4(), name="John Doe", email="jdoe@domain.com", updated_at=now, created_at=now,
last_login_date=now)
last_login_date=last_login_date)
result = find_user_by_id_template(user)

self.assertEqual(result["displayName"], user.name)
self.assertEqual(result["name"]["familyName"], "")
self.assertEqual(days, result["urn:mace:surf.nl:sram:scim:extension:User"]["sramInactiveDays"])

0 comments on commit 48a106b

Please sign in to comment.