Skip to content

Commit

Permalink
Admixer: Fix for bid floor issue#1787 (prebid#1872)
Browse files Browse the repository at this point in the history
  • Loading branch information
avolokha authored and jizeyopera committed Oct 13, 2021
1 parent b13462f commit 09394a0
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 4 deletions.
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 @@
}
}
}
},
{
"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})$"
},
"customFloor": {
"type": "number",
Expand All @@ -22,4 +22,4 @@
},

"required": ["zone"]
}
}

0 comments on commit 09394a0

Please sign in to comment.