forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'prebid:master' into master
- Loading branch information
Showing
31 changed files
with
2,514 additions
and
38 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
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,98 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"app": { | ||
"bundle": "com.prebid" | ||
}, | ||
"device": { | ||
"ua": "test-user-agent", | ||
"ip": "123.123.123.123", | ||
"language": "en", | ||
"dnt": 0 | ||
}, | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}] | ||
}, | ||
"ext": { | ||
"bidder": {} | ||
} | ||
}] | ||
}, | ||
|
||
"httpCalls": [{ | ||
"expectedRequest": { | ||
"uri": "http://localhost/prebid_server", | ||
"body": { | ||
"id": "test-request-id", | ||
"cur": ["USD"], | ||
"app": { | ||
"bundle": "com.prebid" | ||
}, | ||
"device": { | ||
"ua": "test-user-agent", | ||
"ip": "123.123.123.123", | ||
"language": "en", | ||
"dnt": 0 | ||
}, | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}] | ||
}, | ||
"ext": { | ||
"bidder": {} | ||
} | ||
}] | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "test-request-id", | ||
"seatbid": [{ | ||
"seat": "rtbhouse", | ||
"bid": [{ | ||
"id": "randomid", | ||
"impid": "test-imp-id", | ||
"price": 0.500000, | ||
"adid": "12345678", | ||
"adm": "some-test-ad", | ||
"cid": "987", | ||
"crid": "12345678", | ||
"h": 250, | ||
"w": 300, | ||
"mtype": 1 | ||
}] | ||
}], | ||
"cur": "USD" | ||
} | ||
} | ||
}], | ||
|
||
"expectedBidResponses": [{ | ||
"currency": "USD", | ||
"bids": [{ | ||
"bid": { | ||
"id": "randomid", | ||
"impid": "test-imp-id", | ||
"price": 0.5, | ||
"adm": "some-test-ad", | ||
"adid": "12345678", | ||
"cid": "987", | ||
"crid": "12345678", | ||
"w": 300, | ||
"h": 250, | ||
"mtype": 1 | ||
}, | ||
"type": "banner" | ||
}] | ||
}] | ||
} |
112 changes: 112 additions & 0 deletions
112
adapters/rtbhouse/rtbhousetest/exemplary/app_native.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": { | ||
"imp": [ | ||
{ | ||
"ext": { | ||
"bidder": {} | ||
}, | ||
"id": "test-native-imp", | ||
"native": { | ||
"request": "{\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}],\"ver\":\"1.2\",\"assets\":[{\"id\":0,\"required\":1,\"title\":{\"len\":140}},{\"id\":1,\"required\":1,\"data\":{\"type\":2}},{\"id\":2,\"required\":1,\"img\":{\"type\":3}}]}", | ||
"ver": "1.2" | ||
} | ||
} | ||
], | ||
"app": { | ||
"bundle": "com.prebid" | ||
}, | ||
"device": { | ||
"ua": "test-user-agent", | ||
"ip": "123.123.123.123", | ||
"language": "en", | ||
"dnt": 0 | ||
}, | ||
"id": "test-native-request", | ||
"ext": {}, | ||
"debug": 1 | ||
}, | ||
"httpCalls": [ | ||
{ | ||
"expectedRequest": { | ||
"uri": "http://localhost/prebid_server", | ||
"body": { | ||
"id": "test-native-request", | ||
"cur": [ | ||
"USD" | ||
], | ||
"imp": [ | ||
{ | ||
"id": "test-native-imp", | ||
"native": { | ||
"request": "{\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}],\"ver\":\"1.2\",\"assets\":[{\"id\":0,\"required\":1,\"title\":{\"len\":140}},{\"id\":1,\"required\":1,\"data\":{\"type\":2}},{\"id\":2,\"required\":1,\"img\":{\"type\":3}}]}", | ||
"ver": "1.2" | ||
}, | ||
"ext": { | ||
"bidder": {} | ||
} | ||
} | ||
], | ||
"app": { | ||
"bundle": "com.prebid" | ||
}, | ||
"device": { | ||
"ua": "test-user-agent", | ||
"ip": "123.123.123.123", | ||
"language": "en", | ||
"dnt": 0 | ||
}, | ||
"ext": {} | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "test-native-request", | ||
"bidid": "test-bidid", | ||
"cur": "USD", | ||
"seatbid": [ | ||
{ | ||
"seat": "rtbhouse", | ||
"bid": [ | ||
{ | ||
"id": "test-native-request", | ||
"impid": "test-native-imp", | ||
"price": 0.5, | ||
"adid": "test-adid", | ||
"adm": "{\"ver\":\"1.2\",\"assets\":[{\"id\":0,\"title\":{\"text\":\"title text\"}},{\"id\":1,\"data\":{\"value\":\"data value\"}},{\"id\":2,\"img\":{\"url\":\"image.url\",\"w\":1200,\"h\":628}}],\"link\":{\"url\":\"link.url\"},\"imptrackers\":[\"imp.tracker.url\"],\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"event.tracker.url\"}]}", | ||
"adomain": [ "adomain.com" ], | ||
"cid": "test-cid", | ||
"crid": "test-crid", | ||
"dealid": "test-dealid", | ||
"mtype": 4 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"expectedBidResponses": [ | ||
{ | ||
"currency": "USD", | ||
"bids": [ | ||
{ | ||
"bid": { | ||
"id": "test-native-request", | ||
"impid": "test-native-imp", | ||
"price": 0.5, | ||
"adid": "test-adid", | ||
"adm": "{\"ver\":\"1.2\",\"assets\":[{\"id\":0,\"title\":{\"text\":\"title text\"}},{\"id\":1,\"data\":{\"value\":\"data value\"}},{\"id\":2,\"img\":{\"url\":\"image.url\",\"w\":1200,\"h\":628}}],\"link\":{\"url\":\"link.url\"},\"imptrackers\":[\"imp.tracker.url\"],\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"event.tracker.url\"}]}", | ||
"adomain": [ "adomain.com" ], | ||
"cid": "test-cid", | ||
"crid": "test-crid", | ||
"dealid": "test-dealid", | ||
"mtype": 4 | ||
}, | ||
"type": "native" | ||
} | ||
] | ||
} | ||
] | ||
} |
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,87 @@ | ||
package yandex | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/prebid/prebid-server/v2/openrtb_ext" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestValidParams(t *testing.T) { | ||
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") | ||
if err != nil { | ||
t.Fatalf("Failed to fetch the json schema. %v", err) | ||
} | ||
|
||
for _, p := range validParams { | ||
if err := validator.Validate(openrtb_ext.BidderYandex, json.RawMessage(p)); err != nil { | ||
t.Errorf("Schema rejected valid params: %s", p) | ||
} | ||
} | ||
} | ||
|
||
func TestInvalidParams(t *testing.T) { | ||
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") | ||
if err != nil { | ||
t.Fatalf("Failed to fetch the json schema. %v", err) | ||
} | ||
|
||
for _, p := range invalidParams { | ||
if err := validator.Validate(openrtb_ext.BidderYandex, json.RawMessage(p)); err == nil { | ||
t.Errorf("Schema allowed invalid params: %s", p) | ||
} | ||
} | ||
} | ||
|
||
var validParams = []string{ | ||
`{"page_id": 123123, "imp_id": 123}`, | ||
`{"placement_id": "A-123123-123"}`, | ||
`{"placement_id": "B-A-123123-123"}`, | ||
`{"placement_id": "123123-123"}`, | ||
} | ||
|
||
var invalidParams = []string{ | ||
`{"pageId": 123123, "impId": 123}`, | ||
`{"page_id": 0, "imp_id": 0}`, | ||
`{"page_id": "123123", "imp_id": "123"}`, | ||
`{"page_id": "123123", "imp_id": "123", "placement_id": "123123"}`, | ||
`{"page_id": "123123"}`, | ||
`{"imp_id": "123"}`, | ||
`{"placement_id": 123123}`, | ||
`{"placement_id": "123123"}`, | ||
`{"placement_id": "A-123123"}`, | ||
`{"placement_id": "B-A-123123"}`, | ||
`{}`, | ||
} | ||
|
||
func TestValidPlacementIdMapper(t *testing.T) { | ||
for ext, expectedPlacementId := range validPlacementIds { | ||
val, err := mapExtToPlacementID(ext) | ||
|
||
assert.Equal(t, &expectedPlacementId, val) | ||
assert.NoError(t, err) | ||
} | ||
} | ||
|
||
func TestInvalidPlacementIdMapper(t *testing.T) { | ||
for _, ext := range invalidPlacementIds { | ||
_, err := mapExtToPlacementID(ext) | ||
|
||
assert.Error(t, err) | ||
} | ||
} | ||
|
||
var validPlacementIds = map[openrtb_ext.ExtImpYandex]yandexPlacementID{ | ||
{PlacementID: "A-12345-1"}: {PageID: "12345", ImpID: "1"}, | ||
{PlacementID: "B-A-123123-123"}: {PageID: "123123", ImpID: "123"}, | ||
{PlacementID: "111-222"}: {PageID: "111", ImpID: "222"}, | ||
{PageID: 111, ImpID: 222}: {PageID: "111", ImpID: "222"}, | ||
} | ||
|
||
var invalidPlacementIds = []openrtb_ext.ExtImpYandex{ | ||
{PlacementID: "123123"}, | ||
{PlacementID: "A-123123"}, | ||
{PlacementID: "B-A-123123"}, | ||
{PlacementID: "C-B-A-123123"}, | ||
} |
Oops, something went wrong.