From f10bd432b3d1db00049655a2bf5fecd58ba09db0 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 14 Jun 2021 19:54:31 +0200 Subject: [PATCH] policies/reputation: fix race condition in tests Signed-off-by: Jens Langhammer --- authentik/policies/reputation/models.py | 11 +++++++---- authentik/policies/reputation/tests.py | 2 ++ website/docs/integrations/services/nextcloud/index.md | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/authentik/policies/reputation/models.py b/authentik/policies/reputation/models.py index ac29fd8cd..305a33832 100644 --- a/authentik/policies/reputation/models.py +++ b/authentik/policies/reputation/models.py @@ -36,14 +36,17 @@ class ReputationPolicy(Policy): passing = True if self.check_ip: score = cache.get_or_set(CACHE_KEY_IP_PREFIX + remote_ip, 0) - LOGGER.debug("Score for IP", ip=remote_ip, score=score) passing = passing and score <= self.threshold + LOGGER.debug("Score for IP", ip=remote_ip, score=score, passing=passing) if self.check_username: score = cache.get_or_set(CACHE_KEY_USER_PREFIX + request.user.username, 0) - LOGGER.debug( - "Score for Username", username=request.user.username, score=score - ) passing = passing and score <= self.threshold + LOGGER.debug( + "Score for Username", + username=request.user.username, + score=score, + passing=passing, + ) return PolicyResult(passing) class Meta: diff --git a/authentik/policies/reputation/tests.py b/authentik/policies/reputation/tests.py index ebd606bb3..9e944c584 100644 --- a/authentik/policies/reputation/tests.py +++ b/authentik/policies/reputation/tests.py @@ -4,6 +4,7 @@ from django.core.cache import cache from django.test import RequestFactory, TestCase from authentik.core.models import User +from authentik.lib.utils.http import DEFAULT_IP from authentik.policies.reputation.models import ( CACHE_KEY_IP_PREFIX, CACHE_KEY_USER_PREFIX, @@ -24,6 +25,7 @@ class TestReputationPolicy(TestCase): self.test_ip = "127.0.0.1" self.test_username = "test" cache.delete(CACHE_KEY_IP_PREFIX + self.test_ip) + cache.delete(CACHE_KEY_IP_PREFIX + DEFAULT_IP) cache.delete(CACHE_KEY_USER_PREFIX + self.test_username) # We need a user for the one-to-one in userreputation self.user = User.objects.create(username=self.test_username) diff --git a/website/docs/integrations/services/nextcloud/index.md b/website/docs/integrations/services/nextcloud/index.md index ccc99b4bc..571123d92 100644 --- a/website/docs/integrations/services/nextcloud/index.md +++ b/website/docs/integrations/services/nextcloud/index.md @@ -38,7 +38,7 @@ You can of course use a custom signing certificate, and adjust durations. ## NextCloud -In NextCloud, ensure that the `SSO & SAML Authentication` extension is installed. Navigate to `Settings`, then `SSO & SAML Authentication`. +In NextCloud, ensure that the `SSO & SAML Authentication` app is installed. Navigate to `Settings`, then `SSO & SAML Authentication`. Set the following values: