Skip to content

Commit

Permalink
Rename integration to channel in account config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtuchkova committed Nov 29, 2021
1 parent b9cac43 commit 459e658
Show file tree
Hide file tree
Showing 15 changed files with 603 additions and 140 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.functional.model.config
package org.prebid.server.functional.model

import com.fasterxml.jackson.annotation.JsonValue

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.prebid.server.functional.model.config

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.PropertyNamingStrategies
import com.fasterxml.jackson.databind.annotation.JsonNaming
import groovy.transform.ToString
import org.prebid.server.functional.model.ChannelType

@ToString(includeNames = true, ignoreNulls = true)
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy)
class AccountCcpaConfig {

Boolean enabled
@JsonProperty("channel-enabled")
Map<ChannelType, Boolean> enabledForRequestType
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package org.prebid.server.functional.model.config

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.PropertyNamingStrategies
import com.fasterxml.jackson.databind.annotation.JsonNaming
import groovy.transform.ToString
import org.prebid.server.functional.model.ChannelType

@ToString(includeNames = true, ignoreNulls = true)
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy)
class AccountGdprConfig {

Boolean enabled
@JsonProperty("channel-enabled")
Map<ChannelType, Boolean> enabledForRequestType
Map<Purpose, PurposeConfig> purposes
Map<SpecialFeature, SpecialFeatureConfig> specialFeatures
Expand Down
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 @@ -22,6 +22,9 @@ class App {
String keywords

static App getDefaultApp() {
new App(id: PBSUtils.randomString)
new App().tap {
id = PBSUtils.randomString
publisher = Publisher.defaultPublisher
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package org.prebid.server.functional.model.request.auction
import com.fasterxml.jackson.annotation.JsonIgnore
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
import org.prebid.server.functional.model.ChannelType

import static org.prebid.server.functional.model.ChannelType.APP
import static org.prebid.server.functional.model.ChannelType.WEB

@EqualsAndHashCode
@ToString(includeNames = true, ignoreNulls = true)
Expand All @@ -29,14 +33,19 @@ class BidRequest {
Regs regs
BidRequestExt ext

static BidRequest getDefaultBidRequest() {
static BidRequest getDefaultBidRequest(ChannelType channelType = WEB) {
new BidRequest().tap {
it.addImp(Imp.defaultImpression)
regs = Regs.defaultRegs
id = UUID.randomUUID()
tmax = 2500
site = Site.defaultSite
ext = new BidRequestExt(prebid: new Prebid(debug: 1))
if (channelType == WEB) {
site = Site.defaultSite
}
if (channelType == APP) {
app = App.defaultApp
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.prebid.server.functional.model.request.auction

import groovy.transform.ToString
import org.prebid.server.functional.model.ChannelType

@ToString(includeNames = true, ignoreNulls = true)
class Channel {

String name
ChannelType name
String version
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import org.prebid.server.functional.util.privacy.ConsentString
@ToString(includeNames = true, ignoreNulls = true)
class UserExt {

ConsentString consent
String consent
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.prebid.server.functional.testcontainers.container

import org.prebid.server.functional.testcontainers.Dependencies
import org.prebid.server.functional.util.privacy.TcfConsent
import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.MySQLContainer
import org.testcontainers.containers.wait.strategy.Wait

import static org.prebid.server.functional.util.privacy.TcfConsent.RUBICON_VENDOR_ID

class PrebidServerContainer extends GenericContainer<PrebidServerContainer> {

public static final int PORT = 8080
Expand Down Expand Up @@ -114,9 +117,10 @@ LIMIT 1

void withBidder(String host) {
withConfig(["adapters.generic.enabled" : "true",
"adapters.generic.endpoint" : "$host/auction".toString(),
"adapters.generic.usersync.url" : "$host/generic-usersync".toString(),
"adapters.generic.usersync.type": "redirect"
"adapters.generic.endpoint" : "$host/auction" as String,
"adapters.generic.usersync.url" : "$host/generic-usersync" as String,
"adapters.generic.usersync.type": "redirect",
"adapters.generic.meta-info.vendor-id": RUBICON_VENDOR_ID as String
])
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package org.prebid.server.functional.tests.privacy

import org.prebid.server.functional.model.bidder.BidderName
import org.prebid.server.functional.model.config.AccountCcpaConfig
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.testcontainers.PBSTest
import org.prebid.server.functional.util.privacy.BogusConsent
import org.prebid.server.functional.util.privacy.CcpaConsent
import spock.lang.PendingFeature
import spock.lang.Unroll

import static org.prebid.server.functional.model.ChannelType.AMP
import static org.prebid.server.functional.util.privacy.CcpaConsent.Signal.ENFORCED

@PBSTest
class CcpaAmpSpec extends PrivacyBaseSpec {

@PendingFeature
def "PBS should add debug log for amp request when valid ccpa was passed"() {
given: "Default AmpRequest"
def validCcpa = new CcpaConsent(explicitNotice: ENFORCED, optOutSale: ENFORCED)
def ampRequest = getCcpaAmpRequest(validCcpa)

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

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

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

verifyAll {
privacy.originPrivacy?.ccpa?.usPrivacy == validCcpa as String
privacy.resolvedPrivacy?.ccpa?.usPrivacy == validCcpa as String

!privacy.originPrivacy?.coppa?.coppa
!privacy.resolvedPrivacy?.coppa?.coppa

!privacy.originPrivacy?.tcf?.gdpr
!privacy.originPrivacy?.tcf?.tcfConsentString
!privacy.originPrivacy?.tcf?.tcfConsentVersion
!privacy.originPrivacy?.tcf?.inEea
!privacy.resolvedPrivacy?.tcf?.gdpr
!privacy.resolvedPrivacy?.tcf?.tcfConsentString
!privacy.resolvedPrivacy?.tcf?.tcfConsentVersion
!privacy.resolvedPrivacy?.tcf?.inEea

privacy.privacyActionsPerBidder[BidderName.GENERIC] ==
["Geolocation was masked in request to bidder according to CCPA policy."]

privacy.errors?.isEmpty()
}
}

@PendingFeature
def "PBS should add debug log for amp request when invalid ccpa was passed"() {
given: "Default AmpRequest"
def invalidCcpa = new BogusConsent()
def ampRequest = getCcpaAmpRequest(invalidCcpa)

and: "Save storedRequest into DB"
def ampStoredRequest = storedRequestWithGeo
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

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

verifyAll {
privacy.originPrivacy?.ccpa?.usPrivacy == invalidCcpa as String
privacy.resolvedPrivacy?.ccpa?.usPrivacy == invalidCcpa as String

privacy.privacyActionsPerBidder[BidderName.GENERIC].isEmpty()

privacy.errors ==
["Amp request parameter consent_string or gdpr_consent have invalid format: $invalidCcpa" as String]
}
}

@Unroll
def "PBS should apply ccpa when privacy.ccpa.channel-enabled.amp or privacy.ccpa.enabled = true in account config"() {
given: "Default AmpRequest"
def validCcpa = new CcpaConsent(explicitNotice: ENFORCED, optOutSale: ENFORCED)
def ampRequest = getCcpaAmpRequest(validCcpa)

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

and: "Save account config into DB"
def privacy = new AccountPrivacyConfig(ccpa: ccpaConfig)
def accountConfig = new AccountConfig(privacy: privacy)
def account = new Account(uuid: ampRequest.account, config: accountConfig)
accountDao.save(account)

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

then: "Bidder request should contain masked values"
def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id)
assert bidderRequests.device?.geo == maskGeo(ampStoredRequest)

where:
ccpaConfig << [new AccountCcpaConfig(enabled: false, enabledForRequestType: [(AMP): true]),
new AccountCcpaConfig(enabled: true)]
}

@Unroll
def "PBS should not apply ccpa when privacy.ccpa.channel-enabled.amp or privacy.ccpa.enabled = false in account config"() {
given: "Default AmpRequest"
def validCcpa = new CcpaConsent(explicitNotice: ENFORCED, optOutSale: ENFORCED)
def ampRequest = getCcpaAmpRequest(validCcpa)

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

and: "Save account config into DB"
def privacy = new AccountPrivacyConfig(ccpa: ccpaConfig)
def accountConfig = new AccountConfig(privacy: privacy)
def account = new Account(uuid: ampRequest.account, config: accountConfig)
accountDao.save(account)

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

then: "Bidder request should contain not masked values"
def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id)
assert bidderRequests.device?.geo?.lat == ampStoredRequest.device.geo.lat
assert bidderRequests.device?.geo?.lon == ampStoredRequest.device.geo.lon

where:
ccpaConfig << [new AccountCcpaConfig(enabled: true, enabledForRequestType: [(AMP): false]),
new AccountCcpaConfig(enabled: false)]
}
}
Loading

0 comments on commit 459e658

Please sign in to comment.