diff --git a/adapters/resetdigital/.gitignore b/adapters/resetdigital/.gitignore deleted file mode 100644 index 3633130423..0000000000 --- a/adapters/resetdigital/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore test coverage output -cover.out diff --git a/adapters/resetdigital/params_test.go b/adapters/resetdigital/params_test.go new file mode 100644 index 0000000000..4098b44493 --- /dev/null +++ b/adapters/resetdigital/params_test.go @@ -0,0 +1,58 @@ +package resetdigital + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v3/openrtb_ext" +) + +// TestValidParams tests valid parameter(s) declared in openrtb_ext/imp_resetdigital.go +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.BidderResetDigital, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected ResetDigital params: %s \n Error: %s", validParam, err) + } + } +} + +// TestValidParams tests invalid parameter(s) declared in openrtb_ext/imp_resetdigital.go +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.BidderResetDigital, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected ResetDigital params: %s", invalidParam) + } + } +} + +// list of valid parameter(s) test cases +var validParams = []string{ + `{"placement_id":"1000"}`, + `{"placement_id":"0"}`, + `{"placement_id":"abc"}`, + `{"placement_id":"123abc"}`, + `{}`, + `{"cp":"1000"}`, +} + +// list of invalid parameter(s) test cases +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{"placement_id":}`, + `{"placement_id":""}`, +} diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index fec83a1e0e..e3d7b7419c 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -237,11 +237,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R continue } - bidType, err := GetMediaTypeForImp(requestImps[bid.ImpID]) - if err != nil { - errs = append(errs, err) - continue - } + bidType := GetMediaTypeForImp(requestImps[bid.ImpID]) b := &adapters.TypedBid{ Bid: bid, @@ -295,13 +291,13 @@ func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID) } -func GetMediaTypeForImp(reqImp openrtb2.Imp) (openrtb_ext.BidType, error) { +func GetMediaTypeForImp(reqImp openrtb2.Imp) openrtb_ext.BidType { if reqImp.Video != nil { - return openrtb_ext.BidTypeVideo, nil + return openrtb_ext.BidTypeVideo } if reqImp.Audio != nil { - return openrtb_ext.BidTypeAudio, nil + return openrtb_ext.BidTypeAudio } - return openrtb_ext.BidTypeBanner, nil + return openrtb_ext.BidTypeBanner } diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index f93c597e49..80028cb727 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -399,8 +399,8 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderQT: qt.Builder, openrtb_ext.BidderReadpeak: readpeak.Builder, openrtb_ext.BidderRelevantDigital: relevantdigital.Builder, - openrtb_ext.BidderRevcontent: revcontent.Builder, openrtb_ext.BidderResetDigital: resetdigital.Builder, + openrtb_ext.BidderRevcontent: revcontent.Builder, openrtb_ext.BidderRichaudience: richaudience.Builder, openrtb_ext.BidderRise: rise.Builder, openrtb_ext.BidderRoulax: roulax.Builder,