1717import org .prebid .server .activity .infrastructure .ActivityInfrastructure ;
1818import org .prebid .server .auction .model .AuctionContext ;
1919import org .prebid .server .auction .privacy .enforcement .mask .UserFpdActivityMask ;
20- import org .prebid .server .hooks .execution .v1 .auction .AuctionInvocationContextImpl ;
2120import org .prebid .server .hooks .execution .v1 .auction .AuctionRequestPayloadImpl ;
2221import org .prebid .server .hooks .modules .liveintent .omni .channel .identity .model .IdResResponse ;
2322import org .prebid .server .hooks .modules .liveintent .omni .channel .identity .model .config .LiveIntentOmniChannelProperties ;
@@ -51,7 +50,7 @@ public class LiveIntentOmniChannelIdentityProcessedAuctionRequestHookTest {
5150
5251 private static final JacksonMapper MAPPER = new JacksonMapper (ObjectMapperProvider .mapper ());
5352
54- @ Mock
53+ @ Mock ( strictness = LENIENT )
5554 private UserFpdActivityMask userFpdActivityMask ;
5655
5756 @ Mock
@@ -112,22 +111,13 @@ public void geoPassingRestrictionShouldBeRespected() {
112111 .build ();
113112 final BidRequest givenBidRequest = BidRequest .builder ().id ("request" ).device (givenDevice ).build ();
114113
115- final Geo expectedGeo = givenGeo .toBuilder ()
116- .country (null )
117- .city (null )
114+ final Geo expectedGeo = Geo .builder ()
118115 .lat (52.52f )
119116 .lon (13.38f )
120117 .build ();
121- final Device expectedDevice = givenDevice . toBuilder ()
118+ final Device expectedDevice = Device . builder ()
122119 .geo (expectedGeo )
123120 .ip ("192.168.127.0" )
124- .ifa (null )
125- .macsha1 (null )
126- .macmd5 (null )
127- .dpidsha1 (null )
128- .dpidmd5 (null )
129- .didsha1 (null )
130- .didmd5 (null )
131121 .build ();
132122 final BidRequest expectedBidRequest = givenBidRequest .toBuilder ().device (expectedDevice ).build ();
133123
@@ -137,8 +127,15 @@ public void geoPassingRestrictionShouldBeRespected() {
137127 given (httpClient .post (any (), any (), any (), anyLong ()))
138128 .willReturn (Future .succeededFuture (HttpClientResponse .of (200 , null , responseBody )));
139129
130+ given (auctionInvocationContext .auctionContext ()).willReturn (auctionContext );
131+ given (auctionContext .getActivityInfrastructure ()).willReturn (activityInfrastructure );
132+ given (activityInfrastructure .isAllowed (any (), any ())).willReturn (true );
140133 given (activityInfrastructure .isAllowed (eq (Activity .TRANSMIT_GEO ), any ())).willReturn (false );
141134 given (activityInfrastructure .isAllowed (eq (Activity .TRANSMIT_UFPD ), any ())).willReturn (false );
135+ given (userFpdActivityMask .maskUser (any (), eq (true ), eq (false )))
136+ .will (invocation -> invocation .getArgument (0 ));
137+ given (userFpdActivityMask .maskDevice (any (), eq (true ), eq (true )))
138+ .will (invocation -> expectedDevice );
142139
143140 // when
144141 final InvocationResult <AuctionRequestPayload > result =
@@ -174,6 +171,10 @@ public void tidPassingRestrictionShouldBeRespected() {
174171
175172 given (activityInfrastructure .isAllowed (eq (Activity .TRANSMIT_TID ), any ())).willReturn (false );
176173 given (activityInfrastructure .isAllowed (eq (Activity .TRANSMIT_UFPD ), any ())).willReturn (false );
174+ given (userFpdActivityMask .maskUser (any (), eq (false ), eq (false )))
175+ .willAnswer (invocation -> invocation .getArgument (0 ));
176+ given (userFpdActivityMask .maskDevice (any (), eq (false ), eq (false )))
177+ .willAnswer (invocation -> invocation .getArgument (0 ));
177178
178179 // when
179180 final InvocationResult <AuctionRequestPayload > result =
@@ -196,8 +197,7 @@ public void eidPassingRestrictionShouldBeRespected() {
196197 final User givenUser = User .builder ().eids (singletonList (givenEid )).build ();
197198 final BidRequest givenBidRequest = BidRequest .builder ().id ("request" ).user (givenUser ).build ();
198199
199- final User expectedUser = givenUser .toBuilder ().eids (null ).build ();
200- final BidRequest expectedBidRequest = givenBidRequest .toBuilder ().user (expectedUser ).build ();
200+ final BidRequest expectedBidRequest = givenBidRequest .toBuilder ().user (null ).build ();
201201
202202 final Eid expectedEid = Eid .builder ().source ("liveintent.com" ).build ();
203203
@@ -210,6 +210,10 @@ public void eidPassingRestrictionShouldBeRespected() {
210210 given (activityInfrastructure .isAllowed (any (), any ())).willReturn (true );
211211 given (activityInfrastructure .isAllowed (eq (Activity .TRANSMIT_EIDS ), any ())).willReturn (false );
212212 given (activityInfrastructure .isAllowed (eq (Activity .TRANSMIT_UFPD ), any ())).willReturn (false );
213+ given (userFpdActivityMask .maskUser (any (), eq (true ), eq (true )))
214+ .willReturn (null );
215+ given (userFpdActivityMask .maskDevice (any (), eq (false ), eq (false )))
216+ .willAnswer (invocation -> invocation .getArgument (0 ));
213217
214218 // when
215219 final InvocationResult <AuctionRequestPayload > result =
@@ -241,8 +245,13 @@ public void callShouldEnrichUserEidsWithRequestedEids() {
241245 given (httpClient .post (any (), any (), any (), anyLong ()))
242246 .willReturn (Future .succeededFuture (HttpClientResponse .of (200 , null , responseBody )));
243247
244- final AuctionInvocationContext auctionInvocationContext = AuctionInvocationContextImpl .of (
245- null , null , false , null , null );
248+ given (auctionInvocationContext .auctionContext ()).willReturn (auctionContext );
249+ given (auctionContext .getActivityInfrastructure ()).willReturn (activityInfrastructure );
250+ given (activityInfrastructure .isAllowed (any (), any ())).willReturn (true );
251+ given (userFpdActivityMask .maskUser (any (), eq (false ), eq (false )))
252+ .willAnswer (invocation -> invocation .getArgument (0 ));
253+ given (userFpdActivityMask .maskDevice (any (), eq (false ), eq (false )))
254+ .willAnswer (invocation -> invocation .getArgument (0 ));
246255
247256 // when
248257 final InvocationResult <AuctionRequestPayload > result =
@@ -278,8 +287,13 @@ public void callShouldCreateUserAndUseRequestedEidsWhenUserIsAbsent() {
278287 given (httpClient .post (any (), any (), any (), anyLong ()))
279288 .willReturn (Future .succeededFuture (HttpClientResponse .of (200 , null , responseBody )));
280289
281- final AuctionInvocationContext auctionInvocationContext = AuctionInvocationContextImpl .of (
282- null , null , false , null , null );
290+ given (auctionInvocationContext .auctionContext ()).willReturn (auctionContext );
291+ given (auctionContext .getActivityInfrastructure ()).willReturn (activityInfrastructure );
292+ given (activityInfrastructure .isAllowed (any (), any ())).willReturn (true );
293+ given (userFpdActivityMask .maskUser (any (), eq (false ), eq (false )))
294+ .willAnswer (invocation -> invocation .getArgument (0 ));
295+ given (userFpdActivityMask .maskDevice (any (), eq (false ), eq (false )))
296+ .willAnswer (invocation -> invocation .getArgument (0 ));
283297
284298 // when
285299 final InvocationResult <AuctionRequestPayload > result =
@@ -304,13 +318,7 @@ public void callShouldCreateUserAndUseRequestedEidsWhenUserIsAbsent() {
304318 @ Test
305319 public void callShouldReturnNoActionSuccessfullyWhenTreatmentRateIsLowerThanThreshold () {
306320 // given
307- final Uid givenUid = Uid .builder ().id ("id1" ).atype (2 ).build ();
308- final Eid givebEid = Eid .builder ().source ("some.source.com" ).uids (singletonList (givenUid )).build ();
309- final User givenUser = User .builder ().eids (singletonList (givebEid )).build ();
310- final BidRequest givenBidRequest = BidRequest .builder ().id ("request" ).user (givenUser ).build ();
311-
312- final AuctionInvocationContext auctionInvocationContext = AuctionInvocationContextImpl .of (
313- null , null , false , null , null );
321+ final BidRequest givenBidRequest = BidRequest .builder ().build ();
314322
315323 given (properties .getTreatmentRate ()).willReturn (0.0f );
316324
@@ -334,8 +342,13 @@ public void callShouldReturnFailureWhenRequestingEidsIsFailed() {
334342 final User givenUser = User .builder ().eids (singletonList (givebEid )).build ();
335343 final BidRequest givenBidRequest = BidRequest .builder ().id ("request" ).user (givenUser ).build ();
336344
337- final AuctionInvocationContext auctionInvocationContext = AuctionInvocationContextImpl .of (
338- null , null , false , null , null );
345+ given (auctionInvocationContext .auctionContext ()).willReturn (auctionContext );
346+ given (auctionContext .getActivityInfrastructure ()).willReturn (activityInfrastructure );
347+ given (activityInfrastructure .isAllowed (any (), any ())).willReturn (true );
348+ given (userFpdActivityMask .maskUser (any (), eq (false ), eq (false )))
349+ .willAnswer (invocation -> invocation .getArgument (0 ));
350+ given (userFpdActivityMask .maskDevice (any (), eq (false ), eq (false )))
351+ .willAnswer (invocation -> invocation .getArgument (0 ));
339352
340353 given (httpClient .post (any (), any (), any (), anyLong ()))
341354 .willReturn (Future .failedFuture (new TimeoutException ("Timeout exceeded" )));
0 commit comments