diff --git a/adapters/axonix/axonix.go b/adapters/axonix/axonix.go index d3016235319..268b0e3ee2f 100644 --- a/adapters/axonix/axonix.go +++ b/adapters/axonix/axonix.go @@ -4,25 +4,39 @@ import ( "encoding/json" "fmt" "net/http" + "net/url" + "text/template" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" "github.com/prebid/prebid-server/openrtb_ext" ) type adapter struct { - URI string + EndpointTemplate template.Template } func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + endpoint, err := template.New("endpointTemplate").Parse(config.Endpoint) + if err != nil { + return nil, fmt.Errorf("unable to parse endpoint url template: %v", err) + } bidder := &adapter{ - URI: config.Endpoint, + EndpointTemplate: *endpoint, } return bidder, nil } +func (a *adapter) getEndpoint(ext *openrtb_ext.ExtImpAxonix) (string, error) { + endpointParams := macros.EndpointTemplateParams{ + AccountID: url.PathEscape(ext.SupplyId), + } + return macros.ResolveMacros(a.EndpointTemplate, endpointParams) +} + func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errors []error @@ -44,9 +58,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte return nil, errors } - thisURI := a.URI - if len(thisURI) == 0 { - thisURI = "https://openrtb-us-east-1.axonix.com/supply/prebid-server/" + axonixExt.SupplyId + endpoint, err := a.getEndpoint(&axonixExt) + if err != nil { + errors = append(errors, err) + return nil, errors } requestJSON, err := json.Marshal(request) @@ -60,7 +75,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte requestData := &adapters.RequestData{ Method: "POST", - Uri: thisURI, + Uri: endpoint, Body: requestJSON, Headers: headers, } diff --git a/adapters/axonix/axonix_test.go b/adapters/axonix/axonix_test.go index 6c4a3eb34d6..fcac320075f 100644 --- a/adapters/axonix/axonix_test.go +++ b/adapters/axonix/axonix_test.go @@ -1,6 +1,7 @@ package axonix import ( + "github.com/stretchr/testify/assert" "testing" "github.com/prebid/prebid-server/adapters/adapterstest" @@ -8,9 +9,10 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) -func TestJsonSamplesWithConfiguredURI(t *testing.T) { +func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderAxonix, config.Adapter{ - Endpoint: "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8"}) + Endpoint: "https://axonix.com/supply/prebid-server/{{.AccountID}}", + }) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) @@ -19,12 +21,8 @@ func TestJsonSamplesWithConfiguredURI(t *testing.T) { adapterstest.RunJSONBidderTest(t, "axonixtest", bidder) } -func TestJsonSamplesWithHardcodedURI(t *testing.T) { - bidder, buildErr := Builder(openrtb_ext.BidderAxonix, config.Adapter{}) +func TestEndpointTemplateMalformed(t *testing.T) { + _, buildErr := Builder(openrtb_ext.BidderAxonix, config.Adapter{Endpoint: "{{Malformed}}"}) - if buildErr != nil { - t.Fatalf("Builder returned unexpected error %v", buildErr) - } - - adapterstest.RunJSONBidderTest(t, "axonixtest", bidder) + assert.Error(t, buildErr) } diff --git a/adapters/axonix/axonixtest/exemplary/banner-and-video.json b/adapters/axonix/axonixtest/exemplary/banner-and-video.json index 1755cd0ef22..04b640826dc 100644 --- a/adapters/axonix/axonixtest/exemplary/banner-and-video.json +++ b/adapters/axonix/axonixtest/exemplary/banner-and-video.json @@ -18,7 +18,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } }, @@ -32,7 +32,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -41,7 +41,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -61,7 +61,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } }, @@ -75,7 +75,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/exemplary/banner-video-native.json b/adapters/axonix/axonixtest/exemplary/banner-video-native.json index 3944eb358b9..5dd5775004a 100644 --- a/adapters/axonix/axonixtest/exemplary/banner-video-native.json +++ b/adapters/axonix/axonixtest/exemplary/banner-video-native.json @@ -18,7 +18,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } }, @@ -30,7 +30,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } }, @@ -44,7 +44,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -53,7 +53,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -73,7 +73,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } }, @@ -85,7 +85,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } }, @@ -99,7 +99,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/exemplary/simple-banner.json b/adapters/axonix/axonixtest/exemplary/simple-banner.json index 581e59b9b9e..40441a46425 100644 --- a/adapters/axonix/axonixtest/exemplary/simple-banner.json +++ b/adapters/axonix/axonixtest/exemplary/simple-banner.json @@ -18,7 +18,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -28,7 +28,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -48,7 +48,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/exemplary/simple-video.json b/adapters/axonix/axonixtest/exemplary/simple-video.json index c15d7876470..56964b13565 100644 --- a/adapters/axonix/axonixtest/exemplary/simple-video.json +++ b/adapters/axonix/axonixtest/exemplary/simple-video.json @@ -12,7 +12,7 @@ }, "ext":{ "bidder":{ - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -22,7 +22,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -36,7 +36,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/params/race/banner.json b/adapters/axonix/axonixtest/params/race/banner.json index 7217c9c394f..136be9b1517 100644 --- a/adapters/axonix/axonixtest/params/race/banner.json +++ b/adapters/axonix/axonixtest/params/race/banner.json @@ -1,3 +1,3 @@ { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } diff --git a/adapters/axonix/axonixtest/params/race/video.json b/adapters/axonix/axonixtest/params/race/video.json index 7217c9c394f..136be9b1517 100644 --- a/adapters/axonix/axonixtest/params/race/video.json +++ b/adapters/axonix/axonixtest/params/race/video.json @@ -1,3 +1,3 @@ { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } diff --git a/adapters/axonix/axonixtest/supplemental/bad-response-no-body.json b/adapters/axonix/axonixtest/supplemental/bad-response-no-body.json index f89f40f122d..a4704990ef6 100644 --- a/adapters/axonix/axonixtest/supplemental/bad-response-no-body.json +++ b/adapters/axonix/axonixtest/supplemental/bad-response-no-body.json @@ -12,7 +12,7 @@ }, "ext":{ "bidder":{ - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -22,7 +22,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -36,7 +36,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/supplemental/status-bad-request.json b/adapters/axonix/axonixtest/supplemental/status-bad-request.json index d64a855e348..7483da19834 100644 --- a/adapters/axonix/axonixtest/supplemental/status-bad-request.json +++ b/adapters/axonix/axonixtest/supplemental/status-bad-request.json @@ -12,7 +12,7 @@ }, "ext":{ "bidder":{ - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -22,7 +22,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -36,7 +36,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/supplemental/status-no-content.json b/adapters/axonix/axonixtest/supplemental/status-no-content.json index 96dd899c1fb..7d4cd79589d 100644 --- a/adapters/axonix/axonixtest/supplemental/status-no-content.json +++ b/adapters/axonix/axonixtest/supplemental/status-no-content.json @@ -12,7 +12,7 @@ }, "ext":{ "bidder":{ - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -22,7 +22,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -36,7 +36,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/supplemental/unexpected-status-code.json b/adapters/axonix/axonixtest/supplemental/unexpected-status-code.json index e7a7be7847e..fe0f7141bc8 100644 --- a/adapters/axonix/axonixtest/supplemental/unexpected-status-code.json +++ b/adapters/axonix/axonixtest/supplemental/unexpected-status-code.json @@ -12,7 +12,7 @@ }, "ext":{ "bidder":{ - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -22,7 +22,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -36,7 +36,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/supplemental/valid-extension.json b/adapters/axonix/axonixtest/supplemental/valid-extension.json index 372f24d4f76..c174d245bc8 100644 --- a/adapters/axonix/axonixtest/supplemental/valid-extension.json +++ b/adapters/axonix/axonixtest/supplemental/valid-extension.json @@ -12,7 +12,7 @@ }, "ext":{ "bidder":{ - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -22,7 +22,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "imp": [ @@ -36,7 +36,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/axonixtest/supplemental/valid-with-device.json b/adapters/axonix/axonixtest/supplemental/valid-with-device.json index 62f4ea06b5a..50d48410e8a 100644 --- a/adapters/axonix/axonixtest/supplemental/valid-with-device.json +++ b/adapters/axonix/axonixtest/supplemental/valid-with-device.json @@ -16,7 +16,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } @@ -25,7 +25,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://openrtb-us-east-1.axonix.com/supply/prebid-server/24cc9034-f861-47b8-a6a8-b7e0968c00b8", + "uri": "https://axonix.com/supply/prebid-server/supply-test", "body": { "id": "test-request-id", "device": { @@ -43,7 +43,7 @@ }, "ext": { "bidder": { - "supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8" + "supplyId": "supply-test" } } } diff --git a/adapters/axonix/params_test.go b/adapters/axonix/params_test.go index e9c0cc5b83e..22b17a862f0 100644 --- a/adapters/axonix/params_test.go +++ b/adapters/axonix/params_test.go @@ -40,7 +40,7 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8"}`, + `{"supplyId": "test-supply"}`, `{"supplyId": "test"}`, } diff --git a/config/config.go b/config/config.go index b8ff3bd6116..c9b9e4aaf27 100644 --- a/config/config.go +++ b/config/config.go @@ -876,7 +876,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.audiencenetwork.disabled", true) v.SetDefault("adapters.audiencenetwork.endpoint", "https://an.facebook.com/placementbid.ortb") v.SetDefault("adapters.avocet.disabled", true) - v.SetDefault("adapters.axonix.disabled", true) + v.SetDefault("adapters.axonix.endpoint", "https://openrtb-us-east-1.axonix.com/supply/prebid-server/{{.AccountID}}") v.SetDefault("adapters.beachfront.endpoint", "https://display.bfmio.com/prebid_display") v.SetDefault("adapters.beachfront.extra_info", "{\"video_endpoint\":\"https://reachms.bfmio.com/bid.json?exchange_id\"}") v.SetDefault("adapters.beintoo.endpoint", "https://ib.beintoo.com/um")