From e2b6f8e949a6f5e7528f38e02ef7590b67e70a39 Mon Sep 17 00:00:00 2001 From: Samuel Fabel Date: Tue, 12 Nov 2024 14:42:30 -0300 Subject: [PATCH 1/4] Add a new property called "placementId" to the Blue adapter params schema --- static/bidder-params/blue.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/bidder-params/blue.json b/static/bidder-params/blue.json index 6624defd4dc..537fc44da74 100644 --- a/static/bidder-params/blue.json +++ b/static/bidder-params/blue.json @@ -4,6 +4,10 @@ "description": "A schema which validates params accepted by the Blue adapter", "type": "object", "properties": { + "placementId": { + "type": "string", + "description": "Placement ID provided by Blue" + }, "publisherId": { "type": "string", "description": "The publisher’s ID provided by Blue" @@ -12,4 +16,4 @@ "required": [ "publisherId" ] -} \ No newline at end of file +} From 0d9fd7f24a0e1e8d260b376680042fd569b5860d Mon Sep 17 00:00:00 2001 From: Samuel Fabel Date: Sat, 23 Nov 2024 12:33:36 -0300 Subject: [PATCH 2/4] =?UTF-8?q?Inclus=C3=A3o=20de=20teste=20de=20parametro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapters/blue/params_test.go | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 adapters/blue/params_test.go diff --git a/adapters/blue/params_test.go b/adapters/blue/params_test.go new file mode 100644 index 00000000000..3d53cdf72ea --- /dev/null +++ b/adapters/blue/params_test.go @@ -0,0 +1,50 @@ +package blue + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v3/openrtb_ext" +) + +// This file actually intends to test static/bidder-params/blue.json TODO: MUST BE CREATED +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.BidderBlue, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected blue 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.BidderBlue, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"publisherId":"1234"}`, + `{"publisherId":"1234", "placementId":"12345"}`, +} + +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{}`, +} From a8e2584a56753bf55d8803671c311effda42fa4f Mon Sep 17 00:00:00 2001 From: Samuel Fabel Date: Sat, 23 Nov 2024 12:33:36 -0300 Subject: [PATCH 3/4] Include param tests to blue adapters --- adapters/blue/params_test.go | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 adapters/blue/params_test.go diff --git a/adapters/blue/params_test.go b/adapters/blue/params_test.go new file mode 100644 index 00000000000..3d53cdf72ea --- /dev/null +++ b/adapters/blue/params_test.go @@ -0,0 +1,50 @@ +package blue + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v3/openrtb_ext" +) + +// This file actually intends to test static/bidder-params/blue.json TODO: MUST BE CREATED +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.BidderBlue, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected blue 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.BidderBlue, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"publisherId":"1234"}`, + `{"publisherId":"1234", "placementId":"12345"}`, +} + +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{}`, +} From 072d686827520f3d04bd05ad4ebedba15ed6a14e Mon Sep 17 00:00:00 2001 From: Samuel Fabel Date: Wed, 4 Dec 2024 16:50:19 -0300 Subject: [PATCH 4/4] Add new test cases for Blue bidder parameter validation --- adapters/blue/params_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adapters/blue/params_test.go b/adapters/blue/params_test.go index 3d53cdf72ea..27b1e02ea8e 100644 --- a/adapters/blue/params_test.go +++ b/adapters/blue/params_test.go @@ -7,7 +7,6 @@ import ( "github.com/prebid/prebid-server/v3/openrtb_ext" ) -// This file actually intends to test static/bidder-params/blue.json TODO: MUST BE CREATED func TestValidParams(t *testing.T) { validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") if err != nil { @@ -37,6 +36,7 @@ func TestInvalidParams(t *testing.T) { var validParams = []string{ `{"publisherId":"1234"}`, `{"publisherId":"1234", "placementId":"12345"}`, + `{"publisherId":"", "placementId":""}`, } var invalidParams = []string{ @@ -47,4 +47,5 @@ var invalidParams = []string{ `4.2`, `[]`, `{}`, + `{"placementId":"12345"}`, }