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

Removing legacy partner code #3

Merged
merged 1 commit into from
Mar 3, 2022
Merged
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
25 changes: 1 addition & 24 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -172,28 +172,6 @@ export const spec = {
return spec._getCrbFromCookie();
},

_getKruxUserId() {
return spec._getLocalStorageSafely('kxkar_user');
},

_getKruxSegments() {
return spec._getLocalStorageSafely('kxkar_segs');
},

_getKrux() {
const segmentsStr = spec._getKruxSegments();
let segments = [];

if (segmentsStr) {
segments = segmentsStr.split(',');
}

return {
userID: spec._getKruxUserId(),
segments: segments
};
},

_getLocalStorageSafely(key) {
try {
return storage.getDataFromLocalStorage(key);
@@ -205,7 +183,7 @@ export const spec = {
_getUserIds(tdid, usp, gdpr) {
const crb = spec._getCrb();
const userIds = {
kargoID: crb.userId,
kargoID: crb.lexId,
clientID: crb.clientId,
crbIDs: crb.syncIds || {},
optOut: crb.optOut,
@@ -235,7 +213,6 @@ export const spec = {
_getAllMetadata(tdid, usp, gdpr) {
return {
userIDs: spec._getUserIds(tdid, usp, gdpr),
krux: spec._getKrux(),
pageURL: window.location.href,
rawCRB: spec._readCookie('krg_crb'),
rawCRBLocalStorage: spec._getLocalStorageSafely('krg_crb')
87 changes: 19 additions & 68 deletions test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -149,20 +149,12 @@ describe('kargo adapter tests', function () {
};
}

function initializeKruxUser() {
setLocalStorageItem('kxkar_user', 'rsgr9pnij');
}

function initializeKruxSegments() {
setLocalStorageItem('kxkar_segs', 'qv9v984dy,rpx2gy365,qrd5u4axv,rnub9nmtd,reha00jnu');
}

function get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LCIyMyI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjI0IjoiVm94SWs4QW9KejBBQUVkQ2V5QUFBQUMyJjUwMiIsIjI1IjoiNWVlMjQxMzgtNWUwMy00YjlkLWE5NTMtMzhlODMzZjI4NDlmIiwiMl84MCI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjJfOTMiOiI1ZWUyNDEzOC01ZTAzLTRiOWQtYTk1My0zOGU4MzNmMjg0OWYifSwibGV4SWQiOiI1ZjEwODgzMS0zMDJkLTExZTctYmY2Yi00NTk1YWNkM2JmNmMiLCJjbGllbnRJZCI6IjI0MTBkOGYyLWMxMTEtNDgxMS04OGE1LTdiNWUxOTBlNDc1ZiIsIm9wdE91dCI6ZmFsc2UsImV4cGlyZVRpbWUiOjE0OTc0NDkzODI2NjgsImxhc3RTeW5jZWRBdCI6MTQ5NzM2Mjk3OTAxMn0=%22%7D';
}

function initializeKrgCrb(cookieOnly) {
@@ -236,7 +228,7 @@ describe('kargo adapter tests', function () {
return spec._getSessionId();
}

function getExpectedKrakenParams(excludeUserIds, excludeKrux, expectedRawCRB, expectedRawCRBCookie, expectedGDPR) {
function getExpectedKrakenParams(excludeUserIds, expectedRawCRB, expectedRawCRBCookie, expectedGDPR) {
var base = {
timeout: 200,
requestCount: requestCount++,
@@ -273,16 +265,6 @@ describe('kargo adapter tests', function () {
optOut: false,
usp: '1---'
},
krux: {
userID: 'rsgr9pnij',
segments: [
'qv9v984dy',
'rpx2gy365',
'qrd5u4axv',
'rnub9nmtd',
'reha00jnu'
]
},
pageURL: window.location.href,
prebidRawBidRequests: [
{
@@ -326,13 +308,6 @@ describe('kargo adapter tests', function () {
delete base.prebidRawBidRequests[0].userId.tdid;
}

if (excludeKrux) {
base.krux = {
userID: null,
segments: []
};
}

return base;
}

@@ -367,101 +342,77 @@ describe('kargo adapter tests', function () {
}

it('works when all params and localstorage and cookies are correctly set', function() {
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb();
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle()));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle()));
});

it('works when all params and cookies are correctly set but no localstorage', function() {
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb(true);
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, null, getKrgCrbOldStyle()));
testBuildRequests(false, getExpectedKrakenParams(undefined, null, getKrgCrbOldStyle()));
});

it('gracefully handles nothing being set', function() {
testBuildRequests(true, getExpectedKrakenParams(true, true, null, null));
testBuildRequests(true, getExpectedKrakenParams(true, null, null));
});

it('gracefully handles browsers without localStorage', function() {
simulateNoLocalStorage();
testBuildRequests(true, getExpectedKrakenParams(true, true, null, null));
testBuildRequests(true, getExpectedKrakenParams(true, null, null));
});

it('handles empty yet valid Kargo CRB', function() {
initializeKruxUser();
initializeKruxSegments();
initializeEmptyKrgCrb();
initializeEmptyKrgCrbCookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, getEmptyKrgCrb(), getEmptyKrgCrbOldStyle()));
testBuildRequests(true, getExpectedKrakenParams(true, getEmptyKrgCrb(), getEmptyKrgCrbOldStyle()));
});

it('handles broken Kargo CRBs where base64 encoding is invalid', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType1();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, getInvalidKrgCrbType1(), null));
testBuildRequests(true, getExpectedKrakenParams(true, getInvalidKrgCrbType1(), null));
});

it('handles broken Kargo CRBs where top level JSON is invalid on cookie', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType1Cookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType1()));
testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType1()));
});

it('handles broken Kargo CRBs where decoded JSON is invalid', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType2();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, getInvalidKrgCrbType2(), null));
testBuildRequests(true, getExpectedKrakenParams(true, getInvalidKrgCrbType2(), null));
});

it('handles broken Kargo CRBs where inner base 64 is invalid on cookie', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType2Cookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType2OldStyle()));
testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType2OldStyle()));
});

it('handles broken Kargo CRBs where inner JSON is invalid on cookie', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType3Cookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType3OldStyle()));
testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType3OldStyle()));
});

it('handles broken Kargo CRBs where inner JSON is falsey', function() {
initializeKruxUser();
initializeKruxSegments();
initializeInvalidKrgCrbType4Cookie();
testBuildRequests(true, getExpectedKrakenParams(true, undefined, null, getInvalidKrgCrbType4OldStyle()));
testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType4OldStyle()));
});

it('handles a non-existant currency object on the config', function() {
simulateNoCurrencyObject();
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb();
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle()));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle()));
});

it('handles no ad server currency being set on the currency object in the config', function() {
simulateNoAdServerCurrency();
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb();
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle()));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle()));
});

it('sends gdpr consent', function () {
initializeKruxUser();
initializeKruxSegments();
initializeKrgCrb();
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(true, true)), generateGDPR(true, true));
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, true)), generateGDPR(false, true));
testBuildRequests(false, getExpectedKrakenParams(undefined, undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, false)), generateGDPR(false, false));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(true, true)), generateGDPR(true, true));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, true)), generateGDPR(false, true));
testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, false)), generateGDPR(false, false));
});
});