-
Notifications
You must be signed in to change notification settings - Fork 328
Cleanup RealmContextFilter #2747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of changes: 1. Remove the call to ContextLocals (context: apache#2720 (comment)). 2. Don't include the exception's message in the response as it can leak details about Polaris internals. 3. Add a small test for success and failure cases.
snazy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
just a few now failing test assertions
Whoops there were tests for that already 😅 I didn't know. I will merge the two test classes together. |
snazy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
|
||
| @Test | ||
| public void testDefaultRealm() { | ||
| givenTokenRequest("client1", "secret1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between this test and the one above it? Per what I'm seeing, it's the exact same request for different users who both have correct credentials as per L51.
I don't see the require-header variable changing between the two so I'm confused whether this is testing the default header properly or not, as the test names suggest? And if the default header was triggering the IllegalArgumentException, wouldn't that be a 400 Bad Request error code rather than Unauthorized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior is different because the default realm is realm1.
In the original test class there were comments explaining this, which I forgot to port over. I will add them now.
flyrain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for working on it, @adutra !
| .onItem() | ||
| .invoke(realmContext -> rc.setProperty(REALM_CONTEXT_KEY, realmContext)) | ||
| // ContextLocals is used by RealmIdTagContributor to add the realm id to metrics | ||
| .invoke(realmContext -> ContextLocals.put(REALM_CONTEXT_KEY, realmContext)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to understand why RealmIdTagContributor cannot read from the ContainerRequestContext instead of relying on ContextLocals to pass around any object needed for a HttpServerMetricsTagsContributor. Or would it be reasonable to copy the whole rc into a ContextLocals by default? So that any operation on the ContextLocals can use the ContainerRequestContext. Would you mind sharing your thought on it?
adnanhemani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks @adutra!
|
Thanks a lot for working on it @adutra ! Thanks @snazy @dimas-b @adnanhemani for the review! |
Summary of changes:
Remove the call to.ContextLocals(context: Extract interface for RequestIdGenerator #2720 (comment))UPDATE: we cannot remove
ContextLocals, it's used byRealmIdTagContributor.