diff --git a/adapters/blue/params_test.go b/adapters/blue/params_test.go new file mode 100644 index 0000000000..27b1e02ea8 --- /dev/null +++ b/adapters/blue/params_test.go @@ -0,0 +1,51 @@ +package blue + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v3/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.BidderBlue, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected blue 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.BidderBlue, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"publisherId":"1234"}`, + `{"publisherId":"1234", "placementId":"12345"}`, + `{"publisherId":"", "placementId":""}`, +} + +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{}`, + `{"placementId":"12345"}`, +} diff --git a/static/bidder-params/blue.json b/static/bidder-params/blue.json index 6624defd4d..537fc44da7 100644 --- a/static/bidder-params/blue.json +++ b/static/bidder-params/blue.json @@ -4,6 +4,10 @@ "description": "A schema which validates params accepted by the Blue adapter", "type": "object", "properties": { + "placementId": { + "type": "string", + "description": "Placement ID provided by Blue" + }, "publisherId": { "type": "string", "description": "The publisher’s ID provided by Blue" @@ -12,4 +16,4 @@ "required": [ "publisherId" ] -} \ No newline at end of file +}