-
Notifications
You must be signed in to change notification settings - Fork 6
UID2-6797 replace allowed sites null to empty with dsp type #607
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
Open
caroline-ttd
wants to merge
15
commits into
main
Choose a base branch
from
ccm-UID2-6797-replace-allowed-sites-null-to-empty-with-dsp-type
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+184
−60
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0126ee6
Replace allowed_site is null with allowed_site is empty and client ty…
caroline-ttd af7dbc7
Fix unit tests
caroline-ttd 48d391d
Add more unit tests
caroline-ttd 65f4fd7
[CI Pipeline] Released Snapshot version: 6.13.1-alpha-225-SNAPSHOT
4df44b5
Ignore for testing
caroline-ttd 7dc2bdf
[CI Pipeline] Released Snapshot version: 6.13.2-alpha-226-SNAPSHOT
6dbf9d8
Remove test
caroline-ttd 01359ac
Merge branch 'main' into ccm-UID2-6797-replace-allowed-sites-null-to-…
caroline-ttd 79a2742
Address comments
caroline-ttd 94c9ec5
Address comments
caroline-ttd 7ef1043
Replaced createDefaultKeyset with createKeysetSharedWithDsps
caroline-ttd 42b08f7
Remove resetAllowedSitesToNull
caroline-ttd c261274
[CI Pipeline] Released Snapshot version: 6.13.1-alpha-227-SNAPSHOT
869e05f
Update unit test names in SharingServiceTest
caroline-ttd fe665e1
Merge branch 'ccm-UID2-6797-replace-allowed-sites-null-to-empty-with-…
caroline-ttd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,16 +58,16 @@ public void testAddOrReplaceKeyset() throws Exception{ | |
| keysetKeyManager, true); | ||
|
|
||
| Map<Integer, AdminKeyset> keysets = new HashMap<Integer, AdminKeyset>() {{ | ||
| put(1, KeysetManager.createDefaultKeyset(3, 1)); | ||
| put(2, KeysetManager.createDefaultKeyset(4, 2)); | ||
| put(3, KeysetManager.createDefaultKeyset(5, 3)); | ||
| put(4, KeysetManager.createDefaultKeyset(6, 4)); | ||
| put(1, KeysetManager.createKeysetSharedWithDsps(3, 1)); | ||
| put(2, KeysetManager.createKeysetSharedWithDsps(4, 2)); | ||
| put(3, KeysetManager.createKeysetSharedWithDsps(5, 3)); | ||
| put(4, KeysetManager.createKeysetSharedWithDsps(6, 4)); | ||
| }}; | ||
|
|
||
| setKeysets(keysets); | ||
| final int keysetId = 5; | ||
| // add new keyset | ||
| AdminKeyset keyset1 = KeysetManager.createDefaultKeyset(7, keysetId); | ||
| AdminKeyset keyset1 = KeysetManager.createKeysetSharedWithDsps(7, keysetId); | ||
| keysetManager.addOrReplaceKeyset(keyset1); | ||
| assertTrue(keysets.containsKey(5)); | ||
| assertTrue(keyset1.equals(keysets.get(5))); | ||
|
|
@@ -102,7 +102,7 @@ public void createsKeysetWhenNoneExists() throws Exception { | |
|
|
||
| @Test | ||
| public void doesNotCreateKeysetWhenOneExists() throws Exception { | ||
| final AdminKeyset keyset = KeysetManager.createDefaultKeyset(1, 1); | ||
| final AdminKeyset keyset = KeysetManager.createKeysetSharedWithDsps(1, 1); | ||
| final HashMap<Integer, AdminKeyset> keysets = new HashMap<>(); | ||
| keysets.put(1, keyset); | ||
|
|
||
|
|
@@ -135,10 +135,10 @@ public void testCreateKeysetForClient() throws Exception { | |
| keysetKeyManager, true); | ||
|
|
||
| Map<Integer, AdminKeyset> keysets = new HashMap<Integer, AdminKeyset>() {{ | ||
| put(1, KeysetManager.createDefaultKeyset(3, 1)); | ||
| put(2, KeysetManager.createDefaultKeyset(4, 2)); | ||
| put(3, KeysetManager.createDefaultKeyset(5, 3)); | ||
| put(4, KeysetManager.createDefaultKeyset(6, 4)); | ||
| put(1, KeysetManager.createKeysetSharedWithDsps(3, 1)); | ||
| put(2, KeysetManager.createKeysetSharedWithDsps(4, 2)); | ||
| put(3, KeysetManager.createKeysetSharedWithDsps(5, 3)); | ||
| put(4, KeysetManager.createKeysetSharedWithDsps(6, 4)); | ||
| }}; | ||
|
|
||
| setKeysets(keysets); | ||
|
|
@@ -149,20 +149,22 @@ public void testCreateKeysetForClient() throws Exception { | |
| assertTrue(sharerKeyset.equals(returnedKeyset)); | ||
| assertEquals(sharerKeyset.getAllowedSites(), Set.of()); | ||
|
|
||
| // Generator makes a null list | ||
| // Generator makes an empty allowed_sites list with default allowed_types [DSP] | ||
| ClientKey generator = new ClientKey("", "", "", "", "", Instant.now(), Set.of(Role.GENERATOR), 8, false, "key-id-8"); | ||
| returnedKeyset = keysetManager.createKeysetForClient(generator); | ||
| AdminKeyset generatorKeyset = keysets.get(returnedKeyset.getKeysetId()); | ||
| assertTrue(generatorKeyset.equals(returnedKeyset)); | ||
| assertNull(generatorKeyset.getAllowedSites()); | ||
| assertEquals(Set.of(), generatorKeyset.getAllowedSites()); | ||
| assertEquals(Set.of(ClientType.DSP), generatorKeyset.getAllowedTypes()); | ||
|
|
||
| // Generator takes priority of sharer | ||
| ClientKey sharerGenerator = new ClientKey("", "", "", "", "", Instant.now(), Set.of(Role.SHARER, Role.GENERATOR), 9, false, "key-id-9"); | ||
| keysetManager.createKeysetForClient(sharerGenerator); | ||
| returnedKeyset = keysetManager.createKeysetForClient(sharerGenerator); | ||
| AdminKeyset bothKeyset = keysets.get(returnedKeyset.getKeysetId()); | ||
| assertTrue(bothKeyset.equals(returnedKeyset)); | ||
| assertNull(bothKeyset.getAllowedSites()); | ||
| assertEquals(Set.of(), bothKeyset.getAllowedSites()); | ||
| assertEquals(Set.of(ClientType.DSP), bothKeyset.getAllowedTypes()); | ||
|
|
||
| // If keyset already exists none gets added | ||
| returnedKeyset = keysetManager.createKeysetForClient(sharer); | ||
|
|
@@ -172,6 +174,30 @@ public void testCreateKeysetForClient() throws Exception { | |
| assertEquals(7, keysets.keySet().size()); | ||
| } | ||
|
|
||
| @Test | ||
| public void createKeysetForSite_newKeyset_hasNonNullEmptyAllowedSitesAndDspType() throws Exception { | ||
|
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. can you create some end to end tests like in SharingServiceTest that would test calling an http endpoint on when creating a new site or new client key which will go thru the old workflow to generate keyset that now has allowed_type = DSP? testing these are not enough i think. |
||
| setKeysets(new HashMap<>()); | ||
| KeysetManager keysetManager = new KeysetManager(keysetProvider, keysetStoreWriter, keysetKeyManager, true); | ||
|
|
||
| AdminKeyset created = keysetManager.createKeysetForSite(99); | ||
|
|
||
| assertNotNull(created.getAllowedSites()); | ||
| assertTrue(created.getAllowedSites().isEmpty()); | ||
| assertTrue(created.getAllowedTypes().contains(ClientType.DSP)); | ||
| } | ||
|
|
||
| @Test | ||
| public void createAndAddKeyset_emptyAllowedSites_nullAllowedTypes_hasEmptySitesAndNullAllowedTypes() | ||
| throws Exception { | ||
| setKeysets(new HashMap<>()); | ||
| KeysetManager keysetManager = new KeysetManager(keysetProvider, keysetStoreWriter, keysetKeyManager, true); | ||
|
|
||
| AdminKeyset created = keysetManager.createAndAddKeyset(42, new HashSet<>(), null); | ||
|
|
||
| assertNotNull(created.getAllowedSites()); | ||
| assertTrue(created.getAllowedSites().isEmpty()); | ||
| assertNull(created.getAllowedTypes()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLookUpKeyset() { | ||
|
|
@@ -228,33 +254,33 @@ public void testGetMaxKeyset() { | |
| public void testKeysetNameCreation() { | ||
|
|
||
| //expected cases of special keysets when site id and keyset id match our expectations | ||
| AdminKeyset keyset = createDefaultKeyset(-1, -1); | ||
| AdminKeyset keyset = createKeysetSharedWithDsps(-1, -1); | ||
| assertEquals(keyset.getName(), KeysetManager.MasterKeysetName); | ||
| keyset = createDefaultKeyset(-2, -2); | ||
| keyset = createKeysetSharedWithDsps(-2, -2); | ||
| assertEquals(keyset.getName(), KeysetManager.RefreshKeysetName); | ||
| keyset = createDefaultKeyset(2, 2); | ||
| keyset = createKeysetSharedWithDsps(2, 2); | ||
| assertEquals(keyset.getName(), KeysetManager.FallbackPublisherKeysetName); | ||
|
|
||
| //only site id matches but keyset id aren't the same as what we expected | ||
| keyset = createDefaultKeyset(-1, 3); | ||
| keyset = createKeysetSharedWithDsps(-1, 3); | ||
| assertEquals(keyset.getName(), ""); | ||
| keyset = createDefaultKeyset(-2, 34); | ||
| keyset = createKeysetSharedWithDsps(-2, 34); | ||
| assertEquals(keyset.getName(), ""); | ||
| keyset = createDefaultKeyset(2, 56); | ||
| keyset = createKeysetSharedWithDsps(2, 56); | ||
| assertEquals(keyset.getName(), ""); | ||
|
|
||
| //only keyset id matches but site Id aren't the same as what we expected | ||
| keyset = createDefaultKeyset(-5, 1); | ||
| keyset = createKeysetSharedWithDsps(-5, 1); | ||
| assertEquals(keyset.getName(), ""); | ||
| keyset = createDefaultKeyset(-3, 2); | ||
| keyset = createKeysetSharedWithDsps(-3, 2); | ||
| assertEquals(keyset.getName(), ""); | ||
| keyset = createDefaultKeyset(20, 3); | ||
| keyset = createKeysetSharedWithDsps(20, 3); | ||
| assertEquals(keyset.getName(), ""); | ||
|
|
||
| //for any other normal keyset creation | ||
| keyset = createDefaultKeyset(6, 7); | ||
| keyset = createKeysetSharedWithDsps(6, 7); | ||
| assertEquals(keyset.getName(), ""); | ||
| keyset = createDefaultKeyset(9, 23); | ||
| keyset = createKeysetSharedWithDsps(9, 23); | ||
| assertEquals(keyset.getName(), ""); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 add a comment why we're adding DSP here? is it because it's equivalent to the old behaviour?
e.g. it's not correct for a keyset belonging to a DATA_PROVIDER or ADVERTISER to automatically share with DSPs, but if we're doing it to match old behaviour then it's reasonable
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.
Yes, it is equivalent to the old behavior, will add the comment.
Uh oh!
There was an error while loading. Please reload this page.
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.
having a second thought - we should backport adding DSP type into existing sites when appropriate, but going forward, for any new site, we should by default add/enable DSP type in the admin/portal UI and not relying on checking allowed_sites = null from the JSON array input from admin UI.
So that the behaviour is by default, add DSP type to allowed_types and site needs to explicitly disable the DSP type?
Uh oh!
There was an error while loading. Please reload this page.
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.
For existing entries, for example where
allowed_typeincludes ADVERTISER andallowed_sitesis null, we add DSP; for future entries, we don’t apply this change, is it correct?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.
yes that's what i'm proposing - for futre entries by default in the admin UI/portal, we enable DSP but user can disable/un-choose it, but whatever allowed_types remain in the call is the actual allowed_types we are setting (not adding DSP regardless)
Uh oh!
There was an error while loading. Please reload this page.
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.
It might not just be the UI that calls
createDefaultKeysetthough; need to find all callers to figure out if that change would be okThere 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.
I think maybe we can keep the logic that sets
allowed_sites = []andallowed_types = [DSP]here. Since this function iscreateDefaultKeyset(notcreateKeyset), it represents a specific default behavior. Using these values for the default keyset should be clear and not cause confusion in the future. What do you think?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.
Discussed with @jon8787 , replaced
createDefaultKeysetwithcreateKeysetSharedWithDsps