Skip to content
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

Add functional tests for support testing label header #2963

Conversation

osulzhenko
Copy link
Collaborator

No description provided.

@osulzhenko osulzhenko added the tests Functional or other tests label Feb 12, 2024
@osulzhenko osulzhenko requested a review from marki1an February 12, 2024 08:42
Copy link
Collaborator

@marki1an marki1an left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this requirement ?

@@ -141,6 +142,16 @@ class PrebidServerService implements ObjectMapperWrapper {
response.as(CookieSyncResponse)
}

@Step("[POST RAW] /cookie_sync with uids cookies")
RawCookieSyncResponse sendCookieSyncRequestRaw(CookieSyncRequest request, UidsCookie uidsCookie) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please place those methods in order overloads

@@ -89,6 +91,8 @@ class CookieSyncSpec extends BaseSpec {
private static final Map<String, String> ACUITYADS_CONFIG = ["adapters.${ACUITYADS.value}.enabled": "true"]
private static final Map<String, String> ADKERNEL_CONFIG = ["adapters.${ADKERNEL.value}.enabled": "true"]

private static final def SET_COOKIE_HEADER = 'Set-Cookie'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move upper to the rest constant.

def uidsCookie = UidsCookie.defaultUidsCookie

and: "Save account with cookie and privacySandbox configs"
def cookieSyncConfig = new AccountCookieSyncConfig(defaultLimit: 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope we can remove AccountCookieSyncConfig since it doesn't affect our logic

def accountConfig = new AccountConfig(status: AccountStatus.ACTIVE, cookieSync: cookieSyncConfig, auction: accountAuctionConfig)
def account = new Account(uuid: accountId, config: accountConfig)
accountDao.save(account)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove redundant empty line

Comment on lines +2184 to +2185
and: "Set up generic uids cookie"
def uidsCookie = UidsCookie.defaultUidsCookie
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one also can be removed

Comment on lines 2205 to 2206
PrivacySandbox.getDefaultPrivacySandbox(true, -PBSUtils.randomNumber),
PrivacySandbox.getDefaultPrivacySandbox(true, null)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that two conditions shouldn't work?

def uidsCookie = UidsCookie.defaultUidsCookie

and: "Save account with cookie and privacySandbox configs"
def cookieSyncConfig = new AccountCookieSyncConfig(defaultLimit: 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AccountCookieSyncConfig can be removed

def accountConfig = new AccountConfig(status: AccountStatus.ACTIVE, cookieSync: cookieSyncConfig, auction: accountAuctionConfig)
def account = new Account(uuid: accountId, config: accountConfig)
accountDao.save(account)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same empty line

assert response.headers[SET_COOKIE_HEADER] == getCookieDeprecationHeader(privacySandbox.cookieDeprecation.ttlSeconds)
}

def "PBS should set cookie deprecation header from the default account when the accountId from the request is not matched"() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when default account contain privacy sandbox

Comment on lines 476 to 477
and: "Sec-Cookie-Deprecation header"
def secCookieDeprecation = [(COOKIE_DEPRECATION_HEADER): PBSUtils.randomString]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't really need set sec-cookie-deprecation header when privacy sandbox is null or false

@osulzhenko osulzhenko changed the base branch from master to testing-label-header-support February 16, 2024 07:57
@osulzhenko osulzhenko requested a review from marki1an February 16, 2024 09:23
when: "PBS processes auction request with header"
defaultPbsService.sendAuctionRequest(bidRequest, secCookieDeprecation)

then: "BidResponse should have device.ext.cdep from sec-cookie-deprecation header"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably BidderRequest should have..., please check other places

assert bidderRequest.device.ext.cdep == secCookieDeprecation[COOKIE_DEPRECATION_HEADER]
}

def "PBS should set device.ext.cdep from header when default account don't contain privacy sandbox and request account is empty"() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not

def response = prebidServerService.sendCookieSyncRequestRaw(cookieSyncRequest, uidsCookie)

then: "Response should contain cookie header"
assert extractCookieParameter(response.headers[SET_COOKIE_HEADER], 'Max-Age') == TimeUnit.DAYS.toSeconds(7) as Integer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any test that check the whole set-cookie header value

assert extractCookieParameter(response.headers[SET_COOKIE_HEADER], 'Max-Age') == privacySandbox.cookieDeprecation.ttlSeconds
}

def "PBS shouldn't set cookie deprecation header when default account don't contain privacy sandbox and request account is empty"() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just when cookie sync request doesn't contain account

@SerhiiNahornyi SerhiiNahornyi merged commit d3b1b89 into testing-label-header-support Feb 20, 2024
@SerhiiNahornyi SerhiiNahornyi deleted the functional-tests/support-testing-label-header branch February 20, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Functional or other tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants