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 DSA fields and validation #2931

Merged
merged 7 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ private static boolean isDsaValidationRequired(BidRequest bidRequest) {
return Optional.ofNullable(bidRequest.getRegs())
.map(Regs::getExt)
.map(ExtRegs::getDsa)
.map(ExtRegsDsa::getRequired)
.map(ExtRegsDsa::getDsarequired)
.map(DSA_REQUIRED::contains)
.orElse(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
public class ExtRegsDsa {

/**
* Defines the contract for bidrequest.regs.ext.dsa.required
* Defines the contract for bidrequest.regs.ext.dsa.dsarequired
*/
Integer required;
Integer dsarequired;
AntoxaAntoxic marked this conversation as resolved.
Show resolved Hide resolved

/**
* Defines the contract for bidrequest.regs.ext.dsa.pubrender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ExtRegsDsaTransparency {
String domain;

/**
* Defines the contract for bidrequest.regs.ext.dsa.transparency[i].params[]
* Defines the contract for bidrequest.regs.ext.dsa.transparency[i].dsaparams[]
*/
List<Integer> params;
List<Integer> dsaparams;
AntoxaAntoxic marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.prebid.server.functional.util.PBSUtils
class DsaTransparency {

String domain
List<Integer> params
List<Integer> dsaparams
AntoxaAntoxic marked this conversation as resolved.
Show resolved Hide resolved

static DsaTransparency getDefaultRegsDsaTransparency() {
new DsaTransparency(domain: PBSUtils.randomString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import org.prebid.server.functional.util.PBSUtils
@ToString(includeNames = true, ignoreNulls = true)
class RegsDsa {

Integer required
Integer dsarequired
AntoxaAntoxic marked this conversation as resolved.
Show resolved Hide resolved
Integer pubRender
Integer dataToPub
List<DsaTransparency> transparency

static RegsDsa getDefaultRegsDsa(ReqsDsaRequiredType required) {
new RegsDsa(
required: required.value,
dsarequired: required.value,
pubRender: PBSUtils.getRandomNumber(0, 2),
dataToPub: PBSUtils.getRandomNumber(0, 2),
transparency: [DsaTransparency.defaultRegsDsaTransparency]
Expand Down
28 changes: 14 additions & 14 deletions src/test/groovy/org/prebid/server/functional/tests/DsaSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class DsaSpec extends BaseSpec {
then: "Bidder request should contain DSA"
def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id)
verifyAll {
bidderRequests.regs.ext.dsa.required == dsa.required
bidderRequests.regs.ext.dsa.dsarequired == dsa.dsarequired
bidderRequests.regs.ext.dsa.dataToPub == dsa.dataToPub
bidderRequests.regs.ext.dsa.pubRender == dsa.pubRender
bidderRequests.regs.ext.dsa.transparency[0].domain == dsa.transparency[0].domain
bidderRequests.regs.ext.dsa.transparency[0].params == dsa.transparency[0].params
bidderRequests.regs.ext.dsa.transparency[0].dsaparams == dsa.transparency[0].dsaparams
}

and: "Bidder response should not contain DSA"
Expand Down Expand Up @@ -94,19 +94,19 @@ class DsaSpec extends BaseSpec {
then: "Bidder request should contain DSA"
def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id)
verifyAll {
bidderRequests.regs.ext.dsa.required == dsa.required
bidderRequests.regs.ext.dsa.dsarequired == dsa.dsarequired
bidderRequests.regs.ext.dsa.dataToPub == dsa.dataToPub
bidderRequests.regs.ext.dsa.pubRender == dsa.pubRender
bidderRequests.regs.ext.dsa.transparency[0].domain == dsa.transparency[0].domain
bidderRequests.regs.ext.dsa.transparency[0].params == dsa.transparency[0].params
bidderRequests.regs.ext.dsa.transparency[0].dsaparams == dsa.transparency[0].dsaparams
}

and: "Bidder response should contain DSA"
def bidderResponse = decode(response.ext.debug.httpcalls.get(BidderName.GENERIC.value)[0].responseBody, BidResponse)
def actualDsa = bidderResponse.seatbid[0].bid[0].ext.dsa
verifyAll {
actualDsa.transparency[0].domain == bidDsa.transparency[0].domain
actualDsa.transparency[0].params == bidDsa.transparency[0].params
actualDsa.transparency[0].dsaparams == bidDsa.transparency[0].dsaparams
actualDsa.adrender == bidDsa.adrender
actualDsa.behalf == bidDsa.behalf
actualDsa.paid == bidDsa.paid
Expand Down Expand Up @@ -149,11 +149,11 @@ class DsaSpec extends BaseSpec {
then: "Bidder request should contain DSA"
def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id)
verifyAll {
bidderRequests.regs.ext.dsa.required == dsa.required
bidderRequests.regs.ext.dsa.dsarequired == dsa.dsarequired
bidderRequests.regs.ext.dsa.dataToPub == dsa.dataToPub
bidderRequests.regs.ext.dsa.pubRender == dsa.pubRender
bidderRequests.regs.ext.dsa.transparency[0].domain == dsa.transparency[0].domain
bidderRequests.regs.ext.dsa.transparency[0].params == dsa.transparency[0].params
bidderRequests.regs.ext.dsa.transparency[0].dsaparams == dsa.transparency[0].dsaparams
}

and: "Bidder response should not contain DSA"
Expand Down Expand Up @@ -192,11 +192,11 @@ class DsaSpec extends BaseSpec {
then: "Bidder request should contain DSA"
def bidderRequests = bidder.getBidderRequest(bidRequest.id)
verifyAll {
bidderRequests.regs.ext.dsa.required == dsa.required
bidderRequests.regs.ext.dsa.dsarequired == dsa.dsarequired
bidderRequests.regs.ext.dsa.dataToPub == dsa.dataToPub
bidderRequests.regs.ext.dsa.pubRender == dsa.pubRender
bidderRequests.regs.ext.dsa.transparency[0].domain == dsa.transparency[0].domain
bidderRequests.regs.ext.dsa.transparency[0].params == dsa.transparency[0].params
bidderRequests.regs.ext.dsa.transparency[0].dsaparams == dsa.transparency[0].dsaparams
}

and: "DSA is not returned"
Expand Down Expand Up @@ -228,18 +228,18 @@ class DsaSpec extends BaseSpec {
then: "Bidder request should contain DSA"
def bidderRequests = bidder.getBidderRequest(bidRequest.id)
verifyAll {
bidderRequests.regs.ext.dsa.required == dsa.required
bidderRequests.regs.ext.dsa.dsarequired == dsa.dsarequired
bidderRequests.regs.ext.dsa.dataToPub == dsa.dataToPub
bidderRequests.regs.ext.dsa.pubRender == dsa.pubRender
bidderRequests.regs.ext.dsa.transparency[0].domain == dsa.transparency[0].domain
bidderRequests.regs.ext.dsa.transparency[0].params == dsa.transparency[0].params
bidderRequests.regs.ext.dsa.transparency[0].dsaparams == dsa.transparency[0].dsaparams
}

and: "DSA is not returned"
def actualDsa = response.seatbid[0].bid[0].ext.dsa
verifyAll {
actualDsa.transparency[0].domain == bidDsa.transparency[0].domain
actualDsa.transparency[0].params == bidDsa.transparency[0].params
actualDsa.transparency[0].dsaparams == bidDsa.transparency[0].dsaparams
actualDsa.adrender == bidDsa.adrender
actualDsa.behalf == bidDsa.behalf
actualDsa.paid == bidDsa.paid
Expand Down Expand Up @@ -270,11 +270,11 @@ class DsaSpec extends BaseSpec {
then: "Bidder request should contain DSA"
def bidderRequests = bidder.getBidderRequest(bidRequest.id)
verifyAll {
bidderRequests.regs.ext.dsa.required == dsa.required
bidderRequests.regs.ext.dsa.dsarequired == dsa.dsarequired
bidderRequests.regs.ext.dsa.dataToPub == dsa.dataToPub
bidderRequests.regs.ext.dsa.pubRender == dsa.pubRender
bidderRequests.regs.ext.dsa.transparency[0].domain == dsa.transparency[0].domain
bidderRequests.regs.ext.dsa.transparency[0].params == dsa.transparency[0].params
bidderRequests.regs.ext.dsa.transparency[0].dsaparams == dsa.transparency[0].dsaparams
}

and: "Response should contain error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void convertShouldMoveSourceSupplyChain() {
public void convertShouldMoveRegsData() {
// given
final Map<String, Object> dsaMap = Map.of(
"required", 1,
"dsarequired", 1,
"pubrender", 2,
"datatopub", 3,
"transparency", emptyList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@
"ext": {
"gdpr": 0,
"dsa": {
"required": 1,
"dsarequired": 1,
"pubrender": 0,
"datatopub": 2,
"transparency": [
{
"domain": "platform1domain.com",
"params": [
"dsaparams": [
1
]
},
{
"domain": "SSP2domain.com",
"params": [
"dsaparams": [
1,
2
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"paid": "Advertiser",
"transparency": {
"domain": "dsp1domain.com",
"params": [
"dsaparams": [
1,
2
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"paid" : "Advertiser",
"transparency" : {
"domain" : "dsp1domain.com",
"params" : [ 1, 2 ]
"dsaparams" : [ 1, 2 ]
},
"adrender" : 1
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@
"ext" : {
"gdpr" : 0,
"dsa": {
"required": 1,
"dsarequired": 1,
"pubrender": 0,
"datatopub": 2,
"transparency": [
{
"domain": "platform1domain.com",
"params": [
"dsaparams": [
1
]
},
{
"domain": "SSP2domain.com",
"params": [
"dsaparams": [
1,
2
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"paid": "Advertiser",
"transparency": {
"domain": "dsp1domain.com",
"params": [
"dsaparams": [
1,
2
]
Expand Down
Loading