@@ -654,6 +654,10 @@ describe('S2S Adapter', function () {
654
654
prebid : {
655
655
aliases : {
656
656
brealtime : 'appnexus'
657
+ } ,
658
+ targeting : {
659
+ includebidderkeys : false ,
660
+ includewinners : true
657
661
}
658
662
}
659
663
} ) ;
@@ -684,6 +688,10 @@ describe('S2S Adapter', function () {
684
688
prebid : {
685
689
aliases : {
686
690
[ alias ] : 'appnexus'
691
+ } ,
692
+ targeting : {
693
+ includebidderkeys : false ,
694
+ includewinners : true
687
695
}
688
696
}
689
697
} ) ;
@@ -822,6 +830,146 @@ describe('S2S Adapter', function () {
822
830
expect ( requestBid . user . ext . tpid . foo ) . is . equal ( 'abc123' ) ;
823
831
expect ( requestBid . user . ext . tpid . unifiedid ) . is . equal ( '1234' ) ;
824
832
} )
833
+
834
+ it ( 'always add ext.prebid.targeting.includebidderkeys: false for ORTB' , function ( ) {
835
+ const s2sConfig = Object . assign ( { } , CONFIG , {
836
+ endpoint : 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' ,
837
+ adapterOptions : {
838
+ appnexus : {
839
+ key : 'value'
840
+ }
841
+ }
842
+ } ) ;
843
+ const _config = {
844
+ s2sConfig : s2sConfig ,
845
+ device : { ifa : '6D92078A-8246-4BA4-AE5B-76104861E7DC' } ,
846
+ app : { bundle : 'com.test.app' } ,
847
+ } ;
848
+
849
+ config . setConfig ( _config ) ;
850
+ adapter . callBids ( REQUEST , BID_REQUESTS , addBidResponse , done , ajax ) ;
851
+ const requestBid = JSON . parse ( requests [ 0 ] . requestBody ) ;
852
+
853
+ expect ( requestBid . ext . prebid . targeting ) . to . haveOwnProperty ( 'includebidderkeys' ) ;
854
+ expect ( requestBid . ext . prebid . targeting . includebidderkeys ) . to . equal ( false ) ;
855
+ } ) ;
856
+
857
+ it ( 'always add ext.prebid.targeting.includewinners: true for ORTB' , function ( ) {
858
+ const s2sConfig = Object . assign ( { } , CONFIG , {
859
+ endpoint : 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' ,
860
+ adapterOptions : {
861
+ appnexus : {
862
+ key : 'value'
863
+ }
864
+ }
865
+ } ) ;
866
+ const _config = {
867
+ s2sConfig : s2sConfig ,
868
+ device : { ifa : '6D92078A-8246-4BA4-AE5B-76104861E7DC' } ,
869
+ app : { bundle : 'com.test.app' } ,
870
+ } ;
871
+
872
+ config . setConfig ( _config ) ;
873
+ adapter . callBids ( REQUEST , BID_REQUESTS , addBidResponse , done , ajax ) ;
874
+ const requestBid = JSON . parse ( requests [ 0 ] . requestBody ) ;
875
+
876
+ expect ( requestBid . ext . prebid . targeting ) . to . haveOwnProperty ( 'includewinners' ) ;
877
+ expect ( requestBid . ext . prebid . targeting . includewinners ) . to . equal ( true ) ;
878
+ } ) ;
879
+
880
+ it ( 'adds s2sConfig video.ext.prebid to request for ORTB' , function ( ) {
881
+ const s2sConfig = Object . assign ( { } , CONFIG , {
882
+ endpoint : 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' ,
883
+ extPrebid : {
884
+ foo : 'bar'
885
+ }
886
+ } ) ;
887
+ const _config = {
888
+ s2sConfig : s2sConfig ,
889
+ device : { ifa : '6D92078A-8246-4BA4-AE5B-76104861E7DC' } ,
890
+ app : { bundle : 'com.test.app' } ,
891
+ } ;
892
+
893
+ config . setConfig ( _config ) ;
894
+ adapter . callBids ( REQUEST , BID_REQUESTS , addBidResponse , done , ajax ) ;
895
+ const requestBid = JSON . parse ( requests [ 0 ] . requestBody ) ;
896
+
897
+ expect ( requestBid ) . to . haveOwnProperty ( 'ext' ) ;
898
+ expect ( requestBid . ext ) . to . haveOwnProperty ( 'prebid' ) ;
899
+ expect ( requestBid . ext . prebid ) . to . deep . equal ( {
900
+ foo : 'bar' ,
901
+ targeting : {
902
+ includewinners : true ,
903
+ includebidderkeys : false
904
+ }
905
+ } ) ;
906
+ } ) ;
907
+
908
+ it ( 'overrides request.ext.prebid properties using s2sConfig video.ext.prebid values for ORTB' , function ( ) {
909
+ const s2sConfig = Object . assign ( { } , CONFIG , {
910
+ endpoint : 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' ,
911
+ extPrebid : {
912
+ targeting : {
913
+ includewinners : false ,
914
+ includebidderkeys : true
915
+ }
916
+ }
917
+ } ) ;
918
+ const _config = {
919
+ s2sConfig : s2sConfig ,
920
+ device : { ifa : '6D92078A-8246-4BA4-AE5B-76104861E7DC' } ,
921
+ app : { bundle : 'com.test.app' } ,
922
+ } ;
923
+
924
+ config . setConfig ( _config ) ;
925
+ adapter . callBids ( REQUEST , BID_REQUESTS , addBidResponse , done , ajax ) ;
926
+ const requestBid = JSON . parse ( requests [ 0 ] . requestBody ) ;
927
+
928
+ expect ( requestBid ) . to . haveOwnProperty ( 'ext' ) ;
929
+ expect ( requestBid . ext ) . to . haveOwnProperty ( 'prebid' ) ;
930
+ expect ( requestBid . ext . prebid ) . to . deep . equal ( {
931
+ targeting : {
932
+ includewinners : false ,
933
+ includebidderkeys : true
934
+ }
935
+ } ) ;
936
+ } ) ;
937
+
938
+ it ( 'overrides request.ext.prebid properties using s2sConfig video.ext.prebid values for ORTB' , function ( ) {
939
+ const s2sConfig = Object . assign ( { } , CONFIG , {
940
+ endpoint : 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' ,
941
+ extPrebid : {
942
+ cache : {
943
+ vastxml : 'vastxml-set-though-extPrebid.cache.vastXml'
944
+ } ,
945
+ targeting : {
946
+ includewinners : false ,
947
+ includebidderkeys : false
948
+ }
949
+ }
950
+ } ) ;
951
+ const _config = {
952
+ s2sConfig : s2sConfig ,
953
+ device : { ifa : '6D92078A-8246-4BA4-AE5B-76104861E7DC' } ,
954
+ app : { bundle : 'com.test.app' } ,
955
+ } ;
956
+
957
+ config . setConfig ( _config ) ;
958
+ adapter . callBids ( REQUEST , BID_REQUESTS , addBidResponse , done , ajax ) ;
959
+ const requestBid = JSON . parse ( requests [ 0 ] . requestBody ) ;
960
+
961
+ expect ( requestBid ) . to . haveOwnProperty ( 'ext' ) ;
962
+ expect ( requestBid . ext ) . to . haveOwnProperty ( 'prebid' ) ;
963
+ expect ( requestBid . ext . prebid ) . to . deep . equal ( {
964
+ cache : {
965
+ vastxml : 'vastxml-set-though-extPrebid.cache.vastXml'
966
+ } ,
967
+ targeting : {
968
+ includewinners : false ,
969
+ includebidderkeys : false
970
+ }
971
+ } ) ;
972
+ } ) ;
825
973
} ) ;
826
974
827
975
describe ( 'response handler' , function ( ) {
@@ -1058,6 +1206,85 @@ describe('S2S Adapter', function () {
1058
1206
expect ( response ) . to . have . property ( 'cpm' , 10 ) ;
1059
1207
} ) ;
1060
1208
1209
+ it ( 'handles response cache from ext.prebid.cache.vastXml' , function ( ) {
1210
+ const s2sConfig = Object . assign ( { } , CONFIG , {
1211
+ endpoint : 'https://prebidserverurl/openrtb2/auction?querystring=param'
1212
+ } ) ;
1213
+ config . setConfig ( { s2sConfig} ) ;
1214
+ const cacheResponse = utils . deepClone ( RESPONSE_OPENRTB_VIDEO ) ;
1215
+ cacheResponse . seatbid . forEach ( item => {
1216
+ item . bid [ 0 ] . ext . prebid . cache = {
1217
+ vastXml : {
1218
+ cacheId : 'abcd1234' ,
1219
+ url : 'https://prebid-cache.net/cache?uuid=abcd1234'
1220
+ }
1221
+ }
1222
+ } ) ;
1223
+ server . respondWith ( JSON . stringify ( cacheResponse ) ) ;
1224
+ adapter . callBids ( VIDEO_REQUEST , BID_REQUESTS , addBidResponse , done , ajax ) ;
1225
+ server . respond ( ) ;
1226
+
1227
+ sinon . assert . calledOnce ( addBidResponse ) ;
1228
+ const response = addBidResponse . firstCall . args [ 1 ] ;
1229
+
1230
+ expect ( response ) . to . have . property ( 'statusMessage' , 'Bid available' ) ;
1231
+ expect ( response ) . to . have . property ( 'videoCacheKey' , 'abcd1234' ) ;
1232
+ expect ( response ) . to . have . property ( 'vastUrl' , 'https://prebid-cache.net/cache?uuid=abcd1234' ) ;
1233
+ } ) ;
1234
+
1235
+ it ( 'add adserverTargeting object to bids when ext.prebid.targeting is defined' , function ( ) {
1236
+ const s2sConfig = Object . assign ( { } , CONFIG , {
1237
+ endpoint : 'https://prebidserverurl/openrtb2/auction?querystring=param'
1238
+ } ) ;
1239
+ config . setConfig ( { s2sConfig} ) ;
1240
+ const cacheResponse = utils . deepClone ( RESPONSE_OPENRTB_VIDEO ) ;
1241
+ const targetingTestData = {
1242
+ hb_cache_path : '/cache' ,
1243
+ hb_cache_host : 'prebid-cache.testurl.com'
1244
+ } ;
1245
+
1246
+ cacheResponse . seatbid . forEach ( item => {
1247
+ item . bid [ 0 ] . ext . prebid . targeting = targetingTestData
1248
+ } ) ;
1249
+ server . respondWith ( JSON . stringify ( cacheResponse ) ) ;
1250
+ adapter . callBids ( VIDEO_REQUEST , BID_REQUESTS , addBidResponse , done , ajax ) ;
1251
+ server . respond ( ) ;
1252
+
1253
+ sinon . assert . calledOnce ( addBidResponse ) ;
1254
+ const response = addBidResponse . firstCall . args [ 1 ] ;
1255
+
1256
+ expect ( response ) . to . have . property ( 'adserverTargeting' ) ;
1257
+ expect ( response . adserverTargeting ) . to . deep . equal ( {
1258
+ 'hb_cache_path' : '/cache' ,
1259
+ 'hb_cache_host' : 'prebid-cache.testurl.com'
1260
+ } ) ;
1261
+ } ) ;
1262
+
1263
+ it ( 'handles response cache from ext.prebid.targeting' , function ( ) {
1264
+ const s2sConfig = Object . assign ( { } , CONFIG , {
1265
+ endpoint : 'https://prebidserverurl/openrtb2/auction?querystring=param'
1266
+ } ) ;
1267
+ config . setConfig ( { s2sConfig} ) ;
1268
+ const cacheResponse = utils . deepClone ( RESPONSE_OPENRTB_VIDEO ) ;
1269
+ cacheResponse . seatbid . forEach ( item => {
1270
+ item . bid [ 0 ] . ext . prebid . targeting = {
1271
+ hb_uuid : 'a5ad3993' ,
1272
+ hb_cache_host : 'prebid-cache.net' ,
1273
+ hb_cache_path : '/cache'
1274
+ }
1275
+ } ) ;
1276
+ server . respondWith ( JSON . stringify ( cacheResponse ) ) ;
1277
+ adapter . callBids ( VIDEO_REQUEST , BID_REQUESTS , addBidResponse , done , ajax ) ;
1278
+ server . respond ( ) ;
1279
+
1280
+ sinon . assert . calledOnce ( addBidResponse ) ;
1281
+ const response = addBidResponse . firstCall . args [ 1 ] ;
1282
+
1283
+ expect ( response ) . to . have . property ( 'statusMessage' , 'Bid available' ) ;
1284
+ expect ( response ) . to . have . property ( 'videoCacheKey' , 'a5ad3993' ) ;
1285
+ expect ( response ) . to . have . property ( 'vastUrl' , 'https://prebid-cache.net/cache?uuid=a5ad3993' ) ;
1286
+ } ) ;
1287
+
1061
1288
it ( 'should log warning for unsupported bidder' , function ( ) {
1062
1289
server . respondWith ( JSON . stringify ( RESPONSE_UNSUPPORTED_BIDDER ) ) ;
1063
1290
0 commit comments