Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData

import java.time.Instant

import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST
import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED
import static org.prebid.server.functional.model.config.DataActivity.CONSENT
import static org.prebid.server.functional.model.config.DataActivity.NOTICE_NOT_PROVIDED
Expand Down Expand Up @@ -825,8 +824,11 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec {
new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)]
}

def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() {
given: "Generic BidRequest with gpp and account setup"
def "PBS auction call when custom privacy regulation empty and normalize is disabled should process request and emit error log"() {
given: "Test start time"
def startTime = Instant.now()

and: "Generic BidRequest with gpp and account setup"
def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build()
def accountId = PBSUtils.randomNumber as String
def bidRequest = BidRequest.defaultBidRequest.tap {
Expand Down Expand Up @@ -860,14 +862,16 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec {
when: "PBS processes auction requests"
activityPbsService.sendAuctionRequest(bidRequest)

then: "Response should contain error"
def error = thrown(PrebidServerException)
assert error.statusCode == BAD_REQUEST.code()
assert error.responseBody == "JsonLogic exception: objects must have exactly 1 key defined, found 0"
then: "Generic bidder should be called due to positive allow in activities"
assert bidder.getBidderRequest(bidRequest.id)

and: "Metrics for disallowed activities should be updated"
def metrics = activityPbsService.sendCollectedMetricsRequest()
assert metrics[ALERT_GENERAL] == 1

and: "Logs should contain error"
def logs = activityPbsService.getLogsByTime(startTime)
assert getLogsByText(logs, "USCustomLogic creation failed: objects must have exactly 1 key defined, found 0").size() == 1
}

def "PBS auction call when custom privacy regulation with normalizing should ignore call to bidder"() {
Expand Down Expand Up @@ -1571,8 +1575,11 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec {
new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)]
}

def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() {
given: "Store bid request with gpp string and link for account"
def "PBS amp call when custom privacy regulation empty and normalize is disabled should process request and emit error log"() {
given: "Test start time"
def startTime = Instant.now()

and: "Store bid request with gpp string and link for account"
def accountId = PBSUtils.randomNumber as String
def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build()
def ampStoredRequest = BidRequest.defaultBidRequest.tap {
Expand Down Expand Up @@ -1615,15 +1622,16 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec {
when: "PBS processes amp requests"
activityPbsService.sendAmpRequest(ampRequest)

then: "Response should contain error"
def error = thrown(PrebidServerException)
assert error.statusCode == BAD_REQUEST.code()
assert error.responseBody == "Invalid account configuration: JsonLogic exception: " +
"objects must have exactly 1 key defined, found 0"
then: "Generic bidder should be called"
assert bidder.getBidderRequests(ampStoredRequest.id)

and: "Metrics for disallowed activities should be updated"
def metrics = activityPbsService.sendCollectedMetricsRequest()
assert metrics[ALERT_GENERAL] == 1

and: "Logs should contain error"
def logs = activityPbsService.getLogsByTime(startTime)
assert getLogsByText(logs, "USCustomLogic creation failed: objects must have exactly 1 key defined, found 0").size() == 1
}

def "PBS amp call when custom privacy regulation with normalizing should ignore call to bidder"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData

import java.time.Instant

import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST
import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED
import static org.prebid.server.functional.model.config.DataActivity.CONSENT
import static org.prebid.server.functional.model.config.DataActivity.NOTICE_NOT_PROVIDED
Expand Down Expand Up @@ -1528,8 +1527,11 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec {
new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)]
}

def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() {
given: "Generic BidRequest with gpp and account setup"
def "PBS auction call when custom privacy regulation empty and normalize is disabled should not round lat/lon data and emit error log"() {
given: "Test start time"
def startTime = Instant.now()

and: "Generic BidRequest with gpp and account setup"
def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build()
def accountId = PBSUtils.randomNumber as String
def bidRequest = bidRequestWithGeo.tap {
Expand Down Expand Up @@ -1565,14 +1567,38 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec {
when: "PBS processes auction requests"
activityPbsService.sendAuctionRequest(bidRequest)

then: "Response should contain error"
def error = thrown(PrebidServerException)
assert error.statusCode == BAD_REQUEST.code()
assert error.responseBody == "JsonLogic exception: objects must have exactly 1 key defined, found 0"
then: "Bidder request should contain not rounded geo data for device and user"
def bidderRequests = bidder.getBidderRequest(bidRequest.id)
def deviceBidderRequest = bidderRequests.device
verifyAll {
deviceBidderRequest.ip == bidRequest.device.ip
deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::"
deviceBidderRequest.geo.lat == bidRequest.device.geo.lat
deviceBidderRequest.geo.lon == bidRequest.device.geo.lon
deviceBidderRequest.geo.country == bidRequest.device.geo.country
deviceBidderRequest.geo.region == bidRequest.device.geo.region
deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset
deviceBidderRequest.geo.metro == bidRequest.device.geo.metro
deviceBidderRequest.geo.city == bidRequest.device.geo.city
deviceBidderRequest.geo.zip == bidRequest.device.geo.zip
deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy
deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice
deviceBidderRequest.geo.ext == bidRequest.device.geo.ext
}

and: "Bidder request user.geo.{lat,lon} shouldn't mask"
verifyAll {
bidderRequests.user.geo.lat == bidRequest.user.geo.lat
bidderRequests.user.geo.lon == bidRequest.user.geo.lon
}

and: "Metrics for disallowed activities should be updated"
def metrics = activityPbsService.sendCollectedMetricsRequest()
assert metrics[ALERT_GENERAL] == 1

and: "Logs should contain error"
def logs = activityPbsService.getLogsByTime(startTime)
assert getLogsByText(logs, "USCustomLogic creation failed: objects must have exactly 1 key defined, found 0").size() == 1
}

def "PBS auction call when custom privacy regulation with normalizing should change request consent and call to bidder"() {
Expand Down Expand Up @@ -2810,8 +2836,11 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec {
new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)]
}

def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() {
given: "Store bid request with gpp string and link for account"
def "PBS amp call when custom privacy regulation empty and normalize is disabled should not round lat/lon data and emit error log"() {
given: "Test start time"
def startTime = Instant.now()

and: "Store bid request with gpp string and link for account"
def accountId = PBSUtils.randomNumber as String
def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build()
def ampStoredRequest = bidRequestWithGeo.tap {
Expand Down Expand Up @@ -2854,15 +2883,38 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec {
when: "PBS processes amp requests"
activityPbsService.sendAmpRequest(ampRequest)

then: "Response should contain error"
def error = thrown(PrebidServerException)
assert error.statusCode == BAD_REQUEST.code()
assert error.responseBody == "Invalid account configuration: JsonLogic exception: " +
"objects must have exactly 1 key defined, found 0"
then: "Bidder request should contain not rounded geo data for device and user"
def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id)
def deviceBidderRequest = bidderRequests.device
verifyAll {
deviceBidderRequest.ip == ampStoredRequest.device.ip
deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::"
deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat
deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon
deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country
deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region
deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset
deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro
deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city
deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip
deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy
deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice
deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext
}

and: "Bidder request user.geo.{lat,lon} shouldn't mask"
verifyAll {
bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat
bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon
}

and: "Metrics for disallowed activities should be updated"
def metrics = activityPbsService.sendCollectedMetricsRequest()
assert metrics[ALERT_GENERAL] == 1

and: "Logs should contain error"
def logs = activityPbsService.getLogsByTime(startTime)
assert getLogsByText(logs, "USCustomLogic creation failed: objects must have exactly 1 key defined, found 0").size() == 1
}

def "PBS amp call when custom privacy regulation with normalizing should change request consent and call to bidder"() {
Expand Down
Loading