From 0ae53a1216918a614997855a9051702c6ca6ec2b Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 21 Jul 2021 13:31:30 -0400 Subject: [PATCH 1/3] update required site id field to be more flexible for ix bidder --- static/bidder-params/ix.json | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/static/bidder-params/ix.json b/static/bidder-params/ix.json index 155cfa21892..ac1b23b2350 100644 --- a/static/bidder-params/ix.json +++ b/static/bidder-params/ix.json @@ -4,11 +4,21 @@ "description": "A schema which validates params accepted by the Ix adapter", "type": "object", "properties": { + "siteid": { + "type": "string", + "minLength": 1, + "description": "An ID which identifies the site selling the impression" + }, "siteId": { "type": "string", "minLength": 1, "description": "An ID which identifies the site selling the impression" }, + "siteID": { + "type": "string", + "minLength": 1, + "description": "An ID which identifies the site selling the impression" + }, "size": { "type": "array", "items": { @@ -19,5 +29,9 @@ "description": "An array of two integer containing the dimension" } }, - "required": ["siteId"] + "oneOf": [ + {"required": ["siteid"]}, + {"required": ["siteId"]}, + {"required": ["siteID"]} + ] } From 54f57271fc41676a9cd7539fa5c2a5614df47765 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 22 Jul 2021 12:59:39 -0400 Subject: [PATCH 2/3] add json-schema params tests for ix bidder --- adapters/ix/params_test.go | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 adapters/ix/params_test.go diff --git a/adapters/ix/params_test.go b/adapters/ix/params_test.go new file mode 100644 index 00000000000..c3d1fde1d0a --- /dev/null +++ b/adapters/ix/params_test.go @@ -0,0 +1,54 @@ +package ix + +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-schemas. %v", err) + } + + for _, validParam := range validParams { + if err := validator.Validate(openrtb_ext.BidderIx, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected ix 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.BidderIx, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"siteid":"1234"}`, + `{"siteID":"12345"}`, + `{"siteId":"123456"}`, + `{"siteid":"1234567", "size": [640,480]}`, +} + +var invalidParams = []string{ + `{"siteid":123}`, + `{"siteids":"123"}`, + `{"notaparam":"123"}`, + `{"siteid":"123", "size": [1,2,3]}`, + `null`, + `true`, + `0`, + `abc`, + `[]`, + `{}`, +} From 400af235716c3d3ff003cf5b8f3420f052c2d9fb Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 29 Jul 2021 13:31:16 -0400 Subject: [PATCH 3/3] add few more test cases and make siteid param preferred --- adapters/ix/params_test.go | 5 +++++ static/bidder-params/ix.json | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/adapters/ix/params_test.go b/adapters/ix/params_test.go index c3d1fde1d0a..9246a43a725 100644 --- a/adapters/ix/params_test.go +++ b/adapters/ix/params_test.go @@ -41,6 +41,11 @@ var validParams = []string{ } var invalidParams = []string{ + `{"siteid":""}`, + `{"siteID":""}`, + `{"siteId":""}`, + `{"siteid":"1234", "siteID":"12345"}`, + `{"siteid":"1234", "siteId":"123456"}`, `{"siteid":123}`, `{"siteids":"123"}`, `{"notaparam":"123"}`, diff --git a/static/bidder-params/ix.json b/static/bidder-params/ix.json index ac1b23b2350..a7a5cb7308a 100644 --- a/static/bidder-params/ix.json +++ b/static/bidder-params/ix.json @@ -7,17 +7,17 @@ "siteid": { "type": "string", "minLength": 1, - "description": "An ID which identifies the site selling the impression" + "description": "An ID which identifies the site selling the impression, preferred." }, "siteId": { "type": "string", "minLength": 1, - "description": "An ID which identifies the site selling the impression" + "description": "An ID which identifies the site selling the impression." }, "siteID": { "type": "string", "minLength": 1, - "description": "An ID which identifies the site selling the impression" + "description": "An ID which identifies the site selling the impression." }, "size": { "type": "array",