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

Adhese: Switch to openrtb2 endpoint #3864

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
343 changes: 136 additions & 207 deletions adapters/adhese/adhese.go

Large diffs are not rendered by default.

52 changes: 49 additions & 3 deletions adapters/adhese/adhese_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,63 @@
package adhese

import (
"testing"

"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v2/adapters/adapterstest"
"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/openrtb_ext"
"testing"

"github.com/stretchr/testify/assert"
)

func TestInferBidType(t *testing.T) {
imp := openrtb2.Imp{}

_, err := inferBidTypeFromImp(imp)

assert.EqualError(t, err[0], "Could not infer bid type from imp", "Error should be 'Could not infer bid type from imp'")
assert.NotEmpty(t, err, "Error should not be empty")

// Test for banner type
var bannerImp openrtb2.Imp
bannerImp.Banner = &openrtb2.Banner{}
inferredType, err := inferBidTypeFromImp(bannerImp)
assert.Nil(t, err, "Error should be nil")
assert.Equal(t, openrtb_ext.BidTypeBanner, inferredType, "Inferred type should be 'Banner'")

// Test for native type
var nativeImp openrtb2.Imp
nativeImp.Native = &openrtb2.Native{}
nativeImp.Native = &openrtb2.Native{}
inferredType, err = inferBidTypeFromImp(nativeImp)
assert.Nil(t, err, "Error should be nil")
assert.Equal(t, openrtb_ext.BidTypeNative, inferredType, "Inferred type should be 'Native'")

// Test for video type
var videoImp openrtb2.Imp
videoImp.Video = &openrtb2.Video{}
inferredType, err = inferBidTypeFromImp(videoImp)
assert.Nil(t, err, "Error should be nil")
assert.Equal(t, openrtb_ext.BidTypeVideo, inferredType, "Inferred type should be 'Video'")

// Test for audio type
var audioImp openrtb2.Imp
audioImp.Audio = &openrtb2.Audio{}
inferredType, err = inferBidTypeFromImp(audioImp)
assert.Nil(t, err, "Error should be nil")
assert.Equal(t, openrtb_ext.BidTypeAudio, inferredType, "Inferred type should be 'Audio'")

// Test for unsupported type
var unsupportedImp openrtb2.Imp
unsupportedImp.PMP = &openrtb2.PMP{}
inferredType, err = inferBidTypeFromImp(unsupportedImp)
assert.EqualError(t, err[0], "Could not infer bid type from imp", "Error should be 'Could not infer bid type from imp'")
assert.NotEmpty(t, err, "Error should not be empty")
}

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderAdhese, config.Adapter{
Endpoint: "https://ads-{{.AccountID}}.adhese.com/json"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
Endpoint: "https://ads-{{.AccountID}}.adhese.com/openrtb2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
Expand Down
107 changes: 0 additions & 107 deletions adapters/adhese/adhesetest/exemplary/banner-internal.json

This file was deleted.

175 changes: 111 additions & 64 deletions adapters/adhese/adhesetest/exemplary/banner-market.json
Original file line number Diff line number Diff line change
@@ -1,101 +1,148 @@
{
"mockBidRequest": {
"id": "test-req",
"user": {
"ext": {
"consent": "dummy"
}
},
"imp": [
{
"id": "test-req",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
"w": 300,
"h": 250
},
"ext": {
"bidder": {
"location": "pbs_test",
"format": "pbs_mr",
"account": "market",
"location": "_adhese_prebid_demo_",
"format": "leaderboard",
"targets":
{
"ci": ["gent", "brussels"],
"ag": ["55"],
"tl": ["all"]
"targets": {
"ci": [
"gent",
"brussels"
],
"ag": [
"55"
],
"tl": [
"all"
]
}
}
},
"tid": "6811e2a1-3649-4e54-ba03-c9b1401ae728"
}
}
],
"site": {
"id": "test",
"publisher": {
"id": "123"
},
"page": "dummy"
}
}
},
"httpCalls": [
{
"expectedRequest": {
"uri": "https://ads-market.adhese.com/json/sl_adhese_prebid_demo_-leaderboard/ag55/cigent;brussels/tlall/xfdummy",
"impIDs":["test-req"]
"uri": "https://ads-market.adhese.com/openrtb2",
"impIDs": [
"test-req"
],
"body": {
"id": "test-req",
"imp": [
{
"banner": {
"h": 250,
"w": 300
},
"ext": {
"adhese": {
"SL": [
"pbs_test-pbs_mr"
],
"ag": [
"55"
],
"ci": [
"gent",
"brussels"
],
"tl": [
"all"
]
}
},
"id": "test-req"
}
],
"site": {
"id": "test",
"publisher": {
"id": "123"
}
},
"user": {
"ext": {
"consent": "dummy"
}
}
}
},
"mockResponse": {
"status": 200,
"body": [{
"origin": "APPNEXUS",
"originInstance": "",
"ext": "js",
"slotName": "_main_page_-leaderboard",
"adType": "leaderboard",
"originData": {
"seatbid": [
{
"bid": [
{
"crid": "60613369",
"dealid": null
}
],
"seat": "958"
}
]
},
"width": "728",
"height": "90",
"body": "<div style='background-color:red; height:250px; width:300px'></div>",
"tracker": "https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a",
"impressionCounter": "https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a",
"extension": {
"prebid": {
"cpm": {
"amount": "1",
"currency": "USD"
}
"body": {
"id": "test-req",
"seatbid": [
{
"bid": [
{
"price": 1.087,
"adm": "<html><body style=\\\"margin:0%\\\"><a href=\\\"http://dev.tokyo.iponweb.net/click/KqFxs5SWsPYVXsL3wNKozGVQHK0aIuJ7t4amL-rK1dP0KFlKd3Z.K-Ch.NZ5GYKUyKRDAU794n-hSF9-LWCpovlxqPY49KxpP97JlRh2ux4f.kndmby6vvs0hXLFu4r0WBlhUT9qANUJZJ2bsvPV3kF4a6k60.wwL36qDxplquNmhT5mxsORhcUjFbDP1Sc0KNOfqf6kys.YEQ3VB8XvPK.1m.kZ2lCH6zP30PnHTdQO.6zyDRjFASwdDW-ayaRAiTWMeqpRzQlBMyG3MzWg6VgOclmvkn6BdlvNooBrQg2aIfYeNs8WMQ8LGKgjtH6ADbmE00uWsKQJaAMCrxFROhUVLvYGa.T.KDiHMDR6.FPQ5TCG.GrUS95X4c1S1w0ln7W9UKVh-Q3T7Qr6kj9VbyvtkLVhMhVT5Gnk4dw01Xneb4eih8hK8qU5urejYRdeVW3iFTx.MModFQw2WfarrFoeyB.Sjc5lbYcFDce5QlLoDXV14faAz6WSylogVnkHdCP9oTOuGMDeC752tCZt36HWbXucBBseAmi5njcmdfpF//http%3A%2F%2Fwww.chris.com\\\" target=\\\"_blank\\\"><img style=\\\"border: 0;\\\" border=\\\"0\\\" width=\\\"300\\\" height=\\\"250\\\" src=\\\"http://test.360yield.com/file/226569/LeftAligned_blue.png\\\" alt=\\\"\\\"/></a><img src=\\\"http://dev.tokyo.iponweb.net/imp_pixel?ic=KqFxs3bhZwS9j9reQlSW5affOay54sEDsEqQzNMeQr0olHvVZJJVG8HOZ.mPgdCcksXTG1UvtBnYVxu2F0jlB76NSwEQaxULkEsUfXMPbKKkP8v0tLFkLeF1iDgO9bjAJmxyVYtIA4C-hGy80tDfcltIKfy1JNz-zf7E0XNHKo1T8yGugThU2Uo65uR1v8jsYEFh3VmpI2pUvQgKAspX.WLBmON8jCfPuHCZr2dpyVhJ50PBavKBsON0gcwc5iwNhiF-.RFbqkmAZOXtt1DluDjddZelUghV8FnKLV1OAaJvHeMaeSwMYEYs355-53R3szvp2s9yvFDTI9P5X9Z.a0uMtuXoHyqjUFn79MCnntwYtqPxu9Ho17jgB2w4HCI2qd3bhEJG04lC-pDMOUkrD19.-ivMBkdYVKgl-5b13gS2e9absDIuy.1YWsdex3PTGXDMr68kpHI9lisCMd7EEWLQep-J37l1HyVZqT63cPvpim3siP6smbiAiR8lzu6JUKHgglc0oYWAVBCL4cwA4qKKqvpRrL8xQ4vRG8V9DPI8\\\" alt=\\\" \\\" style=\\\"display:none\\\"/><improvedigital_ad_output_information tp_id=\\\"\\\" buyer_id=\\\"0\\\" rtb_advertiser=\\\"\\\" campaign_id=\\\"284945\\\" line_item_id=\\\"367603\\\" creative_id=\\\"456851\\\" crid=\\\"0\\\" placement_id=\\\"1071749\\\"></improvedigital_ad_output_information></body></html><div style=\\\"position: absolute; left: 0px; top: 0px; visibility: hidden;\\\"><img src=\\\"http://127.0.0.1:8080/rtb_gateway/handlers/client/track/?id=0a9348ab-973d-4596-9ee8-bafa4e5d0865\\\" border=\\\"0\\\" width=\\\"1\\\" height=\\\"1\\\" alt=\\\"\\\" style=\\\"display:none\\\"></div>",
"w": 300,
"h": 250,
"crid": "demo-475",
"dealid": "demo-234",
"ext": {
"adhese": {
"adType": "leaderboard",
"adFormat": "superadformat"
}
},
"id": "a5ec99e8-aa6b-42f4-bf8b-b68dabf96caf",
"impid": "imp_id"
}
]
}
}
}]
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"adm": "<div style='background-color:red; height:250px; width:300px'></div>",
"w": 728,
"h": 90,
"id": "",
"impid": "",
"crid": "60613369",
"price": 1.000000
},
"type": "banner"
}
]
"bids": [
{
"bid": {
"adm": "<html><body style=\\\"margin:0%\\\"><a href=\\\"http://dev.tokyo.iponweb.net/click/KqFxs5SWsPYVXsL3wNKozGVQHK0aIuJ7t4amL-rK1dP0KFlKd3Z.K-Ch.NZ5GYKUyKRDAU794n-hSF9-LWCpovlxqPY49KxpP97JlRh2ux4f.kndmby6vvs0hXLFu4r0WBlhUT9qANUJZJ2bsvPV3kF4a6k60.wwL36qDxplquNmhT5mxsORhcUjFbDP1Sc0KNOfqf6kys.YEQ3VB8XvPK.1m.kZ2lCH6zP30PnHTdQO.6zyDRjFASwdDW-ayaRAiTWMeqpRzQlBMyG3MzWg6VgOclmvkn6BdlvNooBrQg2aIfYeNs8WMQ8LGKgjtH6ADbmE00uWsKQJaAMCrxFROhUVLvYGa.T.KDiHMDR6.FPQ5TCG.GrUS95X4c1S1w0ln7W9UKVh-Q3T7Qr6kj9VbyvtkLVhMhVT5Gnk4dw01Xneb4eih8hK8qU5urejYRdeVW3iFTx.MModFQw2WfarrFoeyB.Sjc5lbYcFDce5QlLoDXV14faAz6WSylogVnkHdCP9oTOuGMDeC752tCZt36HWbXucBBseAmi5njcmdfpF//http%3A%2F%2Fwww.chris.com\\\" target=\\\"_blank\\\"><img style=\\\"border: 0;\\\" border=\\\"0\\\" width=\\\"300\\\" height=\\\"250\\\" src=\\\"http://test.360yield.com/file/226569/LeftAligned_blue.png\\\" alt=\\\"\\\"/></a><img src=\\\"http://dev.tokyo.iponweb.net/imp_pixel?ic=KqFxs3bhZwS9j9reQlSW5affOay54sEDsEqQzNMeQr0olHvVZJJVG8HOZ.mPgdCcksXTG1UvtBnYVxu2F0jlB76NSwEQaxULkEsUfXMPbKKkP8v0tLFkLeF1iDgO9bjAJmxyVYtIA4C-hGy80tDfcltIKfy1JNz-zf7E0XNHKo1T8yGugThU2Uo65uR1v8jsYEFh3VmpI2pUvQgKAspX.WLBmON8jCfPuHCZr2dpyVhJ50PBavKBsON0gcwc5iwNhiF-.RFbqkmAZOXtt1DluDjddZelUghV8FnKLV1OAaJvHeMaeSwMYEYs355-53R3szvp2s9yvFDTI9P5X9Z.a0uMtuXoHyqjUFn79MCnntwYtqPxu9Ho17jgB2w4HCI2qd3bhEJG04lC-pDMOUkrD19.-ivMBkdYVKgl-5b13gS2e9absDIuy.1YWsdex3PTGXDMr68kpHI9lisCMd7EEWLQep-J37l1HyVZqT63cPvpim3siP6smbiAiR8lzu6JUKHgglc0oYWAVBCL4cwA4qKKqvpRrL8xQ4vRG8V9DPI8\\\" alt=\\\" \\\" style=\\\"display:none\\\"/><improvedigital_ad_output_information tp_id=\\\"\\\" buyer_id=\\\"0\\\" rtb_advertiser=\\\"\\\" campaign_id=\\\"284945\\\" line_item_id=\\\"367603\\\" creative_id=\\\"456851\\\" crid=\\\"0\\\" placement_id=\\\"1071749\\\"></improvedigital_ad_output_information></body></html><div style=\\\"position: absolute; left: 0px; top: 0px; visibility: hidden;\\\"><img src=\\\"http://127.0.0.1:8080/rtb_gateway/handlers/client/track/?id=0a9348ab-973d-4596-9ee8-bafa4e5d0865\\\" border=\\\"0\\\" width=\\\"1\\\" height=\\\"1\\\" alt=\\\"\\\" style=\\\"display:none\\\"></div>",
"w": 300,
"h": 250,
"id": "a5ec99e8-aa6b-42f4-bf8b-b68dabf96caf",
"impid": "imp_id",
"crid": "demo-475",
"dealid": "demo-234",
"price": 1.087,
"ext": {
"adType": "leaderboard",
"adFormat": "superadformat"
}
},
"type": "banner"
}
]
}
]
}
Loading
Loading