Skip to content
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

Adnuntius Bid Adapter: send script-override parameter to ad server #11363

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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