-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests: Increase test coverage for cookie_sync
#2570
Changes from 7 commits
6c963ff
d9d013c
50d07ba
e358376
a9f873c
9de7a0e
8d8bc04
9c5db82
d6cb22b
24d8540
7f1a7ff
c8ced28
a89d752
a8c5317
40e7e12
c9aaa16
8258f8d
86bbb24
8826730
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package org.prebid.server.functional.model.mock.services.vendorlist | ||
|
||
import org.prebid.server.functional.util.PBSUtils | ||
import org.prebid.server.functional.util.privacy.TcfConsent | ||
|
||
import java.time.Clock | ||
import java.time.ZonedDateTime | ||
|
||
import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID | ||
import static org.prebid.server.functional.util.privacy.TcfConsent.VENDOR_LIST_VERSION | ||
|
||
class VendorListResponse { | ||
|
||
|
@@ -19,9 +18,8 @@ class VendorListResponse { | |
static VendorListResponse getDefaultVendorListResponse() { | ||
new VendorListResponse().tap { | ||
it.gvlSpecificationVersion = 2 | ||
it.tcfPolicyVersion = 2 | ||
it.vendorListVersion = VENDOR_LIST_VERSION | ||
it.lastUpdated = ZonedDateTime.now(Clock.systemUTC()).minusWeeks(2) | ||
it.vendors = [(GENERIC_VENDOR_ID): Vendor.defaultVendor] | ||
} | ||
} | ||
|
||
|
@@ -43,9 +41,9 @@ class VendorListResponse { | |
Boolean usesNonCookieAccess | ||
Boolean deviceStorageDisclosureUrl | ||
|
||
static Vendor getDefaultVendor() { | ||
static Vendor getDefaultVendor(Integer id) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
new Vendor().tap { | ||
it.id = GENERIC_VENDOR_ID | ||
it.id = id | ||
it.name = PBSUtils.randomString | ||
it.purposes = [1, 3, 4, 5] | ||
it.legIntPurposes = [2, 7, 10] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package org.prebid.server.functional.model.request.cookiesync | ||
|
||
import groovy.transform.ToString | ||
import org.prebid.server.functional.model.bidder.BidderName | ||
|
||
@ToString(includeNames = true, ignoreNulls = true) | ||
class MethodFilter { | ||
class MethodFilter<T> { | ||
|
||
List<BidderName> bidders | ||
// Here we use wildcard for different compatibility | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what you meant by this comment. |
||
T bidders | ||
FilterType filter | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
package org.prebid.server.functional.model.response.setuid | ||
|
||
import groovy.transform.ToString | ||
import io.restassured.http.Headers | ||
import org.prebid.server.functional.model.UidsCookie | ||
|
||
@ToString(includeNames = true, ignoreNulls = true) | ||
class SetuidResponse { | ||
|
||
Headers headers | ||
Map<String, String> headers | ||
UidsCookie uidsCookie | ||
Byte[] responseBody | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,7 +127,7 @@ class PrebidServerService implements ObjectMapperWrapper { | |
|
||
@Step("[POST] /cookie_sync with headers") | ||
CookieSyncResponse sendCookieSyncRequest(CookieSyncRequest request, Map<String, String> headers) { | ||
def response = postCookieSync(request, headers) | ||
def response = postCookieSync(request, null, headers) | ||
|
||
checkResponseStatusCode(response) | ||
response.as(CookieSyncResponse) | ||
|
@@ -141,6 +141,14 @@ class PrebidServerService implements ObjectMapperWrapper { | |
response.as(CookieSyncResponse) | ||
} | ||
|
||
@Step("[POST] /cookie_sync with uids cookie") | ||
CookieSyncResponse sendCookieSyncRequest(CookieSyncRequest request, String uidsCookie) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the point of duplicating the method, but using a String instead of POJO? |
||
def response = postCookieSync(request, null, null, null, uidsCookie) | ||
|
||
checkResponseStatusCode(response) | ||
response.as(CookieSyncResponse) | ||
} | ||
|
||
@Step("[POST] /cookie_sync with uids and additional cookies") | ||
CookieSyncResponse sendCookieSyncRequest(CookieSyncRequest request, | ||
UidsCookie uidsCookie, | ||
|
@@ -165,7 +173,7 @@ class PrebidServerService implements ObjectMapperWrapper { | |
def setuidResponse = new SetuidResponse() | ||
setuidResponse.uidsCookie = getDecodedUidsCookie(response) | ||
setuidResponse.responseBody = response.asByteArray() | ||
setuidResponse.headers = response.headers() | ||
setuidResponse.headers = getHeaders(response) | ||
setuidResponse | ||
} | ||
|
||
|
@@ -310,25 +318,22 @@ class PrebidServerService implements ObjectMapperWrapper { | |
.post(AUCTION_ENDPOINT) | ||
} | ||
|
||
private Response postCookieSync(CookieSyncRequest cookieSyncRequest, Map<String, String> header) { | ||
postCookieSync(cookieSyncRequest, null, header) | ||
} | ||
|
||
private Response postCookieSync(CookieSyncRequest cookieSyncRequest, | ||
UidsCookie uidsCookie = null, | ||
Map<String, ?> additionalCookies = null, | ||
Map<String, String> header = null) { | ||
|
||
def cookies = [:] | ||
Map<String, String> header = null, | ||
String uidsAudit = null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be here at all. |
||
|
||
if (additionalCookies) { | ||
cookies.putAll(additionalCookies) | ||
} | ||
def cookies = additionalCookies ?: [:] | ||
|
||
if (uidsCookie) { | ||
cookies.put(UIDS_COOKIE_NAME, Base64.urlEncoder.encodeToString(encode(uidsCookie).bytes)) | ||
} | ||
|
||
if (uidsAudit) { | ||
cookies.put("uids-audit", uidsAudit) | ||
} | ||
|
||
postCookieSync(cookieSyncRequest, cookies, header) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rearrange the list and put
BOGUS
somewhere at the beginning.