From 09394a00f8b4c6c1381279de96974da05f8dd1e5 Mon Sep 17 00:00:00 2001 From: avolokha <84977155+avolokha@users.noreply.github.com> Date: Tue, 27 Jul 2021 20:37:20 +0300 Subject: [PATCH] Admixer: Fix for bid floor issue#1787 (#1872) --- adapters/admixer/admixer.go | 7 +- .../exemplary/optional-params.json | 133 ++++++++++++++++++ adapters/admixer/params_test.go | 4 + static/bidder-params/admixer.json | 4 +- 4 files changed, 144 insertions(+), 4 deletions(-) diff --git a/adapters/admixer/admixer.go b/adapters/admixer/admixer.go index ec49950a17e..5008b0ce5c6 100644 --- a/adapters/admixer/admixer.go +++ b/adapters/admixer/admixer.go @@ -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 diff --git a/adapters/admixer/admixertest/exemplary/optional-params.json b/adapters/admixer/admixertest/exemplary/optional-params.json index 8ef112bbdb5..b93aa9c8154 100644 --- a/adapters/admixer/admixertest/exemplary/optional-params.json +++ b/adapters/admixer/admixertest/exemplary/optional-params.json @@ -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" + ] + } + } + } } ] }, @@ -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" + ] + } + } } ] } diff --git a/adapters/admixer/params_test.go b/adapters/admixer/params_test.go index 71cccb6a3da..11f3feb0657 100644 --- a/adapters/admixer/params_test.go +++ b/adapters/admixer/params_test.go @@ -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{ @@ -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"}`, } diff --git a/static/bidder-params/admixer.json b/static/bidder-params/admixer.json index 886e33ff2bb..78671931561 100644 --- a/static/bidder-params/admixer.json +++ b/static/bidder-params/admixer.json @@ -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", @@ -22,4 +22,4 @@ }, "required": ["zone"] -} +} \ No newline at end of file