Skip to content

Commit

Permalink
Adnuntius Bid Adapter: send script-override parameter to ad server (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
antosarho authored and DecayConstant committed Jul 18, 2024
1 parent 43755c1 commit ba0c16c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/adnuntiusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ export const spec = {
queryParamsAndValues.push('gdpr=' + flag);
}

const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('script-override')) {
queryParamsAndValues.push('so=' + searchParams.get('script-override'));
}

storageTool.refreshStorage(bidderRequest);

const urlRelatedMetaData = storageTool.getUrlRelatedData();
Expand Down
19 changes: 18 additions & 1 deletion test/spec/modules/adnuntiusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ describe('adnuntiusBidAdapter', function() {
const meta = [{key: 'valueless'}, {value: 'keyless'}, {key: 'voidAuIds'}, {key: 'voidAuIds', value: [{auId: '11118b6bc', exp: misc.getUnixTimestamp()}, {exp: misc.getUnixTimestamp(1)}]}, {key: 'valid-withnetwork', value: 'also-valid-network', network: 'the-network', exp: misc.getUnixTimestamp(1)}, {key: 'valid', value: 'also-valid', exp: misc.getUnixTimestamp(1)}, {key: 'expired', value: 'fwefew', exp: misc.getUnixTimestamp()}, {key: 'usi', value: 'should be skipped because timestamp', exp: misc.getUnixTimestamp(), network: 'adnuntius'}, {key: 'usi', value: usi, exp: misc.getUnixTimestamp(100), network: 'adnuntius'}, {key: 'usi', value: 'should be skipped because timestamp', exp: misc.getUnixTimestamp()}]
let storage;

// need this to make the restore work correctly -- something to do with stubbing static prototype methods
let stub1 = {}, stub2 = {};

before(() => {
getGlobal().bidderSettings = {
adnuntius: {
Expand All @@ -34,6 +37,13 @@ describe('adnuntiusBidAdapter', function() {

afterEach(function() {
config.resetConfig();

if (stub1.restore) {
stub1.restore();
}
if (stub2.restore) {
stub2.restore();
}
});

const tzo = new Date().getTimezoneOffset();
Expand Down Expand Up @@ -457,13 +467,20 @@ describe('adnuntiusBidAdapter', function() {

describe('buildRequests', function() {
it('Test requests', function() {
stub1 = sinon.stub(URLSearchParams.prototype, 'has').callsFake(() => {
return true;
});
stub2 = sinon.stub(URLSearchParams.prototype, 'get').callsFake(() => {
return 'overridden-value';
});

const request = spec.buildRequests(bidderRequests, {});
expect(request.length).to.equal(1);
expect(request[0]).to.have.property('bid');
const bid = request[0].bid[0]
expect(bid).to.have.property('bidId');
expect(request[0]).to.have.property('url');
expect(request[0].url).to.equal(ENDPOINT_URL);
expect(request[0].url).to.equal(ENDPOINT_URL.replace('format=prebid', 'format=prebid&so=overridden-value'));
expect(request[0]).to.have.property('data');
expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"123","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","dimensions":[[1640,1480],[1600,1400]]}]}');
});
Expand Down

0 comments on commit ba0c16c

Please sign in to comment.