-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix expiration logic for ldap internal credential cache #11395
Conversation
0382af2
to
dc66caa
Compare
|
||
public void testIsExpiredWhenMaxDurationIsSmall() throws InterruptedException | ||
{ | ||
Thread.sleep(1000); |
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.
Maybe you could avoid the sleeps by changing isExpired
to accept "now" as a parameter, and passing in an explicit "created at" time when creating the principal
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 about exposing the private constructor (for testing) and adding the now parameter as you indicate? however passing now to isExpired feels like an error prone decision (callers may make mistakes violating the contract of the expiration logic --- violation of encapsulation)
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.
Done. I left the original isExpired
method and added a new isExpired
, visible for testing, with the new parameters.
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
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
Assert.assertTrue(PRINCIPAL.isExpired(100, 1000)); | ||
} | ||
|
||
public void testIsExpiredWhenMaxDurationIsSmall() throws InterruptedException |
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.
Exception is never thrown. Same for other tests below. Failing intelliJ inspection because of this.
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.
Fixed
* Fix expiration logic for ldap internal credential cache * Removed sleeps from tests * Make method package scoped so it can be used in unit tests * Removed unused thrown exceptions
Fixes a bug with the expiration logic for
LdapUserPrincipal
. The entry should unconditionally expire whenmaxDuration
is up among other conditions. It was not expiring in that case.This PR has: