github.com/prebid/prebid-server/v2@v2.18.0/adapters/telaria/params_test.go (about) 1 package telaria 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/prebid/prebid-server/v2/openrtb_ext" 8 ) 9 10 func TestValidParams(t *testing.T) { 11 validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") 12 if err != nil { 13 t.Fatalf("Failed to fetch the json-schemas. %v", err) 14 } 15 16 for _, validParam := range validParams { 17 if err := validator.Validate(openrtb_ext.BidderTelaria, json.RawMessage(validParam)); err != nil { 18 t.Errorf("Schema rejected Telaria params: %s", validParam) 19 } 20 } 21 } 22 23 // TestInvalidParams makes sure that the Telaria schema rejects all the imp.ext fields we don't support. 24 func TestInvalidParams(t *testing.T) { 25 validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") 26 if err != nil { 27 t.Fatalf("Failed to fetch the json-schemas. %v", err) 28 } 29 30 for _, invalidParam := range invalidParams { 31 if err := validator.Validate(openrtb_ext.BidderTelaria, json.RawMessage(invalidParam)); err == nil { 32 t.Errorf("Schema allowed unexpected params: %s", invalidParam) 33 } 34 } 35 } 36 37 var validParams = []string{ 38 `{"adCode": "string", "seatCode": "string", "originalPublisherid": "string"}`, 39 } 40 41 var invalidParams = []string{ 42 ``, 43 `null`, 44 `true`, 45 `5`, 46 `4.2`, 47 `[]`, 48 `{}`, 49 `{"adCode": "string", "originalPublisherid": "string"}`, 50 `{"adCode": "string", "seatCode": 5, "originalPublisherid": "string"}`, 51 }