-
Notifications
You must be signed in to change notification settings - Fork 6
sch-UID2-5339 salt rotation populate previous salt #460
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
sch-UID2-5339 salt rotation populate previous salt #460
Conversation
…tation-previous-salt
…tation-previous-salt
| assertEquals("salt1", result.getSnapshot().getAllRotatingSalts()[0].previousSalt()); | ||
| assertEquals("salt2", result.getSnapshot().getAllRotatingSalts()[1].previousSalt()); | ||
| assertEquals("salt3", result.getSnapshot().getAllRotatingSalts()[2].previousSalt()); | ||
| assertEquals(7, Arrays.stream(result.getSnapshot().getAllRotatingSalts()).filter(s -> s.previousSalt() == null).count()); |
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.
As I understand, this is the "preserve old value of previousSalt for not rotated salts"? I suggest we move that into a separate test and use a mix of salts with previousSalt null and previousSalt not null.
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.
This one is just checking that we haven't populated the previous salt for salts that haven't rotated, not necessarily preserving the old value.
|
|
||
| final SaltRotation.Result result = saltRotation.rotateSalts(lastSnapshot, minAges, 0.5, targetDate); | ||
| assertTrue(result.hasSnapshot()); | ||
| assertEquals(2, Arrays.stream(result.getSnapshot().getAllRotatingSalts()).filter(s -> "lessThan90DaysOld".equals(s.previousSalt())).count()); |
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 better to just assert on what's the previous salts are at each position like you did in the previous test? This will be a bit more complicated to figure out if this test fails.
| final long over90Days = daysEarlier(100).toEpochMilli(); | ||
| final RotatingSaltProvider.SaltSnapshot lastSnapshot = SnapshotBuilder.start() | ||
| .withEntries( | ||
| new SaltEntry(1, "1", lessThan90Days, "currentSalt", null, "lessThan90DaysOld", null, null), |
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.
Why double up all the test cases?
Unit tests:
rotateSaltsPopulatePreviousSaltOnRotation()
- when a salt is rotated, populate the previous salt field with the current salt
rotateSaltsPreservePreviousSaltsLessThan90DaysOld()
- salts that are under 90 days old and are not being rotated will keep their previous salt
rotateSaltsRemovePreviousSaltsOver90DaysOld()
- salts that are equal to or over 90 days old and are not being rotated will have their previous salts removed