@@ -18,8 +18,11 @@ import {createEidsArray} from '../../../modules/userId/eids.js';
18
18
19
19
describe ( 'Improve Digital Adapter Tests' , function ( ) {
20
20
const METHOD = 'POST' ;
21
- const AD_SERVER_URL = 'https://ad.360yield.com/pb' ;
22
- const BASIC_ADS_URL = 'https://ad.360yield-basic.com/pb' ;
21
+ const AD_SERVER_BASE_URL = 'https://ad.360yield.com' ;
22
+ const BASIC_ADS_BASE_URL = 'https://ad.360yield-basic.com' ;
23
+ const PB_ENDPOINT = 'pb' ;
24
+ const AD_SERVER_URL = `${ AD_SERVER_BASE_URL } /${ PB_ENDPOINT } ` ;
25
+ const BASIC_ADS_URL = `${ BASIC_ADS_BASE_URL } /${ PB_ENDPOINT } ` ;
23
26
const EXTEND_URL = 'https://pbs.360yield.com/openrtb2/auction' ;
24
27
const IFRAME_SYNC_URL = 'https://hb.360yield.com/prebid-universal-creative/load-cookie.html' ;
25
28
const INSTREAM_TYPE = 1 ;
@@ -390,6 +393,7 @@ describe('Improve Digital Adapter Tests', function () {
390
393
const payload = JSON . parse ( spec . buildRequests ( [ bidRequest ] , bidderRequestGdpr ) [ 0 ] . data ) ;
391
394
expect ( payload . regs . ext . gdpr ) . to . exist . and . to . equal ( 1 ) ;
392
395
expect ( payload . user . ext . consent ) . to . equal ( 'CONSENT' ) ;
396
+ expect ( payload . user . ext . ConsentedProvidersSettings ) . to . not . exist ;
393
397
expect ( payload . user . ext . consented_providers_settings . consented_providers ) . to . exist . and . to . deep . equal ( [ 1 , 35 , 41 , 101 ] ) ;
394
398
} ) ;
395
399
@@ -401,6 +405,15 @@ describe('Improve Digital Adapter Tests', function () {
401
405
expect ( payload . user . ext . consented_providers_settings ) . to . not . exist ;
402
406
} ) ;
403
407
408
+ it ( 'should add ConsentedProvidersSettings when extend mode enabled' , function ( ) {
409
+ const bidRequest = deepClone ( extendBidRequest ) ;
410
+ const payload = JSON . parse ( spec . buildRequests ( [ bidRequest ] , bidderRequestGdpr ) [ 0 ] . data ) ;
411
+ expect ( payload . regs . ext . gdpr ) . to . exist . and . to . equal ( 1 ) ;
412
+ expect ( payload . user . ext . consent ) . to . equal ( 'CONSENT' ) ;
413
+ expect ( payload . user . ext . ConsentedProvidersSettings . consented_providers ) . to . exist . and . to . equal ( '1~1.35.41.101' ) ;
414
+ expect ( payload . user . ext . consented_providers_settings ) . to . not . exist ;
415
+ } ) ;
416
+
404
417
it ( 'should add CCPA consent string' , function ( ) {
405
418
const bidRequest = Object . assign ( { } , simpleBidRequest ) ;
406
419
const request = spec . buildRequests ( [ bidRequest ] , { ...bidderRequest , ...{ uspConsent : '1YYY' } } ) ;
@@ -753,6 +766,64 @@ describe('Improve Digital Adapter Tests', function () {
753
766
expect ( requests [ 0 ] . url ) . to . equal ( AD_SERVER_URL ) ;
754
767
expect ( requests [ 1 ] . url ) . to . equal ( EXTEND_URL ) ;
755
768
} ) ;
769
+
770
+ it ( 'should add publisherId to request URL when available in request params' , function ( ) {
771
+ function formatPublisherUrl ( baseUrl , publisherId ) {
772
+ return `${ baseUrl } /${ publisherId } /${ PB_ENDPOINT } ` ;
773
+ }
774
+ const bidRequest = deepClone ( simpleBidRequest ) ;
775
+ bidRequest . params . publisherId = 1000 ;
776
+ let request = spec . buildRequests ( [ bidRequest ] , bidderRequest ) [ 0 ] ;
777
+ expect ( request ) . to . be . an ( 'object' ) ;
778
+ sinon . assert . match ( request , {
779
+ method : METHOD ,
780
+ url : formatPublisherUrl ( AD_SERVER_BASE_URL , 1000 ) ,
781
+ bidderRequest
782
+ } ) ;
783
+
784
+ const bidRequest2 = deepClone ( simpleBidRequest )
785
+ bidRequest2 . params . publisherId = 1002 ;
786
+
787
+ const bidRequest3 = deepClone ( extendBidRequest )
788
+ bidRequest3 . params . publisherId = 1002 ;
789
+
790
+ const request1 = spec . buildRequests ( [ bidRequest , bidRequest2 ] , bidderRequest ) [ 0 ] ;
791
+ expect ( request1 . url ) . to . equal ( formatPublisherUrl ( AD_SERVER_BASE_URL , 1000 ) ) ;
792
+ const request2 = spec . buildRequests ( [ bidRequest , bidRequest2 ] , bidderRequest ) [ 1 ] ;
793
+ expect ( request2 . url ) . to . equal ( formatPublisherUrl ( AD_SERVER_BASE_URL , 1002 ) ) ;
794
+ const request3 = spec . buildRequests ( [ bidRequest , bidRequest3 ] , bidderRequest ) [ 1 ] ;
795
+ expect ( request3 . url ) . to . equal ( EXTEND_URL ) ;
796
+
797
+ // Enable single request mode
798
+ getConfigStub = sinon . stub ( config , 'getConfig' ) ;
799
+ getConfigStub . withArgs ( 'improvedigital.singleRequest' ) . returns ( true ) ;
800
+ try {
801
+ spec . buildRequests ( [ bidRequest , bidRequest2 ] , bidderRequest ) [ 0 ] ;
802
+ } catch ( e ) {
803
+ expect ( e . name ) . to . exist . equal ( 'Error' )
804
+ expect ( e . message ) . to . exist . equal ( `All Improve Digital placements in a single call must have the same publisherId. Please check your 'params.publisherId' or turn off the single request mode.` )
805
+ }
806
+
807
+ bidRequest2 . params . publisherId = null ;
808
+ request = spec . buildRequests ( [ bidRequest , bidRequest2 ] , bidderRequest ) [ 0 ] ;
809
+ expect ( request . url ) . to . equal ( formatPublisherUrl ( AD_SERVER_BASE_URL , 1000 ) ) ;
810
+
811
+ const consent = deepClone ( gdprConsent ) ;
812
+ deepSetValue ( consent , 'vendorData.purpose.consents.1' , false ) ;
813
+ const bidderRequestWithConsent = deepClone ( bidderRequest ) ;
814
+ bidderRequestWithConsent . gdprConsent = consent ;
815
+ request = spec . buildRequests ( [ bidRequest ] , bidderRequestWithConsent ) [ 0 ] ;
816
+ expect ( request . url ) . to . equal ( formatPublisherUrl ( BASIC_ADS_BASE_URL , 1000 ) ) ;
817
+
818
+ deepSetValue ( consent , 'vendorData.purpose.consents.1' , true ) ;
819
+ bidderRequestWithConsent . gdprConsent = consent ;
820
+ request = spec . buildRequests ( [ bidRequest ] , bidderRequestWithConsent ) [ 0 ] ;
821
+ expect ( request . url ) . to . equal ( formatPublisherUrl ( AD_SERVER_BASE_URL , 1000 ) ) ;
822
+
823
+ delete bidRequest . params . publisherId ;
824
+ request = spec . buildRequests ( [ bidRequest ] , bidderRequestWithConsent ) [ 0 ] ;
825
+ expect ( request . url ) . to . equal ( AD_SERVER_URL ) ;
826
+ } ) ;
756
827
} ) ;
757
828
758
829
const serverResponse = {
@@ -1285,5 +1356,16 @@ describe('Improve Digital Adapter Tests', function () {
1285
1356
const syncs = spec . getUserSyncs ( { iframeEnabled : true , pixelEnabled : true } , serverResponses ) ;
1286
1357
expect ( syncs ) . to . deep . equal ( [ { type : 'iframe' , url : basicIframeSyncUrl + '&pbs=1' } ] ) ;
1287
1358
} ) ;
1359
+
1360
+ it ( 'should add bidders to iframe user sync url' , function ( ) {
1361
+ getConfigStub = sinon . stub ( config , 'getConfig' ) ;
1362
+ getConfigStub . withArgs ( 'improvedigital.extend' ) . returns ( true ) ;
1363
+ spec . buildRequests ( [ simpleBidRequest ] , { } ) ;
1364
+ const rawResponse = deepClone ( serverResponse )
1365
+ deepSetValue ( rawResponse , 'body.ext.responsetimemillis' , { a : 1 , b : 1 , c : 1 , d : 1 , e : 1 } )
1366
+ let syncs = spec . getUserSyncs ( { iframeEnabled : true , pixelEnabled : true } , [ rawResponse ] ) ;
1367
+ let url = basicIframeSyncUrl + '&pbs=1' + '&bidders=a,b,c,d,e'
1368
+ expect ( syncs ) . to . deep . equal ( [ { type : 'iframe' , url } ] ) ;
1369
+ } ) ;
1288
1370
} ) ;
1289
1371
} ) ;
0 commit comments