-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IX: update required site id field to be more flexible (#1934)
Co-authored-by: Joshua Gross <joshua.gross@indexexchange.com>
- Loading branch information
Showing
2 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}`, | ||
`{"siteid":"123", "size": [1,2,3]}`, | ||
`null`, | ||
`true`, | ||
`0`, | ||
`abc`, | ||
`[]`, | ||
`{}`, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters