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

IX: update required site id field to be more flexible #1934

Merged
merged 3 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions adapters/ix/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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":""}`,
`{"siteID":""}`,
`{"siteId":""}`,
`{"siteid":"1234", "siteID":"12345"}`,
`{"siteid":"1234", "siteId":"123456"}`,
`{"siteid":123}`,
`{"siteids":"123"}`,
`{"notaparam":"123"}`,
grossjo marked this conversation as resolved.
Show resolved Hide resolved
`{"siteid":"123", "size": [1,2,3]}`,
`null`,
`true`,
`0`,
`abc`,
`[]`,
`{}`,
}
18 changes: 16 additions & 2 deletions static/bidder-params/ix.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@
"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, 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."
},
grossjo marked this conversation as resolved.
Show resolved Hide resolved
"size": {
"type": "array",
Expand All @@ -19,5 +29,9 @@
"description": "An array of two integer containing the dimension"
}
},
"required": ["siteId"]
"oneOf": [
{"required": ["siteid"]},
{"required": ["siteId"]},
{"required": ["siteID"]}
]
}