Skip to content

Commit

Permalink
Remove host param
Browse files Browse the repository at this point in the history
  • Loading branch information
imedvedko committed Sep 5, 2023
1 parent 1804a36 commit cc4e8f1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 8 deletions.
68 changes: 68 additions & 0 deletions adapters/appstock/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package appstock

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 schema. %v", err)
}

for _, p := range validParams {
if err := validator.Validate(openrtb_ext.BidderAppstock, json.RawMessage(p)); err != nil {
t.Errorf("Schema rejected valid params: %s", p)
}
}
}

func TestInvalidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json schema. %v", err)
}

for _, p := range invalidParams {
if err := validator.Validate(openrtb_ext.BidderAppstock, json.RawMessage(p)); err == nil {
t.Errorf("Schema allowed invalid params: %s", p)
}
}
}

var validParams = []string{
`{"publisherId": 1}`,
`{"publisherId": "1"}`,
`{"publisherId": 42}`,
`{"publisherId": "42"}`,
`{"host": "example.com", "publisherId": "42"}`,
`{"publisherId": "42", "adUnitId": 123, "adUnitType": "banner"}`,
`{"host": "example.com", "publisherId": "42", "adUnitId": 123, "adUnitType": "banner"}`,
}

var invalidParams = []string{
`null`,
`nil`,
``,
`[]`,
`true`,
`{}`,
`{"host": "example.com". "publisherId": 1}`,

`{"host": "example.com"}`,

`{"publisherId": ""}`,
`{"publisherId": 0}`,
`{"publisherId": "0"}`,
`{"publisherId": -1}`,
`{"publisherId": "-1"}`,
`{"publisherId": 01}`,
`{"publisherId": "01"}`,
`{"publisherId": -01}`,
`{"publisherId": "-01"}`,
`{"publisherId": -42}`,
`{"publisherId": "-42"}`,
}
2 changes: 1 addition & 1 deletion static/bidder-info/appstock.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
endpoint: "http://ads-pbs.pre.vr-tb.com/openrtb/{{.PublisherID}}?host={{.Host}}"
endpoint: "http://ads-pbs.pre.vr-tb.com/openrtb/{{.PublisherID}}"
maintainer:
email: "[email protected]"
capabilities:
Expand Down
8 changes: 1 addition & 7 deletions static/bidder-params/appstock.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
"type": "object",

"properties": {
"host": {
"type": "string",
"description": "Ad network's RTB host",
"format": "hostname",
"pattern": "^.+\\..+$"
},
"publisherId": {
"type": ["integer", "string"],
"description": "Publisher ID",
Expand All @@ -19,5 +13,5 @@
}
},

"required": ["host", "publisherId"]
"required": ["publisherId"]
}

0 comments on commit cc4e8f1

Please sign in to comment.