Skip to content

enterprise/endpoints/connectors/fleet: fix exception when host has no policies - #24355

Merged
BeryJu merged 2 commits into
mainfrom
enterprise/endpoints/connectors/fleet/fix-null-policies
Jul 25, 2026
Merged

BeryJu merged 2 commits into
mainfrom
enterprise/endpoints/connectors/fleet/fix-null-policies

Conversation

@BeryJu

@BeryJu BeryJu commented Jul 24, 2026

Copy link
Copy Markdown
Member

No description provided.

@BeryJu
BeryJu requested a review from a team as a code owner July 24, 2026 14:20
@BeryJu BeryJu added the backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5 label Jul 24, 2026
@netlify

netlify Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit ded8f08
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6a64a7ab62396b00085fbc10
😎 Deploy Preview https://deploy-preview-24355--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit ded8f08
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a64a7ab056b18000824d824
😎 Deploy Preview https://deploy-preview-24355--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3887 1 3886 1
View the top 1 failed test(s) by shortest run time
authentik.stages.authenticator_validate.tests.test_throttling.ValidateStageThrottlingFlowTests::test_bad_code_then_correct_code_is_still_blocked
Stack Traces | 3.75s run time
self = <unittest.case._Outcome object at 0x7f6470760210>
test_case = <authentik.stages.authenticator_validate.tests.test_throttling.ValidateStageThrottlingFlowTests testMethod=test_bad_code_then_correct_code_is_still_blocked>
subTest = False

    @contextlib.contextmanager
    def testPartExecutor(self, test_case, subTest=False):
        old_success = self.success
        self.success = True
        try:
>           yield

.../hostedtoolcache/Python/3.14.6.............../x64/lib/python3.14/unittest/case.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_throttling.ValidateStageThrottlingFlowTests testMethod=test_bad_code_then_correct_code_is_still_blocked>
result = <TestCaseFunction test_bad_code_then_correct_code_is_still_blocked>

    def run(self, result=None):
        if result is None:
            result = self.defaultTestResult()
            startTestRun = getattr(result, 'startTestRun', None)
            stopTestRun = getattr(result, 'stopTestRun', None)
            if startTestRun is not None:
                startTestRun()
        else:
            stopTestRun = None
    
        result.startTest(self)
        try:
            testMethod = getattr(self, self._testMethodName)
            if (getattr(self.__class__, "__unittest_skip__", False) or
                getattr(testMethod, "__unittest_skip__", False)):
                # If the class or method was skipped.
                skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
                            or getattr(testMethod, '__unittest_skip_why__', ''))
                _addSkip(result, self, skip_why)
                return result
    
            expecting_failure = (
                getattr(self, "__unittest_expecting_failure__", False) or
                getattr(testMethod, "__unittest_expecting_failure__", False)
            )
            outcome = _Outcome(result)
            start_time = time.perf_counter()
            try:
                self._outcome = outcome
    
                with outcome.testPartExecutor(self):
                    self._callSetUp()
                if outcome.success:
                    outcome.expecting_failure = expecting_failure
                    with outcome.testPartExecutor(self):
>                       self._callTestMethod(testMethod)

.../hostedtoolcache/Python/3.14.6.............../x64/lib/python3.14/unittest/case.py:669: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_throttling.ValidateStageThrottlingFlowTests testMethod=test_bad_code_then_correct_code_is_still_blocked>
method = <bound method ValidateStageThrottlingFlowTests.test_bad_code_then_correct_code_is_still_blocked of <authentik.stages.a...te.tests.test_throttling.ValidateStageThrottlingFlowTests testMethod=test_bad_code_then_correct_code_is_still_blocked>>

    def _callTestMethod(self, method):
>       result = method()
                 ^^^^^^^^

.../hostedtoolcache/Python/3.14.6.............../x64/lib/python3.14/unittest/case.py:615: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_throttling.ValidateStageThrottlingFlowTests testMethod=test_bad_code_then_correct_code_is_still_blocked>

    def test_bad_code_then_correct_code_is_still_blocked(self):
        """After a bad code over HTTP, a subsequent correct code is still rejected
        because the lockout persists in the database."""
        device = EmailDevice.objects.create(
            user=self.user,
            confirmed=True,
            stage=self.email_stage,
            email="[email protected]",
        )
        self._identify()
        self._select_email(device)
        # Server generated and stored the token - grab it from DB.
        device.refresh_from_db()
        token = device.token
        # First attempt: bad code - must increment the DB counter.
        self.client.post(
            reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
            {"component": "ak-stage-authenticator-validate", "code": "000000"},
        )
        device.refresh_from_db()
        self.assertEqual(device.throttling_failure_count, 1)
        self.assertEqual(device.token, token)
        # Second attempt with the correct token - still blocked.
        response = self.client.post(
            reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}),
            {"component": "ak-stage-authenticator-validate", "code": token},
        )
>       self.assertStageResponse(
            response,
            flow=self.flow,
            component="ak-stage-authenticator-validate",
        )

.../authenticator_validate/tests/test_throttling.py:238: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_throttling.ValidateStageThrottlingFlowTests testMethod=test_bad_code_then_correct_code_is_still_blocked>
response = <HttpChallengeResponse status_code=200, "application/json">
flow = <Flow: Flow d0WXZ6eh3y (d0wxz6eh3y)>, user = None
kwargs = {'component': 'ak-stage-authenticator-validate'}

    def assertStageResponse(
        self,
        response: HttpResponse,
        flow: Flow | None = None,
        user: User | None = None,
        **kwargs,
    ) -> dict[str, Any]:
        """Assert various attributes of a stage response"""
        self.assertEqual(response.status_code, 200)
        raw_response = loads(response.content.decode())
        self.assertIsNotNone(raw_response["component"])
        if flow:
>           self.assertIn("flow_info", raw_response)

.../flows/tests/__init__.py:34: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_throttling.ValidateStageThrottlingFlowTests testMethod=test_bad_code_then_correct_code_is_still_blocked>
member = 'flow_info'
container = {'component': 'xak-flow-redirect', 'to': '/', 'final_redirect': True}
msg = None

    def assertIn(self, member, container, msg=None):
        """Just like self.assertTrue(a in b), but with a nicer default message."""
        if member not in container:
            standardMsg = '%s not found in %s' % (safe_repr(member),
                                                  safe_repr(container))
>           self.fail(self._formatMessage(msg, standardMsg))

.../hostedtoolcache/Python/3.14.6.............../x64/lib/python3.14/unittest/case.py:1192: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_throttling.ValidateStageThrottlingFlowTests testMethod=test_bad_code_then_correct_code_is_still_blocked>
msg = "'flow_info' not found in {'component': 'xak-flow-redirect', 'to': '/', 'final_redirect': True}"

    def fail(self, msg=None):
        """Fail immediately, with the given message."""
>       raise self.failureException(msg)
E       AssertionError: 'flow_info' not found in {'component': 'xak-flow-redirect', 'to': '/', 'final_redirect': True}

.../hostedtoolcache/Python/3.14.6.............../x64/lib/python3.14/unittest/case.py:750: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@BeryJu
BeryJu merged commit d3cc08d into main Jul 25, 2026
115 of 119 checks passed
@BeryJu
BeryJu deleted the enterprise/endpoints/connectors/fleet/fix-null-policies branch July 25, 2026 13:57
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.5 created: #24366

BeryJu added a commit that referenced this pull request Jul 25, 2026
… policies (cherry-pick #24355 to version-2026.5) (#24366)

enterprise/endpoints/connectors/fleet: fix exception when host has no policies (#24355)

Co-authored-by: Jens L. <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant