Skip to content

Commit 45c3609

Browse files
authored
Tests: Fix invalid GPP tests (#3965)
1 parent 0a44f3b commit 45c3609

2 files changed

Lines changed: 88 additions & 28 deletions

File tree

src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData
3030

3131
import java.time.Instant
3232

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

828-
def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() {
829-
given: "Generic BidRequest with gpp and account setup"
827+
def "PBS auction call when custom privacy regulation empty and normalize is disabled should process request and emit error log"() {
828+
given: "Test start time"
829+
def startTime = Instant.now()
830+
831+
and: "Generic BidRequest with gpp and account setup"
830832
def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build()
831833
def accountId = PBSUtils.randomNumber as String
832834
def bidRequest = BidRequest.defaultBidRequest.tap {
@@ -860,14 +862,16 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec {
860862
when: "PBS processes auction requests"
861863
activityPbsService.sendAuctionRequest(bidRequest)
862864

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

868868
and: "Metrics for disallowed activities should be updated"
869869
def metrics = activityPbsService.sendCollectedMetricsRequest()
870870
assert metrics[ALERT_GENERAL] == 1
871+
872+
and: "Logs should contain error"
873+
def logs = activityPbsService.getLogsByTime(startTime)
874+
assert getLogsByText(logs, "USCustomLogic creation failed: objects must have exactly 1 key defined, found 0").size() == 1
871875
}
872876

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

1574-
def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() {
1575-
given: "Store bid request with gpp string and link for account"
1578+
def "PBS amp call when custom privacy regulation empty and normalize is disabled should process request and emit error log"() {
1579+
given: "Test start time"
1580+
def startTime = Instant.now()
1581+
1582+
and: "Store bid request with gpp string and link for account"
15761583
def accountId = PBSUtils.randomNumber as String
15771584
def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build()
15781585
def ampStoredRequest = BidRequest.defaultBidRequest.tap {
@@ -1615,15 +1622,16 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec {
16151622
when: "PBS processes amp requests"
16161623
activityPbsService.sendAmpRequest(ampRequest)
16171624

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

16241628
and: "Metrics for disallowed activities should be updated"
16251629
def metrics = activityPbsService.sendCollectedMetricsRequest()
16261630
assert metrics[ALERT_GENERAL] == 1
1631+
1632+
and: "Logs should contain error"
1633+
def logs = activityPbsService.getLogsByTime(startTime)
1634+
assert getLogsByText(logs, "USCustomLogic creation failed: objects must have exactly 1 key defined, found 0").size() == 1
16271635
}
16281636

16291637
def "PBS amp call when custom privacy regulation with normalizing should ignore call to bidder"() {

src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData
2828

2929
import java.time.Instant
3030

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

1531-
def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() {
1532-
given: "Generic BidRequest with gpp and account setup"
1530+
def "PBS auction call when custom privacy regulation empty and normalize is disabled should not round lat/lon data and emit error log"() {
1531+
given: "Test start time"
1532+
def startTime = Instant.now()
1533+
1534+
and: "Generic BidRequest with gpp and account setup"
15331535
def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build()
15341536
def accountId = PBSUtils.randomNumber as String
15351537
def bidRequest = bidRequestWithGeo.tap {
@@ -1565,14 +1567,38 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec {
15651567
when: "PBS processes auction requests"
15661568
activityPbsService.sendAuctionRequest(bidRequest)
15671569

1568-
then: "Response should contain error"
1569-
def error = thrown(PrebidServerException)
1570-
assert error.statusCode == BAD_REQUEST.code()
1571-
assert error.responseBody == "JsonLogic exception: objects must have exactly 1 key defined, found 0"
1570+
then: "Bidder request should contain not rounded geo data for device and user"
1571+
def bidderRequests = bidder.getBidderRequest(bidRequest.id)
1572+
def deviceBidderRequest = bidderRequests.device
1573+
verifyAll {
1574+
deviceBidderRequest.ip == bidRequest.device.ip
1575+
deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::"
1576+
deviceBidderRequest.geo.lat == bidRequest.device.geo.lat
1577+
deviceBidderRequest.geo.lon == bidRequest.device.geo.lon
1578+
deviceBidderRequest.geo.country == bidRequest.device.geo.country
1579+
deviceBidderRequest.geo.region == bidRequest.device.geo.region
1580+
deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset
1581+
deviceBidderRequest.geo.metro == bidRequest.device.geo.metro
1582+
deviceBidderRequest.geo.city == bidRequest.device.geo.city
1583+
deviceBidderRequest.geo.zip == bidRequest.device.geo.zip
1584+
deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy
1585+
deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice
1586+
deviceBidderRequest.geo.ext == bidRequest.device.geo.ext
1587+
}
1588+
1589+
and: "Bidder request user.geo.{lat,lon} shouldn't mask"
1590+
verifyAll {
1591+
bidderRequests.user.geo.lat == bidRequest.user.geo.lat
1592+
bidderRequests.user.geo.lon == bidRequest.user.geo.lon
1593+
}
15721594

15731595
and: "Metrics for disallowed activities should be updated"
15741596
def metrics = activityPbsService.sendCollectedMetricsRequest()
15751597
assert metrics[ALERT_GENERAL] == 1
1598+
1599+
and: "Logs should contain error"
1600+
def logs = activityPbsService.getLogsByTime(startTime)
1601+
assert getLogsByText(logs, "USCustomLogic creation failed: objects must have exactly 1 key defined, found 0").size() == 1
15761602
}
15771603

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

2813-
def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() {
2814-
given: "Store bid request with gpp string and link for account"
2839+
def "PBS amp call when custom privacy regulation empty and normalize is disabled should not round lat/lon data and emit error log"() {
2840+
given: "Test start time"
2841+
def startTime = Instant.now()
2842+
2843+
and: "Store bid request with gpp string and link for account"
28152844
def accountId = PBSUtils.randomNumber as String
28162845
def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build()
28172846
def ampStoredRequest = bidRequestWithGeo.tap {
@@ -2854,15 +2883,38 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec {
28542883
when: "PBS processes amp requests"
28552884
activityPbsService.sendAmpRequest(ampRequest)
28562885

2857-
then: "Response should contain error"
2858-
def error = thrown(PrebidServerException)
2859-
assert error.statusCode == BAD_REQUEST.code()
2860-
assert error.responseBody == "Invalid account configuration: JsonLogic exception: " +
2861-
"objects must have exactly 1 key defined, found 0"
2886+
then: "Bidder request should contain not rounded geo data for device and user"
2887+
def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id)
2888+
def deviceBidderRequest = bidderRequests.device
2889+
verifyAll {
2890+
deviceBidderRequest.ip == ampStoredRequest.device.ip
2891+
deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::"
2892+
deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat
2893+
deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon
2894+
deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country
2895+
deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region
2896+
deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset
2897+
deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro
2898+
deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city
2899+
deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip
2900+
deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy
2901+
deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice
2902+
deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext
2903+
}
2904+
2905+
and: "Bidder request user.geo.{lat,lon} shouldn't mask"
2906+
verifyAll {
2907+
bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat
2908+
bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon
2909+
}
28622910

28632911
and: "Metrics for disallowed activities should be updated"
28642912
def metrics = activityPbsService.sendCollectedMetricsRequest()
28652913
assert metrics[ALERT_GENERAL] == 1
2914+
2915+
and: "Logs should contain error"
2916+
def logs = activityPbsService.getLogsByTime(startTime)
2917+
assert getLogsByText(logs, "USCustomLogic creation failed: objects must have exactly 1 key defined, found 0").size() == 1
28662918
}
28672919

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

0 commit comments

Comments
 (0)