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