diff --git a/modules/lunamediahbBidAdapter.js b/modules/lunamediahbBidAdapter.js deleted file mode 100644 index 6ad42a4f3ca..00000000000 --- a/modules/lunamediahbBidAdapter.js +++ /dev/null @@ -1,19 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import { isBidRequestValid, buildRequests, interpretResponse, getUserSyncs } from '../libraries/teqblazeUtils/bidderUtils.js'; - -const BIDDER_CODE = 'lunamediahb'; -const AD_URL = 'https://balancer.lmgssp.com/?c=o&m=multi'; -const SYNC_URL = 'https://cookie.lmgssp.com'; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - isBidRequestValid: isBidRequestValid(['placementId']), - buildRequests: buildRequests(AD_URL), - interpretResponse, - getUserSyncs: getUserSyncs(SYNC_URL) -}; - -registerBidder(spec); diff --git a/modules/lunamediahbBidAdapter.md b/modules/lunamediahbBidAdapter.md index 184dd846a9d..99c4d84e3ea 100644 --- a/modules/lunamediahbBidAdapter.md +++ b/modules/lunamediahbBidAdapter.md @@ -1,72 +1,103 @@ # Overview ``` -Module Name: lunamedia Bidder Adapter -Module Type: lunamedia Bidder Adapter -Maintainer: support@lunamedia.io +Module Name: LunamediaHB Bidder Adapter +Module Type: Bidder Adapter +Maintainer: prebid@ferio.cloud ``` # Description -Module that connects to lunamedia demand sources +Module that connects to LunamediaHB demand sources. + +# Bid Params + +| Name | Scope | Type | Description | +| ------------- | -------- | ------ | ---------------------------------------- | +| `publisherId` | required | String | Publisher ID on the Lunamedia platform. | +| `adUnitId` | required | String | Ad unit ID on the Lunamedia platform. | +| `tenantId` | required | String | Tenant ID on the Lunamedia platform. | # Test Parameters -``` - var adUnits = [ - { - code:'1', - mediaTypes:{ - banner: { - sizes: [[300, 250]], - } - }, - bids:[ - { - bidder: 'lunamediahb', - params: { - placementId: 0 - } - } - ] - }, - { - code:'1', - mediaTypes:{ - video: { - playerSize: [640, 480], - context: 'instream' - } - }, - bids:[ - { - bidder: 'lunamediahb', - params: { - placementId: 0 - } - } - ] - }, - { - code:'1', - mediaTypes:{ - native: { - title: { - required: true - }, - icon: { - required: true, - size: [64, 64] - } - } - }, - bids:[ - { - bidder: 'lunamediahb', - params: { - placementId: 0 - } - } - ] - } - ]; + +```javascript +var adUnits = [ + { + code: "banner-div", + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: "lunamediahb", + params: { + publisherId: "publisher-123", + adUnitId: "ad-unit-456", + tenantId: "tenant-789", + }, + }, + ], + }, + { + code: "video-div", + mediaTypes: { + video: { + playerSize: [640, 480], + context: "instream", + mimes: ["video/mp4"], + protocols: [2, 3, 5, 6], + }, + }, + bids: [ + { + bidder: "lunamediahb", + params: { + publisherId: "publisher-123", + adUnitId: "ad-unit-456", + tenantId: "tenant-789", + }, + }, + ], + }, + { + code: "native-div", + mediaTypes: { + native: { + ortb: { + ver: "1.2", + assets: [ + { + id: 1, + required: 1, + title: { + len: 90, + }, + }, + { + id: 2, + required: 1, + img: { + type: 3, + w: 300, + h: 250, + }, + }, + ], + }, + }, + }, + bids: [ + { + bidder: "lunamediahb", + params: { + publisherId: "publisher-123", + adUnitId: "ad-unit-456", + tenantId: "tenant-789", + }, + }, + ], + }, +]; ``` diff --git a/modules/lunamediahbBidAdapter.ts b/modules/lunamediahbBidAdapter.ts new file mode 100644 index 00000000000..bb7c85ed7b4 --- /dev/null +++ b/modules/lunamediahbBidAdapter.ts @@ -0,0 +1,32 @@ +import { + type BidderSpec, + registerBidder, +} from "../src/adapters/bidderFactory.js"; +import { createFerioBidderSpec } from "../libraries/ferioUtils/bidderUtils.js"; + +const BIDDER_CODE = "lunamediahb"; +const LUNAMEDIAHB_ENDPOINT = "https://lunamedia.bid/prebid"; +const LUNAMEDIAHB_GVLID = 998; + +export interface LunamediaHBBidParams { + publisherId: string; + adUnitId: string; + tenantId: string; +} + +declare module "../src/adUnits" { + interface BidderParams { + [BIDDER_CODE]: LunamediaHBBidParams; + } +} + +export const spec: BidderSpec = { + ...createFerioBidderSpec({ + code: BIDDER_CODE, + endpoint: LUNAMEDIAHB_ENDPOINT, + requiredParams: ["tenantId"], + }), + gvlid: LUNAMEDIAHB_GVLID, +}; + +registerBidder(spec); diff --git a/test/spec/modules/lunamediahbBidAdapter_spec.js b/test/spec/modules/lunamediahbBidAdapter_spec.js index 8804a33eec0..9754cffdd4f 100644 --- a/test/spec/modules/lunamediahbBidAdapter_spec.js +++ b/test/spec/modules/lunamediahbBidAdapter_spec.js @@ -1,465 +1,266 @@ -import { expect } from 'chai'; -import { spec } from '../../../modules/lunamediahbBidAdapter.js'; -import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; -import { getUniqueIdentifierStr } from '../../../src/utils.js'; +import { expect } from "chai"; +import { spec } from "../../../modules/lunamediahbBidAdapter.js"; +import { config } from "../../../src/config.js"; +import { BANNER, NATIVE, VIDEO } from "../../../src/mediaTypes.js"; -const bidder = 'lunamediahb'; +const BIDDER_CODE = "lunamediahb"; +const LUNAMEDIAHB_BID_URL = "https://lunamedia.bid/prebid/bid"; -describe('LunamediaHBBidAdapter', function () { - const userIdAsEids = [{ - source: 'test.org', - uids: [{ - id: '01**********', - atype: 1, - ext: { - third: '01***********' - } - }] - }]; - const bids = [ - { - bidId: getUniqueIdentifierStr(), - bidder: bidder, - mediaTypes: { - [BANNER]: { - sizes: [[300, 250]], - battr: [1, 3] - } - }, - params: { - placementId: 'testBanner' - }, - userIdAsEids - }, - { - bidId: getUniqueIdentifierStr(), - bidder: bidder, - mediaTypes: { - [VIDEO]: { - playerSize: [[300, 300]], - minduration: 5, - maxduration: 60, - battr: [1, 3] - } - }, - params: { - placementId: 'testVideo' - }, - userIdAsEids - }, - { - bidId: getUniqueIdentifierStr(), - bidder: bidder, - mediaTypes: { - [NATIVE]: { - native: { - title: { - required: true - }, - body: { - required: true - }, - icon: { - required: true, - size: [64, 64] - } - } - } - }, - params: { - placementId: 'testNative' - }, - userIdAsEids - } - ]; - - const invalidBid = { - bidId: getUniqueIdentifierStr(), - bidder: bidder, +function bidRequest(overrides = {}) { + return { + bidder: BIDDER_CODE, + bidId: "bid-1", + adUnitCode: "adunit-1", + transactionId: "tx-1", + bidRequestsCount: 1, mediaTypes: { [BANNER]: { - sizes: [[300, 250]] - } + sizes: [[300, 250]], + }, }, params: { - - } + publisherId: "pub-123", + adUnitId: "ad-unit-456", + tenantId: "tenant-123", + }, + ...overrides, }; +} - const bidderRequest = { - uspConsent: '1---', - gdprConsent: { - consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', - vendorData: {} - }, +function bidderRequest(overrides = {}) { + return { + bidderCode: BIDDER_CODE, + auctionId: "auction-1", + timeout: 800, refererInfo: { - referer: 'https://test.com', - page: 'https://test.com' + page: "https://example.com/article", + location: "https://example.com/article", + domain: "example.com", + ref: "https://referrer.example.com", + isAmp: false, }, ortb2: { + site: { + page: "https://example.com/article", + }, device: { - w: 1512, - h: 982, - language: 'en-UK' - } + ua: "Mozilla/5.0 test", + language: "en-US", + w: 1366, + h: 768, + }, }, - timeout: 500 + ...overrides, }; +} - describe('isBidRequestValid', function () { - it('Should return true if there are bidId, params and key parameters present', function () { - expect(spec.isBidRequestValid(bids[0])).to.be.true; - }); - it('Should return false if at least one of parameters is not present', function () { - expect(spec.isBidRequestValid(invalidBid)).to.be.false; - }); - }); +function buildRequest(bidRequests, requestOverrides = {}) { + return spec.buildRequests( + bidRequests, + bidderRequest({ bids: bidRequests, ...requestOverrides }) + )[0]; +} - describe('buildRequests', function () { - let serverRequest = spec.buildRequests(bids, bidderRequest); +function getImp(request, impId) { + return request.data.imp.find((imp) => imp.id === impId); +} - it('Creates a ServerRequest object with method, URL and data', function () { - expect(serverRequest).to.exist; - expect(serverRequest.method).to.exist; - expect(serverRequest.url).to.exist; - expect(serverRequest.data).to.exist; - }); +function serverResponse(bids) { + return { + body: { + id: "response-1", + seatbid: [ + { + seat: BIDDER_CODE, + bid: bids, + }, + ], + cur: "USD", + }, + }; +} - it('Returns POST method', function () { - expect(serverRequest.method).to.equal('POST'); - }); +describe("lunamediahbBidAdapter", function () { + beforeEach(function () { + config.resetConfig(); + }); - it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://balancer.lmgssp.com/?c=o&m=multi'); - }); + it("registers the lunamediahb bidder code", function () { + expect(spec.code).to.equal(BIDDER_CODE); + }); - it('Returns general data valid', function () { - const data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', - 'deviceHeight', - 'device', - 'language', - 'secure', - 'host', - 'page', - 'placements', - 'coppa', - 'ccpa', - 'gdpr', - 'tmax', - 'bcat', - 'badv', - 'bapp' - ); - expect(data.deviceWidth).to.be.a('number'); - expect(data.deviceHeight).to.be.a('number'); - expect(data.language).to.be.a('string'); - expect(data.secure).to.be.within(0, 1); - expect(data.host).to.be.a('string'); - expect(data.page).to.be.a('string'); - expect(data.coppa).to.be.a('number'); - expect(data.gdpr).to.be.a('object'); - expect(data.ccpa).to.be.a('string'); - expect(data.tmax).to.be.a('number'); - expect(data.placements).to.have.lengthOf(3); - }); + it("exposes the Luna Media GVL ID", function () { + expect(spec.gvlid).to.equal(998); + }); - it('Returns valid placements', function () { - const { placements } = serverRequest.data; - for (let i = 0, len = placements.length; i < len; i++) { - const placement = placements[i]; - expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); - expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); - expect(placement.bidId).to.be.a('string'); - expect(placement.schain).to.be.an('object'); - expect(placement.bidfloor).to.exist.and.to.equal(0); - expect(placement.type).to.exist.and.to.equal('publisher'); - expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids); + it("supports banner, video, and native media types", function () { + expect(spec.supportedMediaTypes).to.deep.equal([BANNER, VIDEO, NATIVE]); + }); - switch (placement.adFormat) { - case BANNER: - expect(placement.sizes).to.be.an('array'); - expect(placement.battr).to.deep.equal([1, 3]); - break; - case VIDEO: - expect(placement.playerSize).to.be.an('array'); - expect(placement.minduration).to.be.an('number'); - expect(placement.maxduration).to.be.an('number'); - expect(placement.battr).to.deep.equal([1, 3]); - break; - case NATIVE: - expect(placement.native).to.be.an('object'); - break; - } - } + describe("isBidRequestValid", function () { + it("accepts bids with Ferio params", function () { + expect(spec.isBidRequestValid(bidRequest())).to.equal(true); }); - it('Returns data with gdprConsent and without uspConsent', function () { - delete bidderRequest.uspConsent; - serverRequest = spec.buildRequests(bids, bidderRequest); - const data = serverRequest.data; - expect(data.gdpr).to.exist; - expect(data.gdpr).to.be.a('object'); - expect(data.gdpr).to.have.property('consentString'); - expect(data.gdpr).to.not.have.property('vendorData'); - expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString); - expect(data.ccpa).to.not.exist; - delete bidderRequest.gdprConsent; + it("rejects old placementId-only bids", function () { + expect( + spec.isBidRequestValid( + bidRequest({ + params: { + placementId: "legacy-placement", + }, + }) + ) + ).to.equal(false); }); - it('Returns data with uspConsent and without gdprConsent', function () { - bidderRequest.uspConsent = '1---'; - delete bidderRequest.gdprConsent; - serverRequest = spec.buildRequests(bids, bidderRequest); - const data = serverRequest.data; - expect(data.ccpa).to.exist; - expect(data.ccpa).to.be.a('string'); - expect(data.ccpa).to.equal(bidderRequest.uspConsent); - expect(data.gdpr).to.not.exist; + it("rejects bids missing required Ferio params", function () { + ["publisherId", "adUnitId", "tenantId"].forEach((paramName) => { + const params = { + publisherId: "pub-123", + adUnitId: "ad-unit-456", + tenantId: "tenant-123", + }; + delete params[paramName]; + + expect( + spec.isBidRequestValid( + bidRequest({ + params, + }) + ) + ).to.equal(false); + }); }); }); - describe('gpp consent', function () { - it('bidderRequest.gppConsent', () => { - bidderRequest.gppConsent = { - gppString: 'abc123', - applicableSections: [8] - }; + describe("buildRequests", function () { + it("builds one POST OpenRTB request to the Lunamedia endpoint", function () { + const bannerBid = bidRequest({ bidId: "banner-bid" }); + const videoBid = bidRequest({ + bidId: "video-bid", + mediaTypes: { + [VIDEO]: { + playerSize: [[640, 480]], + context: "instream", + protocols: [2, 3, 5, 6], + mimes: ["video/mp4"], + }, + }, + }); + const nativeBid = bidRequest({ + bidId: "native-bid", + mediaTypes: { + [NATIVE]: {}, + }, + nativeOrtbRequest: { + ver: "1.2", + assets: [{ id: 1, title: { len: 90 } }], + }, + }); - const serverRequest = spec.buildRequests(bids, bidderRequest); - const data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.property('gpp'); - expect(data).to.have.property('gpp_sid'); + const requests = spec.buildRequests( + [bannerBid, videoBid, nativeBid], + bidderRequest({ bids: [bannerBid, videoBid, nativeBid] }) + ); - delete bidderRequest.gppConsent; + expect(requests).to.be.an("array").with.lengthOf(1); + expect(requests[0].method).to.equal("POST"); + expect(requests[0].url).to.equal(LUNAMEDIAHB_BID_URL); + expect(requests[0].options).to.deep.equal({ + contentType: "text/plain", + withCredentials: true, + }); + expect(requests[0].data.tmax).to.equal(800); + expect(requests[0].data.imp.map((imp) => imp.id)).to.deep.equal([ + "banner-bid", + "video-bid", + "native-bid", + ]); }); - it('bidderRequest.ortb2.regs.gpp', () => { - bidderRequest.ortb2 = bidderRequest.ortb2 || {}; - bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {}; - bidderRequest.ortb2.regs.gpp = 'abc123'; - bidderRequest.ortb2.regs.gpp_sid = [8]; + it("places bidder params under imp.ext.prebid.bidder.lunamediahb", function () { + const request = buildRequest([bidRequest()]); + const imp = getImp(request, "bid-1"); - const serverRequest = spec.buildRequests(bids, bidderRequest); - const data = serverRequest.data; - expect(data).to.be.an('object'); - expect(data).to.have.property('gpp'); - expect(data).to.have.property('gpp_sid'); + expect(imp.ext.prebid.bidder.lunamediahb).to.deep.equal({ + publisherId: "pub-123", + adUnitId: "ad-unit-456", + tenantId: "tenant-123", + }); }); }); - describe('interpretResponse', function () { - it('Should interpret banner response', function () { - const banner = { - body: [{ - mediaType: 'banner', - width: 300, - height: 250, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1', - meta: { - advertiserDomains: ['google.com'], - advertiserId: 1234 - } - }] - }; - const bannerResponses = spec.interpretResponse(banner); - expect(bannerResponses).to.be.an('array').that.is.not.empty; - const dataItem = bannerResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); - expect(dataItem.requestId).to.equal(banner.body[0].requestId); - expect(dataItem.cpm).to.equal(banner.body[0].cpm); - expect(dataItem.width).to.equal(banner.body[0].width); - expect(dataItem.height).to.equal(banner.body[0].height); - expect(dataItem.ad).to.equal(banner.body[0].ad); - expect(dataItem.ttl).to.equal(banner.body[0].ttl); - expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal(banner.body[0].currency); - expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); - }); - it('Should interpret video response', function () { - const video = { - body: [{ - vastUrl: 'test.com', - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1', - meta: { - advertiserDomains: ['google.com'], - advertiserId: 1234 - } - }] - }; - const videoResponses = spec.interpretResponse(video); - expect(videoResponses).to.be.an('array').that.is.not.empty; - - const dataItem = videoResponses[0]; - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.5); - expect(dataItem.vastUrl).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); - }); - it('Should interpret native response', function () { - const native = { - body: [{ - mediaType: 'native', - native: { - clickUrl: 'test.com', - title: 'Test', - image: 'test.com', - impressionTrackers: ['test.com'], + describe("interpretResponse", function () { + it("interprets an OpenRTB banner response with lunamediahb adapter codes", function () { + const request = buildRequest([bidRequest()]); + const bids = spec.interpretResponse( + serverResponse([ + { + id: "response-bid-1", + impid: "bid-1", + price: 1.1, + adm: "
ad
", + crid: "creative-banner", + w: 300, + h: 250, + mtype: 1, + adomain: ["advertiser.example"], }, - ttl: 120, - cpm: 0.4, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - meta: { - advertiserDomains: ['google.com'], - advertiserId: 1234 - } - }] - }; - const nativeResponses = spec.interpretResponse(native); - expect(nativeResponses).to.be.an('array').that.is.not.empty; - - const dataItem = nativeResponses[0]; - expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); - expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image'); - expect(dataItem.requestId).to.equal('23fhj33i987f'); - expect(dataItem.cpm).to.equal(0.4); - expect(dataItem.native.clickUrl).to.equal('test.com'); - expect(dataItem.native.title).to.equal('Test'); - expect(dataItem.native.image).to.equal('test.com'); - expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; - expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); - expect(dataItem.ttl).to.equal(120); - expect(dataItem.creativeId).to.equal('2'); - expect(dataItem.netRevenue).to.be.true; - expect(dataItem.currency).to.equal('USD'); - expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); - }); - it('Should return an empty array if invalid banner response is passed', function () { - const invBanner = { - body: [{ - width: 300, - cpm: 0.4, - ad: 'Test', - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; + ]), + request + ); - const serverResponses = spec.interpretResponse(invBanner); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid video response is passed', function () { - const invVideo = { - body: [{ - mediaType: 'video', - cpm: 0.5, - requestId: '23fhj33i987f', - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - const serverResponses = spec.interpretResponse(invVideo); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid native response is passed', function () { - const invNative = { - body: [{ - mediaType: 'native', - clickUrl: 'test.com', - title: 'Test', - impressionTrackers: ['test.com'], - ttl: 120, - requestId: '23fhj33i987f', - creativeId: '2', - netRevenue: true, - currency: 'USD', - }] - }; - const serverResponses = spec.interpretResponse(invNative); - expect(serverResponses).to.be.an('array').that.is.empty; - }); - it('Should return an empty array if invalid response is passed', function () { - const invalid = { - body: [{ - ttl: 120, - creativeId: '2', - netRevenue: true, - currency: 'USD', - dealId: '1' - }] - }; - const serverResponses = spec.interpretResponse(invalid); - expect(serverResponses).to.be.an('array').that.is.empty; + expect(bids).to.have.lengthOf(1); + expect(bids[0]).to.deep.include({ + requestId: "bid-1", + cpm: 1.1, + width: 300, + height: 250, + ad: "
ad
", + creativeId: "creative-banner", + currency: "USD", + netRevenue: true, + ttl: 300, + mediaType: BANNER, + bidderCode: BIDDER_CODE, + adapterCode: BIDDER_CODE, + }); + expect(bids[0].meta.advertiserDomains).to.deep.equal([ + "advertiser.example", + ]); }); }); - describe('getUserSyncs', function() { - it('Should return array of objects with proper sync config , include GDPR', function() { - const syncData = spec.getUserSyncs({ pixelEnabled: true }, {}, { - consentString: 'ALL', - gdprApplies: true, - }, undefined); - expect(syncData).to.be.an('array').which.is.not.empty; - expect(syncData[0]).to.be.an('object'); - expect(syncData[0].type).to.be.a('string'); - expect(syncData[0].type).to.equal('image'); - expect(syncData[0].url).to.be.a('string'); - expect(syncData[0].url).to.equal('https://cookie.lmgssp.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0'); - }); - it('Should return array of objects with proper sync config , include CCPA', function() { - const syncData = spec.getUserSyncs({ pixelEnabled: true }, {}, {}, '1---'); - expect(syncData).to.be.an('array').which.is.not.empty; - expect(syncData[0]).to.be.an('object'); - expect(syncData[0].type).to.be.a('string'); - expect(syncData[0].type).to.equal('image'); - expect(syncData[0].url).to.be.a('string'); - expect(syncData[0].url).to.equal('https://cookie.lmgssp.com/image?pbjs=1&ccpa_consent=1---&coppa=0'); - }); - it('Should return array of objects with proper sync config , include GPP', function() { - const syncData = spec.getUserSyncs({ pixelEnabled: true }, {}, {}, undefined, { - gppString: 'abc123', - applicableSections: [8] - }); - expect(syncData).to.be.an('array').which.is.not.empty; - expect(syncData[0]).to.be.an('object'); - expect(syncData[0].type).to.be.a('string'); - expect(syncData[0].type).to.equal('image'); - expect(syncData[0].url).to.be.a('string'); - expect(syncData[0].url).to.equal('https://cookie.lmgssp.com/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0'); + describe("getUserSyncs", function () { + it("derives image and iframe sync URLs from the Lunamedia endpoint", function () { + const syncs = spec.getUserSyncs( + { + iframeEnabled: true, + pixelEnabled: true, + }, + [], + { + gdprApplies: true, + consentString: "gdpr consent", + }, + "1YA-", + { + gppString: "gpp consent", + applicableSections: [8, 9], + } + ); + + expect(syncs).to.deep.equal([ + { + type: "image", + url: "https://lunamedia.bid/prebid/sync?us_privacy=1YA-&gdpr=1&gdpr_consent=gdpr%20consent&gpp=gpp%20consent&gpp_sid=8%2C9", + }, + { + type: "iframe", + url: "https://lunamedia.bid/prebid/cli/iframe.html?us_privacy=1YA-&gdpr=1&gdpr_consent=gdpr%20consent&gpp=gpp%20consent&gpp_sid=8%2C9", + }, + ]); }); }); });