Skip to content

Commit

Permalink
AppNexus: Make Ad Pod Id Optional (prebid#1792)
Browse files Browse the repository at this point in the history
  • Loading branch information
VeronikaSolovei9 authored and sachin-pubmatic committed Aug 2, 2021
1 parent 31f1f97 commit b1de4d4
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 8 deletions.
1 change: 1 addition & 0 deletions adapters/adapterstest/test_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func RunJSONBidderTest(t *testing.T, rootDir string, bidder adapters.Bidder) {
runTests(t, fmt.Sprintf("%s/supplemental", rootDir), bidder, true, false, false)
runTests(t, fmt.Sprintf("%s/amp", rootDir), bidder, true, true, false)
runTests(t, fmt.Sprintf("%s/video", rootDir), bidder, false, false, true)
runTests(t, fmt.Sprintf("%s/videosupplemental", rootDir), bidder, true, false, true)
}

// runTests runs all the *.json files in a directory. If allowErrors is false, and one of the test files
Expand Down
14 changes: 6 additions & 8 deletions adapters/appnexus/appnexus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestMemberQueryParam(t *testing.T) {
req.ID = "test_id"
reqExt := `{"prebid":{}}`
impExt := `{"bidder":{"placementId":123}}`
impExt := `{"bidder":{"placementId":123, "generate_ad_pod_id":true}}`
req.Ext = []byte(reqExt)
req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_0", Ext: []byte(impExt)})
Expand All @@ -88,7 +88,7 @@ func TestMemberQueryParam(t *testing.T) {
error = json.Unmarshal(reqData.Ext, &reqDataExt)
assert.NoError(t, error, "Response ext unmarshalling error should be nil")
regMatch, matchErr := regexp.Match(`[0-9]19`, []byte(reqDataExt.Appnexus.AdPodId))
regMatch, matchErr := regexp.Match(`^[0-9]+$`, []byte(reqDataExt.Appnexus.AdPodId))
assert.NoError(t, matchErr, "Regex match error should be nil")
assert.True(t, regMatch, "AdPod id doesn't present in Appnexus extension or has incorrect format")
}
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestVideoSinglePodManyImps(t *testing.T) {
error = json.Unmarshal(reqData1.Ext, &reqDataExt1)
assert.NoError(t, error, "Response ext unmarshalling error should be nil")
adPodId1 := reqDataExt1.Appnexus.AdPodId
assert.Equal(t, "", reqDataExt1.Appnexus.AdPodId, "AdPod id should not be present in first request")
var reqData2 *openrtb2.BidRequest
error = json.Unmarshal(res[1].Body, &reqData2)
Expand All @@ -148,9 +148,7 @@ func TestVideoSinglePodManyImps(t *testing.T) {
error = json.Unmarshal(reqData2.Ext, &reqDataExt2)
assert.NoError(t, error, "Response ext unmarshalling error should be nil")
adPodId2 := reqDataExt2.Appnexus.AdPodId
assert.Equal(t, adPodId1, adPodId2, "AdPod id is not the same for the same pod")
assert.Equal(t, "", reqDataExt2.Appnexus.AdPodId, "AdPod id should not be present in second request")
}
func TestVideoTwoPods(t *testing.T) {
Expand All @@ -165,7 +163,7 @@ func TestVideoTwoPods(t *testing.T) {
req.ID = "test_id"
reqExt := `{"prebid":{}}`
impExt := `{"bidder":{"placementId":123}}`
impExt := `{"bidder":{"placementId":123, "generate_ad_pod_id": true}}`
req.Ext = []byte(reqExt)
req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_0", Ext: []byte(impExt)})
Expand Down Expand Up @@ -217,7 +215,7 @@ func TestVideoTwoPodsManyImps(t *testing.T) {
req.ID = "test_id"
reqExt := `{"prebid":{}}`
impExt := `{"bidder":{"placementId":123}}`
impExt := `{"bidder":{"placementId":123, "generate_ad_pod_id":true}}`
req.Ext = []byte(reqExt)
req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_0", Ext: []byte(impExt)})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1
}
}
},
{
"id": "2_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "http://ib.adnxs.com/openrtb2",
"body": {
"id": "test-request-id",
"ext": {
"appnexus": {
"hb_source": 6
},
"prebid": {}
},
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"appnexus": {
"placement_id": 1
}
}
},
{
"id": "2_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"appnexus": {
"placement_id": 1
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": true
}
}
},
{
"id": "1_2",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": true
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "http://ib.adnxs.com/openrtb2",
"body": {
"id": "test-request-id",
"ext": {
"appnexus": {
"adpod_id": "5577006791947779410",
"hb_source": 6
},
"prebid": {}
},
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"appnexus": {
"placement_id": 1
}
}
},
{
"id": "1_2",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"appnexus": {
"placement_id": 1
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": false
}
}
},
{
"id": "2_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": true
}
}
}
]
},

"expectedMakeRequestsErrors": [
{
"value": "generate ad pod option should be same for all pods in request",
"comparison": "literal"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "1_1",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": false
}
}
},
{
"id": "1_2",
"video": {
"mimes": ["video/mp4"],
"minduration": 15,
"maxduration": 30,
"protocols": [2, 3, 5, 6, 7, 8],
"w": 940,
"h": 560
},
"ext": {
"bidder": {
"placement_id": 1,
"generate_ad_pod_id": true
}
}
}
]
},

"expectedMakeRequestsErrors": [
{
"value": "generate ad pod option should be same for all pods in request",
"comparison": "literal"
}
]
}
1 change: 1 addition & 0 deletions openrtb_ext/imp_appnexus.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ExtImpAppnexus struct {
UsePmtRule *bool `json:"use_pmt_rule"`
// At this time we do no processing on the private sizes, so just leaving it as a JSON blob.
PrivateSizes json.RawMessage `json:"private_sizes"`
AdPodId bool `json:"generate_ad_pod_id"`
}

// ExtImpAppnexusKeyVal defines the contract for bidrequest.imp[i].ext.appnexus.keywords[i]
Expand Down
4 changes: 4 additions & 0 deletions static/bidder-params/appnexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
"type": "boolean",
"description": "Boolean to signal AppNexus to apply the relevant payment rule"
},
"generate_ad_pod_id": {
"type": "boolean",
"description": "Boolean to signal AppNexus to add ad pod id to each request"
},
"private_sizes" :{
"type": "array",
"items": {
Expand Down

0 comments on commit b1de4d4

Please sign in to comment.