Skip to content

Commit

Permalink
Blue: Add placementId bidder param (#4051)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuel Fabel <samuel.fabel@opencircle.com.br>
  • Loading branch information
samuelfabel and samuelfabelopencircle authored Dec 10, 2024
1 parent 2bc2d36 commit a9564da
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
51 changes: 51 additions & 0 deletions adapters/blue/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package blue

import (
"encoding/json"
"testing"

"github.com/prebid/prebid-server/v3/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.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"}`,
`{"publisherId":"", "placementId":""}`,
}

var invalidParams = []string{
``,
`null`,
`true`,
`5`,
`4.2`,
`[]`,
`{}`,
`{"placementId":"12345"}`,
}
6 changes: 5 additions & 1 deletion static/bidder-params/blue.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -12,4 +16,4 @@
"required": [
"publisherId"
]
}
}

0 comments on commit a9564da

Please sign in to comment.