Skip to content
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

Change UID2-Shared for OptOut Policy Check #127

Merged

Conversation

zaiweidu
Copy link
Contributor

@zaiweidu zaiweidu commented Sep 13, 2023

  1. Added a new method getOldestClientKey() to RotatingClientKeyProvider.java
  2. Added unit tests to RotatingClientKeyProviderTest.java

@zaiweidu zaiweidu force-pushed the zdu-UID2-1863-Change-UID2-Shard-for-opt-out-policy-check branch from 71c7834 to b1a55c1 Compare September 13, 2023 07:27
@zaiweidu zaiweidu requested a review from scong-ttd September 13, 2023 07:46
@zaiweidu zaiweidu force-pushed the zdu-UID2-1863-Change-UID2-Shard-for-opt-out-policy-check branch from 8fed857 to 4897aef Compare September 13, 2023 08:08
List<ClientKey> keys = reader.getSnapshot().values().stream()
.filter(k -> k.getSiteId() == siteId) // filter by site id
.sorted(Comparator.comparing(ClientKey::getCreated)) // sort by key creation timestamp ascending
.collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

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

Would findFirst() be more appropriate here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced get(0) with findFirst() as suggested.

@@ -93,4 +95,12 @@ public CloudPath getMetadataPath() {
public IAuthorizable get(String key) {
return getClientKey(key);
}

public ClientKey getOldestClientKey(int siteId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a method on the snapshot instead? This is not really specific to the rotating provider.

Copy link
Contributor Author

@zaiweidu zaiweidu Sep 18, 2023

Choose a reason for hiding this comment

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

Per our slack discussion, we'll keep getOldestClientKey() here, and refactor RotatingClientKeyProvider in UID2-1901


public class RotatingClientKeyProviderTest {
@Test
public void testGetOldestClientKeyBySiteId() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

A test for when site does not have any keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test case added as suggested.

@zaiweidu zaiweidu force-pushed the zdu-UID2-1863-Change-UID2-Shard-for-opt-out-policy-check branch from 4897aef to e47848f Compare September 13, 2023 09:19
@zaiweidu zaiweidu changed the title Change UID2-Shared for OptOut Policy Check zdu Change UID2-Shared for OptOut Policy Check Sep 13, 2023
@zaiweidu zaiweidu changed the title zdu Change UID2-Shared for OptOut Policy Check Change UID2-Shared for OptOut Policy Check Sep 13, 2023
@zaiweidu zaiweidu force-pushed the zdu-UID2-1863-Change-UID2-Shard-for-opt-out-policy-check branch from 4d8bdd3 to d434c01 Compare September 19, 2023 02:33
@zaiweidu zaiweidu force-pushed the zdu-UID2-1863-Change-UID2-Shard-for-opt-out-policy-check branch from 595af36 to 66f6cf6 Compare September 19, 2023 09:06
@zaiweidu zaiweidu merged commit 07b6c8c into master Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants