-
Notifications
You must be signed in to change notification settings - Fork 249
Tests: ORTB Error Response #4386
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -6,8 +6,8 @@ import groovy.transform.ToString | |
|
|
||
| import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.AUDIO_BATTR | ||
| import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BADV | ||
| import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BAPP | ||
| import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BANNER_BATTR | ||
| import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BAPP | ||
|
Collaborator
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. Please revert the changes. |
||
| import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BCAT | ||
| import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BTYPE | ||
| import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.VIDEO_BATTR | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package org.prebid.server.functional.model.mock.services.vendorlist | ||
|
|
||
| import org.prebid.server.functional.util.PBSUtils | ||
|
|
||
|
Collaborator
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. Same here |
||
| import java.time.Clock | ||
| import java.time.ZonedDateTime | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.prebid.server.functional.model.response | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonValue | ||
| import groovy.transform.ToString | ||
|
|
||
| @ToString(includeNames = true, ignoreNulls = true) | ||
| enum BidderErrorCode { | ||
|
|
||
| BAD_INPUT(2), | ||
| BAD_SERVER_RESPONSE(3), | ||
| FAILED_TO_REQUEST_BIDS(4), | ||
| INVALID_BID(5), | ||
| REJECTED_IPF(6), | ||
| TIMEOUT(1), | ||
| GENERIC(999) | ||
|
marki1an marked this conversation as resolved.
|
||
|
|
||
| @JsonValue | ||
| final Integer value | ||
|
|
||
| BidderErrorCode(Integer value) { | ||
| this.value = value | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import io.restassured.authentication.BasicAuthScheme | |
| import io.restassured.builder.RequestSpecBuilder | ||
| import io.restassured.response.Response | ||
| import io.restassured.specification.RequestSpecification | ||
| import org.apache.http.HttpStatus | ||
| import org.prebid.server.functional.model.UidsCookie | ||
| import org.prebid.server.functional.model.bidder.BidderName | ||
| import org.prebid.server.functional.model.mock.services.prebidcache.response.PrebidCacheResponse | ||
|
|
@@ -86,10 +87,14 @@ class PrebidServerService implements ObjectMapperWrapper { | |
| prometheusRequestSpecification = buildAndGetRequestSpecification(pbsContainer.prometheusRootUri, authenticationScheme) | ||
| } | ||
|
|
||
| BidResponse sendAuctionRequest(BidRequest bidRequest, Map<String, ?> headers = [:]) { | ||
| BidResponse sendAuctionRequest(BidRequest bidRequest, Integer statusCode = HttpStatus.SC_OK) { | ||
| sendAuctionRequest(bidRequest, [:], statusCode) | ||
| } | ||
|
|
||
| BidResponse sendAuctionRequest(BidRequest bidRequest, Map<String, ?> headers, int statusCode = HttpStatus.SC_OK) { | ||
|
Collaborator
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 like this approach. We send a request and at the same time include some code—what's the purpose of that?
Collaborator
Author
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. "With the new implementation and ortb-error-response enabled, the system now returns a proper bidResponse with specific status codes. This allows for validation against a consistent body schema, even for errors. Previously, we relied on the system 'breaking correctly' with plain text; now, error responses follow nearly the same structure as success responses |
||
| def response = postAuction(bidRequest, headers) | ||
|
|
||
| checkResponseStatusCode(response) | ||
| checkResponseStatusCode(response, statusCode) | ||
| decode(response.body.asString(), BidResponse) | ||
| } | ||
|
|
||
|
|
@@ -98,6 +103,7 @@ class PrebidServerService implements ObjectMapperWrapper { | |
|
|
||
| new RawAuctionResponse().tap { | ||
| it.headers = getHeaders(response) | ||
| it.statusCode = response.statusCode() | ||
| it.responseBody = response.body.asString() | ||
| } | ||
| } | ||
|
|
@@ -109,10 +115,14 @@ class PrebidServerService implements ObjectMapperWrapper { | |
| decode(response.body.asString(), AmpResponse) | ||
| } | ||
|
|
||
| AmpResponse sendAmpRequest(AmpRequest ampRequest, Map<String, String> headers = [:]) { | ||
| AmpResponse sendAmpRequest(AmpRequest ampRequest, int statusCode = HttpStatus.SC_OK) { | ||
| sendAmpRequest(ampRequest, [:], statusCode) | ||
| } | ||
|
|
||
| AmpResponse sendAmpRequest(AmpRequest ampRequest, Map<String, String> headers, int statusCode = HttpStatus.SC_OK) { | ||
| def response = getAmp(ampRequest, headers) | ||
|
|
||
| checkResponseStatusCode(response) | ||
| checkResponseStatusCode(response, statusCode) | ||
| decode(response.body.asString(), AmpResponse) | ||
| } | ||
|
|
||
|
|
@@ -121,6 +131,7 @@ class PrebidServerService implements ObjectMapperWrapper { | |
|
|
||
| new RawAmpResponse().tap { | ||
| it.headers = getHeaders(response) | ||
| it.statusCode = response.statusCode() | ||
| it.responseBody = response.body.asString() | ||
| } | ||
| } | ||
|
|
@@ -372,7 +383,7 @@ class PrebidServerService implements ObjectMapperWrapper { | |
| .get(AMP_ENDPOINT) | ||
| } | ||
|
|
||
| private void checkResponseStatusCode(Response response, int statusCode = 200) { | ||
| private void checkResponseStatusCode(Response response, int statusCode = HttpStatus.SC_OK) { | ||
|
Collaborator
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. Can be as static import, just |
||
| def responseStatusCode = response.statusCode | ||
| if (responseStatusCode != statusCode) { | ||
| def responseBody = response.body.asString() | ||
|
|
||
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.
empty line