@@ -52,6 +52,18 @@ describe('ID5 ID System', function () {
52
52
'signature' : ID5_RESPONSE_SIGNATURE ,
53
53
'link_type' : ID5_RESPONSE_LINK_TYPE
54
54
} ;
55
+ const ALLOWED_ID5_VENDOR_DATA = {
56
+ purpose : {
57
+ consents : {
58
+ 1 : true
59
+ }
60
+ } ,
61
+ vendor : {
62
+ consents : {
63
+ 131 : true
64
+ }
65
+ }
66
+ }
55
67
56
68
function getId5FetchConfig ( storageName = ID5_STORAGE_NAME , storageType = 'html5' ) {
57
69
return {
@@ -205,6 +217,37 @@ describe('ID5 ID System', function () {
205
217
} ) ;
206
218
} ) ;
207
219
220
+ describe ( 'Check for valid consent' , function ( ) {
221
+ const dataConsentVals = [
222
+ [ { purpose : { consents : { 1 : false } } } , { vendor : { consents : { 131 : true } } } , ' no purpose consent' ] ,
223
+ [ { purpose : { consents : { 1 : true } } } , { vendor : { consents : { 131 : false } } } , ' no vendor consent' ] ,
224
+ [ { purpose : { consents : { 1 : false } } } , { vendor : { consents : { 131 : false } } } , ' no purpose and vendor consent' ] ,
225
+ [ { purpose : { consents : undefined } } , { vendor : { consents : { 131 : true } } } , ' undefined purpose consent' ] ,
226
+ [ { purpose : { consents : { 1 : false } } } , { vendor : { consents : undefined } } ] , ' undefined vendor consent' ,
227
+ [ undefined , { vendor : { consents : { 131 : true } } } , ' undefined purpose' ] ,
228
+ [ { purpose : { consents : { 1 : true } } } , { vendor : undefined } , ' undefined vendor' ] ,
229
+ [ { purpose : { consents : { 1 : true } } } , { vendor : { consents : { 31 : true } } } , ' incorrect vendor consent' ]
230
+ ] ;
231
+
232
+ dataConsentVals . forEach ( function ( [ purposeConsent , vendorConsent , caseName ] ) {
233
+ it ( 'should fail with invalid consent because of ' + caseName , function ( ) {
234
+ let dataConsent = {
235
+ gdprApplies : true ,
236
+ consentString : 'consentString' ,
237
+ vendorData : {
238
+ purposeConsent, vendorConsent
239
+ }
240
+ }
241
+ expect ( id5IdSubmodule . getId ( config ) ) . is . eq ( undefined ) ;
242
+ expect ( id5IdSubmodule . getId ( config , dataConsent ) ) . is . eq ( undefined ) ;
243
+
244
+ let cacheIdObject = 'cacheIdObject' ;
245
+ expect ( id5IdSubmodule . extendId ( config ) ) . is . eq ( undefined ) ;
246
+ expect ( id5IdSubmodule . extendId ( config , dataConsent , cacheIdObject ) ) . is . eq ( cacheIdObject ) ;
247
+ } ) ;
248
+ } ) ;
249
+ } ) ;
250
+
208
251
describe ( 'Xhr Requests from getId()' , function ( ) {
209
252
const responseHeader = { 'Content-Type' : 'application/json' } ;
210
253
@@ -248,7 +291,8 @@ describe('ID5 ID System', function () {
248
291
let xhrServerMock = new XhrServerMock ( sinon . createFakeServer ( ) )
249
292
let consentData = {
250
293
gdprApplies : true ,
251
- consentString : 'consentString'
294
+ consentString : 'consentString' ,
295
+ vendorData : ALLOWED_ID5_VENDOR_DATA
252
296
}
253
297
254
298
let submoduleResponse = callSubmoduleGetId ( getId5FetchConfig ( ) , consentData , undefined ) ;
@@ -297,7 +341,8 @@ describe('ID5 ID System', function () {
297
341
let xhrServerMock = new XhrServerMock ( sinon . createFakeServer ( ) )
298
342
let consentData = {
299
343
gdprApplies : true ,
300
- consentString : 'consentString'
344
+ consentString : 'consentString' ,
345
+ vendorData : ALLOWED_ID5_VENDOR_DATA
301
346
}
302
347
303
348
let submoduleResponse = callSubmoduleGetId ( getId5FetchConfig ( ) , consentData , undefined ) ;
0 commit comments