Skip to content

Refacoring test case for MisdirectedFilter - #51443

Closed
ahus1 wants to merge 1 commit into
keycloak:mainfrom
ahus1:is-51442-test-case-refactoring
Closed

Refacoring test case for MisdirectedFilter#51443
ahus1 wants to merge 1 commit into
keycloak:mainfrom
ahus1:is-51442-test-case-refactoring

Conversation

@ahus1

@ahus1 ahus1 commented Aug 5, 2026

Copy link
Copy Markdown
Member

Closes #51442

@ahus1 ahus1 self-assigned this Aug 5, 2026
Closes keycloak#51442

Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
@ahus1
ahus1 force-pushed the is-51442-test-case-refactoring branch from 7d8f053 to 0ff60bd Compare August 5, 2026 03:48
@ahus1
ahus1 requested a balanced review from Copilot August 5, 2026 07:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves MisdirectedFilter coverage into the regular test suite for easier debugging and faster execution.

Changes:

  • Adds test-framework-based HTTP/2 misdirection coverage.
  • Removes equivalent distribution test code.
  • Documents the filter’s purpose and behavior.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/base/.../MisdirectedRequestTest.java Adds the migrated TLS test.
quarkus/tests/.../HttpDistTest.java Removes the former distribution test.
quarkus/runtime/.../MisdirectedFilter.java Adds class-level JavaDoc.
Suppressed comments (1)

tests/base/src/test/java/org/keycloak/tests/ssl/MisdirectedRequestTest.java:74

  • A hung Vert.x shutdown can add another five-minute delay after the client cleanup timeout, so one failure may hold a test worker for roughly ten minutes. Restore the prior seconds-based bound for automated runs.
            // Timeout set to minutes to allow manual debugging
            vertx.close().toCompletionStage().toCompletableFuture().get(5, TimeUnit.MINUTES);

@ahus1
ahus1 marked this pull request as ready for review August 5, 2026 07:28
@ahus1
ahus1 requested review from a team as code owners August 5, 2026 07:28
@ahus1
ahus1 requested a review from shawkins August 5, 2026 07:29
@ahus1

ahus1 commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

@shawkins - please review when you have the time. Thanks!

@michalvavrik michalvavrik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, for whether we should do this, let's refer to the discussion in the linked issue. My takeaway ATM is to "have embedded mode", which is good enough for me, but I'll watch the discussion.

Comment on lines +26 to +30
* <li>No SNI sent ({@code indicatedServerName()} is null) — happens with health checks
* or non-FQDN connections; rejecting these would break monitoring.</li>
* <li>SNI matches authority — the connection was established for this hostname.
* This also allows health checks that connect with an arbitrary hostname
* not configured in Keycloak.</li>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you want to mention it, but these account for all "backend" requests made directly to the Keycloak instance, not just monitoring.

Comment on lines +31 to +33
* <li>Authority matches a configured Keycloak hostname ({@code hostname} or
* {@code hostname-admin}) — the request is legitimately for this server, even if
* the connection was originally established for a different hostname.</li>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth mentioning here that we aren't yet trying to account for the realm front-end urls - and that 421s may erroneously occur then.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are "realm front-end urls"? It seems that I missed that discussion :D

If I know what they are, I'm happy to add them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each realm can be configured to have its own frontend url -

Click a question mark *?* icon to show the definition of a field such as *Frontend URL*.

The hostname provider looks for it here

.map(r -> r.getAttribute("frontendUrl"))

@ahus1

ahus1 commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

@shawkins - given the discussion in the parent issue, I'd like to know if you want to keep the test case in the original place, or move it. I'll leave it you and the cloud native dist team to decide.

@shawkins

shawkins commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@shawkins - given the discussion in the parent issue, I'd like to know if you want to keep the test case in the original place, or move it. I'll leave it you and the cloud native dist team to decide.

I'd just like to capture additional issues like adding embedded mode for quarkus integration tests, or moving additional tests to the new test suite, to capture more of the motivation behind doing this.

After that, it doesn't really matter to me where the test lives.

@ahus1

ahus1 commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

I'd just like to capture additional issues like adding embedded mode for quarkus integration tests, or moving additional tests to the new test suite, to capture more of the motivation behind doing this.

@shawkins - can you please make this more actionable for me? Should I keep the changes about the test, or should I remove it?

@ahus1

ahus1 commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Each realm can be configured to have its own frontend url

I wasn't aware of this concept as I never used it. I thought the current configuration was already hard enough, but it is then even more complex...

Might be worth mentioning here that we aren't yet trying to account for the realm front-end urls - and that 421s may erroneously occur then.

This makes me feel that I'm not the right person to document that. If I think about your comment, 421s will erroneously occur. And if I understand it correctly, it would occur by default once someone uses TLS and Keycloak assumes it is passthrough.

This sounds to me like a bug. I'd say this is better handled in the cloud-native team. Feel free to reuse any part of this PR, but my knowledge seems to be too limited here.

@ahus1 ahus1 closed this Aug 6, 2026
@shawkins

shawkins commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@shawkins - can you please make this more actionable for me? Should I keep the changes about the test, or should I remove it?

Again I don't have a strong opinion on where the test is - if you want it in the new test suite that's fine. What I'm looking for on the issue is to make sure we capture more behind the intent for that change. Otherwise it just seems like a one-off. It sounds like we'll be capturing one issue to add embedded mode for the quarkus integration tests. Then there is already an issue on reusing the quarkus integration test optimization for the new test suite if performance is a concern. Finally since we already had some discussions on this, I was wondering if we should have a parent issue on migrating more of the quarkus integration tests to the new tests

@shawkins

shawkins commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

And if I understand it correctly, it would occur by default once someone uses TLS and Keycloak assumes it is passthrough.

If and only if realm frontend urls are in use and they are using a different host from the hostname / hostname admin. This should not be a common configuration.

This sounds to me like a bug. I'd say this is better handled in the cloud-native team. Feel free to reuse any part of this PR, but my knowledge seems to be too limited here.

It could be seen as bug, but out initial perspective is that this would be a small performance regression for an uncommon setup. The browser is expected to automatically retry with a new connection to the realm frontend should it get a 421 trying to switch from another realm frontend, the hostname, or hostname admin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor test for MisdirectedFilter

4 participants