-
Notifications
You must be signed in to change notification settings - Fork 769
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#164911891] Co-authored-by: Josh Becker <[email protected]>
- Loading branch information
Mathieu Pheulpin
and
Josh Becker
authored
May 15, 2019
1 parent
44455a2
commit a17beca
Showing
5 changed files
with
71 additions
and
1 deletion.
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,58 @@ | ||
package sharethrough | ||
|
||
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.BidderSharethrough, json.RawMessage(validParam)); err != nil { | ||
t.Errorf("Schema rejected Sharethrough 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.BidderSharethrough, json.RawMessage(invalidParam)); err == nil { | ||
t.Errorf("Schema allowed unexpected params: %s", invalidParam) | ||
} | ||
} | ||
} | ||
|
||
var validParams = []string{ | ||
`{"pkey": "123"}`, | ||
`{"pkey": "123", "iframe": true}`, | ||
`{"pkey": "abc", "iframe": false}`, | ||
`{"pkey": "abc123", "iframe": true, "iframeSize": [20, 20]}`, | ||
} | ||
|
||
var invalidParams = []string{ | ||
``, | ||
`null`, | ||
`true`, | ||
`5`, | ||
`4.2`, | ||
`[]`, | ||
`{}`, | ||
`{"pkey": 123}`, | ||
`{"iframe": 123}`, | ||
`{"iframeSize": [20, 20]}`, | ||
`{"pkey": 123, "iframe": 123}`, | ||
`{"pkey": 123, "iframe": true, "iframeSize": [20]}`, | ||
`{"pkey": 123, "iframe": true, "iframeSize": []}`, | ||
`{"pkey": 123, "iframe": true, "iframeSize": 123}`, | ||
} |
5 changes: 5 additions & 0 deletions
5
adapters/sharethrough/sharethroughtest/params/race/banner.json
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,5 @@ | ||
{ | ||
"pkey": "abc123", | ||
"iframe": true, | ||
"iframeSize": [50, 50] | ||
} |
5 changes: 5 additions & 0 deletions
5
adapters/sharethrough/sharethroughtest/params/race/native.json
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,5 @@ | ||
{ | ||
"pkey": "abc123", | ||
"iframe": true, | ||
"iframeSize": [50, 50] | ||
} |
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
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 |
---|---|---|
|
@@ -4,6 +4,8 @@ capabilities: | |
app: | ||
mediaTypes: | ||
- native | ||
- banner | ||
site: | ||
mediaTypes: | ||
- native | ||
- banner |