-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Triplelift Native add site.publisher nil check (#3824)
- Loading branch information
Showing
21 changed files
with
1,155 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package triplelift_native | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/prebid/prebid-server/v2/openrtb_ext" | ||
) | ||
|
||
func TestValidParams(t *testing.T) { | ||
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") | ||
if err != nil { | ||
t.Fatalf("Failed to fetch the json-schemas. %v", err) | ||
} | ||
|
||
for _, validParam := range validParams { | ||
if err := validator.Validate(openrtb_ext.BidderTripleliftNative, json.RawMessage(validParam)); err != nil { | ||
t.Errorf("Schema rejected triplelift native params: %s", validParam) | ||
} | ||
} | ||
} | ||
|
||
func TestInvalidParams(t *testing.T) { | ||
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") | ||
if err != nil { | ||
t.Fatalf("Failed to fetch the json-schemas. %v", err) | ||
} | ||
|
||
for _, invalidParam := range invalidParams { | ||
if err := validator.Validate(openrtb_ext.BidderTripleliftNative, json.RawMessage(invalidParam)); err == nil { | ||
t.Errorf("Schema allowed unexpected params: %s", invalidParam) | ||
} | ||
} | ||
} | ||
|
||
var validParams = []string{ | ||
`{"inventoryCode":"1"}`, | ||
`{"inventoryCode":"test"}`, | ||
`{"inventoryCode":"test", "floor":10}`, | ||
} | ||
|
||
var invalidParams = []string{ | ||
``, | ||
`null`, | ||
`true`, | ||
`5`, | ||
`4.2`, | ||
`[]`, | ||
`{}`, | ||
`{"inventoryCode":1}`, | ||
`{"inventoryCode":""}`, | ||
`{"inventoryCode":"1", "floor": "10"}`, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
adapters/triplelift_native/triplelift_nativetest/exemplary/app-msn-no-tag-code.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"app": { | ||
"publisher": { | ||
"id": "foo", | ||
"name": "foo", | ||
"domain": "msn.com" | ||
} | ||
}, | ||
"imp": [{ | ||
"native": { | ||
"request": "{\"plcmtcnt\":1,\"plcmttype\":2,\"privacy\":1,\"context\":1,\"contextsubtype\":12,\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]},{\"event\":2,\"methods\":[1]}],\"assets\":[{\"data\":{\"type\":12},\"required\":1},{\"title\":{\"len\":50},\"required\":1},{\"img\":{\"w\":80,\"h\":80,\"type\":1},\"required\":1},{\"img\":{\"w\":1200,\"h\":627,\"type\":3},\"required\":1},{\"data\":{\"type\":3},\"required\":0},{\"data\":{\"len\":100,\"type\":2},\"required\":1},{\"video\":{\"mimes\":[\"video/mpeg\",\"video/mp4\"],\"minduration\":2,\"protocols\":[2,5],\"maxduration\":2,\"ext\":{\"playbackmethod\":[1,2]}},\"required\":1}],\"ver\":\"1.2\"}" | ||
}, | ||
"id": "test-imp-id", | ||
"ext": { | ||
"bidder": { | ||
"inventoryCode": "invcode", | ||
"floor": 20 | ||
}, | ||
"data": { | ||
"tag_code": "" | ||
} | ||
} | ||
}] | ||
}, | ||
"httpCalls": [{ | ||
"expectedRequest": { | ||
"uri": "http://tlx.3lift.net/s2sn/auction?supplier_id=20", | ||
"body": { | ||
"id": "test-request-id", | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"native": { | ||
"request": "{\"plcmtcnt\":1,\"plcmttype\":2,\"privacy\":1,\"context\":1,\"contextsubtype\":12,\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]},{\"event\":2,\"methods\":[1]}],\"assets\":[{\"data\":{\"type\":12},\"required\":1},{\"title\":{\"len\":50},\"required\":1},{\"img\":{\"w\":80,\"h\":80,\"type\":1},\"required\":1},{\"img\":{\"w\":1200,\"h\":627,\"type\":3},\"required\":1},{\"data\":{\"type\":3},\"required\":0},{\"data\":{\"len\":100,\"type\":2},\"required\":1},{\"video\":{\"mimes\":[\"video/mpeg\",\"video/mp4\"],\"minduration\":2,\"protocols\":[2,5],\"maxduration\":2,\"ext\":{\"playbackmethod\":[1,2]}},\"required\":1}],\"ver\":\"1.2\"}" | ||
}, | ||
"tagid": "invcode", | ||
"bidfloor": 20, | ||
"ext": { | ||
"bidder": { | ||
"inventoryCode": "invcode", | ||
"floor": 20 | ||
}, | ||
"data": { | ||
"tag_code": "" | ||
} | ||
} | ||
}], | ||
"app": { | ||
"publisher": { | ||
"id": "foo", | ||
"name": "foo", | ||
"domain": "msn.com" | ||
} | ||
} | ||
}, | ||
"impIDs": ["test-imp-id"] | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "test-request-id", | ||
"seatbid": [{ | ||
"seat": "958", | ||
"bid": [{ | ||
"id": "7706636740145184841", | ||
"impid": "test-imp-id", | ||
"price": 0.5, | ||
"adid": "29681110", | ||
"adm": "some-test-ad", | ||
"adomain": [ | ||
"triplelift.com" | ||
], | ||
"iurl": "http://example.com", | ||
"cid": "958", | ||
"crid": "29681110", | ||
"h": 250, | ||
"w": 300, | ||
"ext": "aaa" | ||
}] | ||
}], | ||
"bidid": "5778926625248726496", | ||
"cur": "USD" | ||
} | ||
} | ||
}], | ||
"expectedBidResponses": [{ | ||
"currency": "USD", | ||
"bids": [{ | ||
"id": "test-request-id", | ||
"type": "native", | ||
"bid": { | ||
"id": "7706636740145184841", | ||
"impid": "test-imp-id", | ||
"price": 0.5, | ||
"adid": "29681110", | ||
"adm": "some-test-ad", | ||
"adomain": [ | ||
"triplelift.com" | ||
], | ||
"iurl": "http://example.com", | ||
"cid": "958", | ||
"crid": "29681110", | ||
"h": 250, | ||
"w": 300, | ||
"ext": "aaa" | ||
}, | ||
"bidid": "5778926625248726496", | ||
"cur": "USD" | ||
}] | ||
}] | ||
} |
112 changes: 112 additions & 0 deletions
112
adapters/triplelift_native/triplelift_nativetest/exemplary/app-msn.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"app": { | ||
"publisher": { | ||
"id": "foo", | ||
"name": "foo", | ||
"domain": "msn.com" | ||
} | ||
}, | ||
"imp": [{ | ||
"native": { | ||
"request": "{\"plcmtcnt\":1,\"plcmttype\":2,\"privacy\":1,\"context\":1,\"contextsubtype\":12,\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]},{\"event\":2,\"methods\":[1]}],\"assets\":[{\"data\":{\"type\":12},\"required\":1},{\"title\":{\"len\":50},\"required\":1},{\"img\":{\"w\":80,\"h\":80,\"type\":1},\"required\":1},{\"img\":{\"w\":1200,\"h\":627,\"type\":3},\"required\":1},{\"data\":{\"type\":3},\"required\":0},{\"data\":{\"len\":100,\"type\":2},\"required\":1},{\"video\":{\"mimes\":[\"video/mpeg\",\"video/mp4\"],\"minduration\":2,\"protocols\":[2,5],\"maxduration\":2,\"ext\":{\"playbackmethod\":[1,2]}},\"required\":1}],\"ver\":\"1.2\"}" | ||
}, | ||
"id": "test-imp-id", | ||
"ext": { | ||
"bidder": { | ||
"inventoryCode": "invcode", | ||
"floor": 20 | ||
}, | ||
"data": { | ||
"tag_code": "bar" | ||
} | ||
} | ||
}] | ||
}, | ||
"httpCalls": [{ | ||
"expectedRequest": { | ||
"uri": "http://tlx.3lift.net/s2sn/auction?supplier_id=20", | ||
"body": { | ||
"id": "test-request-id", | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"native": { | ||
"request": "{\"plcmtcnt\":1,\"plcmttype\":2,\"privacy\":1,\"context\":1,\"contextsubtype\":12,\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]},{\"event\":2,\"methods\":[1]}],\"assets\":[{\"data\":{\"type\":12},\"required\":1},{\"title\":{\"len\":50},\"required\":1},{\"img\":{\"w\":80,\"h\":80,\"type\":1},\"required\":1},{\"img\":{\"w\":1200,\"h\":627,\"type\":3},\"required\":1},{\"data\":{\"type\":3},\"required\":0},{\"data\":{\"len\":100,\"type\":2},\"required\":1},{\"video\":{\"mimes\":[\"video/mpeg\",\"video/mp4\"],\"minduration\":2,\"protocols\":[2,5],\"maxduration\":2,\"ext\":{\"playbackmethod\":[1,2]}},\"required\":1}],\"ver\":\"1.2\"}" | ||
}, | ||
"tagid": "bar", | ||
"bidfloor": 20, | ||
"ext": { | ||
"bidder": { | ||
"inventoryCode": "invcode", | ||
"floor": 20 | ||
}, | ||
"data": { | ||
"tag_code": "bar" | ||
} | ||
} | ||
}], | ||
"app": { | ||
"publisher": { | ||
"id": "foo", | ||
"name": "foo", | ||
"domain": "msn.com" | ||
} | ||
} | ||
}, | ||
"impIDs": ["test-imp-id"] | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "test-request-id", | ||
"seatbid": [{ | ||
"seat": "958", | ||
"bid": [{ | ||
"id": "7706636740145184841", | ||
"impid": "test-imp-id", | ||
"price": 0.5, | ||
"adid": "29681110", | ||
"adm": "some-test-ad", | ||
"adomain": [ | ||
"triplelift.com" | ||
], | ||
"iurl": "http://example.com", | ||
"cid": "958", | ||
"crid": "29681110", | ||
"h": 250, | ||
"w": 300, | ||
"ext": "aaa" | ||
}] | ||
}], | ||
"bidid": "5778926625248726496", | ||
"cur": "USD" | ||
} | ||
} | ||
}], | ||
"expectedBidResponses": [{ | ||
"currency": "USD", | ||
"bids": [{ | ||
"id": "test-request-id", | ||
"type": "native", | ||
"bid": { | ||
"id": "7706636740145184841", | ||
"impid": "test-imp-id", | ||
"price": 0.5, | ||
"adid": "29681110", | ||
"adm": "some-test-ad", | ||
"adomain": [ | ||
"triplelift.com" | ||
], | ||
"iurl": "http://example.com", | ||
"cid": "958", | ||
"crid": "29681110", | ||
"h": 250, | ||
"w": 300, | ||
"ext": "aaa" | ||
}, | ||
"bidid": "5778926625248726496", | ||
"cur": "USD" | ||
}] | ||
}] | ||
} |
Oops, something went wrong.