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

Admixer: Fix for bid floor issue#1787 #1872

Merged
merged 3 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions adapters/admixer/admixer.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,17 @@ func preprocess(imp *openrtb2.Imp) error {
}

//don't use regexp due to possible performance reduce
if len(admixerExt.ZoneId) != 36 {
if len(admixerExt.ZoneId) < 32 || len(admixerExt.ZoneId) > 36 {
return &errortypes.BadInput{
Message: "ZoneId must be UUID/GUID",
}
}

imp.TagID = admixerExt.ZoneId
imp.BidFloor = admixerExt.CustomBidFloor

if imp.BidFloor == 0 && admixerExt.CustomBidFloor > 0 {
imp.BidFloor = admixerExt.CustomBidFloor
}

imp.Ext = nil

Expand Down
133 changes: 133 additions & 0 deletions adapters/admixer/admixertest/exemplary/optional-params.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,76 @@
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please also add a test where both the imp BidFloor and CustomBidFloor are set to non-zero values and the request to your service has it set to the imp's BidFloor value? You can just do this by adding imp.bidfloor in one of the imps above and modifying the expected HTTP request accordingly as well

},
{
"id": "test-imp-id",
"bidfloor": 0.5,
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"ext": {
"bidder": {
"zone": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"customParams": {
"foo": [
"bar",
"baz"
]
}
}
}
},
{
"id": "test-imp-id",
"bidfloor": 0.5,
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"ext": {
"bidder": {
"zone": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"customParams": {
"foo": [
"bar",
"baz"
]
}
},
"customFloor": 0.9
}
},
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"ext": {
"bidder": {
"customFloor": 0.9,
"zone": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"customParams": {
"foo": [
"bar",
"baz"
]
}
}
}
}
]
},
Expand Down Expand Up @@ -92,6 +162,69 @@
]
}
}
},
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"tagid": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"bidfloor": 0.5,
"ext": {
"customParams": {
"foo": [
"bar",
"baz"
]
}
}
},
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"tagid": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"bidfloor": 0.5,
"ext": {
"customParams": {
"foo": [
"bar",
"baz"
]
}
}
},
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"tagid": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"bidfloor": 0.9,
"ext": {
"customParams": {
"foo": [
"bar",
"baz"
]
}
}
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/admixer/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var validParams = []string{
`{"zone": "9FF668A2-4122-462E-AAF8-36EA3A54BA21", "customFloor": 0.1}`,
`{"zone": "9FF668A2-4122-462E-AAF8-36EA3A54BA21", "customParams": {"foo": "bar"}}`,
`{"zone": "9ff668a2-4122-462e-aaf8-36ea3a54ba21", "customFloor": 0.1, "customParams": {"foo": ["bar", "baz"]}}`,
`{"zone": "9FF668A24122462EAAF836EA3A54BA21"}`,
`{"zone": "9FF668A24122462EAAF836EA3A54BA212"}`,
}

var invalidParams = []string{
Expand All @@ -54,4 +56,6 @@ var invalidParams = []string{
`{"zone": "123", "customFloor": "0.1"}`,
`{"zone": "9FF668A2-4122-462E-AAF8-36EA3A54BA21", "customFloor": -0.1}`,
`{"zone": "9FF668A2-4122-462E-AAF8-36EA3A54BA21", "customParams": "foo: bar"}`,
`{"zone": "9FF668A24122462EAAF836EA3A54BA2"}`,
`{"zone": "9FF668A24122462EAAF836EA3A54BA2112336"}`,
}
4 changes: 2 additions & 2 deletions static/bidder-params/admixer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"zone": {
"type": "string",
"description": "Zone ID.",
"pattern": "^([a-fA-F\\d\\-]{36})$"
"pattern": "^([a-fA-F\\d\\-]{32,36})$"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add tests for this change as well in adapters/admixer/params_test.go?

Choose a reason for hiding this comment

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

Hi @mansinahar , sure, we will add tests.

},
"customFloor": {
"type": "number",
Expand All @@ -22,4 +22,4 @@
},

"required": ["zone"]
}
}