-
Notifications
You must be signed in to change notification settings - Fork 6
Preliminary refactoring #456
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,17 +19,15 @@ | |
| import static org.mockito.Mockito.*; | ||
|
|
||
| public class SaltRotationTest { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can put this class-level annotation: Then you won't need to do If the test fails because the stubs are too lenient, you can additionally add this class-level annotation:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would require importing some new libraries. I suggest we keep this for a separate PR. |
||
| private AutoCloseable mocks; | ||
|
|
||
| @Mock private IKeyGenerator keyGenerator; | ||
| private SaltRotation saltRotation; | ||
|
|
||
| private final LocalDate targetDate = LocalDate.of(2025, 1, 1); | ||
| private final Instant targetDateAsInstant = targetDate.atStartOfDay().toInstant(ZoneOffset.UTC); | ||
|
|
||
| @BeforeEach | ||
| void setup() throws Exception { | ||
| mocks = MockitoAnnotations.openMocks(this); | ||
| void setup() { | ||
| MockitoAnnotations.openMocks(this); | ||
|
|
||
| saltRotation = new SaltRotation(keyGenerator); | ||
| } | ||
|
|
@@ -51,7 +49,7 @@ public SnapshotBuilder withEntries(int count, Instant lastUpdated) { | |
|
|
||
| public RotatingSaltProvider.SaltSnapshot build(Instant effective, Instant expires) { | ||
| return new RotatingSaltProvider.SaltSnapshot( | ||
| effective, expires, entries.stream().toArray(SaltEntry[]::new), "test_first_level_salt"); | ||
| effective, expires, entries.toArray(SaltEntry[]::new), "test_first_level_salt"); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Can we just skip the function call if
!shouldRotateand setupdatedSalts[i] = oldSalts[i]?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.
We can, but the whole point of this refactoring is to prepare for updating refreshFrom. We're planning to always calculate refreshFrom so we'd need to cycle through every salt.
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.
And we'll also need to update the previous from salt in here too