diff --git a/config/config.go b/config/config.go index ec3f501d922..2c3acefab2e 100644 --- a/config/config.go +++ b/config/config.go @@ -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. @@ -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"` @@ -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) diff --git a/config/config_test.go b/config/config_test.go index b216fe4a48d..c17226ded0a 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -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) @@ -422,6 +423,8 @@ gdpr: vendor_exceptions: ["foo10"] special_feature1: vendor_exceptions: ["fooSP1"] +video: + enable_deprecated_endpoint: true ccpa: enforce: true lmt: @@ -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) diff --git a/endpoints/openrtb2/video_auction.go b/endpoints/openrtb2/video_auction.go index 047511f379e..9b7a9a3beac 100644 --- a/endpoints/openrtb2/video_auction.go +++ b/endpoints/openrtb2/video_auction.go @@ -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), diff --git a/endpoints/openrtb2/video_auction_test.go b/endpoints/openrtb2/video_auction_test.go index cd3e0d9c372..2ba5cea6842 100644 --- a/endpoints/openrtb2/video_auction_test.go +++ b/endpoints/openrtb2/video_auction_test.go @@ -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{}, @@ -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{}, @@ -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{}, @@ -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{}, @@ -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") +}