Skip to content

Commit

Permalink
Tests for validation amp request
Browse files Browse the repository at this point in the history
  • Loading branch information
mtuchkova committed Dec 22, 2021
1 parent 90baabe commit f410de7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AmpRequest {
String slot
String curl
Integer account
ConsentString gdprConsent
String gdprConsent
String targeting
Integer consentType
Boolean gdprApplies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import org.prebid.server.functional.model.config.AccountConfig
import org.prebid.server.functional.model.config.AccountPrivacyConfig
import org.prebid.server.functional.model.db.Account
import org.prebid.server.functional.model.db.StoredRequest
import org.prebid.server.functional.model.request.amp.AmpRequest
import org.prebid.server.functional.model.request.auction.BidRequest
import org.prebid.server.functional.testcontainers.PBSTest
import org.prebid.server.functional.util.privacy.BogusConsent
import org.prebid.server.functional.util.privacy.CcpaConsent
Expand Down Expand Up @@ -177,10 +179,7 @@ class CcpaSpec extends PrivacyBaseSpec {
when: "PBS processes amp request"
def response = defaultPbsService.sendAmpRequest(ampRequest)

then: "Response should not contain error"
assert !response.ext?.errors

and: "Response should contain debug log with error"
then: "Response should contain debug log with error"
assert response.ext?.debug?.privacy
def privacy = response.ext?.debug?.privacy

Expand All @@ -194,4 +193,23 @@ class CcpaSpec extends PrivacyBaseSpec {
["Amp request parameter consent_string or gdpr_consent have invalid format: $invalidCcpa" as String]
}
}

def "PBS should not emit error for amp request when gdpr_consent contains invalid ccpa consent"() {
given: "Default AmpRequest with invalid ccpa consent"
def invalidCcpa = new BogusConsent()
def ampRequest = getCcpaAmpRequest(invalidCcpa)
def ampStoredRequest = BidRequest.defaultBidRequest.tap {
site.publisher.id = ampRequest.account
}

and: "Save storedRequest into DB"
def storedRequest = StoredRequest.getDbStoredRequest(ampRequest, ampStoredRequest)
storedRequestDao.save(storedRequest)

when: "PBS processes amp request"
def response = defaultPbsService.sendAmpRequest(ampRequest)

then: "Response should not contain error"
assert !response.ext?.errors
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.prebid.server.functional.tests.privacy

import org.prebid.server.functional.model.bidder.BidderName
import org.prebid.server.functional.model.db.StoredRequest
import org.prebid.server.functional.model.request.amp.AmpRequest
import org.prebid.server.functional.model.request.auction.BidRequest
import org.prebid.server.functional.testcontainers.PBSTest
import org.prebid.server.functional.util.privacy.BogusConsent
import org.prebid.server.functional.util.privacy.TcfConsent
Expand Down Expand Up @@ -141,10 +143,7 @@ class GdprSpec extends PrivacyBaseSpec {
when: "PBS processes amp request"
def response = defaultPbsService.sendAmpRequest(ampRequest)

then: "Response should not contain ext.errors"
assert !response.ext?.errors

and: "Response should contain debug log with error"
then: "Response should contain debug log with error"
assert response.ext?.debug?.privacy
def privacy = response.ext?.debug?.privacy

Expand All @@ -164,4 +163,27 @@ class GdprSpec extends PrivacyBaseSpec {
" $invalidConsentString" as String]
}
}

def "PBS should not emit error for amp request when gdpr_consent is #description"() {
given: "Default AmpRequest"
def ampRequest = AmpRequest.defaultAmpRequest
def ampStoredRequest = BidRequest.defaultBidRequest.tap {
site.publisher.id = ampRequest.account
}

and: "Save storedRequest into DB"
def storedRequest = StoredRequest.getDbStoredRequest(ampRequest, ampStoredRequest)
storedRequestDao.save(storedRequest)

when: "PBS processes amp request"
def response = defaultPbsService.sendAmpRequest(ampRequest)

then: "Response should not contain error"
assert !response.ext?.errors

where:
description | request
"not specified" | AmpRequest.defaultAmpRequest
"invalid tcf consent" | getGdprAmpRequest(new BogusConsent())
}
}

0 comments on commit f410de7

Please sign in to comment.