Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Configuration struct {
CategoryMapping StoredRequests `mapstructure:"category_mapping"`
VTrack VTrack `mapstructure:"vtrack"`
Event Event `mapstructure:"event"`
Video Video `mapstructure:"video"`
Accounts StoredRequests `mapstructure:"accounts"`
UserSync UserSync `mapstructure:"user_sync"`
// Note that StoredVideo refers to stored video requests, and has nothing to do with caching video creatives.
Expand Down Expand Up @@ -550,6 +551,10 @@ type Event struct {
TimeoutMS int64 `mapstructure:"timeout_ms"`
}

type Video struct {
EnableDeprecatedEndpoint bool `mapstructure:"enable_deprecated_endpoint"`
}

type HostCookie struct {
Domain string `mapstructure:"domain"`
Family string `mapstructure:"family"`
Expand Down Expand Up @@ -1123,6 +1128,8 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) {

v.SetDefault("event.timeout_ms", 1000)

v.SetDefault("video.enable_deprecated_endpoint", false)

v.SetDefault("user_sync.priority_groups", [][]string{})

v.SetDefault("accounts.filesystem.enabled", false)
Expand Down
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func TestDefaults(t *testing.T) {
cmpStrings(t, "stored_requests.http.endpoint", "", cfg.StoredRequests.HTTP.Endpoint)
cmpStrings(t, "stored_requests.http.amp_endpoint", "", cfg.StoredRequests.HTTP.AmpEndpoint)
cmpBools(t, "stored_requests.http.use_rfc3986_compliant_request_builder", false, cfg.StoredRequests.HTTP.UseRfcCompliantBuilder)
cmpBools(t, "video.enable_deprecated_endpoint", false, cfg.Video.EnableDeprecatedEndpoint)
cmpBools(t, "accounts.filesystem.enabled", false, cfg.Accounts.Files.Enabled)
cmpStrings(t, "accounts.filesystem.directorypath", "./stored_requests/data/by_id", cfg.Accounts.Files.Path)
cmpStrings(t, "accounts.http.endpoint", "", cfg.Accounts.HTTP.Endpoint)
Expand Down Expand Up @@ -422,6 +423,8 @@ gdpr:
vendor_exceptions: ["foo10"]
special_feature1:
vendor_exceptions: ["fooSP1"]
video:
enable_deprecated_endpoint: true
ccpa:
enforce: true
lmt:
Expand Down Expand Up @@ -685,6 +688,7 @@ func TestFullConfig(t *testing.T) {
cmpInts(t, "http_client_cache.idle_connection_timeout_seconds", 3, cfg.CacheClient.IdleConnTimeout)
cmpInts(t, "gdpr.host_vendor_id", 15, cfg.GDPR.HostVendorID)
cmpStrings(t, "gdpr.default_value", "1", cfg.GDPR.DefaultValue)
cmpBools(t, "video.enable_deprecated_endpoint", true, cfg.Video.EnableDeprecatedEndpoint)
cmpStrings(t, "host_schain_node.asi", "pbshostcompany.com", cfg.HostSChainNode.ASI)
cmpStrings(t, "host_schain_node.sid", "00001", cfg.HostSChainNode.SID)
cmpStrings(t, "host_schain_node.rid", "BidRequest", cfg.HostSChainNode.RID)
Expand Down
6 changes: 6 additions & 0 deletions endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ func NewVideoEndpoint(
func (deps *endpointDeps) VideoAuctionEndpoint(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
start := time.Now()

if !deps.cfg.Video.EnableDeprecatedEndpoint {
w.WriteHeader(http.StatusNotImplemented)
w.Write([]byte("The video endpoint is deprecated and will be removed in 5.0. You may re-enable it via the host configuration setting video.enable_deprecated_endpoint"))
return
}

vo := analytics.VideoObject{
Status: http.StatusOK,
Errors: make([]error, 0),
Expand Down
42 changes: 38 additions & 4 deletions endpoints/openrtb2/video_auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ func mockDepsWithMetrics(t *testing.T, ex *mockExchangeVideo) (*endpointDeps, *m
&mockVideoStoredReqFetcher{},
&mockVideoStoredReqFetcher{},
&mockAccountFetcher{data: mockVideoAccountData},
&config.Configuration{MaxRequestSize: maxSize},
&config.Configuration{Video: config.Video{EnableDeprecatedEndpoint: true}, MaxRequestSize: maxSize},
metrics,
mockModule,
map[string]string{},
Expand Down Expand Up @@ -1324,7 +1324,7 @@ func mockDeps(t *testing.T, ex *mockExchangeVideo) *endpointDeps {
&mockVideoStoredReqFetcher{},
&mockVideoStoredReqFetcher{},
&mockAccountFetcher{data: mockVideoAccountData},
&config.Configuration{MaxRequestSize: maxSize},
&config.Configuration{Video: config.Video{EnableDeprecatedEndpoint: true}, MaxRequestSize: maxSize},
&metricsConfig.NilMetricsEngine{},
analyticsBuild.New(&config.Analytics{}),
map[string]string{},
Expand All @@ -1349,7 +1349,7 @@ func mockDepsAppendBidderNames(t *testing.T, ex *mockExchangeAppendBidderNames)
&mockVideoStoredReqFetcher{},
&mockVideoStoredReqFetcher{},
empty_fetcher.EmptyFetcher{},
&config.Configuration{MaxRequestSize: maxSize},
&config.Configuration{Video: config.Video{EnableDeprecatedEndpoint: true}, MaxRequestSize: maxSize},
&metricsConfig.NilMetricsEngine{},
analyticsBuild.New(&config.Analytics{}),
map[string]string{},
Expand All @@ -1376,7 +1376,7 @@ func mockDepsNoBids(t *testing.T, ex *mockExchangeVideoNoBids) *endpointDeps {
&mockVideoStoredReqFetcher{},
&mockVideoStoredReqFetcher{},
empty_fetcher.EmptyFetcher{},
&config.Configuration{MaxRequestSize: maxSize},
&config.Configuration{Video: config.Video{EnableDeprecatedEndpoint: true}, MaxRequestSize: maxSize},
&metricsConfig.NilMetricsEngine{},
analyticsBuild.New(&config.Analytics{}),
map[string]string{},
Expand Down Expand Up @@ -1548,3 +1548,37 @@ func TestVideoRequestValidationFailed(t *testing.T) {
assert.Equal(t, 500, recorder.Code, "Should catch error in request")
assert.Equal(t, "Critical error while running the video endpoint: request.tmax must be nonnegative. Got -2", errorMessage, "Incorrect request validation message")
}

func TestVideoEndpointDisabled(t *testing.T) {
ex := &mockExchangeVideo{}
req := httptest.NewRequest("POST", "/openrtb2/video", strings.NewReader("{}"))
recorder := httptest.NewRecorder()

deps := &endpointDeps{
fakeUUIDGenerator{},
ex,
ortb.NewRequestValidator(openrtb_ext.BuildBidderMap(), map[string]string{}, mockBidderParamValidator{}),
&mockVideoStoredReqFetcher{},
&mockVideoStoredReqFetcher{},
&mockAccountFetcher{data: mockVideoAccountData},
&config.Configuration{Video: config.Video{EnableDeprecatedEndpoint: false}, MaxRequestSize: maxSize},
&metricsConfig.NilMetricsEngine{},
analyticsBuild.New(&config.Analytics{}),
map[string]string{},
false,
[]byte{},
openrtb_ext.BuildBidderMap(),
ex.cache,
regexp.MustCompile(`[<>]`),
hardcodedResponseIPValidator{response: true},
empty_fetcher.EmptyFetcher{},
hooks.EmptyPlanBuilder{},
nil,
openrtb_ext.NormalizeBidderName,
}

deps.VideoAuctionEndpoint(recorder, req, nil)

assert.Equal(t, http.StatusNotImplemented, recorder.Code, "Expected 501 status code when video endpoint is disabled")
assert.Equal(t, "The video endpoint is deprecated and will be removed in 5.0. You may re-enable it via the host configuration setting video.enable_deprecated_endpoint", recorder.Body.String(), "Unexpected error message")
}
Loading