Skip to content

Commit 320d8e9

Browse files
mefjushskonky
andauthored
Adhese: Switch to openrtb2 endpoint (prebid#3864)
Co-authored-by: skonky <[email protected]>
1 parent 02048f2 commit 320d8e9

23 files changed

+727
-1411
lines changed

adapters/adhese/adhese.go

+125-211
Large diffs are not rendered by default.

adapters/adhese/adhese_test.go

+55-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package adhese
22

33
import (
4+
"github.com/prebid/openrtb/v20/openrtb2"
45
"testing"
56

67
"github.com/prebid/prebid-server/v3/adapters/adapterstest"
@@ -9,9 +10,62 @@ import (
910
"github.com/stretchr/testify/assert"
1011
)
1112

13+
func TestInferBidType(t *testing.T) {
14+
tests := []struct {
15+
description string
16+
imp openrtb2.Imp
17+
expectedType openrtb_ext.BidType
18+
expectedError string
19+
}{
20+
{
21+
description: "Error case: empty imp",
22+
imp: openrtb2.Imp{},
23+
expectedError: "Could not infer bid type from imp",
24+
},
25+
{
26+
description: "Banner type",
27+
imp: openrtb2.Imp{Banner: &openrtb2.Banner{}},
28+
expectedType: openrtb_ext.BidTypeBanner,
29+
},
30+
{
31+
description: "Native type",
32+
imp: openrtb2.Imp{Native: &openrtb2.Native{}},
33+
expectedType: openrtb_ext.BidTypeNative,
34+
},
35+
{
36+
description: "Video type",
37+
imp: openrtb2.Imp{Video: &openrtb2.Video{}},
38+
expectedType: openrtb_ext.BidTypeVideo,
39+
},
40+
{
41+
description: "Audio type",
42+
imp: openrtb2.Imp{Audio: &openrtb2.Audio{}},
43+
expectedType: openrtb_ext.BidTypeAudio,
44+
},
45+
{
46+
description: "Unsupported type",
47+
imp: openrtb2.Imp{PMP: &openrtb2.PMP{}},
48+
expectedError: "Could not infer bid type from imp",
49+
},
50+
}
51+
52+
for _, test := range tests {
53+
t.Run(test.description, func(t *testing.T) {
54+
inferredType, err := inferBidTypeFromImp(test.imp)
55+
56+
if test.expectedError != "" {
57+
assert.EqualError(t, err[0], test.expectedError)
58+
} else {
59+
assert.Nil(t, err)
60+
assert.Equal(t, test.expectedType, inferredType)
61+
}
62+
})
63+
}
64+
}
65+
1266
func TestJsonSamples(t *testing.T) {
1367
bidder, buildErr := Builder(openrtb_ext.BidderAdhese, config.Adapter{
14-
Endpoint: "https://ads-{{.AccountID}}.adhese.com/json"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
68+
Endpoint: "https://{{.AccountID}}.foo.bar/"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
1569

1670
if buildErr != nil {
1771
t.Fatalf("Builder returned unexpected error %v", buildErr)

adapters/adhese/adhesetest/exemplary/banner-internal.json

-107
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,130 @@
11
{
22
"mockBidRequest": {
33
"id": "test-req",
4+
"user": {
5+
"ext": {
6+
"consent": "dummy"
7+
}
8+
},
49
"imp": [
510
{
611
"id": "test-req",
712
"banner": {
8-
"format": [
9-
{
10-
"w": 300,
11-
"h": 250
12-
}
13-
]
13+
"w": 300,
14+
"h": 250
1415
},
1516
"ext": {
1617
"bidder": {
18+
"location": "pbs_test",
19+
"format": "pbs_mr",
1720
"account": "market",
18-
"location": "_adhese_prebid_demo_",
19-
"format": "leaderboard",
20-
"targets":
21-
{
21+
"targets": {
2222
"ci": ["gent", "brussels"],
2323
"ag": ["55"],
2424
"tl": ["all"]
2525
}
26-
}
26+
},
27+
"tid": "6811e2a1-3649-4e54-ba03-c9b1401ae728"
2728
}
2829
}
2930
],
3031
"site": {
3132
"id": "test",
3233
"publisher": {
3334
"id": "123"
34-
},
35-
"page": "dummy"
35+
}
3636
}
3737
},
3838
"httpCalls": [
3939
{
4040
"expectedRequest": {
41-
"uri": "https://ads-market.adhese.com/json/sl_adhese_prebid_demo_-leaderboard/ag55/cigent;brussels/tlall/xfdummy",
42-
"impIDs":["test-req"]
41+
"uri": "https://market.foo.bar/",
42+
"impIDs": ["test-req"],
43+
"body": {
44+
"id": "test-req",
45+
"imp": [
46+
{
47+
"banner": {
48+
"h": 250,
49+
"w": 300
50+
},
51+
"ext": {
52+
"adhese": {
53+
"SL": ["pbs_test-pbs_mr"],
54+
"ag": ["55"],
55+
"ci": ["gent", "brussels"],
56+
"tl": ["all"]
57+
}
58+
},
59+
"id": "test-req"
60+
}
61+
],
62+
"site": {
63+
"id": "test",
64+
"publisher": {
65+
"id": "123"
66+
}
67+
},
68+
"user": {
69+
"ext": {
70+
"consent": "dummy"
71+
}
72+
}
73+
}
4374
},
4475
"mockResponse": {
4576
"status": 200,
46-
"body": [{
47-
"origin": "APPNEXUS",
48-
"originInstance": "",
49-
"ext": "js",
50-
"slotName": "_main_page_-leaderboard",
51-
"adType": "leaderboard",
52-
"originData": {
53-
"seatbid": [
54-
{
55-
"bid": [
56-
{
57-
"crid": "60613369",
58-
"dealid": null
59-
}
60-
],
61-
"seat": "958"
62-
}
63-
]
64-
},
65-
"width": "728",
66-
"height": "90",
67-
"body": "<div style='background-color:red; height:250px; width:300px'></div>",
68-
"tracker": "https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a",
69-
"impressionCounter": "https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a",
70-
"extension": {
71-
"prebid": {
72-
"cpm": {
73-
"amount": "1",
74-
"currency": "USD"
75-
}
77+
"body": {
78+
"id": "test-req",
79+
"seatbid": [
80+
{
81+
"bid": [
82+
{
83+
"price": 1.087,
84+
"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>",
85+
"w": 300,
86+
"h": 250,
87+
"crid": "demo-475",
88+
"dealid": "demo-234",
89+
"ext": {
90+
"adhese": {
91+
"adType": "leaderboard",
92+
"adFormat": "superadformat"
93+
}
94+
},
95+
"id": "a5ec99e8-aa6b-42f4-bf8b-b68dabf96caf",
96+
"impid": "imp_id"
97+
}
98+
]
7699
}
77-
}
78-
}]
100+
],
101+
"cur": "USD"
102+
}
79103
}
80104
}
81105
],
82106
"expectedBidResponses": [
83107
{
84108
"currency": "USD",
85-
"bids": [
86-
{
87-
"bid": {
88-
"adm": "<div style='background-color:red; height:250px; width:300px'></div>",
89-
"w": 728,
90-
"h": 90,
91-
"id": "",
92-
"impid": "",
93-
"crid": "60613369",
94-
"price": 1.000000
95-
},
96-
"type": "banner"
97-
}
98-
]
109+
"bids": [
110+
{
111+
"bid": {
112+
"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>",
113+
"w": 300,
114+
"h": 250,
115+
"id": "a5ec99e8-aa6b-42f4-bf8b-b68dabf96caf",
116+
"impid": "imp_id",
117+
"crid": "demo-475",
118+
"dealid": "demo-234",
119+
"price": 1.087,
120+
"ext": {
121+
"adType": "leaderboard",
122+
"adFormat": "superadformat"
123+
}
124+
},
125+
"type": "banner"
126+
}
127+
]
99128
}
100129
]
101-
}
130+
}

0 commit comments

Comments
 (0)