-
Notifications
You must be signed in to change notification settings - Fork 755
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
Debug disable feature implementation: #1677
Changes from 4 commits
a5886cd
2e05c58
4c7d53a
c7ca474
f485731
9821fd3
5f1e090
fdbe72f
6c64aa8
d40309a
e482baf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,6 +206,7 @@ type BidderInfo struct { | |
Capabilities *CapabilitiesInfo `yaml:"capabilities" json:"capabilities"` | ||
AliasOf string `json:"aliasOf,omitempty"` | ||
ModifyingVastXmlAllowed bool `yaml:"modifyingVastXmlAllowed" json:"-" xml:"-"` | ||
DebugInfo *config.DebugInfo `yaml:"debug,omitempty" json:"debug,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would calling it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed, no conflicts |
||
} | ||
|
||
type MaintainerInfo struct { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ type Account struct { | |
EventsEnabled bool `mapstructure:"events_enabled" json:"events_enabled"` | ||
CCPA AccountCCPA `mapstructure:"ccpa" json:"ccpa"` | ||
GDPR AccountGDPR `mapstructure:"gdpr" json:"gdpr"` | ||
DebugAllowed bool `mapstructure:"debugallowed" json:"debugallowed"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's call the JSON There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified! |
||
} | ||
|
||
// AccountCCPA represents account-specific CCPA configuration | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -446,6 +446,10 @@ type Debug struct { | |
TimeoutNotification TimeoutNotification `mapstructure:"timeout_notification"` | ||
} | ||
|
||
type DebugInfo struct { | ||
Allow bool `yaml:"allow" json:"allow"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default in Go for a boolean is false, but this is okay since it is inside of a pointer to an object that will be empty if not specified. This does result in this Do we need to advertise this in the bidder info data? You can hide this in the bidder config, which seems a more logical place to house this data, and avoids the issue of the bidder infos being inconsistent on if they include an "optional" parameter. Also this is a setting that a PBS host would be expected to set, are there any other parameters in the bidder info that a PBS host might touch? That would argue that it goes in the bidder config if not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SyntaxNode please advice if we want to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, moved to adapters/info.go, good catch! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you missed my point. I was thinking of moving this flag out of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion. Bret introduced this config as debug allow and that makes sense to me, but yes - it does play against the boolean zero value. We'd need to ask in the GitHub issues to swap it to something like restricted.
I think both have valid arguments. I had spec'd it for the bidder yaml since I didn't expect a host to override this value. I thought if the bidder knows its url will include sensitive information, then it could specify such here for all hosts to follow. We've also had discussions about in the future using bidder yaml as the base config for each adapter as is done in PBS-Java and then using the config system to override those values if needed. This would work well for reducing the code length of config.go, making it easier to port adapters to PBS-Java, and would provide a nice way to override yaml information for aliases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, if PBS-Java is already using it for config, then it is not such a big change to for us to do the same. I have no opinion on if this struct should be in config/config.go or adapters/info.go |
||
} | ||
|
||
func (cfg *Debug) validate(errs []error) []error { | ||
return cfg.TimeoutNotification.validate(errs) | ||
} | ||
|
@@ -937,6 +941,7 @@ func SetupViper(v *viper.Viper, filename string) { | |
v.SetDefault("blacklisted_accts", []string{""}) | ||
v.SetDefault("account_required", false) | ||
v.SetDefault("account_defaults.disabled", false) | ||
v.SetDefault("account_defaults.debugallowed", true) | ||
v.SetDefault("certificates_file", "") | ||
v.SetDefault("auto_gen_source_tid", true) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,6 +274,17 @@ func (deps *endpointDeps) VideoAuctionEndpoint(w http.ResponseWriter, r *http.Re | |
return | ||
} | ||
|
||
ctx = context.WithValue(ctx, exchange.DebugAllowedContextKey, account.DebugAllowed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really don't like the context. Is there a way we can do without this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactored. We have this variable in account. To have this in |
||
|
||
/*if debugLog.Enabled && account.DebugAllowed { | ||
debugLog.Data.Request = string(requestJson) | ||
if headerBytes, err := json.Marshal(r.Header); err == nil { | ||
debugLog.Data.Headers = string(headerBytes) | ||
} else { | ||
debugLog.Data.Headers = fmt.Sprintf("Unable to marshal headers data: %s", err.Error()) | ||
} | ||
}*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be removed? Are the request and header fields added elsewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this commented block of code is moved to line 160. It's not removed. |
||
|
||
auctionRequest := exchange.AuctionRequest{ | ||
BidRequest: bidReq, | ||
Account: *account, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,7 @@ type pbsOrtbSeatBid struct { | |
// | ||
// The name refers to the "Adapter" architecture pattern, and should not be confused with a Prebid "Adapter" | ||
// (which is being phased out and replaced by Bidder for OpenRTB auctions) | ||
func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Configuration, me metrics.MetricsEngine, name openrtb_ext.BidderName) adaptedBidder { | ||
func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Configuration, me metrics.MetricsEngine, name openrtb_ext.BidderName, debugInfo *config.DebugInfo) adaptedBidder { | ||
return &bidderAdapter{ | ||
Bidder: bidder, | ||
BidderName: name, | ||
|
@@ -102,10 +102,22 @@ func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Config | |
config: bidderAdapterConfig{ | ||
Debug: cfg.Debug, | ||
DisableConnMetrics: cfg.Metrics.Disabled.AdapterConnectionMetrics, | ||
DebugInfo: parseDebugInfo(debugInfo), | ||
}, | ||
} | ||
} | ||
|
||
func parseDebugInfo(info *config.DebugInfo) config.DebugInfo { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor point, but perhaps we just want to return the final boolean value here, rather than a full There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, fixed |
||
var confDebugInfo config.DebugInfo | ||
|
||
if info == nil { | ||
confDebugInfo.Allow = true | ||
} else { | ||
confDebugInfo.Allow = info.Allow | ||
} | ||
return confDebugInfo | ||
} | ||
|
||
type bidderAdapter struct { | ||
Bidder adapters.Bidder | ||
BidderName openrtb_ext.BidderName | ||
|
@@ -117,6 +129,7 @@ type bidderAdapter struct { | |
type bidderAdapterConfig struct { | ||
Debug config.Debug | ||
DisableConnMetrics bool | ||
DebugInfo config.DebugInfo | ||
} | ||
|
||
func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo) (*pbsOrtbSeatBid, []error) { | ||
|
@@ -155,8 +168,16 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.Bi | |
for i := 0; i < len(reqData); i++ { | ||
httpInfo := <-responseChannel | ||
// If this is a test bid, capture debugging info from the requests. | ||
// Write debug data to ext in case if: | ||
// - debugContextKey (url param) in true | ||
// - account debug is allowed | ||
// - bidder debug is allowed | ||
if debugInfo := ctx.Value(DebugContextKey); debugInfo != nil && debugInfo.(bool) { | ||
seatBid.httpCalls = append(seatBid.httpCalls, makeExt(httpInfo)) | ||
if debugAllowed := ctx.Value(DebugAllowedContextKey); debugAllowed != nil && debugAllowed.(bool) { | ||
if bidder.config.DebugInfo.Allow { | ||
seatBid.httpCalls = append(seatBid.httpCalls, makeExt(httpInfo)) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you combine the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, was going to to this too, done! :) |
||
} | ||
|
||
if httpInfo.err == nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,16 @@ import ( | |
// 1. The Bidder implementation is called with the arguments we expect. | ||
// 2. The returned values are correct for a non-test bid. | ||
func TestSingleBidder(t *testing.T) { | ||
type aTest struct { | ||
debugInfo *config.DebugInfo | ||
httpCallsLen int | ||
} | ||
|
||
testCases := []*aTest{ | ||
{&config.DebugInfo{Allow: false}, 0}, | ||
{&config.DebugInfo{Allow: true}, 1}, | ||
} | ||
|
||
respStatus := 200 | ||
respBody := "{\"bid\":false}" | ||
server := httptest.NewServer(mockHandler(respStatus, "getBody", respBody)) | ||
|
@@ -46,24 +56,6 @@ func TestSingleBidder(t *testing.T) { | |
bidAdjustment := 2.0 | ||
firstInitialPrice := 3.0 | ||
secondInitialPrice := 4.0 | ||
mockBidderResponse := &adapters.BidderResponse{ | ||
Bids: []*adapters.TypedBid{ | ||
{ | ||
Bid: &openrtb.Bid{ | ||
Price: firstInitialPrice, | ||
}, | ||
BidType: openrtb_ext.BidTypeBanner, | ||
DealPriority: 4, | ||
}, | ||
{ | ||
Bid: &openrtb.Bid{ | ||
Price: secondInitialPrice, | ||
}, | ||
BidType: openrtb_ext.BidTypeVideo, | ||
DealPriority: 5, | ||
}, | ||
}, | ||
} | ||
|
||
bidderImpl := &goodSingleBidder{ | ||
httpRequest: &adapters.RequestData{ | ||
|
@@ -72,53 +64,82 @@ func TestSingleBidder(t *testing.T) { | |
Body: []byte("{\"key\":\"val\"}"), | ||
Headers: http.Header{}, | ||
}, | ||
bidResponse: mockBidderResponse, | ||
bidResponse: nil, | ||
} | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus) | ||
currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) | ||
seatBid, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, "test", bidAdjustment, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}) | ||
|
||
// Make sure the goodSingleBidder was called with the expected arguments. | ||
if bidderImpl.httpResponse == nil { | ||
t.Errorf("The Bidder should be called with the server's response.") | ||
} | ||
if bidderImpl.httpResponse.StatusCode != respStatus { | ||
t.Errorf("Bad response status. Expected %d, got %d", respStatus, bidderImpl.httpResponse.StatusCode) | ||
} | ||
if string(bidderImpl.httpResponse.Body) != respBody { | ||
t.Errorf("Bad response body. Expected %s, got %s", respBody, string(bidderImpl.httpResponse.Body)) | ||
} | ||
ctx := context.Background() | ||
ctx = context.WithValue(ctx, DebugAllowedContextKey, true) | ||
ctx = context.WithValue(ctx, DebugContextKey, true) | ||
|
||
// Make sure the returned values are what we expect | ||
if len(errs) != 0 { | ||
t.Errorf("bidder.Bid returned %d errors. Expected 0", len(errs)) | ||
} | ||
if len(seatBid.bids) != len(mockBidderResponse.Bids) { | ||
t.Fatalf("Expected %d bids. Got %d", len(mockBidderResponse.Bids), len(seatBid.bids)) | ||
} | ||
for index, typedBid := range mockBidderResponse.Bids { | ||
if typedBid.Bid != seatBid.bids[index].bid { | ||
t.Errorf("Bid %d did not point to the same bid returned by the Bidder.", index) | ||
for _, test := range testCases { | ||
|
||
mockBidderResponse := &adapters.BidderResponse{ | ||
Bids: []*adapters.TypedBid{ | ||
{ | ||
Bid: &openrtb.Bid{ | ||
Price: firstInitialPrice, | ||
}, | ||
BidType: openrtb_ext.BidTypeBanner, | ||
DealPriority: 4, | ||
}, | ||
{ | ||
Bid: &openrtb.Bid{ | ||
Price: secondInitialPrice, | ||
}, | ||
BidType: openrtb_ext.BidTypeVideo, | ||
DealPriority: 5, | ||
}, | ||
}, | ||
} | ||
if typedBid.BidType != seatBid.bids[index].bidType { | ||
t.Errorf("Bid %d did not have the right type. Expected %s, got %s", index, typedBid.BidType, seatBid.bids[index].bidType) | ||
bidderImpl.bidResponse = mockBidderResponse | ||
|
||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, test.debugInfo) | ||
currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) | ||
|
||
seatBid, errs := bidder.requestBid(ctx, &openrtb.BidRequest{}, "test", bidAdjustment, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}) | ||
|
||
// Make sure the goodSingleBidder was called with the expected arguments. | ||
if bidderImpl.httpResponse == nil { | ||
t.Errorf("The Bidder should be called with the server's response.") | ||
} | ||
if typedBid.DealPriority != seatBid.bids[index].dealPriority { | ||
t.Errorf("Bid %d did not have the right deal priority. Expected %s, got %s", index, typedBid.BidType, seatBid.bids[index].bidType) | ||
if bidderImpl.httpResponse.StatusCode != respStatus { | ||
t.Errorf("Bad response status. Expected %d, got %d", respStatus, bidderImpl.httpResponse.StatusCode) | ||
} | ||
if string(bidderImpl.httpResponse.Body) != respBody { | ||
t.Errorf("Bad response body. Expected %s, got %s", respBody, string(bidderImpl.httpResponse.Body)) | ||
} | ||
} | ||
if mockBidderResponse.Bids[0].Bid.Price != bidAdjustment*firstInitialPrice { | ||
t.Errorf("Bid[0].Price was not adjusted properly. Expected %f, got %f", bidAdjustment*firstInitialPrice, mockBidderResponse.Bids[0].Bid.Price) | ||
} | ||
if mockBidderResponse.Bids[1].Bid.Price != bidAdjustment*secondInitialPrice { | ||
t.Errorf("Bid[1].Price was not adjusted properly. Expected %f, got %f", bidAdjustment*secondInitialPrice, mockBidderResponse.Bids[1].Bid.Price) | ||
} | ||
if len(seatBid.httpCalls) != 0 { | ||
t.Errorf("The bidder shouldn't log HttpCalls when request.test == 0. Found %d", len(seatBid.httpCalls)) | ||
} | ||
|
||
if len(seatBid.ext) != 0 { | ||
t.Errorf("The bidder shouldn't define any seatBid.ext. Got %s", string(seatBid.ext)) | ||
// Make sure the returned values are what we expect | ||
if len(errs) != 0 { | ||
t.Errorf("bidder.Bid returned %d errors. Expected 0", len(errs)) | ||
} | ||
if len(seatBid.bids) != len(mockBidderResponse.Bids) { | ||
t.Fatalf("Expected %d bids. Got %d", len(mockBidderResponse.Bids), len(seatBid.bids)) | ||
} | ||
for index, typedBid := range mockBidderResponse.Bids { | ||
if typedBid.Bid != seatBid.bids[index].bid { | ||
t.Errorf("Bid %d did not point to the same bid returned by the Bidder.", index) | ||
} | ||
if typedBid.BidType != seatBid.bids[index].bidType { | ||
t.Errorf("Bid %d did not have the right type. Expected %s, got %s", index, typedBid.BidType, seatBid.bids[index].bidType) | ||
} | ||
if typedBid.DealPriority != seatBid.bids[index].dealPriority { | ||
t.Errorf("Bid %d did not have the right deal priority. Expected %s, got %s", index, typedBid.BidType, seatBid.bids[index].bidType) | ||
} | ||
} | ||
if mockBidderResponse.Bids[0].Bid.Price != bidAdjustment*firstInitialPrice { | ||
t.Errorf("Bid[0].Price was not adjusted properly. Expected %f, got %f", bidAdjustment*firstInitialPrice, mockBidderResponse.Bids[0].Bid.Price) | ||
} | ||
if mockBidderResponse.Bids[1].Bid.Price != bidAdjustment*secondInitialPrice { | ||
t.Errorf("Bid[1].Price was not adjusted properly. Expected %f, got %f", bidAdjustment*secondInitialPrice, mockBidderResponse.Bids[1].Bid.Price) | ||
} | ||
if len(seatBid.httpCalls) != test.httpCallsLen { | ||
t.Errorf("The bidder shouldn't log HttpCalls when request.test == 0. Found %d", len(seatBid.httpCalls)) | ||
} | ||
|
||
if len(seatBid.ext) != 0 { | ||
t.Errorf("The bidder shouldn't define any seatBid.ext. Got %s", string(seatBid.ext)) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -162,7 +183,7 @@ func TestMultiBidder(t *testing.T) { | |
}}, | ||
bidResponse: mockBidderResponse, | ||
} | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus) | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, nil) | ||
currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) | ||
seatBid, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, "test", 1.0, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}) | ||
|
||
|
@@ -524,7 +545,7 @@ func TestMultiCurrencies(t *testing.T) { | |
) | ||
|
||
// Execute: | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus) | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, nil) | ||
currencyConverter := currency.NewRateConverter( | ||
&http.Client{}, | ||
mockedHTTPServer.URL, | ||
|
@@ -675,7 +696,7 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) { | |
} | ||
|
||
// Execute: | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus) | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, nil) | ||
currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) | ||
seatBid, errs := bidder.requestBid( | ||
context.Background(), | ||
|
@@ -841,7 +862,7 @@ func TestMultiCurrencies_RequestCurrencyPick(t *testing.T) { | |
} | ||
|
||
// Execute: | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus) | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, nil) | ||
currencyConverter := currency.NewRateConverter( | ||
&http.Client{}, | ||
mockedHTTPServer.URL, | ||
|
@@ -1020,7 +1041,7 @@ func TestMobileNativeTypes(t *testing.T) { | |
}, | ||
bidResponse: tc.mockBidderResponse, | ||
} | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus) | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, nil) | ||
currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) | ||
|
||
seatBids, _ := bidder.requestBid( | ||
|
@@ -1041,7 +1062,7 @@ func TestMobileNativeTypes(t *testing.T) { | |
} | ||
|
||
func TestErrorReporting(t *testing.T) { | ||
bidder := adaptBidder(&bidRejector{}, nil, &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus) | ||
bidder := adaptBidder(&bidRejector{}, nil, &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, nil) | ||
currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) | ||
bids, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, "test", 1.0, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}) | ||
if bids != nil { | ||
|
@@ -1224,7 +1245,7 @@ func TestCallRecordAdapterConnections(t *testing.T) { | |
metrics.On("RecordAdapterConnections", expectedAdapterName, false, mock.MatchedBy(compareConnWaitTime)).Once() | ||
|
||
// Run requestBid using an http.Client with a mock handler | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, metrics, openrtb_ext.BidderAppnexus) | ||
bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, metrics, openrtb_ext.BidderAppnexus, nil) | ||
currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) | ||
_, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, "test", bidAdjustment, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}) | ||
|
||
|
@@ -1401,6 +1422,23 @@ func TestTimeoutNotificationOn(t *testing.T) { | |
assert.EqualValues(t, logExpected, logActual) | ||
} | ||
|
||
func TestParseDebugInfoTrue(t *testing.T) { | ||
debugInfo := &config.DebugInfo{Allow: true} | ||
resDebugInfo := parseDebugInfo(debugInfo) | ||
assert.True(t, resDebugInfo.Allow, "Debug Allow value should be false") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The failure message here should mention true instead of false There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, thank you! |
||
} | ||
|
||
func TestParseDebugInfoFalse(t *testing.T) { | ||
debugInfo := &config.DebugInfo{Allow: false} | ||
resDebugInfo := parseDebugInfo(debugInfo) | ||
assert.False(t, resDebugInfo.Allow, "Debug Allow value should be false") | ||
} | ||
|
||
func TestParseDebugInfoIsNil(t *testing.T) { | ||
resDebugInfo := parseDebugInfo(nil) | ||
assert.True(t, resDebugInfo.Allow, "Debug Allow value should be false") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, just need to change failure message to true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
} | ||
|
||
func wrapWithBidderInfo(bidder adapters.Bidder) adapters.Bidder { | ||
bidderInfo := adapters.BidderInfo{ | ||
Status: adapters.StatusActive, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The json must be
json:"-" xml:"-"
to play nicely with the /info/bidders endpoint.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, didn't know about this, fixed