From cc4e8f174ff15d4887b702e0e726774f6a8aa091 Mon Sep 17 00:00:00 2001 From: Ilia Medvedev Date: Tue, 5 Sep 2023 09:43:23 +0400 Subject: [PATCH] Remove host param --- adapters/appstock/params_test.go | 68 ++++++++++++++++++++++++++++++ static/bidder-info/appstock.yaml | 2 +- static/bidder-params/appstock.json | 8 +--- 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 adapters/appstock/params_test.go diff --git a/adapters/appstock/params_test.go b/adapters/appstock/params_test.go new file mode 100644 index 00000000000..3018a48bda2 --- /dev/null +++ b/adapters/appstock/params_test.go @@ -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"}`, +} diff --git a/static/bidder-info/appstock.yaml b/static/bidder-info/appstock.yaml index 28f420e9e88..e782dff2a95 100644 --- a/static/bidder-info/appstock.yaml +++ b/static/bidder-info/appstock.yaml @@ -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: "engineering@project-limelight.com" capabilities: diff --git a/static/bidder-params/appstock.json b/static/bidder-params/appstock.json index eb2251e4e47..c2541e5a3c6 100644 --- a/static/bidder-params/appstock.json +++ b/static/bidder-params/appstock.json @@ -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", @@ -19,5 +13,5 @@ } }, - "required": ["host", "publisherId"] + "required": ["publisherId"] }