Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Disabled Bidders List #2993

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion endpoints/openrtb2/auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func doBadAliasRequest(t *testing.T, filename string, expectMsg string) {
bidderInfos := getBidderInfos(nil, openrtb_ext.CoreBidderNames())

bidderMap := exchange.GetActiveBidders(bidderInfos)
disabledBidders := exchange.GetDisabledBiddersErrorMessages(bidderInfos)
disabledBidders := exchange.NewDisabledBidders().GetWarningMessages(bidderInfos)
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved

// NewMetrics() will create a new go_metrics MetricsEngine, bypassing the need for a crafted configuration set to support it.
// As a side effect this gives us some coverage of the go_metrics piece of the metrics engine.
Expand Down
2 changes: 1 addition & 1 deletion endpoints/openrtb2/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ func buildTestEndpoint(test testCase, cfg *config.Configuration) (httprouter.Han

bidderInfos := getBidderInfos(test.Config.DisabledAdapters, openrtb_ext.CoreBidderNames())
bidderMap := exchange.GetActiveBidders(bidderInfos)
disabledBidders := exchange.GetDisabledBiddersErrorMessages(bidderInfos)
disabledBidders := exchange.NewDisabledBidders().GetWarningMessages(bidderInfos)
met := &metricsConfig.NilMetricsEngine{}
mockFetcher := empty_fetcher.EmptyFetcher{}

Expand Down
38 changes: 26 additions & 12 deletions exchange/adapter_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/metrics"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/prebid/prebid-server/util/maputil"
)

func BuildAdapters(client *http.Client, cfg *config.Configuration, infos config.BidderInfos, me metrics.MetricsEngine) (map[openrtb_ext.BidderName]AdaptedBidder, []error) {
Expand Down Expand Up @@ -86,19 +87,32 @@ func GetActiveBidders(infos config.BidderInfos) map[string]openrtb_ext.BidderNam
return activeBidders
}

// GetDisabledBiddersErrorMessages returns a map of error messages for disabled bidders.
func GetDisabledBiddersErrorMessages(infos config.BidderInfos) map[string]string {
disabledBidders := map[string]string{
"lifestreet": `Bidder "lifestreet" is no longer available in Prebid Server. Please update your configuration.`,
"adagio": `Bidder "adagio" is no longer available in Prebid Server. Please update your configuration.`,
"somoaudience": `Bidder "somoaudience" is no longer available in Prebid Server. Please update your configuration.`,
"yssp": `Bidder "yssp" is no longer available in Prebid Server. If you're looking to use the Yahoo SSP adapter, please rename it to "yahooAds" in your configuration.`,
"andbeyondmedia": `Bidder "andbeyondmedia" is no longer available in Prebid Server. If you're looking to use the AndBeyond.Media SSP adapter, please rename it to "beyondmedia" in your configuration.`,
"oftmedia": `Bidder "oftmedia" is no longer available in Prebid Server. Please update your configuration.`,
"groupm": `Bidder "groupm" is no longer available in Prebid Server. Please update your configuration.`,
"verizonmedia": `Bidder "verizonmedia" is no longer available in Prebid Server. Please update your configuration.`,
"brightroll": `Bidder "brightroll" is no longer available in Prebid Server. Please update your configuration.`,
type DisabledBidders interface {
GetWarningMessages(infos config.BidderInfos) map[string]string
}

func NewDisabledBidders() DisabledBidders {
return &standardDisabledBidders{
removedBidders: map[string]string{
"lifestreet": `Bidder "lifestreet" is no longer available in Prebid Server. Please update your configuration.`,
"adagio": `Bidder "adagio" is no longer available in Prebid Server. Please update your configuration.`,
"somoaudience": `Bidder "somoaudience" is no longer available in Prebid Server. Please update your configuration.`,
"yssp": `Bidder "yssp" is no longer available in Prebid Server. If you're looking to use the Yahoo SSP adapter, please rename it to "yahooAds" in your configuration.`,
"andbeyondmedia": `Bidder "andbeyondmedia" is no longer available in Prebid Server. If you're looking to use the AndBeyond.Media SSP adapter, please rename it to "beyondmedia" in your configuration.`,
"oftmedia": `Bidder "oftmedia" is no longer available in Prebid Server. Please update your configuration.`,
"groupm": `Bidder "groupm" is no longer available in Prebid Server. Please update your configuration.`,
"verizonmedia": `Bidder "verizonmedia" is no longer available in Prebid Server. Please update your configuration.`,
"brightroll": `Bidder "brightroll" is no longer available in Prebid Server. Please update your configuration.`,
},
}
}

type standardDisabledBidders struct {
removedBidders map[string]string
}

func (s standardDisabledBidders) GetWarningMessages(infos config.BidderInfos) map[string]string {
disabledBidders := maputil.Clone(s.removedBidders)

for name, info := range infos {
if info.Disabled {
Expand Down
106 changes: 46 additions & 60 deletions exchange/adapter_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
metrics "github.com/prebid/prebid-server/metrics/config"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var (
Expand Down Expand Up @@ -204,79 +205,64 @@ func TestGetActiveBidders(t *testing.T) {
}
}

func TestGetDisabledBiddersErrorMessages(t *testing.T) {
func TestNewDisabledBidders(t *testing.T) {
disabledBidders := NewDisabledBidders()

result := disabledBidders.GetWarningMessages(nil)

// test proper construction by verifying one expected bidder is in the list
require.Contains(t, result, "groupm")
assert.Equal(t, result["groupm"], `Bidder "groupm" is no longer available in Prebid Server. Please update your configuration.`)
}

func TestStandardDisabledBiddersGetWarningMessages(t *testing.T) {
testCases := []struct {
description string
bidderInfos map[string]config.BidderInfo
expected map[string]string
name string
givenRemoved map[string]string
givenBidderInfos map[string]config.BidderInfo
expected map[string]string
}{
{
description: "None",
bidderInfos: map[string]config.BidderInfo{},
expected: map[string]string{
"lifestreet": `Bidder "lifestreet" is no longer available in Prebid Server. Please update your configuration.`,
"adagio": `Bidder "adagio" is no longer available in Prebid Server. Please update your configuration.`,
"somoaudience": `Bidder "somoaudience" is no longer available in Prebid Server. Please update your configuration.`,
"yssp": `Bidder "yssp" is no longer available in Prebid Server. If you're looking to use the Yahoo SSP adapter, please rename it to "yahooAds" in your configuration.`,
"andbeyondmedia": `Bidder "andbeyondmedia" is no longer available in Prebid Server. If you're looking to use the AndBeyond.Media SSP adapter, please rename it to "beyondmedia" in your configuration.`,
"oftmedia": `Bidder "oftmedia" is no longer available in Prebid Server. Please update your configuration.`,
"groupm": `Bidder "groupm" is no longer available in Prebid Server. Please update your configuration.`,
"verizonmedia": `Bidder "verizonmedia" is no longer available in Prebid Server. Please update your configuration.`,
"brightroll": `Bidder "brightroll" is no longer available in Prebid Server. Please update your configuration.`,
},
name: "none",
givenRemoved: map[string]string{},
givenBidderInfos: map[string]config.BidderInfo{},
expected: map[string]string{},
},
{
description: "Enabled",
bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled},
expected: map[string]string{
"lifestreet": `Bidder "lifestreet" is no longer available in Prebid Server. Please update your configuration.`,
"adagio": `Bidder "adagio" is no longer available in Prebid Server. Please update your configuration.`,
"somoaudience": `Bidder "somoaudience" is no longer available in Prebid Server. Please update your configuration.`,
"yssp": `Bidder "yssp" is no longer available in Prebid Server. If you're looking to use the Yahoo SSP adapter, please rename it to "yahooAds" in your configuration.`,
"andbeyondmedia": `Bidder "andbeyondmedia" is no longer available in Prebid Server. If you're looking to use the AndBeyond.Media SSP adapter, please rename it to "beyondmedia" in your configuration.`,
"oftmedia": `Bidder "oftmedia" is no longer available in Prebid Server. Please update your configuration.`,
"groupm": `Bidder "groupm" is no longer available in Prebid Server. Please update your configuration.`,
"verizonmedia": `Bidder "verizonmedia" is no longer available in Prebid Server. Please update your configuration.`,
"brightroll": `Bidder "brightroll" is no longer available in Prebid Server. Please update your configuration.`,
},
name: "removed",
givenRemoved: map[string]string{"bidderA": `Bidder A Message`},
givenBidderInfos: map[string]config.BidderInfo{},
expected: map[string]string{"bidderA": `Bidder A Message`},
},
{
description: "Disabled",
bidderInfos: map[string]config.BidderInfo{"appnexus": infoDisabled},
expected: map[string]string{
"lifestreet": `Bidder "lifestreet" is no longer available in Prebid Server. Please update your configuration.`,
"adagio": `Bidder "adagio" is no longer available in Prebid Server. Please update your configuration.`,
"somoaudience": `Bidder "somoaudience" is no longer available in Prebid Server. Please update your configuration.`,
"yssp": `Bidder "yssp" is no longer available in Prebid Server. If you're looking to use the Yahoo SSP adapter, please rename it to "yahooAds" in your configuration.`,
"appnexus": `Bidder "appnexus" has been disabled on this instance of Prebid Server. Please work with the PBS host to enable this bidder again.`,
"andbeyondmedia": `Bidder "andbeyondmedia" is no longer available in Prebid Server. If you're looking to use the AndBeyond.Media SSP adapter, please rename it to "beyondmedia" in your configuration.`,
"oftmedia": `Bidder "oftmedia" is no longer available in Prebid Server. Please update your configuration.`,
"groupm": `Bidder "groupm" is no longer available in Prebid Server. Please update your configuration.`,
"verizonmedia": `Bidder "verizonmedia" is no longer available in Prebid Server. Please update your configuration.`,
"brightroll": `Bidder "brightroll" is no longer available in Prebid Server. Please update your configuration.`,
},
name: "enabled",
givenRemoved: map[string]string{},
givenBidderInfos: map[string]config.BidderInfo{"bidderA": infoEnabled},
expected: map[string]string{},
},
{
description: "Mixed",
bidderInfos: map[string]config.BidderInfo{"appnexus": infoDisabled, "openx": infoEnabled},
expected: map[string]string{
"lifestreet": `Bidder "lifestreet" is no longer available in Prebid Server. Please update your configuration.`,
"adagio": `Bidder "adagio" is no longer available in Prebid Server. Please update your configuration.`,
"somoaudience": `Bidder "somoaudience" is no longer available in Prebid Server. Please update your configuration.`,
"yssp": `Bidder "yssp" is no longer available in Prebid Server. If you're looking to use the Yahoo SSP adapter, please rename it to "yahooAds" in your configuration.`,
"appnexus": `Bidder "appnexus" has been disabled on this instance of Prebid Server. Please work with the PBS host to enable this bidder again.`,
"andbeyondmedia": `Bidder "andbeyondmedia" is no longer available in Prebid Server. If you're looking to use the AndBeyond.Media SSP adapter, please rename it to "beyondmedia" in your configuration.`,
"oftmedia": `Bidder "oftmedia" is no longer available in Prebid Server. Please update your configuration.`,
"groupm": `Bidder "groupm" is no longer available in Prebid Server. Please update your configuration.`,
"verizonmedia": `Bidder "verizonmedia" is no longer available in Prebid Server. Please update your configuration.`,
"brightroll": `Bidder "brightroll" is no longer available in Prebid Server. Please update your configuration.`,
},
name: "disabled",
givenRemoved: map[string]string{},
givenBidderInfos: map[string]config.BidderInfo{"bidderA": infoDisabled},
expected: map[string]string{"bidderA": `Bidder "bidderA" has been disabled on this instance of Prebid Server. Please work with the PBS host to enable this bidder again.`},
},
{
name: "mixed",
givenRemoved: map[string]string{"bidderA": `Bidder A Message`},
givenBidderInfos: map[string]config.BidderInfo{"bidderB": infoEnabled, "bidderC": infoDisabled},
expected: map[string]string{"bidderA": `Bidder A Message`, "bidderC": `Bidder "bidderC" has been disabled on this instance of Prebid Server. Please work with the PBS host to enable this bidder again.`},
},
}

for _, test := range testCases {
result := GetDisabledBiddersErrorMessages(test.bidderInfos)
assert.Equal(t, test.expected, result, test.description)
t.Run(test.name, func(t *testing.T) {
disabledBidders := standardDisabledBidders{
removedBidders: test.givenRemoved,
}

result := disabledBidders.GetWarningMessages(test.givenBidderInfos)
assert.Equal(t, test.expected, result, test.name)
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func New(cfg *config.Configuration, rateConvertor *currency.RateConverter) (r *R
}

activeBidders := exchange.GetActiveBidders(cfg.BidderInfos)
disabledBidders := exchange.GetDisabledBiddersErrorMessages(cfg.BidderInfos)
disabledBidders := exchange.NewDisabledBidders().GetWarningMessages(cfg.BidderInfos)

defaultAliases, defReqJSON := readDefaultRequest(cfg.DefReqConfig)
if err := validateDefaultAliases(defaultAliases); err != nil {
Expand Down