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

Axonix: enabled by default #1936

Merged
merged 5 commits into from
Jul 30, 2021
Merged
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
27 changes: 21 additions & 6 deletions adapters/axonix/axonix.go
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the err from this call in the errors slice before returning it:

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,
}
16 changes: 7 additions & 9 deletions adapters/axonix/axonix_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package axonix

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/prebid/prebid-server/adapters/adapterstest"
"github.com/prebid/prebid-server/config"
"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)
}
10 changes: 5 additions & 5 deletions adapters/axonix/axonixtest/exemplary/banner-and-video.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
14 changes: 7 additions & 7 deletions adapters/axonix/axonixtest/exemplary/banner-video-native.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
6 changes: 3 additions & 3 deletions adapters/axonix/axonixtest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
6 changes: 3 additions & 3 deletions adapters/axonix/axonixtest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
2 changes: 1 addition & 1 deletion adapters/axonix/axonixtest/params/race/banner.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8"
"supplyId": "supply-test"
}
2 changes: 1 addition & 1 deletion adapters/axonix/axonixtest/params/race/video.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8"
"supplyId": "supply-test"
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
6 changes: 3 additions & 3 deletions adapters/axonix/axonixtest/supplemental/valid-extension.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
2 changes: 1 addition & 1 deletion adapters/axonix/params_test.go
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ func TestInvalidParams(t *testing.T) {
}

var validParams = []string{
`{"supplyId": "24cc9034-f861-47b8-a6a8-b7e0968c00b8"}`,
`{"supplyId": "test-supply"}`,
`{"supplyId": "test"}`,
}

2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -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")