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

New Adapter: RichAudience #2001

Merged
merged 16 commits into from
Oct 22, 2021
48 changes: 48 additions & 0 deletions adapters/richaudience/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package richaudience

import (
"encoding/json"
"testing"

"github.com/prebid/prebid-server/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 schema. %v", err)
}

for _, p := range validParams {
if err := validator.Validate(openrtb_ext.BidderRichaudience, 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.BidderRichaudience, json.RawMessage(p)); err == nil {
t.Errorf("Schema allowed invalid params: %s", p)
}
}
}

var validParams = []string{
`{"pid":"hash", "supplyType":"site"}`,
`{"pid":"hash", "supplyType":"site", "TestRa": true}`,
}

var invalidParams = []string{
`{"pid": 42}`,
`{"pid": "", "supplyType":0}`,
`{"pid": 11, "supplyType":"site"}`,
`{"pid": "hash", "supplyType":11}`,
`{"pid": "hash"}`,
`{"supplyType":"site"}`,
}
richaudience marked this conversation as resolved.
Show resolved Hide resolved
Loading