Skip to content

Commit

Permalink
fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
mtuchkova committed Nov 4, 2021
1 parent c6bd407 commit cece2af
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class AmpSpec extends BaseSpec {
}

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

when: "PBS processes amp request"
Expand Down
18 changes: 9 additions & 9 deletions src/test/groovy/org/prebid/server/functional/AuctionSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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.model.request.auction.PrebidStoredRequest
import org.prebid.server.functional.service.PrebidServerService
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Shared
Expand All @@ -21,7 +21,7 @@ class AuctionSpec extends BaseSpec {
given: "Default basic BidRequest with generic bidder"
def bidRequest = BidRequest.defaultBidRequest.tap {
tmax = null
ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString())
ext.prebid.storedRequest = new PrebidStoredRequest(id: PBSUtils.randomNumber.toString())
}

and: "Default stored request with timeout"
Expand All @@ -31,7 +31,7 @@ class AuctionSpec extends BaseSpec {
}

and: "Save storedRequest into DB"
def storedRequest = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequestModel)
def storedRequest = StoredRequest.getDbStoredRequest(bidRequest, storedRequestModel)
storedRequestDao.save(storedRequest)

when: "PBS processes auction request"
Expand All @@ -48,7 +48,7 @@ class AuctionSpec extends BaseSpec {
def timeout = PBSUtils.getRandomNumber(0, MAX_TIMEOUT)
def bidRequest = BidRequest.defaultBidRequest.tap {
tmax = timeout
ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString())
ext.prebid.storedRequest = new PrebidStoredRequest(id: PBSUtils.randomNumber.toString())
}

and: "Default stored request"
Expand All @@ -57,7 +57,7 @@ class AuctionSpec extends BaseSpec {
}

and: "Save storedRequest into DB"
def storedRequest = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequestModel)
def storedRequest = StoredRequest.getDbStoredRequest(bidRequest, storedRequestModel)
storedRequestDao.save(storedRequest)

when: "PBS processes auction request"
Expand All @@ -76,7 +76,7 @@ class AuctionSpec extends BaseSpec {
given: "Default basic BidRequest with generic bidder"
def bidRequest = BidRequest.defaultBidRequest.tap {
tmax = autcionRequestTimeout
ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString())
ext.prebid.storedRequest = new PrebidStoredRequest(id: PBSUtils.randomNumber.toString())
}

and: "Default stored request"
Expand All @@ -85,7 +85,7 @@ class AuctionSpec extends BaseSpec {
}

and: "Save storedRequest into DB"
def storedRequestModel = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequest)
def storedRequestModel = StoredRequest.getDbStoredRequest(bidRequest, storedRequest)
storedRequestDao.save(storedRequestModel)

when: "PBS processes auction request"
Expand All @@ -106,7 +106,7 @@ class AuctionSpec extends BaseSpec {
given: "Default basic BidRequest without timeout"
def bidRequest = BidRequest.defaultBidRequest.tap {
tmax = null
ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString())
ext.prebid.storedRequest = new PrebidStoredRequest(id: PBSUtils.randomNumber.toString())
}

and: "Default stored request without timeout"
Expand All @@ -115,7 +115,7 @@ class AuctionSpec extends BaseSpec {
}

and: "Save storedRequest into DB"
def storedRequestModel = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequest)
def storedRequestModel = StoredRequest.getDbStoredRequest(bidRequest, storedRequest)
storedRequestDao.save(storedRequestModel)

when: "PBS processes auction request"
Expand Down
4 changes: 2 additions & 2 deletions src/test/groovy/org/prebid/server/functional/DebugSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class DebugSpec extends BaseSpec {
}

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

when: "PBS processes amp request"
Expand Down Expand Up @@ -292,7 +292,7 @@ class DebugSpec extends BaseSpec {
}

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

when: "PBS processes amp request"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class HttpSettingsSpec extends BaseSpec {
ampStoredRequest.regs.ext.gdpr = 1

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

and: "Prepare default account response with gdpr = 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SmokeSpec extends BaseSpec {
ampStoredRequest.site.publisher.id = ampRequest.account

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

when: "PBS processes amp request"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
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
Expand All @@ -15,8 +13,7 @@ class UidsCookie {
Map<String, String> uids
Map<String, UidWithExpiry> tempUIDs
Boolean optout
@JsonFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss.SSS'Z'", timezone = "UTC")
@JsonDeserialize(using = ZonedDateTimeDeserializer)
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
ZonedDateTime bday

static UidsCookie getDefaultUidsCookie() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class StoredRequest {
@Convert(converter = StoredRequestConfigTypeConverter)
BidRequest requestData

static StoredRequest getAmpDbStoredRequest(AmpRequest ampRequest, BidRequest bidRequest) {
static StoredRequest getDbStoredRequest(AmpRequest ampRequest, BidRequest bidRequest) {
new StoredRequest(reqid: ampRequest.tagId, accountId: ampRequest.account, requestData: bidRequest)
}

static StoredRequest getAuctionDbStoredRequest(BidRequest bidRequest, BidRequest storedRequest) {
static StoredRequest getDbStoredRequest(BidRequest bidRequest, BidRequest storedRequest) {
new StoredRequest(reqid: bidRequest.ext.prebid.storedRequest.id, accountId: bidRequest.site.publisher.id,
requestData: storedRequest)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Prebid {
Integer debug
Targeting targeting
PrebidCache cache
StoredRequestExt storedRequest
PrebidStoredRequest storedRequest
Amp amp
Channel channel
List<PrebidSchain> schains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.prebid.server.functional.model.request.auction
import groovy.transform.ToString

@ToString(includeNames = true, ignoreNulls = true)
class StoredRequestExt {
class PrebidStoredRequest {

String id
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
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

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

String uid
@JsonFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss.SSS'Z'", timezone = "UTC")
@JsonDeserialize(using = ZonedDateTimeDeserializer)
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
ZonedDateTime expires
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ class PrebidServerService {
checkResponseStatusCode(response)

def setuidResponse = new SetuidResponse()
def uids = response.detailedCookie("uids").value
setuidResponse.uidsCookie = mapper.decode(new String(Base64.urlDecoder.decode(uids)), UidsCookie)
setuidResponse.uidsCookie = getDecodedUidsCookie(response)
setuidResponse.responseBody = response.asByteArray()
setuidResponse
}
Expand Down Expand Up @@ -254,6 +253,15 @@ class PrebidServerService {
}
}

private UidsCookie getDecodedUidsCookie(Response response) {
def uids = response.detailedCookie("uids")?.value
if (uids) {
return mapper.decode(new String(Base64.urlDecoder.decode(uids)), UidsCookie)
} else {
throw new IllegalStateException()
}
}

List<String> getLogsByTime(Instant testStart,
Instant testEnd = Instant.now()) {
if (!testEnd.isAfter(testStart)) {
Expand Down

0 comments on commit cece2af

Please sign in to comment.