From 5494da34dd5936cc922e14b7170c35a0f4dc06cc Mon Sep 17 00:00:00 2001 From: mtuchkova Date: Fri, 22 Oct 2021 16:25:19 +0300 Subject: [PATCH] Timeout tests --- .../prebid/server/functional/AmpSpec.groovy | 2 +- .../server/functional/AuctionSpec.groovy | 121 +++++++++++++++++- .../server/functional/CookieSyncSpec.groovy | 34 +++++ .../prebid/server/functional/DebugSpec.groovy | 4 +- .../prebid/server/functional/EventSpec.groovy | 28 ++++ .../server/functional/HttpSettingsSpec.groovy | 10 +- .../server/functional/SetuidSpec.groovy | 35 +++++ .../prebid/server/functional/SmokeSpec.groovy | 11 +- .../server/functional/VtrackSpec.groovy | 27 ++++ .../{request/setuid => }/UidsCookie.groovy | 6 +- .../functional/model/db/StoredRequest.groovy | 7 +- .../model/request/auction/Prebid.groovy | 2 +- ...Request.groovy => StoredRequestExt.groovy} | 2 +- .../model/request/setuid/UidWithExpiry.groovy | 3 + .../response/setuid/SetuidResponse.groovy | 6 +- .../setuid/ZonedDateTimeDeserializer.groovy | 20 +++ .../service/PrebidServerService.groovy | 7 +- .../container/PrebidServerContainer.groovy | 2 +- 18 files changed, 303 insertions(+), 24 deletions(-) create mode 100644 src/test/groovy/org/prebid/server/functional/CookieSyncSpec.groovy create mode 100644 src/test/groovy/org/prebid/server/functional/EventSpec.groovy create mode 100644 src/test/groovy/org/prebid/server/functional/SetuidSpec.groovy create mode 100644 src/test/groovy/org/prebid/server/functional/VtrackSpec.groovy rename src/test/groovy/org/prebid/server/functional/model/{request/setuid => }/UidsCookie.groovy (71%) rename src/test/groovy/org/prebid/server/functional/model/request/auction/{StoredRequest.groovy => StoredRequestExt.groovy} (86%) create mode 100644 src/test/groovy/org/prebid/server/functional/model/response/setuid/ZonedDateTimeDeserializer.groovy diff --git a/src/test/groovy/org/prebid/server/functional/AmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/AmpSpec.groovy index e306f0801f0..e7782ca106c 100644 --- a/src/test/groovy/org/prebid/server/functional/AmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/AmpSpec.groovy @@ -113,7 +113,7 @@ class AmpSpec extends BaseSpec { } and: "Save storedRequest into DB" - def storedRequest = StoredRequest.getDbStoredRequest(ampRequest, ampStoredRequest) + def storedRequest = StoredRequest.getAmpDbStoredRequest(ampRequest, ampStoredRequest) storedRequestDao.save(storedRequest) when: "PBS processes amp request" diff --git a/src/test/groovy/org/prebid/server/functional/AuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/AuctionSpec.groovy index f08f9b70e4f..463ddba3a77 100644 --- a/src/test/groovy/org/prebid/server/functional/AuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/AuctionSpec.groovy @@ -1,13 +1,21 @@ package org.prebid.server.functional +import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.auction.BidRequest +import org.prebid.server.functional.model.request.auction.StoredRequestExt +import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.PBSUtils +import spock.lang.Shared import spock.lang.Unroll -import static org.prebid.server.functional.util.SystemProperties.PBS_VERSION - class AuctionSpec extends BaseSpec { + private static final int MAX_TIMEOUT = 5000 + private static final int DEFAULT_TIMEOUT = PBSUtils.getRandomNumber(1000, MAX_TIMEOUT) private static final String PBS_VERSION_HEADER = "pbs-java/$PBS_VERSION" + @Shared + PrebidServerService prebidServerService = pbsServiceFactory.getService(["auction.max-timeout-ms" : MAX_TIMEOUT as String, + "auction.default-timeout-ms": DEFAULT_TIMEOUT as String]) @Unroll def "PBS should return version in response header for auction request for #description"() { @@ -23,4 +31,113 @@ class AuctionSpec extends BaseSpec { BidRequest.defaultBidRequest || "valid bid request" new BidRequest() || "invalid bid request" } + + def "PBS should apply timeout from stored request when it's not specified in the auction request"() { + given: "Default basic BidRequest with generic bidder" + def bidRequest = BidRequest.defaultBidRequest.tap { + tmax = null + ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString()) + } + + and: "Default stored request with timeout" + def timeout = PBSUtils.getRandomNumber(0, MAX_TIMEOUT) + def storedRequestModel = BidRequest.defaultStoredRequest.tap { + tmax = timeout + } + + and: "Save storedRequest into DB" + def storedRequest = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequestModel) + storedRequestDao.save(storedRequest) + + when: "PBS processes auction request" + prebidServerService.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain timeout from the stored request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.tmax == timeout as Long + } + + @Unroll + def "PBS should prefer timeout from the auction request when stored request timeout is #tmax"() { + given: "Default basic BidRequest with generic bidder" + def timeout = PBSUtils.getRandomNumber(0, MAX_TIMEOUT) + def bidRequest = BidRequest.defaultBidRequest.tap { + tmax = timeout + ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString()) + } + + and: "Default stored request" + def storedRequestModel = BidRequest.defaultStoredRequest.tap { + it.tmax = tmaxStoredRequest + } + + and: "Save storedRequest into DB" + def storedRequest = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequestModel) + storedRequestDao.save(storedRequest) + + when: "PBS processes auction request" + prebidServerService.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain timeout from the request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.tmax == timeout as Long + + where: + tmaxStoredRequest << [null, PBSUtils.getRandomNumber(0, MAX_TIMEOUT)] + } + + @Unroll + def "PBS should honor max timeout from the settings for auction request"() { + given: "Default basic BidRequest with generic bidder" + def bidRequest = BidRequest.defaultBidRequest.tap { + tmax = autcionRequestTimeout + ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString()) + } + + and: "Default stored request" + def storedRequest = BidRequest.defaultStoredRequest.tap { + it.tmax = storedRequestTimeout + } + + and: "Save storedRequest into DB" + def storedRequestModel = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequest) + storedRequestDao.save(storedRequestModel) + + when: "PBS processes auction request" + prebidServerService.sendAuctionRequest(bidRequest) + + then: "Bidder request timeout should correspond to the maximum from the settings" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.tmax == MAX_TIMEOUT as Long + + where: + autcionRequestTimeout || storedRequestTimeout + MAX_TIMEOUT + 1 || null + null || MAX_TIMEOUT + 1 + MAX_TIMEOUT + 1 || MAX_TIMEOUT + 1 + } + + def "PBS should honor default timeout for auction request"() { + given: "Default basic BidRequest without timeout" + def bidRequest = BidRequest.defaultBidRequest.tap { + tmax = null + ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString()) + } + + and: "Default stored request without timeout" + def storedRequest = BidRequest.defaultStoredRequest.tap { + it.tmax = null + } + + and: "Save storedRequest into DB" + def storedRequestModel = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequest) + storedRequestDao.save(storedRequestModel) + + when: "PBS processes auction request" + prebidServerService.sendAuctionRequest(bidRequest) + + then: "Bidder request timeout should correspond to the maximum from the settings" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.tmax == DEFAULT_TIMEOUT as Long + } } diff --git a/src/test/groovy/org/prebid/server/functional/CookieSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/CookieSyncSpec.groovy new file mode 100644 index 00000000000..8241dd30121 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/CookieSyncSpec.groovy @@ -0,0 +1,34 @@ +package org.prebid.server.functional + +import org.prebid.server.functional.model.UidsCookie +import org.prebid.server.functional.model.db.Account +import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest +import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.PBSUtils +import spock.lang.PendingFeature + +class CookieSyncSpec extends BaseSpec { + + @PendingFeature + def "PBS should return an error for cookie_sync request when the timeout time is exceeded"() { + given: "PBS with timeout configuration" + def pbsService = pbsServiceFactory.getService(["cookie-sync.default-timeout-ms": "1"]) + + and: "Default CookieSyncRequest with account" + def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest + cookieSyncRequest.account = PBSUtils.randomNumber.toString() + def uidsCookie = UidsCookie.defaultUidsCookie + + and: "Account in the DB" + def account = new Account(uuid: cookieSyncRequest.account, eventsEnabled: true) + accountDao.save(account) + + when: "PBS processes cookie sync request" + pbsService.sendCookieSyncRequest(cookieSyncRequest, uidsCookie) + + then: "Request should fail with error" + def exception = thrown(PrebidServerException) + assert exception.statusCode == 500 + assert exception.responseBody.contains("Timed out while executing SQL query") + } +} diff --git a/src/test/groovy/org/prebid/server/functional/DebugSpec.groovy b/src/test/groovy/org/prebid/server/functional/DebugSpec.groovy index 670a7302176..506504d7657 100644 --- a/src/test/groovy/org/prebid/server/functional/DebugSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/DebugSpec.groovy @@ -262,7 +262,7 @@ class DebugSpec extends BaseSpec { } and: "Save storedRequest into DB" - def storedRequest = StoredRequest.getDbStoredRequest(ampRequest, ampStoredRequest) + def storedRequest = StoredRequest.getAmpDbStoredRequest(ampRequest, ampStoredRequest) storedRequestDao.save(storedRequest) when: "PBS processes amp request" @@ -292,7 +292,7 @@ class DebugSpec extends BaseSpec { } and: "Save storedRequest into DB" - def storedRequest = StoredRequest.getDbStoredRequest(ampRequest, ampStoredRequest) + def storedRequest = StoredRequest.getAmpDbStoredRequest(ampRequest, ampStoredRequest) storedRequestDao.save(storedRequest) when: "PBS processes amp request" diff --git a/src/test/groovy/org/prebid/server/functional/EventSpec.groovy b/src/test/groovy/org/prebid/server/functional/EventSpec.groovy new file mode 100644 index 00000000000..77fd156b6e1 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/EventSpec.groovy @@ -0,0 +1,28 @@ +package org.prebid.server.functional + +import org.prebid.server.functional.model.db.Account +import org.prebid.server.functional.model.request.event.EventRequest +import org.prebid.server.functional.service.PrebidServerException + +class EventSpec extends BaseSpec { + + def "PBS should return an error for event request when the timeout time is exceeded"() { + given: "PBS with timeout configuration" + def pbsService = pbsServiceFactory.getService(["event.default-timeout-ms": "1"]) + + and: "Default EventRequest" + def eventRequest = EventRequest.defaultEventRequest + + and: "Account in the DB" + def account = new Account(uuid: eventRequest.accountId, eventsEnabled: true) + accountDao.save(account) + + when: "PBS processes event request" + pbsService.sendEventRequest(eventRequest) + + then: "Request should fail with error" + def exception = thrown(PrebidServerException) + assert exception.statusCode == 500 + assert exception.responseBody.contains("Timed out while executing SQL query") + } +} diff --git a/src/test/groovy/org/prebid/server/functional/HttpSettingsSpec.groovy b/src/test/groovy/org/prebid/server/functional/HttpSettingsSpec.groovy index 47c607fc64c..9a996f4a6b9 100644 --- a/src/test/groovy/org/prebid/server/functional/HttpSettingsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/HttpSettingsSpec.groovy @@ -6,7 +6,7 @@ import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.event.EventRequest import org.prebid.server.functional.model.request.setuid.SetuidRequest -import org.prebid.server.functional.model.request.setuid.UidsCookie +import org.prebid.server.functional.model.UidsCookie import org.prebid.server.functional.model.request.vtrack.VtrackRequest import org.prebid.server.functional.model.request.vtrack.xml.Vast import org.prebid.server.functional.service.PrebidServerException @@ -63,7 +63,7 @@ class HttpSettingsSpec extends BaseSpec { ampStoredRequest.regs.ext.gdpr = 1 and: "Save storedRequest into DB" - def storedRequest = StoredRequest.getDbStoredRequest(ampRequest, ampStoredRequest) + def storedRequest = StoredRequest.getAmpDbStoredRequest(ampRequest, ampStoredRequest) storedRequestDao.save(storedRequest) and: "Prepare default account response with gdpr = 0" @@ -117,8 +117,10 @@ class HttpSettingsSpec extends BaseSpec { def response = prebidServerService.sendSetUidRequest(request, uidsCookie) then: "Response should contain uids cookie" - assert response.uidsCookie - assert !response.responseBody?.isEmpty() + assert response.uidsCookie.bday + assert !response.uidsCookie.tempUIDs + assert !response.uidsCookie.uids + assert response.responseBody == ResourceUtil.readByteArrayFromClassPath("org/prebid/server/functional/tracking-pixel.png") and: "There should be only one account request" assert httpSettings.getRequestCount(request.account) == 1 diff --git a/src/test/groovy/org/prebid/server/functional/SetuidSpec.groovy b/src/test/groovy/org/prebid/server/functional/SetuidSpec.groovy new file mode 100644 index 00000000000..7e8b96f98c1 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/SetuidSpec.groovy @@ -0,0 +1,35 @@ +package org.prebid.server.functional + +import org.prebid.server.functional.model.UidsCookie +import org.prebid.server.functional.model.db.Account +import org.prebid.server.functional.model.request.setuid.SetuidRequest +import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.PBSUtils +import spock.lang.PendingFeature + +class SetuidSpec extends BaseSpec { + + @PendingFeature + def "PBS should return an error for setuid request when the timeout time is exceeded"() { + given: "PBS with timeout configuration" + def pbsService = pbsServiceFactory.getService(["setuid.default-timeout-ms": "1"]) + + and: "Default setuid request with account" + def request = SetuidRequest.defaultSetuidRequest + def uidsCookie = UidsCookie.defaultUidsCookie + request.account = PBSUtils.randomNumber.toString() + + and: "Account in the DB" + def account = new Account(uuid: request.account, eventsEnabled: true) + accountDao.save(account) + + when: "PBS processes setuid request" + pbsService.sendSetUidRequest(request, uidsCookie) + + then: "Request should fail with error" + def exception = thrown(PrebidServerException) + assert exception.statusCode == 500 + assert exception.responseBody.contains("Timed out while executing SQL query") + + } +} diff --git a/src/test/groovy/org/prebid/server/functional/SmokeSpec.groovy b/src/test/groovy/org/prebid/server/functional/SmokeSpec.groovy index c6894e1e778..515d6fc8e30 100644 --- a/src/test/groovy/org/prebid/server/functional/SmokeSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/SmokeSpec.groovy @@ -8,7 +8,7 @@ import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest import org.prebid.server.functional.model.request.event.EventRequest import org.prebid.server.functional.model.request.logging.httpinteraction.HttpInteractionRequest import org.prebid.server.functional.model.request.setuid.SetuidRequest -import org.prebid.server.functional.model.request.setuid.UidsCookie +import org.prebid.server.functional.model.UidsCookie import org.prebid.server.functional.model.request.vtrack.VtrackRequest import org.prebid.server.functional.model.request.vtrack.xml.Vast import org.prebid.server.functional.model.response.cookiesync.CookieSyncResponse @@ -52,7 +52,7 @@ class SmokeSpec extends BaseSpec { ampStoredRequest.site.publisher.id = ampRequest.account and: "Save storedRequest into DB" - def storedRequest = StoredRequest.getDbStoredRequest(ampRequest, ampStoredRequest) + def storedRequest = StoredRequest.getAmpDbStoredRequest(ampRequest, ampStoredRequest) storedRequestDao.save(storedRequest) when: "PBS processes amp request" @@ -107,8 +107,11 @@ class SmokeSpec extends BaseSpec { def response = defaultPbsService.sendSetUidRequest(request, uidsCookie) then: "Response should contain uids cookie" - assert response.uidsCookie - assert !response.responseBody?.isEmpty() + assert response.uidsCookie.bday + assert !response.uidsCookie.tempUIDs + assert !response.uidsCookie.uids + assert response.responseBody == + ResourceUtil.readByteArrayFromClassPath("org/prebid/server/functional/tracking-pixel.png") } def "PBS should get uids cookie"() { diff --git a/src/test/groovy/org/prebid/server/functional/VtrackSpec.groovy b/src/test/groovy/org/prebid/server/functional/VtrackSpec.groovy new file mode 100644 index 00000000000..3192fcaf638 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/VtrackSpec.groovy @@ -0,0 +1,27 @@ +package org.prebid.server.functional + +import org.prebid.server.functional.model.request.vtrack.VtrackRequest +import org.prebid.server.functional.model.request.vtrack.xml.Vast +import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.PBSUtils + +class VtrackSpec extends BaseSpec { + + def "PBS should return an error for vtrack request when the timeout time is exceeded"() { + given: "PBS with timeout configuration" + def pbsService = pbsServiceFactory.getService(["vtrack.default-timeout-ms": "1"]) + + and: "Default VtrackRequest" + def payload = PBSUtils.randomNumber.toString() + def request = VtrackRequest.getDefaultVtrackRequest(mapper.encodeXml(Vast.getDefaultVastModel(payload))) + def accountId = PBSUtils.randomNumber.toString() + + when: "PBS processes vtrack request" + pbsService.sendVtrackRequest(request, accountId) + + then: "Request should fail with error" + def exception = thrown(PrebidServerException) + assert exception.statusCode == 500 + assert exception.responseBody.contains("Timed out while executing SQL query") + } +} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/setuid/UidsCookie.groovy b/src/test/groovy/org/prebid/server/functional/model/UidsCookie.groovy similarity index 71% rename from src/test/groovy/org/prebid/server/functional/model/request/setuid/UidsCookie.groovy rename to src/test/groovy/org/prebid/server/functional/model/UidsCookie.groovy index 4897eb7b672..46a8dd015f3 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/setuid/UidsCookie.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/UidsCookie.groovy @@ -1,7 +1,10 @@ -package org.prebid.server.functional.model.request.setuid +package org.prebid.server.functional.model import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.databind.annotation.JsonDeserialize import groovy.transform.ToString +import org.prebid.server.functional.model.request.setuid.UidWithExpiry +import org.prebid.server.functional.model.response.setuid.ZonedDateTimeDeserializer import java.time.Clock import java.time.ZonedDateTime @@ -13,6 +16,7 @@ class UidsCookie { Map tempUIDs Boolean optout @JsonFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss.SSS'Z'", timezone = "UTC") + @JsonDeserialize(using = ZonedDateTimeDeserializer) ZonedDateTime bday static UidsCookie getDefaultUidsCookie() { diff --git a/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy index 0b41da34e10..340c06f344e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy @@ -30,7 +30,12 @@ class StoredRequest { @Convert(converter = StoredRequestConfigTypeConverter) BidRequest requestData - static StoredRequest getDbStoredRequest(AmpRequest ampRequest, BidRequest bidRequest) { + static StoredRequest getAmpDbStoredRequest(AmpRequest ampRequest, BidRequest bidRequest) { new StoredRequest(reqid: ampRequest.tagId, accountId: ampRequest.account, requestData: bidRequest) } + + static StoredRequest getAuctionDbStoredRequest(BidRequest bidRequest, BidRequest storedRequest) { + new StoredRequest(reqid: bidRequest.ext.prebid.storedRequest.id, accountId: bidRequest.site.publisher.id, + requestData: storedRequest) + } } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Prebid.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Prebid.groovy index 515e760b5cc..0c9b7b330b6 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Prebid.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Prebid.groovy @@ -12,7 +12,7 @@ class Prebid { Integer debug Targeting targeting PrebidCache cache - StoredRequest storedRequest + StoredRequestExt storedRequest Amp amp Channel channel List schains diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/StoredRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/StoredRequestExt.groovy similarity index 86% rename from src/test/groovy/org/prebid/server/functional/model/request/auction/StoredRequest.groovy rename to src/test/groovy/org/prebid/server/functional/model/request/auction/StoredRequestExt.groovy index d392a3ab817..aae07df359e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/StoredRequest.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/StoredRequestExt.groovy @@ -3,7 +3,7 @@ package org.prebid.server.functional.model.request.auction import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) -class StoredRequest { +class StoredRequestExt { String id } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/setuid/UidWithExpiry.groovy b/src/test/groovy/org/prebid/server/functional/model/request/setuid/UidWithExpiry.groovy index 6cd6b83f689..d435dfa0d80 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/setuid/UidWithExpiry.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/setuid/UidWithExpiry.groovy @@ -1,7 +1,9 @@ package org.prebid.server.functional.model.request.setuid import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.databind.annotation.JsonDeserialize import groovy.transform.ToString +import org.prebid.server.functional.model.response.setuid.ZonedDateTimeDeserializer import java.time.ZonedDateTime @@ -10,5 +12,6 @@ class UidWithExpiry { String uid @JsonFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss.SSS'Z'", timezone = "UTC") + @JsonDeserialize(using = ZonedDateTimeDeserializer) ZonedDateTime expires } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/setuid/SetuidResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/response/setuid/SetuidResponse.groovy index 3bef4783280..b499891449c 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/setuid/SetuidResponse.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/setuid/SetuidResponse.groovy @@ -1,11 +1,11 @@ package org.prebid.server.functional.model.response.setuid import groovy.transform.ToString -import io.restassured.http.Cookie +import org.prebid.server.functional.model.UidsCookie @ToString(includeNames = true, ignoreNulls = true) class SetuidResponse { - Cookie uidsCookie - String responseBody + UidsCookie uidsCookie + Byte[] responseBody } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/setuid/ZonedDateTimeDeserializer.groovy b/src/test/groovy/org/prebid/server/functional/model/response/setuid/ZonedDateTimeDeserializer.groovy new file mode 100644 index 00000000000..4e0bdf91532 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/model/response/setuid/ZonedDateTimeDeserializer.groovy @@ -0,0 +1,20 @@ +package org.prebid.server.functional.model.response.setuid + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonDeserializer + +import java.time.LocalDate +import java.time.ZoneOffset +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter + +class ZonedDateTimeDeserializer extends JsonDeserializer { + + @Override + ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { + LocalDate localDate = LocalDate.parse(jsonParser.getText(), DateTimeFormatter.ISO_ZONED_DATE_TIME) + + localDate.atStartOfDay(ZoneOffset.UTC) + } +} diff --git a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy index 32e2db11e72..1e3db84a859 100644 --- a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy +++ b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy @@ -14,7 +14,7 @@ import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest import org.prebid.server.functional.model.request.event.EventRequest import org.prebid.server.functional.model.request.logging.httpinteraction.HttpInteractionRequest import org.prebid.server.functional.model.request.setuid.SetuidRequest -import org.prebid.server.functional.model.request.setuid.UidsCookie +import org.prebid.server.functional.model.UidsCookie import org.prebid.server.functional.model.request.vtrack.VtrackRequest import org.prebid.server.functional.model.response.amp.AmpResponse import org.prebid.server.functional.model.response.amp.RawAmpResponse @@ -147,8 +147,9 @@ class PrebidServerService { checkResponseStatusCode(response) def setuidResponse = new SetuidResponse() - setuidResponse.uidsCookie = response.detailedCookie("uids") - setuidResponse.responseBody = response.asString() + def uids = response.detailedCookie("uids").value + setuidResponse.uidsCookie = mapper.decode(new String(Base64.urlDecoder.decode(uids)), UidsCookie) + setuidResponse.responseBody = response.asByteArray() setuidResponse } diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/container/PrebidServerContainer.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/container/PrebidServerContainer.groovy index ee13e094c6d..ae34e2fe71e 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/container/PrebidServerContainer.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/container/PrebidServerContainer.groovy @@ -75,7 +75,7 @@ LIMIT 1 } PrebidServerContainer withDebug() { - withEnv("JAVA_TOOL_OPTIONS", "-agentlib:jdwp=transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=n") + withEnv("JAVA_TOOL_OPTIONS", "-agentlib:jdwp=transport=dt_socket,address=*:$DEBUG_PORT,server=y,suspend=n") } void withMysql(String host, int port, String dbname, String user, String password) {