From 35f990b5c35b4b571d90280f73d8e5191ef17d49 Mon Sep 17 00:00:00 2001 From: Alex Maltsev Date: Fri, 12 Apr 2024 17:05:15 +0300 Subject: [PATCH 01/62] Dependencies: Updates (#3054) --- .editorconfig | 2 +- checkstyle.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- .../confiant/adquality/core/RedisClient.java | 6 +- .../confiant/adquality/core/RedisParser.java | 4 +- .../model/PbRichMediaFilterProperties.java | 2 +- extra/pom.xml | 3 +- pom.xml | 65 ++-- .../activity/ActivitiesConfigResolver.java | 2 +- .../ActivityInfrastructureCreator.java | 4 +- .../reporter/AnalyticsReporterDelegator.java | 8 +- .../reporter/log/LogAnalyticsReporter.java | 4 +- .../pubstack/PubstackAnalyticsReporter.java | 12 +- .../pubstack/PubstackEventHandler.java | 10 +- .../server/auction/ExchangeService.java | 6 +- .../auction/GeoLocationServiceWrapper.java | 4 +- .../server/auction/IpAddressHelper.java | 6 +- .../server/auction/OrtbTypesResolver.java | 4 +- .../server/auction/SupplyChainResolver.java | 6 +- .../auction/VideoStoredRequestProcessor.java | 4 +- .../auction/model/BidRejectionTracker.java | 4 +- .../privacy/enforcement/TcfEnforcement.java | 4 +- .../Ortb2ImplicitParametersResolver.java | 6 +- .../requestfactory/Ortb2RequestFactory.java | 6 +- .../requestfactory/VideoRequestFactory.java | 2 +- .../server/bidder/BidderErrorNotifier.java | 4 +- .../server/bidder/HttpBidderRequester.java | 10 +- .../bidder/appnexus/AppnexusBidder.java | 2 +- .../bidder/bidstack/BidstackBidder.java | 2 +- .../bidder/intertech/IntertechBidder.java | 2 +- .../server/bidder/openx/OpenxBidder.java | 4 +- .../bidder/rtbhouse/RtbhouseBidder.java | 2 +- .../server/bidder/rubicon/RubiconBidder.java | 4 +- .../server/bidder/yandex/YandexBidder.java | 2 +- .../bidder/yieldlab/YieldlabBidder.java | 4 +- .../org/prebid/server/cache/CacheService.java | 8 +- .../cookie/PrioritizedCoopSyncProvider.java | 10 +- .../server/cookie/UidsCookieService.java | 6 +- .../currency/CurrencyConversionService.java | 13 +- .../server/execution/RemoteFileSyncer.java | 239 ++++----------- .../floors/BasicPriceFloorEnforcer.java | 4 +- .../floors/BasicPriceFloorProcessor.java | 4 +- .../floors/BasicPriceFloorResolver.java | 4 +- .../server/floors/PriceFloorFetcher.java | 4 +- .../floors/PriceFloorsConfigResolver.java | 4 +- .../model/PriceFloorDebugProperties.java | 2 +- ...rcuitBreakerSecuredGeoLocationService.java | 4 +- .../server/handler/CookieSyncHandler.java | 4 +- .../server/handler/ExceptionHandler.java | 6 +- .../handler/NotificationEventHandler.java | 4 +- .../prebid/server/handler/OptoutHandler.java | 4 +- .../prebid/server/handler/SetuidHandler.java | 4 +- .../prebid/server/handler/VtrackHandler.java | 4 +- .../handler/admin/CurrencyRatesHandler.java | 4 +- .../SettingsCacheNotificationHandler.java | 12 +- .../server/handler/admin/VersionHandler.java | 4 +- .../server/handler/openrtb2/AmpHandler.java | 6 +- .../handler/openrtb2/AuctionHandler.java | 6 +- .../server/handler/openrtb2/VideoHandler.java | 10 +- .../server/hooks/execution/GroupExecutor.java | 2 +- .../server/hooks/execution/GroupResult.java | 2 +- .../prebid/server/log/ConditionalLogger.java | 1 - .../java/org/prebid/server/log/Criteria.java | 1 - .../prebid/server/log/CriteriaLogManager.java | 4 +- .../prebid/server/log/CriteriaManager.java | 1 - .../server/log/HttpInteractionLogger.java | 8 +- .../java/org/prebid/server/log/Logger.java | 141 +++++++++ .../org/prebid/server/log/LoggerFactory.java | 22 ++ .../optout/GoogleRecaptchaVerifier.java | 4 +- .../privacy/HostVendorTcfDefinerService.java | 4 +- .../server/privacy/PrivacyExtractor.java | 4 +- .../privacy/gdpr/TcfDefinerService.java | 4 +- .../BasicEnforcePurposeStrategy.java | 6 +- .../gdpr/vendorlist/VendorListService.java | 8 +- .../settings/CachingApplicationSettings.java | 6 +- .../settings/HttpApplicationSettings.java | 4 +- .../helper/JdbcStoredDataResultMapper.java | 6 +- .../server/settings/model/GdprConfig.java | 2 +- .../service/HttpPeriodicRefreshService.java | 9 +- .../service/JdbcPeriodicRefreshService.java | 8 +- .../spring/config/AnalyticsConfiguration.java | 2 +- .../config/GeoLocationConfiguration.java | 5 +- .../config/InitializationConfiguration.java | 22 +- .../config/PrivacyServiceConfiguration.java | 6 +- .../spring/config/ServiceConfiguration.java | 6 +- .../spring/config/SettingsConfiguration.java | 4 +- .../server/spring/config/VerticleStarter.java | 13 +- .../spring/config/VertxConfiguration.java | 6 +- .../spring/config/VertxContextScope.java | 4 +- .../config/bidder/AaxConfiguration.java | 2 +- .../config/bidder/AceexConfiguration.java | 2 +- .../config/bidder/AcuityadsConfiguration.java | 2 +- .../config/bidder/AdQueryConfiguration.java | 2 +- .../config/bidder/AdelementConfiguration.java | 2 +- .../config/bidder/AdfConfiguration.java | 2 +- .../bidder/AdgenerationConfiguration.java | 2 +- .../config/bidder/AdheseConfiguration.java | 2 +- .../bidder/AdkernelAdnConfiguration.java | 2 +- .../config/bidder/AdkernelConfiguration.java | 2 +- .../config/bidder/AdmanConfiguration.java | 2 +- .../config/bidder/AdmixerConfiguration.java | 2 +- .../bidder/AdnuntiusBidderConfiguration.java | 2 +- .../config/bidder/AdoceanConfiguration.java | 2 +- .../config/bidder/AdopplerConfiguration.java | 2 +- .../config/bidder/AdotConfiguration.java | 2 +- .../config/bidder/AdponeConfiguration.java | 2 +- .../config/bidder/AdprimeConfiguration.java | 2 +- .../config/bidder/AdrinoConfiguration.java | 2 +- .../config/bidder/AdtargetConfiguration.java | 2 +- .../bidder/AdtelligentConfiguration.java | 2 +- .../config/bidder/AdtrgtmeConfiguration.java | 2 +- .../bidder/AdvangelistsConfiguration.java | 2 +- .../config/bidder/AdviewConfiguration.java | 2 +- .../config/bidder/AdxcgConfiguration.java | 2 +- .../config/bidder/AdyoulikeConfiguration.java | 2 +- .../config/bidder/AidemConfiguration.java | 2 +- .../config/bidder/AjaConfiguration.java | 2 +- .../config/bidder/AlgorixConfiguration.java | 2 +- .../config/bidder/AlkimiConfiguration.java | 22 +- .../config/bidder/AmxConfiguration.java | 2 +- .../config/bidder/ApacdexConfiguration.java | 2 +- .../config/bidder/AppnexusConfiguration.java | 2 +- .../config/bidder/AppushConfiguration.java | 2 +- .../bidder/AudienceNetworkConfiguration.java | 2 +- .../bidder/AutomatadBidderConfiguration.java | 2 +- .../config/bidder/AvocetConfiguration.java | 2 +- .../config/bidder/AxisConfiguration.java | 2 +- .../config/bidder/AxonixConfiguration.java | 2 +- .../bidder/BeachfrontConfiguration.java | 2 +- .../config/bidder/BeintooConfiguration.java | 2 +- .../bidder/BematterfullConfiguration.java | 2 +- .../config/bidder/BetweenConfiguration.java | 2 +- .../bidder/BeyondMediaConfiguration.java | 2 +- .../bidder/BidmachineConfiguration.java | 2 +- .../config/bidder/BidmyadzConfiguration.java | 2 +- .../config/bidder/BidscubeConfiguration.java | 2 +- .../config/bidder/BidstackConfiguration.java | 2 +- .../config/bidder/BizzclickConfiguration.java | 2 +- .../bidder/BliinkBidderConfiguration.java | 2 +- .../config/bidder/BlueSeaConfiguration.java | 2 +- .../config/bidder/BmtmConfiguration.java | 2 +- .../config/bidder/BoldwinConfiguration.java | 2 +- .../config/bidder/BraveConfiguration.java | 2 +- .../config/bidder/CcxConfiguration.java | 2 +- .../config/bidder/CoinzillaConfiguration.java | 2 +- .../config/bidder/ColossusConfiguration.java | 2 +- .../config/bidder/CompassConfiguration.java | 2 +- .../config/bidder/ConnectAdConfiguration.java | 2 +- .../bidder/ConsumableConfiguration.java | 2 +- .../config/bidder/CpmStarConfiguration.java | 2 +- .../config/bidder/CriteoConfiguration.java | 2 +- .../bidder/DatablocksConfiguration.java | 2 +- .../bidder/DecenteradsConfiguration.java | 2 +- .../bidder/DeepintentConfiguration.java | 2 +- .../bidder/DianomiBidderConfiguration.java | 2 +- .../config/bidder/DmxConfiguration.java | 2 +- .../bidder/DxKultureBidderConfiguration.java | 2 +- .../config/bidder/Edge226Configuration.java | 2 +- .../config/bidder/EmtvConfiguration.java | 2 +- .../bidder/EmxDigitalConfiguration.java | 2 +- .../config/bidder/EplanningConfiguration.java | 2 +- .../config/bidder/EpomConfiguration.java | 2 +- .../config/bidder/EpsilonConfiguration.java | 4 +- .../config/bidder/EvolutionConfiguration.java | 2 +- .../config/bidder/FlippConfiguration.java | 2 +- .../bidder/FreewheelSSPConfiguration.java | 2 +- .../bidder/FrvrAdnBidderConfiguration.java | 2 +- .../config/bidder/GammaConfiguration.java | 2 +- .../config/bidder/GamoshiConfiguration.java | 2 +- .../bidder/GenericBidderConfiguration.java | 2 +- .../config/bidder/GlobalsunConfiguration.java | 2 +- .../config/bidder/GothamAdsConfiguration.java | 2 +- .../config/bidder/GridConfiguration.java | 2 +- .../config/bidder/GumgumConfiguration.java | 2 +- .../config/bidder/HuaweiAdsConfiguration.java | 6 +- .../config/bidder/ImdsConfiguration.java | 2 +- .../config/bidder/ImpactifyConfiguration.java | 2 +- .../bidder/ImprovedigitalConfiguration.java | 2 +- .../config/bidder/InfytvConfiguration.java | 2 +- .../config/bidder/InmobiConfiguration.java | 2 +- .../InteractiveOffersConfiguration.java | 2 +- .../config/bidder/IntertechConfiguration.java | 2 +- .../config/bidder/InvibesConfiguration.java | 2 +- .../config/bidder/IqxConfiguration.java | 2 +- .../config/bidder/IqzoneConfiguration.java | 2 +- .../spring/config/bidder/IxConfiguration.java | 2 +- .../config/bidder/JixieConfiguration.java | 2 +- .../config/bidder/KargoConfiguration.java | 2 +- .../config/bidder/KayzenConfiguration.java | 2 +- .../config/bidder/KidozConfiguration.java | 2 +- .../bidder/KiviAdsBidderConfiguration.java | 2 +- .../bidder/KrushmediaConfiguration.java | 2 +- .../bidder/LemmaDigitalConfiguration.java | 2 +- .../config/bidder/LiftoffConfiguration.java | 2 +- .../bidder/LimeLightDigitalConfiguration.java | 2 +- .../bidder/LmKiviAdsBidderConfiguration.java | 2 +- .../bidder/LockerdomeConfiguration.java | 2 +- .../config/bidder/LoganConfiguration.java | 2 +- .../config/bidder/LogicadConfiguration.java | 2 +- .../config/bidder/LoopmeConfiguration.java | 2 +- .../config/bidder/LunamediaConfiguration.java | 2 +- .../bidder/MadvertiseConfiguration.java | 2 +- .../config/bidder/MarsmediaConfiguration.java | 2 +- .../config/bidder/MedianetConfiguration.java | 2 +- .../config/bidder/MgidConfiguration.java | 2 +- .../config/bidder/MgidxConfiguration.java | 2 +- .../bidder/MinuteMediaConfiguration.java | 2 +- .../config/bidder/MobfoxpbConfiguration.java | 2 +- .../bidder/MobilefuseConfiguration.java | 2 +- .../config/bidder/MotorikConfiguration.java | 2 +- .../bidder/NextMillenniumConfiguration.java | 2 +- .../config/bidder/NobidConfiguration.java | 2 +- .../config/bidder/OmsBidderConfiguration.java | 2 +- .../config/bidder/OnetagConfiguration.java | 2 +- .../config/bidder/OpenWebConfiguration.java | 2 +- .../config/bidder/OpenxConfiguration.java | 2 +- .../config/bidder/OperaadsConfiguration.java | 2 +- .../config/bidder/OrbidderConfiguration.java | 2 +- .../config/bidder/OutbrainConfiguration.java | 2 +- .../config/bidder/PangleConfiguration.java | 2 +- .../config/bidder/PgamSspConfiguration.java | 2 +- .../config/bidder/PrecisoConfiguration.java | 2 +- .../config/bidder/PubmaticConfiguration.java | 2 +- .../config/bidder/PubnativeConfiguration.java | 2 +- .../bidder/PulsepointConfiguration.java | 2 +- .../config/bidder/PwbidConfiguration.java | 2 +- .../bidder/RelevantDigitalConfiguration.java | 2 +- .../bidder/ResetDigitalConfiguration.java | 2 +- .../bidder/RevcontentConfiguration.java | 2 +- .../bidder/RichaudienceConfiguration.java | 2 +- .../config/bidder/RiseConfiguration.java | 2 +- .../config/bidder/RtbhouseConfiguration.java | 2 +- .../config/bidder/RubiconConfiguration.java | 6 +- .../bidder/SaLunamediaConfiguration.java | 2 +- .../bidder/ScreencoreConfiguration.java | 2 +- .../SeedingAllianceBidderConfiguration.java | 2 +- .../bidder/SharethroughConfiguration.java | 2 +- .../bidder/SilverPushConfiguration.java | 2 +- .../config/bidder/SilvermobConfiguration.java | 2 +- .../bidder/SimpleWantedConfiguration.java | 2 +- .../config/bidder/SmaatoConfiguration.java | 2 +- .../bidder/SmartadserverConfiguration.java | 2 +- .../config/bidder/SmarthubConfiguration.java | 2 +- .../config/bidder/SmartrtbConfiguration.java | 2 +- .../config/bidder/SmartxConfiguration.java | 2 +- .../config/bidder/SmartyAdsConfiguration.java | 2 +- .../config/bidder/SonobiConfiguration.java | 2 +- .../config/bidder/SovrnConfiguration.java | 2 +- .../config/bidder/SovrnXspConfiguration.java | 2 +- .../bidder/SspbcBidderConfiguration.java | 2 +- .../bidder/StroeerCoreConfiguration.java | 2 +- .../config/bidder/TaboolaConfiguration.java | 2 +- .../config/bidder/TappxConfiguration.java | 2 +- .../config/bidder/TeadsConfiguration.java | 2 +- .../config/bidder/TelariaConfiguration.java | 2 +- .../ThirtyThreeAcrossConfiguration.java | 2 +- .../bidder/TpmnAdnBidderConfiguration.java | 2 +- .../bidder/TrafficGateConfiguration.java | 2 +- .../bidder/TripleliftConfiguration.java | 2 +- .../bidder/TripleliftNativeConfiguration.java | 4 +- .../config/bidder/UcfunnelConfiguration.java | 2 +- .../config/bidder/UndertoneConfiguration.java | 2 +- .../config/bidder/UnicornConfiguration.java | 2 +- .../config/bidder/UnrulyConfiguration.java | 2 +- .../bidder/VideoHeroesConfiguration.java | 2 +- .../config/bidder/VideobyteConfiguration.java | 2 +- .../config/bidder/VidoomyConfiguration.java | 2 +- .../bidder/VisibleMeasuresConfiguration.java | 2 +- .../config/bidder/VisxConfiguration.java | 2 +- .../config/bidder/VoxConfiguration.java | 2 +- .../config/bidder/VrtcalConfiguration.java | 2 +- .../bidder/XeworksBidderConfiguration.java | 2 +- .../config/bidder/YahooAdsConfiguration.java | 2 +- .../config/bidder/YandexConfiguration.java | 2 +- .../config/bidder/YeahmobiConfiguration.java | 2 +- .../config/bidder/YearxeroConfiguration.java | 2 +- .../config/bidder/YieldlabConfiguration.java | 2 +- .../config/bidder/YieldmoConfiguration.java | 2 +- .../config/bidder/YieldoneConfiguration.java | 2 +- .../bidder/ZeroclickfraudConfiguration.java | 2 +- .../bidder/ZetaGlobalSspConfiguration.java | 2 +- .../model/BidderConfigurationProperties.java | 6 +- .../spring/config/bidder/model/Debug.java | 2 +- .../DefaultBidderConfigurationProperties.java | 2 +- .../spring/config/bidder/model/MetaInfo.java | 4 +- .../spring/config/bidder/model/Ortb.java | 2 +- .../UsersyncConfigurationProperties.java | 2 +- ...UsersyncMethodConfigurationProperties.java | 4 +- .../DatabaseConfigurationProperties.java | 6 +- .../config/metrics/MetricsConfiguration.java | 23 +- .../metrics/PrometheusConfiguration.java | 6 +- .../PrometheusMapperConfiguration.java | 2 +- .../model/CircuitBreakerProperties.java | 4 +- .../model/ExternalConversionProperties.java | 6 +- .../HttpClientCircuitBreakerProperties.java | 4 +- .../config/model/HttpClientProperties.java | 4 +- .../model/RemoteFileSyncerProperties.java | 6 +- ...offRetryPolicyConfigurationProperties.java | 4 +- ...valRetryPolicyConfigurationProperties.java | 2 +- .../server/admin/AdminResourcesBinder.java | 4 +- .../spring/env/YamlPropertySourceFactory.java | 4 +- .../java/org/prebid/server/util/HttpUtil.java | 6 +- .../org/prebid/server/util/VersionInfo.java | 6 +- .../util/system/CpuLoadAverageStats.java | 4 +- .../server/validation/RequestValidator.java | 2 +- .../validation/ResponseBidValidator.java | 4 +- .../prebid/server/vertx/CircuitBreaker.java | 4 +- .../prebid/server/vertx/CloseableAdapter.java | 17 +- .../prebid/server/vertx/Initializable.java | 3 +- .../vertx/httpclient/BasicHttpClient.java | 130 ++++---- .../CircuitBreakerSecuredHttpClient.java | 8 +- .../server/vertx/jdbc/BasicJdbcClient.java | 4 +- .../jdbc/CircuitBreakerSecuredJdbcClient.java | 4 +- .../verticles/server/DaemonVerticle.java | 63 ++++ .../verticles/server/ServerVerticle.java | 6 +- .../server/functional/model/db/Account.groovy | 14 +- .../functional/model/db/StoredImp.groovy | 14 +- .../functional/model/db/StoredRequest.groovy | 14 +- .../functional/model/db/StoredResponse.groovy | 14 +- .../AccountConfigTypeConverter.groovy | 2 +- .../AccountStatusTypeConverter.groovy | 2 +- .../ImpConfigTypeConverter.groovy | 2 +- ...dAuctionResponseConfigTypeConverter.groovy | 2 +- ...toredBidResponseConfigTypeConverter.groovy | 2 +- .../StoredRequestConfigTypeConverter.groovy | 2 +- .../repository/EntityManagerUtil.groovy | 2 +- .../service/PrebidServerService.groovy | 3 +- .../functional/tests/BidderParamsSpec.groovy | 2 +- .../PubstackAnalyticsReporterTest.java | 13 +- .../auction/BidResponseCreatorTest.java | 5 +- .../CurrencyConversionServiceTest.java | 3 +- .../auction/model/CachedDebugLogTest.java | 10 +- .../VideoRequestFactoryTest.java | 2 +- .../adtelligent/AdtelligentBidderTest.java | 9 +- .../execution/RemoteFileSyncerTest.java | 288 ++++++++---------- .../org/prebid/server/it/ApplicationTest.java | 4 +- .../server/log/ConditionalLoggerTest.java | 1 - .../org/prebid/server/log/CriteriaTest.java | 1 - .../server/log/HttpInteractionLoggerTest.java | 7 +- .../JdbcStoredDataResultMapperTest.java | 9 +- .../HttpPeriodicRefreshServiceTest.java | 3 +- .../JdbcPeriodicRefreshServiceTest.java | 3 +- .../server/vertx/CloseableAdapterTest.java | 13 +- .../vertx/httpclient/BasicHttpClientTest.java | 92 +++--- 344 files changed, 1125 insertions(+), 1086 deletions(-) create mode 100644 src/main/java/org/prebid/server/log/Logger.java create mode 100644 src/main/java/org/prebid/server/log/LoggerFactory.java create mode 100644 src/main/java/org/prebid/server/vertx/verticles/server/DaemonVerticle.java diff --git a/.editorconfig b/.editorconfig index 23e7176794a..7b8947ec3c6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -115,7 +115,7 @@ ij_java_for_statement_wrap = off ij_java_generate_final_locals = false ij_java_generate_final_parameters = false ij_java_if_brace_force = never -ij_java_imports_layout = *,|,javax.**,java.**,|,$* +ij_java_imports_layout = *,|,javax.**,jakarta.**,java.**,|,$* ij_java_indent_case_from_switch = true ij_java_insert_inner_class_imports = false ij_java_insert_override_annotation = true diff --git a/checkstyle.xml b/checkstyle.xml index aac9ec01cfe..b93d0402c9e 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -75,7 +75,7 @@ - + diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 0bb36be1d10..51a81049e5e 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -17,7 +17,7 @@ io.vertx vertx-redis-client - 3.9.10 + ${vertx.version} diff --git a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisClient.java b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisClient.java index f03d07ca33c..7c943c888dd 100644 --- a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisClient.java +++ b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisClient.java @@ -4,8 +4,8 @@ import io.vertx.core.Handler; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import io.vertx.redis.client.Redis; import io.vertx.redis.client.RedisAPI; import io.vertx.redis.client.RedisConnection; @@ -45,7 +45,7 @@ public RedisClient( public void start(Promise startFuture) { createRedisClient(onCreate -> { if (onCreate.succeeded()) { - logger.info("Confiant Redis {0} connection is established", type); + logger.info("Confiant Redis {} connection is established", type); startFuture.tryComplete(); } }, false); diff --git a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisParser.java b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisParser.java index a516497146d..95ed2a2814f 100644 --- a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisParser.java +++ b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisParser.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.hooks.modules.com.confiant.adquality.model.BidScanResult; import org.prebid.server.hooks.modules.com.confiant.adquality.model.RedisError; diff --git a/extra/modules/pb-richmedia-filter/src/main/java/org/prebid/server/hooks/modules/pb/richmedia/filter/model/PbRichMediaFilterProperties.java b/extra/modules/pb-richmedia-filter/src/main/java/org/prebid/server/hooks/modules/pb/richmedia/filter/model/PbRichMediaFilterProperties.java index e22419d1702..e7db7870721 100644 --- a/extra/modules/pb-richmedia-filter/src/main/java/org/prebid/server/hooks/modules/pb/richmedia/filter/model/PbRichMediaFilterProperties.java +++ b/extra/modules/pb-richmedia-filter/src/main/java/org/prebid/server/hooks/modules/pb/richmedia/filter/model/PbRichMediaFilterProperties.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Value; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Value(staticConstructor = "of") public class PbRichMediaFilterProperties { diff --git a/extra/pom.xml b/extra/pom.xml index 0ef8a94ae56..0afb89a0b85 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -19,7 +19,8 @@ UTF-8 17 17 - 1.18.24 + 4.5.5 + 1.18.30 3.0.0-M6 diff --git a/pom.xml b/pom.xml index abbd1a513e1..638bf87e9f5 100644 --- a/pom.xml +++ b/pom.xml @@ -27,9 +27,8 @@ Dockerfile - 2.5.6 + 3.2.3 2.0.1.Final - 3.9.10 3.14.0 4.4 1.26.0 @@ -37,23 +36,22 @@ 4.5.14 5.3.1 6.4.5 - 2.14.1 + 2.16.2 1.0.76 1.13 8.0.28 42.7.2 2.2.0 1.2.2 + 0.16.0 2.0.2 2.0.7 2.12.0 - 1.2.13 5.0.1 3.0.10 3.21.7 3.17.3 1.0.7 - 1.7.32 4.13.2 @@ -63,9 +61,9 @@ 2.35.1 4.2.0 9.4.53.v20231009 - 4.4.0 + 5.4.0 2.2.220 - 2.4-M1-groovy-3.0 + 2.4-M2-groovy-4.0 3.0.14 1.17.4 5.14.0 @@ -76,7 +74,7 @@ 3.1.2 10.3 1.2.0 - 0.8.7 + 0.8.11 2.2.4 3.10.1 2.22.2 @@ -135,8 +133,8 @@ spring-boot-starter-aop - javax.annotation - javax.annotation-api + jakarta.annotation + jakarta.annotation-api javax.validation @@ -338,41 +336,19 @@ io.prometheus - simpleclient_vertx + simpleclient_vertx4 + ${vertx.prometheus.version} io.prometheus simpleclient_dropwizard + ${vertx.prometheus.version} com.maxmind.geoip2 geoip2 ${maxmind-client.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - ch.qos.logback - logback-core - ${logback.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.apache.logging.log4j - log4j-to-slf4j - - - org.apache.logging.log4j - log4j-api - com.zaxxer HikariCP @@ -524,6 +500,18 @@ ${restassured.version} test + + io.rest-assured + json-path + ${restassured.version} + test + + + io.rest-assured + xml-path + ${restassured.version} + test + net.bytebuddy byte-buddy @@ -549,7 +537,7 @@ test - org.hibernate + org.hibernate.orm hibernate-core test @@ -600,6 +588,11 @@ org.apache.maven.plugins maven-compiler-plugin ${maven-compiler-plugin.version} + + + -parameters + + org.apache.maven.plugins diff --git a/src/main/java/org/prebid/server/activity/ActivitiesConfigResolver.java b/src/main/java/org/prebid/server/activity/ActivitiesConfigResolver.java index df267438a4a..aae688556bf 100644 --- a/src/main/java/org/prebid/server/activity/ActivitiesConfigResolver.java +++ b/src/main/java/org/prebid/server/activity/ActivitiesConfigResolver.java @@ -1,7 +1,7 @@ package org.prebid.server.activity; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.AccountPrivacyConfig; import org.prebid.server.settings.model.activity.AccountActivityConfiguration; diff --git a/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java b/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java index 9339582f1e1..f3a0b515a3c 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java @@ -1,7 +1,5 @@ package org.prebid.server.activity.infrastructure.creator; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.ListUtils; import org.prebid.server.activity.Activity; import org.prebid.server.activity.infrastructure.ActivityController; @@ -11,6 +9,8 @@ import org.prebid.server.activity.infrastructure.rule.Rule; import org.prebid.server.auction.gpp.model.GppContext; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.request.TraceLevel; diff --git a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java index 9856f6e1a26..a65b2293a8d 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java +++ b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java @@ -10,8 +10,6 @@ import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.activity.Activity; import org.prebid.server.activity.ComponentType; @@ -31,6 +29,8 @@ import org.prebid.server.auction.privacy.enforcement.mask.UserFpdActivityMask; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.model.PrivacyEnforcementAction; @@ -126,8 +126,8 @@ private void delegateEvent(T event, } } else { final Throwable privacyEnforcementException = privacyEnforcementMapResult.cause(); - logger.error("Analytics TCF enforcement check failed for consentString: {0} and " - + "delegates with vendorIds {1}", privacyEnforcementException, + logger.error("Analytics TCF enforcement check failed for consentString: {} and " + + "delegates with vendorIds {}", privacyEnforcementException, tcfContext.getConsentString(), delegates); } } diff --git a/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java index 61931743085..070bea19992 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java @@ -1,8 +1,6 @@ package org.prebid.server.analytics.reporter.log; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.analytics.AnalyticsReporter; import org.prebid.server.analytics.model.AmpEvent; import org.prebid.server.analytics.model.AuctionEvent; @@ -12,6 +10,8 @@ import org.prebid.server.analytics.model.VideoEvent; import org.prebid.server.analytics.reporter.log.model.LogEvent; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java index 87e52034472..09daf73343d 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java @@ -2,9 +2,8 @@ import io.vertx.core.AsyncResult; import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; import org.prebid.server.analytics.AnalyticsReporter; @@ -20,6 +19,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.Initializable; import org.prebid.server.vertx.httpclient.HttpClient; @@ -124,9 +125,10 @@ public String name() { } @Override - public void initialize() { + public void initialize(Promise initializePromise) { vertx.setPeriodic(configurationRefreshDelay, id -> fetchRemoteConfig()); fetchRemoteConfig(); + initializePromise.tryComplete(); } void shutdown() { @@ -134,7 +136,7 @@ void shutdown() { } private void fetchRemoteConfig() { - logger.info("[pubstack] Updating config: {0}", pubstackConfig); + logger.info("[pubstack] Updating config: {}", pubstackConfig); httpClient.get(makeEventEndpointUrl(pubstackConfig.getEndpoint(), pubstackConfig.getScopeId()), timeout) .map(this::processRemoteConfigurationResponse) .onComplete(this::updateConfigsOnChange); @@ -156,7 +158,7 @@ private PubstackConfig processRemoteConfigurationResponse(HttpClientResponse res private void updateConfigsOnChange(AsyncResult asyncConfigResult) { if (asyncConfigResult.failed()) { - logger.error("[pubstask] Fail to fetch remote configuration: {0}", asyncConfigResult.cause().getMessage()); + logger.error("[pubstask] Fail to fetch remote configuration: {}", asyncConfigResult.cause().getMessage()); } else if (!Objects.equals(pubstackConfig, asyncConfigResult.result())) { final PubstackConfig pubstackConfig = asyncConfigResult.result(); eventHandlers.values().forEach(PubstackEventHandler::reportEvents); diff --git a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java index 0dd4eb229e9..8c77665bede 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java +++ b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java @@ -7,11 +7,11 @@ import io.vertx.core.Vertx; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.analytics.reporter.pubstack.model.PubstackAnalyticsProperties; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.httpclient.HttpClient; import org.prebid.server.vertx.httpclient.model.HttpClientResponse; @@ -118,7 +118,7 @@ private boolean reportEventsOnCondition(Predicate conditionToSend, T cond sendEvents(events); } } catch (Exception exception) { - logger.error("[pubstack] Failed to send analytics report to endpoint {0} with a reason {1}", + logger.error("[pubstack] Failed to send analytics report to endpoint {} with a reason {}", endpoint, exception.getMessage()); } finally { lockOnSend.unlock(); @@ -163,13 +163,13 @@ private static byte[] gzip(String value) { private void handleReportResponse(AsyncResult result) { if (result.failed()) { - logger.error("[pubstack] Failed to send events to endpoint {0} with a reason: {1}", + logger.error("[pubstack] Failed to send events to endpoint {} with a reason: {}", endpoint, result.cause().getMessage()); } else { final HttpClientResponse httpClientResponse = result.result(); final int statusCode = httpClientResponse.getStatusCode(); if (statusCode != HttpResponseStatus.OK.code()) { - logger.error("[pubstack] Wrong code received {0} instead of 200", statusCode); + logger.error("[pubstack] Wrong code received {} instead of 200", statusCode); } } } diff --git a/src/main/java/org/prebid/server/auction/ExchangeService.java b/src/main/java/org/prebid/server/auction/ExchangeService.java index 967046d3ae8..be303320f51 100644 --- a/src/main/java/org/prebid/server/auction/ExchangeService.java +++ b/src/main/java/org/prebid/server/auction/ExchangeService.java @@ -20,8 +20,6 @@ import com.iab.openrtb.response.SeatBid; import io.vertx.core.CompositeFuture; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.map.CaseInsensitiveMap; @@ -46,8 +44,8 @@ import org.prebid.server.auction.model.BidderResponse; import org.prebid.server.auction.model.MultiBidConfig; import org.prebid.server.auction.model.StoredResponseResult; -import org.prebid.server.auction.privacy.enforcement.PrivacyEnforcementService; import org.prebid.server.auction.model.TimeoutContext; +import org.prebid.server.auction.privacy.enforcement.PrivacyEnforcementService; import org.prebid.server.auction.versionconverter.BidRequestOrtbVersionConversionManager; import org.prebid.server.auction.versionconverter.OrtbVersion; import org.prebid.server.bidder.Bidder; @@ -83,6 +81,8 @@ import org.prebid.server.log.ConditionalLogger; import org.prebid.server.log.CriteriaLogManager; import org.prebid.server.log.HttpInteractionLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.CaseInsensitiveMultiMap; diff --git a/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java b/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java index ddafc42fd53..ce1c33a1304 100644 --- a/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java +++ b/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java @@ -3,8 +3,6 @@ import com.iab.openrtb.request.Device; import com.iab.openrtb.request.Geo; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.auction.model.AuctionContext; @@ -13,6 +11,8 @@ import org.prebid.server.execution.Timeout; import org.prebid.server.geolocation.GeoLocationService; import org.prebid.server.geolocation.model.GeoInfo; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.model.HttpRequestContext; import org.prebid.server.settings.model.Account; diff --git a/src/main/java/org/prebid/server/auction/IpAddressHelper.java b/src/main/java/org/prebid/server/auction/IpAddressHelper.java index f99e75cb985..523219fd511 100644 --- a/src/main/java/org/prebid/server/auction/IpAddressHelper.java +++ b/src/main/java/org/prebid/server/auction/IpAddressHelper.java @@ -4,11 +4,11 @@ import inet.ipaddr.IPAddress; import inet.ipaddr.IPAddressString; import inet.ipaddr.IPAddressStringParameters; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.StringUtils; import org.apache.http.conn.util.InetAddressUtils; import org.prebid.server.auction.model.IpAddress; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.util.List; @@ -43,7 +43,7 @@ public String anonymizeIpv6(String ip) { ? ipAddressString.toAddress().mask(ipv6AnonLeftMaskAddress).toCanonicalString() : null; } catch (AddressStringException e) { - logger.debug("Exception occurred while anonymizing IPv6 address: {0}", e.getMessage()); + logger.debug("Exception occurred while anonymizing IPv6 address: {}", e.getMessage()); return null; } } diff --git a/src/main/java/org/prebid/server/auction/OrtbTypesResolver.java b/src/main/java/org/prebid/server/auction/OrtbTypesResolver.java index 3a0063f66ea..35668bbf0f4 100644 --- a/src/main/java/org/prebid/server/auction/OrtbTypesResolver.java +++ b/src/main/java/org/prebid/server/auction/OrtbTypesResolver.java @@ -6,14 +6,14 @@ import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.json.JsonMerger; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/org/prebid/server/auction/SupplyChainResolver.java b/src/main/java/org/prebid/server/auction/SupplyChainResolver.java index 2faa20174d4..6c7246ced6f 100644 --- a/src/main/java/org/prebid/server/auction/SupplyChainResolver.java +++ b/src/main/java/org/prebid/server/auction/SupplyChainResolver.java @@ -4,13 +4,13 @@ import com.iab.openrtb.request.Source; import com.iab.openrtb.request.SupplyChain; import com.iab.openrtb.request.SupplyChainNode; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebidSchain; @@ -72,7 +72,7 @@ private SupplyChain existingSchainOrNull(String bidder, } if (existingSchain != null) { - logger.debug("Schain bidder {0} is rejected since it was defined more than once", bidder); + logger.debug("Schain bidder {} is rejected since it was defined more than once", bidder); return null; } diff --git a/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java b/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java index 91ded451731..6b6cb533c72 100644 --- a/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java +++ b/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java @@ -17,8 +17,6 @@ import com.iab.openrtb.request.video.Podconfig; import io.vertx.core.Future; import io.vertx.core.file.FileSystem; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; @@ -29,6 +27,8 @@ import org.prebid.server.execution.TimeoutFactory; import org.prebid.server.json.JacksonMapper; import org.prebid.server.json.JsonMerger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.ExtIncludeBrandCategory; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; diff --git a/src/main/java/org/prebid/server/auction/model/BidRejectionTracker.java b/src/main/java/org/prebid/server/auction/model/BidRejectionTracker.java index 62cd645bcf3..b0504ec13a3 100644 --- a/src/main/java/org/prebid/server/auction/model/BidRejectionTracker.java +++ b/src/main/java/org/prebid/server/auction/model/BidRejectionTracker.java @@ -1,10 +1,10 @@ package org.prebid.server.auction.model; import com.iab.openrtb.response.Bid; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.MapUtil; import java.util.Collection; diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java index afa0c83e8b1..042e130132b 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java @@ -3,8 +3,6 @@ import com.iab.openrtb.request.Device; import com.iab.openrtb.request.User; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.prebid.server.auction.BidderAliases; @@ -12,6 +10,8 @@ import org.prebid.server.auction.model.BidderPrivacyResult; import org.prebid.server.auction.privacy.enforcement.mask.UserFpdTcfMask; import org.prebid.server.bidder.BidderCatalog; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.TcfDefinerService; diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java index c1b346b0f73..0fdf6497141 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java @@ -15,8 +15,6 @@ import com.iab.openrtb.request.Source; import com.iab.openrtb.request.SupplyChain; import com.iab.openrtb.request.User; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.Value; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.SetUtils; @@ -41,6 +39,8 @@ import org.prebid.server.identity.IdGenerator; import org.prebid.server.json.JacksonMapper; import org.prebid.server.json.JsonMerger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.CaseInsensitiveMultiMap; import org.prebid.server.model.HttpRequestContext; import org.prebid.server.proto.openrtb.ext.request.ExtDevice; @@ -440,7 +440,7 @@ private String getDomainOrNull(String url) { try { return paramsExtractor.domainFrom(url); } catch (PreBidException e) { - logger.warn("Error occurred while populating bid request: {0}", e.getMessage()); + logger.warn("Error occurred while populating bid request: {}", e.getMessage()); return null; } } diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java index 7d819f82618..761bd1d8434 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java @@ -10,8 +10,6 @@ import com.iab.openrtb.request.Site; import io.vertx.core.Future; import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.Getter; import org.apache.commons.collections4.CollectionUtils; @@ -43,6 +41,8 @@ import org.prebid.server.hooks.v1.auction.AuctionRequestPayload; import org.prebid.server.hooks.v1.entrypoint.EntrypointPayload; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.CaseInsensitiveMultiMap; @@ -496,7 +496,7 @@ private Future wrapFailure(Throwable exception, String accountId, HttpR UNKNOWN_ACCOUNT_LOGGER.warn(accountErrorMessage(exception.getMessage(), httpRequest), 100); } else { metrics.updateAccountRequestRejectedByFailedFetch(accountId); - logger.warn("Error occurred while fetching account: {0}", exception.getMessage()); + logger.warn("Error occurred while fetching account: {}", exception.getMessage()); logger.debug("Error occurred while fetching account", exception); } diff --git a/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java index 31e150f78cf..17724deaa03 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java @@ -21,8 +21,8 @@ import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.auction.model.CachedDebugLog; import org.prebid.server.auction.model.WithPodErrors; -import org.prebid.server.auction.privacy.contextfactory.AuctionPrivacyContextFactory; import org.prebid.server.auction.model.debug.DebugContext; +import org.prebid.server.auction.privacy.contextfactory.AuctionPrivacyContextFactory; import org.prebid.server.auction.versionconverter.BidRequestOrtbVersionConversionManager; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.json.DecodeException; diff --git a/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java b/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java index 4fde2bbbcd5..0560ba01e77 100644 --- a/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java +++ b/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java @@ -1,11 +1,11 @@ package org.prebid.server.bidder; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.bidder.model.BidderCall; import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.httpclient.HttpClient; import org.prebid.server.vertx.httpclient.model.HttpClientResponse; diff --git a/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java b/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java index 2514c6c86df..b751cd3aea4 100644 --- a/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java +++ b/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java @@ -7,8 +7,6 @@ import io.vertx.core.CompositeFuture; import io.vertx.core.Future; import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.auction.BidderAliases; @@ -28,6 +26,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.Timeout; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.CaseInsensitiveMultiMap; import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall; import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig; @@ -159,7 +159,7 @@ private boolean isStoredResponse(List> httpRequests, String s if (httpRequests.size() > 1) { logger.warn(""" More than one request was created for stored response, when only single stored response \ - per bidder is supported for the moment. Request to real {0} bidder will be performed.""", + per bidder is supported for the moment. Request to real {} bidder will be performed.""", bidder); return false; } @@ -239,9 +239,9 @@ private static byte[] gzip(byte[] value) { * Produces {@link Future} with {@link BidderCall} containing request and error description. */ private static Future> failResponse(Throwable exception, HttpRequest httpRequest) { - logger.warn("Error occurred while sending HTTP request to a bidder url: {0} with message: {1}", + logger.warn("Error occurred while sending HTTP request to a bidder url: {} with message: {}", httpRequest.getUri(), exception.getMessage()); - logger.debug("Error occurred while sending HTTP request to a bidder url: {0}", + logger.debug("Error occurred while sending HTTP request to a bidder url: {}", exception, httpRequest.getUri()); final BidderError.Type errorType = diff --git a/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java b/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java index 584a72cf67f..053b87c5ec2 100644 --- a/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java +++ b/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java @@ -54,7 +54,7 @@ import org.prebid.server.util.HttpUtil; import org.prebid.server.util.ObjectUtil; -import javax.validation.ValidationException; +import jakarta.validation.ValidationException; import java.math.BigDecimal; import java.net.URISyntaxException; import java.util.ArrayList; diff --git a/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java b/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java index f1b9613ebc8..201c782c409 100644 --- a/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java +++ b/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java @@ -28,8 +28,8 @@ import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collections; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java b/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java index 686a865dfbb..60f05103c1f 100644 --- a/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java +++ b/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java @@ -16,8 +16,8 @@ import org.apache.commons.lang3.StringUtils; import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; import org.prebid.server.exception.PreBidException; diff --git a/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java b/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java index 395ab3a7532..9c3fd9818aa 100644 --- a/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java +++ b/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java @@ -5,10 +5,9 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; import com.iab.openrtb.response.Bid; -import org.apache.commons.collections4.MapUtils; -import org.prebid.server.bidder.openx.proto.OpenxBidResponse; import com.iab.openrtb.response.SeatBid; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.model.BidderBid; @@ -18,6 +17,7 @@ import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; import org.prebid.server.bidder.openx.model.OpenxImpType; +import org.prebid.server.bidder.openx.proto.OpenxBidResponse; import org.prebid.server.bidder.openx.proto.OpenxBidResponseExt; import org.prebid.server.bidder.openx.proto.OpenxRequestExt; import org.prebid.server.bidder.openx.proto.OpenxVideoExt; diff --git a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java index 311e2e1ee69..296071b0765 100644 --- a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java +++ b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java @@ -5,9 +5,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; -import com.iab.openrtb.response.Bid; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.bidder.Bidder; diff --git a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java index 4f4e8b455b3..27d6dc59ff9 100644 --- a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java +++ b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java @@ -29,8 +29,6 @@ import com.iab.openrtb.response.Bid; import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -80,6 +78,8 @@ import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.ExtPrebid; import org.prebid.server.proto.openrtb.ext.FlexibleExtension; import org.prebid.server.proto.openrtb.ext.request.ExtApp; diff --git a/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java b/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java index b5794ce7368..3a9bbf1ce88 100644 --- a/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java +++ b/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java @@ -17,8 +17,8 @@ import org.apache.http.client.utils.URIBuilder; import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; import org.prebid.server.exception.PreBidException; diff --git a/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java b/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java index 6a547009892..f6868ef878f 100644 --- a/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java +++ b/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java @@ -16,8 +16,6 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -33,6 +31,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.ExtPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; diff --git a/src/main/java/org/prebid/server/cache/CacheService.java b/src/main/java/org/prebid/server/cache/CacheService.java index cb4c48a6c6c..be8ff4a3f89 100644 --- a/src/main/java/org/prebid/server/cache/CacheService.java +++ b/src/main/java/org/prebid/server/cache/CacheService.java @@ -7,8 +7,6 @@ import com.iab.openrtb.response.Bid; import io.vertx.core.Future; import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.Value; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; @@ -35,6 +33,8 @@ import org.prebid.server.identity.UUIDIdGenerator; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.response.BidType; @@ -185,7 +185,7 @@ private Future makeRequest(BidCacheRequest bidCacheRequest, private Future failResponse(Throwable exception, String accountId, long startTime) { metrics.updateCacheRequestFailedTime(accountId, clock.millis() - startTime); - logger.warn("Error occurred while interacting with cache service: {0}", exception.getMessage()); + logger.warn("Error occurred while interacting with cache service: {}", exception.getMessage()); logger.debug("Error occurred while interacting with cache service", exception); return Future.failedFuture(exception); @@ -423,7 +423,7 @@ private CacheServiceResult failResponseOpenrtb(Throwable exception, CacheHttpRequest request, long startTime) { - logger.warn("Error occurred while interacting with cache service: {0}", exception.getMessage()); + logger.warn("Error occurred while interacting with cache service: {}", exception.getMessage()); logger.debug("Error occurred while interacting with cache service", exception); metrics.updateCacheRequestFailedTime(accountId, clock.millis() - startTime); diff --git a/src/main/java/org/prebid/server/cookie/PrioritizedCoopSyncProvider.java b/src/main/java/org/prebid/server/cookie/PrioritizedCoopSyncProvider.java index 9a2cd932a09..d3c0dae7150 100644 --- a/src/main/java/org/prebid/server/cookie/PrioritizedCoopSyncProvider.java +++ b/src/main/java/org/prebid/server/cookie/PrioritizedCoopSyncProvider.java @@ -1,8 +1,8 @@ package org.prebid.server.cookie; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.bidder.BidderCatalog; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.AccountCookieSyncConfig; @@ -39,15 +39,15 @@ private static Set validCoopSyncBidders(Set bidders, BidderCatal for (String bidder : bidders) { if (!bidderCatalog.isValidName(bidder)) { logger.info(""" - bidder {0} is provided for prioritized coop-syncing, \ + bidder {} is provided for prioritized coop-syncing, \ but is invalid bidder name, ignoring""", bidder); } else if (!bidderCatalog.isActive(bidder)) { logger.info(""" - bidder {0} is provided for prioritized coop-syncing, \ + bidder {} is provided for prioritized coop-syncing, \ but disabled in current pbs instance, ignoring""", bidder); } else if (bidderCatalog.usersyncerByName(bidder).isEmpty()) { logger.info(""" - bidder {0} is provided for prioritized coop-syncing, \ + bidder {} is provided for prioritized coop-syncing, \ but has no user-sync configuration, ignoring""", bidder); } else { validBidders.add(bidder); diff --git a/src/main/java/org/prebid/server/cookie/UidsCookieService.java b/src/main/java/org/prebid/server/cookie/UidsCookieService.java index 7416abfdfa2..6b608f06307 100644 --- a/src/main/java/org/prebid/server/cookie/UidsCookieService.java +++ b/src/main/java/org/prebid/server/cookie/UidsCookieService.java @@ -3,8 +3,6 @@ import io.vertx.core.buffer.Buffer; import io.vertx.core.http.Cookie; import io.vertx.core.http.CookieSameSite; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; import org.prebid.server.cookie.model.UidWithExpiry; @@ -12,6 +10,8 @@ import org.prebid.server.cookie.proto.Uids; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.model.HttpRequestContext; import org.prebid.server.util.HttpUtil; @@ -131,7 +131,7 @@ public Uids parseUids(Map cookies) { try { return mapper.decodeValue(Buffer.buffer(Base64.getUrlDecoder().decode(cookieValue)), Uids.class); } catch (IllegalArgumentException | DecodeException e) { - logger.debug("Could not decode or parse {0} cookie value {1}", e, COOKIE_NAME, cookieValue); + logger.debug("Could not decode or parse {} cookie value {}", e, COOKIE_NAME, cookieValue); } } return null; diff --git a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java index 9b6d81f77ee..09f5c16f46d 100644 --- a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java +++ b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java @@ -2,15 +2,16 @@ import com.iab.openrtb.request.BidRequest; import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; import org.prebid.server.currency.proto.CurrencyConversionRates; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestCurrency; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; @@ -67,19 +68,23 @@ public CurrencyConversionService(ExternalConversionProperties externalConversion * Must be called on Vertx event loop thread. */ @Override - public void initialize() { + public void initialize(Promise initializePromise) { if (externalConversionProperties != null) { final Long refreshPeriod = externalConversionProperties.getRefreshPeriodMs(); final Long defaultTimeout = externalConversionProperties.getDefaultTimeoutMs(); final HttpClient httpClient = externalConversionProperties.getHttpClient(); final Vertx vertx = externalConversionProperties.getVertx(); - vertx.setPeriodic(refreshPeriod, ignored -> populatesLatestCurrencyRates(currencyServerUrl, defaultTimeout, + vertx.setPeriodic(refreshPeriod, ignored -> populatesLatestCurrencyRates( + currencyServerUrl, + defaultTimeout, httpClient)); populatesLatestCurrencyRates(currencyServerUrl, defaultTimeout, httpClient); externalConversionProperties.getMetrics().createCurrencyRatesGauge(this::isRatesStale); } + + initializePromise.tryComplete(); } /** diff --git a/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java b/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java index f47faf082a7..9a6416ba44c 100644 --- a/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java +++ b/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java @@ -1,48 +1,50 @@ package org.prebid.server.execution; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.file.AsyncFile; import io.vertx.core.file.CopyOptions; import io.vertx.core.file.FileProps; import io.vertx.core.file.FileSystem; import io.vertx.core.file.FileSystemException; import io.vertx.core.file.OpenOptions; import io.vertx.core.http.HttpClient; +import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; import io.vertx.core.http.HttpHeaders; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import io.vertx.core.streams.Pump; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.RequestOptions; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.PreBidException; -import org.prebid.server.execution.retry.Retryable; import org.prebid.server.execution.retry.RetryPolicy; +import org.prebid.server.execution.retry.Retryable; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Paths; import java.util.Objects; -import java.util.concurrent.TimeoutException; public class RemoteFileSyncer { private static final Logger logger = LoggerFactory.getLogger(RemoteFileSyncer.class); + private final RemoteFileProcessor processor; private final String downloadUrl; private final String saveFilePath; private final String tmpFilePath; private final RetryPolicy retryPolicy; - private final long timeout; private final long updatePeriod; private final HttpClient httpClient; private final Vertx vertx; private final FileSystem fileSystem; + private final RequestOptions getFileRequestOptions; + private final RequestOptions isUpdateRequiredRequestOptions; - public RemoteFileSyncer(String downloadUrl, + public RemoteFileSyncer(RemoteFileProcessor processor, + String downloadUrl, String saveFilePath, String tmpFilePath, RetryPolicy retryPolicy, @@ -51,11 +53,11 @@ public RemoteFileSyncer(String downloadUrl, HttpClient httpClient, Vertx vertx) { + this.processor = Objects.requireNonNull(processor); this.downloadUrl = HttpUtil.validateUrl(downloadUrl); this.saveFilePath = Objects.requireNonNull(saveFilePath); this.tmpFilePath = Objects.requireNonNull(tmpFilePath); this.retryPolicy = Objects.requireNonNull(retryPolicy); - this.timeout = timeout; this.updatePeriod = updatePeriod; this.httpClient = Objects.requireNonNull(httpClient); this.vertx = Objects.requireNonNull(vertx); @@ -63,6 +65,16 @@ public RemoteFileSyncer(String downloadUrl, createAndCheckWritePermissionsFor(fileSystem, saveFilePath); createAndCheckWritePermissionsFor(fileSystem, tmpFilePath); + + getFileRequestOptions = new RequestOptions() + .setMethod(HttpMethod.GET) + .setTimeout(timeout) + .setAbsoluteURI(downloadUrl); + + isUpdateRequiredRequestOptions = new RequestOptions() + .setMethod(HttpMethod.HEAD) + .setTimeout(timeout) + .setAbsoluteURI(downloadUrl); } private static void createAndCheckWritePermissionsFor(FileSystem fileSystem, String filePath) { @@ -79,197 +91,80 @@ private static void createAndCheckWritePermissionsFor(FileSystem fileSystem, Str } } - public void sync(RemoteFileProcessor processor) { - isFileExists(saveFilePath) - .compose(exists -> exists ? processSavedFile(processor) : syncRemoteFiles(retryPolicy)) - .onComplete(syncResult -> handleSync(processor, syncResult)); - } - - private Future isFileExists(String filePath) { - final Promise promise = Promise.promise(); - fileSystem.exists(filePath, async -> { - if (async.succeeded()) { - promise.complete(async.result()); - } else { - promise.fail("Cant check if file exists " + filePath); - } - }); - return promise.future(); + public void sync() { + fileSystem.exists(saveFilePath) + .compose(exists -> exists ? processSavedFile() : syncRemoteFile(retryPolicy)) + .onComplete(ignored -> setUpDeferredUpdate()); } - private Future processSavedFile(RemoteFileProcessor processor) { + private Future processSavedFile() { return processor.setDataPath(saveFilePath) - .map(false) - .recover(ignored -> removeCorruptedSaveFile()); + .onFailure(error -> logger.error("Can't process saved file: " + saveFilePath)) + .recover(ignored -> deleteFile(saveFilePath).mapEmpty()) + .mapEmpty(); } - private Future removeCorruptedSaveFile() { - return deleteFileIfExists(saveFilePath) - .compose(ignored -> syncRemoteFiles(retryPolicy)) - .recover(error -> Future.failedFuture(new PreBidException( - "Corrupted file %s can't be deleted. Please check permission or delete manually." - .formatted(saveFilePath), error))); + private Future deleteFile(String filePath) { + return fileSystem.delete(filePath) + .onFailure(error -> logger.error("Can't delete corrupted file: " + saveFilePath)); } - private Future syncRemoteFiles(RetryPolicy retryPolicy) { - return deleteFileIfExists(tmpFilePath) - .compose(ignored -> downloadToTempFile()) - .recover(error -> retrySync(retryPolicy)) - .compose(downloadResult -> swapFiles()) - .map(true); - } + private Future syncRemoteFile(RetryPolicy retryPolicy) { + return fileSystem.open(tmpFilePath, new OpenOptions()) - private Future deleteFileIfExists(String filePath) { - return isFileExists(filePath) - .compose(exists -> exists ? deleteFile(filePath) : Future.succeededFuture()); - } + .compose(tmpFile -> httpClient.request(getFileRequestOptions) + .compose(HttpClientRequest::send) + .compose(response -> response.pipeTo(tmpFile)) + .onComplete(result -> tmpFile.close())) - private Future deleteFile(String filePath) { - final Promise promise = Promise.promise(); - fileSystem.delete(filePath, promise); - return promise.future(); - } + .compose(ignored -> fileSystem.move( + tmpFilePath, saveFilePath, new CopyOptions().setReplaceExisting(true))) - private Future downloadToTempFile() { - return openFile(tmpFilePath) - .compose(tmpFile -> requestData() - .compose(response -> pumpToFile(response, tmpFile))); - } + .compose(ignored -> processSavedFile()) + .onFailure(ignored -> deleteFile(tmpFilePath)) + .onFailure(error -> logger.error("Could not sync remote file", error)) + + .recover(error -> retrySync(retryPolicy).mapEmpty()) + .mapEmpty(); - private Future requestData() { - final Promise promise = Promise.promise(); - httpClient.getAbs(downloadUrl, promise::complete).end(); - return promise.future(); } private Future retrySync(RetryPolicy retryPolicy) { if (retryPolicy instanceof Retryable policy) { - logger.info("Retrying file download from {0} with policy: {1}", downloadUrl, retryPolicy); + logger.info("Retrying file download from {} with policy: {}", downloadUrl, retryPolicy); final Promise promise = Promise.promise(); - vertx.setTimer(policy.delay(), timerId -> - syncRemoteFiles(policy.next()) - .onFailure(promise::fail) - .onSuccess(ignored -> promise.complete())); - + vertx.setTimer(policy.delay(), timerId -> syncRemoteFile(policy.next()).onComplete(promise)); return promise.future(); } else { return Future.failedFuture(new PreBidException("File sync failed")); } } - private Future openFile(String path) { - final Promise promise = Promise.promise(); - fileSystem.open(path, new OpenOptions().setCreateNew(true), promise); - return promise.future(); - } - - private Future pumpToFile(HttpClientResponse httpClientResponse, AsyncFile asyncFile) { - final Promise promise = Promise.promise(); - logger.info("Trying to download file from {0}", downloadUrl); - httpClientResponse.pause(); - - final Pump pump = Pump.pump(httpClientResponse, asyncFile); - pump.start(); - - httpClientResponse.resume(); - final long timeoutTimerId = setTimeoutTimer(asyncFile, pump, promise); - httpClientResponse.endHandler(responseEndResult -> handleResponseEnd(asyncFile, timeoutTimerId, promise)); - - return promise.future(); - } - - private long setTimeoutTimer(AsyncFile asyncFile, Pump pump, Promise promise) { - return vertx.setTimer(timeout, timerId -> handleTimeout(asyncFile, pump, promise)); - } - - private void handleTimeout(AsyncFile asyncFile, Pump pump, Promise promise) { - pump.stop(); - asyncFile.close(); - if (!promise.future().isComplete()) { - promise.fail(new TimeoutException("Timeout on download")); - } - } - - private void handleResponseEnd(AsyncFile asyncFile, long idTimer, Promise promise) { - vertx.cancelTimer(idTimer); - asyncFile.flush().close(promise); - } - - private Future swapFiles() { - final Promise promise = Promise.promise(); - logger.info("Sync {0} to {1}", tmpFilePath, saveFilePath); - - final CopyOptions copyOptions = new CopyOptions().setReplaceExisting(true); - fileSystem.move(tmpFilePath, saveFilePath, copyOptions, promise); - return promise.future(); - } - - private void handleSync(RemoteFileProcessor remoteFileProcessor, AsyncResult syncResult) { - if (syncResult.succeeded()) { - if (syncResult.result()) { - logger.info("Sync service for {0}", saveFilePath); - remoteFileProcessor.setDataPath(saveFilePath) - .onComplete(this::logFileProcessStatus); - } else { - logger.info("Sync is not required for {0}", saveFilePath); - } - } else { - logger.error("Cant sync file from {0}", syncResult.cause(), downloadUrl); - } - - // setup new update regardless of the result + private void setUpDeferredUpdate() { if (updatePeriod > 0) { - vertx.setTimer(updatePeriod, idUpdateNew -> configureAutoUpdates(remoteFileProcessor)); + vertx.setPeriodic(updatePeriod, ignored -> updateIfNeeded()); } } - private void logFileProcessStatus(AsyncResult serviceRespond) { - if (serviceRespond.succeeded()) { - logger.info("Service successfully received file {0}.", saveFilePath); - } else { - logger.error("Service cant process file {0} and still unavailable.", saveFilePath); - } - } - - private void configureAutoUpdates(RemoteFileProcessor remoteFileProcessor) { - logger.info("Check for updated for {0}", saveFilePath); - tryUpdate().onComplete(asyncUpdate -> { - if (asyncUpdate.failed()) { - logger.warn("File {0} update failed", asyncUpdate.cause(), saveFilePath); - } - handleSync(remoteFileProcessor, asyncUpdate); - }); + private void updateIfNeeded() { + httpClient.request(isUpdateRequiredRequestOptions) + .compose(HttpClientRequest::send) + .compose(response -> fileSystem.exists(saveFilePath) + .compose(exists -> exists + ? isLengthChanged(response) + : Future.succeededFuture(true))) + .onSuccess(shouldUpdate -> { + if (shouldUpdate) { + syncRemoteFile(retryPolicy); + } + }); } - private Future tryUpdate() { - return isFileExists(saveFilePath) - .compose(fileExists -> fileExists ? isUpdateRequired() : Future.succeededFuture(true)) - .compose(needUpdate -> needUpdate ? syncRemoteFiles(retryPolicy) : Future.succeededFuture(false)); - } - - private Future isUpdateRequired() { - final Promise isUpdateRequired = Promise.promise(); - httpClient.headAbs(downloadUrl, response -> checkNewVersion(response, isUpdateRequired)) - .exceptionHandler(isUpdateRequired::fail) - .end(); - return isUpdateRequired.future(); - } - - private void checkNewVersion(HttpClientResponse response, Promise isUpdateRequired) { + private Future isLengthChanged(HttpClientResponse response) { final String contentLengthParameter = response.getHeader(HttpHeaders.CONTENT_LENGTH); - if (StringUtils.isNumeric(contentLengthParameter) && !contentLengthParameter.equals("0")) { - final long contentLength = Long.parseLong(contentLengthParameter); - fileSystem.props(saveFilePath, filePropsResult -> { - if (filePropsResult.succeeded()) { - logger.info("Prev length = {0}, new length = {1}", filePropsResult.result().size(), contentLength); - isUpdateRequired.complete(filePropsResult.result().size() != contentLength); - } else { - isUpdateRequired.fail(filePropsResult.cause()); - } - }); - } else { - isUpdateRequired.fail("ContentLength is invalid: " + contentLengthParameter); - } + return StringUtils.isNumeric(contentLengthParameter) && !contentLengthParameter.equals("0") + ? fileSystem.props(saveFilePath).map(props -> props.size() != Long.parseLong(contentLengthParameter)) + : Future.failedFuture("ContentLength is invalid: " + contentLengthParameter); } } diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java index 9e8734576bb..c5bb0e5aa1e 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java @@ -3,8 +3,6 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; import com.iab.openrtb.response.Bid; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.BooleanUtils; @@ -24,6 +22,8 @@ import org.prebid.server.floors.model.PriceFloorEnforcement; import org.prebid.server.floors.model.PriceFloorRules; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java index f5cf62aeb72..c8b6dd17969 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java @@ -4,8 +4,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; @@ -22,6 +20,8 @@ import org.prebid.server.floors.proto.FetchStatus; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebidFloors; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java index 6ce588f9c68..87e293d3b7d 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java @@ -15,8 +15,6 @@ import com.iab.openrtb.request.Publisher; import com.iab.openrtb.request.Site; import com.iab.openrtb.request.Video; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; @@ -35,6 +33,8 @@ import org.prebid.server.geolocation.CountryCodeMapper; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebid; diff --git a/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java b/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java index 39f95f63860..f06d136df48 100644 --- a/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java +++ b/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java @@ -6,8 +6,6 @@ import io.vertx.core.Vertx; import io.vertx.core.http.HttpHeaders; import io.vertx.core.impl.ConcurrentHashSet; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.Value; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; @@ -22,6 +20,8 @@ import org.prebid.server.floors.proto.FetchStatus; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.ApplicationSettings; diff --git a/src/main/java/org/prebid/server/floors/PriceFloorsConfigResolver.java b/src/main/java/org/prebid/server/floors/PriceFloorsConfigResolver.java index f8d5f3baa3c..d47ed2da32c 100644 --- a/src/main/java/org/prebid/server/floors/PriceFloorsConfigResolver.java +++ b/src/main/java/org/prebid/server/floors/PriceFloorsConfigResolver.java @@ -1,11 +1,11 @@ package org.prebid.server.floors; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.PreBidException; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.EnrichingApplicationSettings; diff --git a/src/main/java/org/prebid/server/floors/model/PriceFloorDebugProperties.java b/src/main/java/org/prebid/server/floors/model/PriceFloorDebugProperties.java index 77c2e1c0cab..c75af39004d 100644 --- a/src/main/java/org/prebid/server/floors/model/PriceFloorDebugProperties.java +++ b/src/main/java/org/prebid/server/floors/model/PriceFloorDebugProperties.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; +import jakarta.validation.constraints.Min; @Validated @Data diff --git a/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java b/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java index f7a2c6ca6b9..791a1da06c1 100755 --- a/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java +++ b/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java @@ -2,11 +2,11 @@ import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.execution.Timeout; import org.prebid.server.geolocation.model.GeoInfo; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.CircuitBreaker; diff --git a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java index 343aa09fcef..5ce337fe134 100644 --- a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java +++ b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java @@ -5,8 +5,6 @@ import io.vertx.core.Future; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.BooleanUtils; import org.prebid.server.activity.infrastructure.creator.ActivityInfrastructureCreator; @@ -31,6 +29,8 @@ import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; import org.prebid.server.privacy.gdpr.model.TcfContext; diff --git a/src/main/java/org/prebid/server/handler/ExceptionHandler.java b/src/main/java/org/prebid/server/handler/ExceptionHandler.java index 952d46dd47e..f56a21d8e5c 100644 --- a/src/main/java/org/prebid/server/handler/ExceptionHandler.java +++ b/src/main/java/org/prebid/server/handler/ExceptionHandler.java @@ -1,9 +1,9 @@ package org.prebid.server.handler; import io.vertx.core.Handler; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.StringUtils; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import java.io.IOException; @@ -26,7 +26,7 @@ public static ExceptionHandler create(Metrics metrics) { @Override public void handle(Throwable exception) { if (shouldLogException(exception)) { - logger.warn("Generic error handler: {0}, cause: {1}", + logger.warn("Generic error handler: {}, cause: {}", errorMessageFrom(exception), errorMessageFrom(exception.getCause())); } metrics.updateConnectionAcceptErrors(); diff --git a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java index 61c986c12cc..971cb82204f 100644 --- a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java +++ b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java @@ -7,8 +7,6 @@ import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.Value; import org.prebid.server.activity.infrastructure.ActivityInfrastructure; @@ -21,6 +19,8 @@ import org.prebid.server.events.EventUtil; import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.TimeoutFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.Endpoint; import org.prebid.server.model.HttpRequestContext; import org.prebid.server.settings.ApplicationSettings; diff --git a/src/main/java/org/prebid/server/handler/OptoutHandler.java b/src/main/java/org/prebid/server/handler/OptoutHandler.java index e8ee98b2683..48551d37b03 100644 --- a/src/main/java/org/prebid/server/handler/OptoutHandler.java +++ b/src/main/java/org/prebid/server/handler/OptoutHandler.java @@ -4,12 +4,12 @@ import io.vertx.core.AsyncResult; import io.vertx.core.http.Cookie; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; import org.prebid.server.cookie.UidsCookie; import org.prebid.server.cookie.UidsCookieService; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.Endpoint; import org.prebid.server.optout.GoogleRecaptchaVerifier; import org.prebid.server.optout.model.RecaptchaResponse; diff --git a/src/main/java/org/prebid/server/handler/SetuidHandler.java b/src/main/java/org/prebid/server/handler/SetuidHandler.java index 3f119079d83..bbe0244cc1b 100644 --- a/src/main/java/org/prebid/server/handler/SetuidHandler.java +++ b/src/main/java/org/prebid/server/handler/SetuidHandler.java @@ -8,8 +8,6 @@ import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerRequest; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; @@ -41,6 +39,8 @@ import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.execution.Timeout; import org.prebid.server.execution.TimeoutFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; import org.prebid.server.privacy.HostVendorTcfDefinerService; diff --git a/src/main/java/org/prebid/server/handler/VtrackHandler.java b/src/main/java/org/prebid/server/handler/VtrackHandler.java index 3a50ee05cfd..3059365103b 100644 --- a/src/main/java/org/prebid/server/handler/VtrackHandler.java +++ b/src/main/java/org/prebid/server/handler/VtrackHandler.java @@ -7,8 +7,6 @@ import io.vertx.core.Future; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; @@ -24,6 +22,8 @@ import org.prebid.server.json.DecodeException; import org.prebid.server.json.EncodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.Endpoint; import org.prebid.server.settings.ApplicationSettings; import org.prebid.server.settings.model.Account; diff --git a/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java b/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java index f9b52a807e4..c57e61b9b71 100644 --- a/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java @@ -4,13 +4,13 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.AllArgsConstructor; import lombok.Value; import org.prebid.server.currency.CurrencyConversionService; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import java.io.IOException; diff --git a/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java b/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java index 42eb8368bd3..d237a542ed7 100644 --- a/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java @@ -3,6 +3,7 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; import io.vertx.ext.web.RoutingContext; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; @@ -31,10 +32,13 @@ public SettingsCacheNotificationHandler(CacheNotificationListener cacheNotificat @Override public void handle(RoutingContext routingContext) { - switch (routingContext.request().method()) { - case POST -> doSave(routingContext); - case DELETE -> doInvalidate(routingContext); - default -> doFail(routingContext); + final HttpMethod method = routingContext.request().method(); + if (method.equals(HttpMethod.POST)) { + doSave(routingContext); + } else if (method.equals(HttpMethod.DELETE)) { + doInvalidate(routingContext); + } else { + doFail(routingContext); } } diff --git a/src/main/java/org/prebid/server/handler/admin/VersionHandler.java b/src/main/java/org/prebid/server/handler/admin/VersionHandler.java index adf8088e423..1c48f79a74a 100644 --- a/src/main/java/org/prebid/server/handler/admin/VersionHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/VersionHandler.java @@ -3,13 +3,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.AllArgsConstructor; import lombok.Value; import org.apache.commons.lang3.StringUtils; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java index e50e6018293..b6fb1ea046c 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java @@ -15,8 +15,6 @@ import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; @@ -39,6 +37,8 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; import org.prebid.server.log.HttpInteractionLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; @@ -401,7 +401,7 @@ private void respondWith(RoutingContext routingContext, } private void handleResponseException(Throwable exception) { - logger.warn("Failed to send amp response: {0}", exception.getMessage()); + logger.warn("Failed to send amp response: {}", exception.getMessage()); metrics.updateRequestTypeMetric(REQUEST_TYPE_METRIC, MetricName.networkerr); } diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java index c5a463dce95..4bbc18c53c3 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java @@ -8,8 +8,6 @@ import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.prebid.server.analytics.model.AuctionEvent; import org.prebid.server.analytics.reporter.AnalyticsReporterDelegator; @@ -25,6 +23,8 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; import org.prebid.server.log.HttpInteractionLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; @@ -254,7 +254,7 @@ private void respondWith(RoutingContext routingContext, } private void handleResponseException(Throwable throwable, MetricName requestType) { - logger.warn("Failed to send auction response: {0}", throwable.getMessage()); + logger.warn("Failed to send auction response: {}", throwable.getMessage()); metrics.updateRequestTypeMetric(requestType, MetricName.networkerr); } diff --git a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java index 76831745c47..7ee8f4206ae 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java @@ -6,8 +6,6 @@ import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.prebid.server.analytics.model.VideoEvent; import org.prebid.server.analytics.reporter.AnalyticsReporterDelegator; @@ -21,6 +19,8 @@ import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.UnauthorizedAccountException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; @@ -147,7 +147,7 @@ private void handleResult(AsyncResult responseResult, if (exception instanceof InvalidRequestException) { metricRequestStatus = MetricName.badinput; errorMessages = ((InvalidRequestException) exception).getMessages(); - logger.info("Invalid request format: {0}", errorMessages); + logger.info("Invalid request format: {}", errorMessages); status = HttpResponseStatus.BAD_REQUEST; body = errorMessages.stream() @@ -156,7 +156,7 @@ private void handleResult(AsyncResult responseResult, } else if (exception instanceof UnauthorizedAccountException) { metricRequestStatus = MetricName.badinput; final String errorMessage = exception.getMessage(); - logger.info("Unauthorized: {0}", errorMessage); + logger.info("Unauthorized: {}", errorMessage); errorMessages = Collections.singletonList(errorMessage); status = HttpResponseStatus.UNAUTHORIZED; @@ -236,7 +236,7 @@ private void respondWith(RoutingContext routingContext, } private void handleResponseException(Throwable throwable) { - logger.warn("Failed to send video response: {0}", throwable.getMessage()); + logger.warn("Failed to send video response: {}", throwable.getMessage()); metrics.updateRequestTypeMetric(REQUEST_TYPE_METRIC, MetricName.networkerr); } diff --git a/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java b/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java index 394477d1be4..2525651f872 100644 --- a/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java +++ b/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java @@ -4,7 +4,6 @@ import io.vertx.core.Future; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.hooks.execution.model.ExecutionGroup; import org.prebid.server.hooks.execution.model.HookExecutionContext; import org.prebid.server.hooks.execution.model.HookId; @@ -12,6 +11,7 @@ import org.prebid.server.hooks.v1.InvocationContext; import org.prebid.server.hooks.v1.InvocationResult; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.LoggerFactory; import java.time.Clock; import java.util.concurrent.TimeoutException; diff --git a/src/main/java/org/prebid/server/hooks/execution/GroupResult.java b/src/main/java/org/prebid/server/hooks/execution/GroupResult.java index 47ee0cc3019..a4487e3a60b 100644 --- a/src/main/java/org/prebid/server/hooks/execution/GroupResult.java +++ b/src/main/java/org/prebid/server/hooks/execution/GroupResult.java @@ -1,6 +1,5 @@ package org.prebid.server.hooks.execution; -import io.vertx.core.logging.LoggerFactory; import lombok.Getter; import lombok.experimental.Accessors; import org.prebid.server.hooks.execution.model.ExecutionAction; @@ -13,6 +12,7 @@ import org.prebid.server.hooks.v1.InvocationStatus; import org.prebid.server.hooks.v1.PayloadUpdate; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.LoggerFactory; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/org/prebid/server/log/ConditionalLogger.java b/src/main/java/org/prebid/server/log/ConditionalLogger.java index 899c0d25251..f3e17bb9ed0 100644 --- a/src/main/java/org/prebid/server/log/ConditionalLogger.java +++ b/src/main/java/org/prebid/server/log/ConditionalLogger.java @@ -1,7 +1,6 @@ package org.prebid.server.log; import com.github.benmanes.caffeine.cache.Caffeine; -import io.vertx.core.logging.Logger; import org.apache.commons.lang3.ObjectUtils; import java.time.Instant; diff --git a/src/main/java/org/prebid/server/log/Criteria.java b/src/main/java/org/prebid/server/log/Criteria.java index 7ad5c3039fd..dd6f3cd123f 100644 --- a/src/main/java/org/prebid/server/log/Criteria.java +++ b/src/main/java/org/prebid/server/log/Criteria.java @@ -1,6 +1,5 @@ package org.prebid.server.log; -import io.vertx.core.logging.Logger; import org.apache.commons.lang3.StringUtils; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/log/CriteriaLogManager.java b/src/main/java/org/prebid/server/log/CriteriaLogManager.java index 20344901a31..75ca28f5f81 100644 --- a/src/main/java/org/prebid/server/log/CriteriaLogManager.java +++ b/src/main/java/org/prebid/server/log/CriteriaLogManager.java @@ -3,8 +3,6 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.response.BidResponse; import io.vertx.core.impl.ConcurrentHashSet; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.json.EncodeException; import org.prebid.server.json.JacksonMapper; @@ -38,7 +36,7 @@ public BidResponse traceResponse(Logger logger, jsonBidResponse = mapper.encodeToString(bidResponse); jsonBidRequest = debugEnabled ? null : mapper.encodeToString(bidRequest); } catch (EncodeException e) { - CriteriaLogManager.logger.warn("Failed to parse bidResponse or bidRequest to json string: {0}", e); + CriteriaLogManager.logger.warn("Failed to parse bidResponse or bidRequest to json string: {}", e); return bidResponse; } diff --git a/src/main/java/org/prebid/server/log/CriteriaManager.java b/src/main/java/org/prebid/server/log/CriteriaManager.java index e55087ce50a..8602f182d2e 100644 --- a/src/main/java/org/prebid/server/log/CriteriaManager.java +++ b/src/main/java/org/prebid/server/log/CriteriaManager.java @@ -1,7 +1,6 @@ package org.prebid.server.log; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; import java.util.function.BiConsumer; diff --git a/src/main/java/org/prebid/server/log/HttpInteractionLogger.java b/src/main/java/org/prebid/server/log/HttpInteractionLogger.java index 15cf54303c0..cc89b9cb57b 100644 --- a/src/main/java/org/prebid/server/log/HttpInteractionLogger.java +++ b/src/main/java/org/prebid/server/log/HttpInteractionLogger.java @@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.Value; import org.apache.commons.collections4.CollectionUtils; @@ -47,7 +45,7 @@ public void maybeLogOpenrtb2Auction(AuctionContext auctionContext, if (interactionSatisfiesSpec(HttpLogSpec.Endpoint.auction, statusCode, auctionContext)) { logger.info( - "Requested URL: \"{0}\", request body: \"{1}\", response status: \"{2}\", response body: \"{3}\"", + "Requested URL: \"{}\", request body: \"{}\", response status: \"{}\", response body: \"{}\"", routingContext.request().uri(), toOneLineString(routingContext.getBodyAsString()), statusCode, @@ -72,7 +70,7 @@ public void maybeLogOpenrtb2Amp(AuctionContext auctionContext, if (interactionSatisfiesSpec(HttpLogSpec.Endpoint.amp, statusCode, auctionContext)) { logger.info( - "Requested URL: \"{0}\", response status: \"{1}\", response body: \"{2}\"", + "Requested URL: \"{}\", response status: \"{}\", response body: \"{}\"", routingContext.request().uri(), statusCode, responseBody); @@ -87,7 +85,7 @@ public void maybeLogBidderRequest(AuctionContext context, BidderRequest bidderRe final BidRequest bidRequest = bidderRequest.getBidRequest(); final BidRequest updatedBidRequest = bidRequestWithBidderName(bidder, bidRequest); final String jsonBidRequest = mapper.encodeToString(updatedBidRequest); - logger.info("Request body to {0}: \"{1}\"", bidder, jsonBidRequest); + logger.info("Request body to {}: \"{}\"", bidder, jsonBidRequest); incLoggedInteractions(); } diff --git a/src/main/java/org/prebid/server/log/Logger.java b/src/main/java/org/prebid/server/log/Logger.java new file mode 100644 index 00000000000..9a595f0de2e --- /dev/null +++ b/src/main/java/org/prebid/server/log/Logger.java @@ -0,0 +1,141 @@ +package org.prebid.server.log; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.message.FormattedMessage; +import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.spi.ExtendedLogger; + +public class Logger { + + private static final String FQCN = Logger.class.getCanonicalName(); + + private final ExtendedLogger delegate; + + Logger(ExtendedLogger delegate) { + this.delegate = delegate; + } + + public boolean isWarnEnabled() { + return delegate.isWarnEnabled(); + } + + public boolean isInfoEnabled() { + return delegate.isInfoEnabled(); + } + + public boolean isDebugEnabled() { + return delegate.isDebugEnabled(); + } + + public boolean isTraceEnabled() { + return delegate.isTraceEnabled(); + } + + public void fatal(Object message) { + log(Level.FATAL, message); + } + + public void fatal(Object message, Throwable t) { + log(Level.FATAL, message, t); + } + + public void error(Object message) { + log(Level.ERROR, message); + } + + public void error(Object message, Object... params) { + log(Level.ERROR, message.toString(), params); + } + + public void error(Object message, Throwable t) { + log(Level.ERROR, message, t); + } + + public void error(Object message, Throwable t, Object... params) { + log(Level.ERROR, message.toString(), t, params); + } + + public void warn(Object message) { + log(Level.WARN, message); + } + + public void warn(Object message, Object... params) { + log(Level.WARN, message.toString(), params); + } + + public void warn(Object message, Throwable t) { + log(Level.WARN, message, t); + } + + public void warn(Object message, Throwable t, Object... params) { + log(Level.WARN, message.toString(), t, params); + } + + public void info(Object message) { + log(Level.INFO, message); + } + + public void info(Object message, Object... params) { + log(Level.INFO, message.toString(), params); + } + + public void info(Object message, Throwable t) { + log(Level.INFO, message, t); + } + + public void info(Object message, Throwable t, Object... params) { + log(Level.INFO, message.toString(), t, params); + } + + public void debug(Object message) { + log(Level.DEBUG, message); + } + + public void debug(Object message, Object... params) { + log(Level.DEBUG, message.toString(), params); + } + + public void debug(Object message, Throwable t) { + log(Level.DEBUG, message, t); + } + + public void debug(Object message, Throwable t, Object... params) { + log(Level.DEBUG, message.toString(), t, params); + } + + public void trace(Object message) { + log(Level.TRACE, message); + } + + public void trace(Object message, Object... params) { + log(Level.TRACE, message.toString(), params); + } + + public void trace(Object message, Throwable t) { + log(Level.TRACE, message.toString(), t); + } + + public void trace(Object message, Throwable t, Object... params) { + log(Level.TRACE, message.toString(), t, params); + } + + private void log(Level level, Object message) { + log(level, message, null); + } + + private void log(Level level, Object message, Throwable t) { + if (message instanceof Message) { + delegate.logIfEnabled(FQCN, level, null, (Message) message, t); + } else { + delegate.logIfEnabled(FQCN, level, null, message, t); + } + } + + private void log(Level level, String message, Object... params) { + delegate.logIfEnabled(FQCN, level, null, message, params); + } + + private void log(Level level, String message, Throwable t, Object... params) { + delegate.logIfEnabled(FQCN, level, null, new FormattedMessage(message, params), t); + } +} diff --git a/src/main/java/org/prebid/server/log/LoggerFactory.java b/src/main/java/org/prebid/server/log/LoggerFactory.java new file mode 100644 index 00000000000..7e10b4ac234 --- /dev/null +++ b/src/main/java/org/prebid/server/log/LoggerFactory.java @@ -0,0 +1,22 @@ +package org.prebid.server.log; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.spi.ExtendedLogger; + +public class LoggerFactory { + + private LoggerFactory() { + } + + public static Logger getLogger(Class clazz) { + final String name = clazz.isAnonymousClass() + ? clazz.getEnclosingClass().getCanonicalName() + : clazz.getCanonicalName(); + + return getLogger(name); + } + + public static Logger getLogger(String name) { + return new Logger((ExtendedLogger) LogManager.getLogger(name)); + } +} diff --git a/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java b/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java index a37533586e7..184f7033f7f 100644 --- a/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java +++ b/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java @@ -3,11 +3,11 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.vertx.core.Future; import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.optout.model.RecaptchaResponse; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.httpclient.HttpClient; diff --git a/src/main/java/org/prebid/server/privacy/HostVendorTcfDefinerService.java b/src/main/java/org/prebid/server/privacy/HostVendorTcfDefinerService.java index a555f60608b..471eb5715e3 100644 --- a/src/main/java/org/prebid/server/privacy/HostVendorTcfDefinerService.java +++ b/src/main/java/org/prebid/server/privacy/HostVendorTcfDefinerService.java @@ -1,9 +1,9 @@ package org.prebid.server.privacy; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.experimental.Delegate; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.privacy.gdpr.TcfDefinerService; import org.prebid.server.privacy.gdpr.model.HostVendorTcfResponse; import org.prebid.server.privacy.gdpr.model.TcfContext; diff --git a/src/main/java/org/prebid/server/privacy/PrivacyExtractor.java b/src/main/java/org/prebid/server/privacy/PrivacyExtractor.java index 5f2e6df2025..bae5cf4370b 100644 --- a/src/main/java/org/prebid/server/privacy/PrivacyExtractor.java +++ b/src/main/java/org/prebid/server/privacy/PrivacyExtractor.java @@ -4,13 +4,13 @@ import com.iab.openrtb.request.Regs; import com.iab.openrtb.request.User; import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.privacy.ccpa.Ccpa; import org.prebid.server.privacy.model.Privacy; import org.prebid.server.proto.request.CookieSyncRequest; diff --git a/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java b/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java index ee9b13eb4cc..27f6b25b96a 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java @@ -2,8 +2,6 @@ import com.iabtcf.decoder.TCString; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.Value; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; @@ -15,6 +13,8 @@ import org.prebid.server.execution.Timeout; import org.prebid.server.geolocation.model.GeoInfo; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.model.PrivacyEnforcementAction; diff --git a/src/main/java/org/prebid/server/privacy/gdpr/tcfstrategies/purpose/typestrategies/BasicEnforcePurposeStrategy.java b/src/main/java/org/prebid/server/privacy/gdpr/tcfstrategies/purpose/typestrategies/BasicEnforcePurposeStrategy.java index 8324d606e79..ce9fcd2dc70 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/tcfstrategies/purpose/typestrategies/BasicEnforcePurposeStrategy.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/tcfstrategies/purpose/typestrategies/BasicEnforcePurposeStrategy.java @@ -1,8 +1,8 @@ package org.prebid.server.privacy.gdpr.tcfstrategies.purpose.typestrategies; import com.iabtcf.decoder.TCString; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.privacy.gdpr.model.VendorPermission; import org.prebid.server.privacy.gdpr.model.VendorPermissionWithGvl; import org.prebid.server.privacy.gdpr.vendorlist.proto.PurposeCode; @@ -20,7 +20,7 @@ public Stream allowedByTypeStrategy(PurposeCode purpose, Collection excludedVendors, boolean isEnforceVendors) { - logger.debug("Basic strategy used for purpose {0}", purpose); + logger.debug("Basic strategy used for purpose {}", purpose); final Stream allowedVendorPermissions = toVendorPermissions(vendorsForPurpose) .filter(vendorPermission -> vendorPermission.getVendorId() != null) diff --git a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java index 7aa8583b131..671bdb39170 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java @@ -9,8 +9,6 @@ import io.vertx.core.file.FileProps; import io.vertx.core.file.FileSystem; import io.vertx.core.file.FileSystemException; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.AllArgsConstructor; import lombok.Value; import org.apache.commons.collections4.MapUtils; @@ -19,6 +17,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.vendorlist.proto.Vendor; import org.prebid.server.privacy.gdpr.vendorlist.proto.VendorList; @@ -153,7 +153,7 @@ public Future> forVersion(int version) { metrics.updatePrivacyTcfVendorListMissingMetric(tcf); if (fetchThrottler.registerFetchAttempt(version)) { - logger.info("TCF {0} vendor list for version {1}.{2} not found, started downloading.", + logger.info("TCF {} vendor list for version {}.{} not found, started downloading.", tcf, generationVersion, version); fetchNewVendorListFor(version); } @@ -346,7 +346,7 @@ private Void updateCache(VendorListResult vendorListResult) { metrics.updatePrivacyTcfVendorListOkMetric(tcf); - logger.info("Created new TCF {0} vendor list for version {1}.{2}", tcf, generationVersion, version); + logger.info("Created new TCF {} vendor list for version {}.{}", tcf, generationVersion, version); stopUsingFallbackForVersion(version); diff --git a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java index 3b71936c7cd..7fb363a0ff0 100644 --- a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java @@ -1,11 +1,11 @@ package org.prebid.server.settings; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.Timeout; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.helper.StoredDataFetcher; @@ -243,7 +243,7 @@ private static Map getFromCacheOrAddMissedIds(String accountId, public void invalidateAccountCache(String accountId) { accountCache.remove(accountId); - logger.debug("Account with id {0} was invalidated", accountId); + logger.debug("Account with id {} was invalidated", accountId); } public void invalidateAllAccountCache() { diff --git a/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java b/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java index 72daa7e938d..1c78e4693c5 100644 --- a/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java @@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -14,6 +12,8 @@ import org.prebid.server.execution.Timeout; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.Category; import org.prebid.server.settings.model.StoredDataResult; diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java b/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java index 3cb710193e2..6ea14d294d0 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java @@ -1,11 +1,11 @@ package org.prebid.server.settings.helper; import io.vertx.core.json.JsonArray; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.sql.ResultSet; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.exception.PreBidException; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredDataType; import org.prebid.server.settings.model.StoredItem; @@ -85,7 +85,7 @@ public static StoredDataResult map(ResultSet resultSet, String accountId, Set initializePromise) { getAll(); if (refreshPeriod > 0) { vertx.setPeriodic(refreshPeriod, aLong -> refresh()); } + + initializePromise.tryComplete(); } private void getAll() { diff --git a/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java b/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java index c479c2a0168..13e76bc9c89 100644 --- a/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java +++ b/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java @@ -1,12 +1,13 @@ package org.prebid.server.settings.service; import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.StringUtils; import org.prebid.server.execution.Timeout; import org.prebid.server.execution.TimeoutFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.CacheNotificationListener; @@ -103,11 +104,12 @@ public JdbcPeriodicRefreshService(String initQuery, } @Override - public void initialize() { + public void initialize(Promise initializePromise) { getAll(); if (refreshPeriod > 0) { vertx.setPeriodic(refreshPeriod, aLong -> refresh()); } + initializePromise.tryComplete(); } private void getAll() { diff --git a/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java b/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java index 21ee67ac125..d22378eea64 100644 --- a/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java @@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.List; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/GeoLocationConfiguration.java b/src/main/java/org/prebid/server/spring/config/GeoLocationConfiguration.java index 05f510983b8..bf9f387aa73 100644 --- a/src/main/java/org/prebid/server/spring/config/GeoLocationConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/GeoLocationConfiguration.java @@ -82,12 +82,14 @@ CircuitBreakerSecuredGeoLocationService circuitBreakerSecuredGeoLocationService( } private GeoLocationService createGeoLocationService(RemoteFileSyncerProperties properties, Vertx vertx) { + final MaxMindGeoLocationService maxMindGeoLocationService = new MaxMindGeoLocationService(); final HttpClientProperties httpClientProperties = properties.getHttpClient(); final HttpClientOptions httpClientOptions = new HttpClientOptions() .setConnectTimeout(httpClientProperties.getConnectTimeoutMs()) .setMaxRedirects(httpClientProperties.getMaxRedirects()); final RemoteFileSyncer remoteFileSyncer = new RemoteFileSyncer( + maxMindGeoLocationService, properties.getDownloadUrl(), properties.getSaveFilepath(), properties.getTmpFilepath(), @@ -96,9 +98,8 @@ private GeoLocationService createGeoLocationService(RemoteFileSyncerProperties p properties.getUpdateIntervalMs(), vertx.createHttpClient(httpClientOptions), vertx); - final MaxMindGeoLocationService maxMindGeoLocationService = new MaxMindGeoLocationService(); - remoteFileSyncer.sync(maxMindGeoLocationService); + remoteFileSyncer.sync(); return maxMindGeoLocationService; } } diff --git a/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java b/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java index d52de58ac63..7bce3c5358e 100644 --- a/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java @@ -1,13 +1,14 @@ package org.prebid.server.spring.config; +import com.codahale.metrics.ScheduledReporter; import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.ContextRunner; import org.prebid.server.vertx.Initializable; import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.verticles.VerticleDefinition; +import org.prebid.server.vertx.verticles.server.DaemonVerticle; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.context.event.EventListener; import java.util.List; @@ -27,17 +28,10 @@ @Configuration public class InitializationConfiguration { - @Autowired - private ContextRunner contextRunner; + @Bean + VerticleDefinition daemonVerticleDefinition(@Autowired(required = false) List initializables, + @Autowired(required = false) List reporters) { - @Autowired - private List initializables; - - @EventListener(ContextRefreshedEvent.class) - public void initializeServices() { - contextRunner.runBlocking(promise -> { - initializables.forEach(Initializable::initialize); - promise.complete(); - }); + return VerticleDefinition.ofSingleInstance(() -> new DaemonVerticle(initializables, reporters)); } } diff --git a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java index db8251b9b42..2fa66398e28 100644 --- a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java @@ -52,9 +52,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import java.time.Clock; import java.util.Arrays; import java.util.HashSet; diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index de4e7fddff6..edf2f45b665 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -5,8 +5,6 @@ import io.vertx.core.Vertx; import io.vertx.core.file.FileSystem; import io.vertx.core.http.HttpClientOptions; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.core.net.JksOptions; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -95,7 +93,9 @@ import org.prebid.server.log.CriteriaLogManager; import org.prebid.server.log.CriteriaManager; import org.prebid.server.log.HttpInteractionLogger; +import org.prebid.server.log.Logger; import org.prebid.server.log.LoggerControlKnob; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.optout.GoogleRecaptchaVerifier; import org.prebid.server.privacy.HostVendorTcfDefinerService; @@ -127,7 +127,7 @@ import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; -import javax.validation.constraints.Min; +import jakarta.validation.constraints.Min; import java.io.IOException; import java.time.Clock; import java.util.ArrayList; diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 374edb1d2be..5a6dcac39a5 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -37,8 +37,8 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import java.time.Clock; import java.util.List; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/spring/config/VerticleStarter.java b/src/main/java/org/prebid/server/spring/config/VerticleStarter.java index 49bdae234ae..cb519b88477 100644 --- a/src/main/java/org/prebid/server/spring/config/VerticleStarter.java +++ b/src/main/java/org/prebid/server/spring/config/VerticleStarter.java @@ -6,6 +6,8 @@ import org.prebid.server.vertx.verticles.VerticleDefinition; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.context.event.EventListener; import java.util.List; @@ -13,7 +15,16 @@ public class VerticleStarter { @Autowired - public void start(Vertx vertx, ContextRunner contextRunner, List definitions) { + private Vertx vertx; + + @Autowired + private ContextRunner contextRunner; + + @Autowired + private List definitions; + + @EventListener(ContextRefreshedEvent.class) + public void start() { for (VerticleDefinition definition : definitions) { if (definition.getAmount() <= 0) { continue; diff --git a/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java b/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java index 5dc0f08fc19..9b5250a4233 100644 --- a/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java @@ -3,12 +3,12 @@ import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.core.file.FileSystem; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.dropwizard.DropwizardMetricsOptions; import io.vertx.ext.dropwizard.Match; import io.vertx.ext.dropwizard.MatchType; import io.vertx.ext.web.handler.BodyHandler; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.spring.config.metrics.MetricsConfiguration; import org.prebid.server.vertx.ContextRunner; import org.springframework.beans.factory.annotation.Value; @@ -38,7 +38,7 @@ Vertx vertx(@Value("${vertx.worker-pool-size}") int workerPoolSize, .setMetricsOptions(metricsOptions); final Vertx vertx = Vertx.vertx(vertxOptions); - logger.info("Native transport enabled: {0}", vertx.isNativeTransportEnabled()); + logger.info("Native transport enabled: {}", vertx.isNativeTransportEnabled()); return vertx; } diff --git a/src/main/java/org/prebid/server/spring/config/VertxContextScope.java b/src/main/java/org/prebid/server/spring/config/VertxContextScope.java index b1d79b1a0aa..8dbc6869695 100644 --- a/src/main/java/org/prebid/server/spring/config/VertxContextScope.java +++ b/src/main/java/org/prebid/server/spring/config/VertxContextScope.java @@ -1,8 +1,8 @@ package org.prebid.server.spring.config; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.springframework.beans.factory.ObjectFactory; import org.springframework.context.support.SimpleThreadScope; diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java index 3e6e38cee29..83cc2694122 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/aax.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AceexConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AceexConfiguration.java index d93b5428a19..f8a168d86b8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AceexConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AceexConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/aceex.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AcuityadsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AcuityadsConfiguration.java index 14aeb9c023d..77bec41b1c2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AcuityadsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AcuityadsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/acuityads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdQueryConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdQueryConfiguration.java index 8c68cc8422c..0f5dda54587 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdQueryConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdQueryConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adquery.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdelementConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdelementConfiguration.java index d3d1a0e0e7a..c38ca1c1fbe 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdelementConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdelementConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adelement.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdfConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdfConfiguration.java index 43d1f0fd4f6..64091a95ef0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdfConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdfConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adf.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdgenerationConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdgenerationConfiguration.java index 3d551f7fe34..b377b46d1f2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdgenerationConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdgenerationConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adgeneration.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdheseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdheseConfiguration.java index 33cb3fbf6a7..d0ac8674d9a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdheseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdheseConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adhese.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdkernelAdnConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdkernelAdnConfiguration.java index 23974f5a2ff..ca4ff6cbd07 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdkernelAdnConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdkernelAdnConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adkerneladn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdkernelConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdkernelConfiguration.java index 3defba5f55c..cc360ff91f8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdkernelConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdkernelConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adkernel.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdmanConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdmanConfiguration.java index 0be512c5930..c4b5f011268 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdmanConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdmanConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adman.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdmixerConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdmixerConfiguration.java index f981511bd4b..2a7a4cc8596 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdmixerConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdmixerConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/admixer.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdnuntiusBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdnuntiusBidderConfiguration.java index d31a23ade02..687c2897b8f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdnuntiusBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdnuntiusBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.time.Clock; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdoceanConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdoceanConfiguration.java index 2d41d75e914..d16984e3c5e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdoceanConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdoceanConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adocean.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdopplerConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdopplerConfiguration.java index aabbf780e6a..89163bceeab 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdopplerConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdopplerConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adoppler.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdotConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdotConfiguration.java index 8c7eb644316..9c0ac457d71 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdotConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdotConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adot.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdponeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdponeConfiguration.java index 2a41025ce3e..3792a998ea8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdponeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdponeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adpone.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdprimeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdprimeConfiguration.java index 4792b91ec5b..c9f6f950059 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdprimeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdprimeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adprime.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java index 601b108e571..415835e1b10 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adrino.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdtargetConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdtargetConfiguration.java index 04d87dbb076..2b3996f7fef 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdtargetConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdtargetConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adtarget.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdtelligentConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdtelligentConfiguration.java index b45262b6a70..de3713761b0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdtelligentConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdtelligentConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adtelligent.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdtrgtmeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdtrgtmeConfiguration.java index b544af026a6..7a578330380 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdtrgtmeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdtrgtmeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adtrgtme.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdvangelistsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdvangelistsConfiguration.java index a5b9b8b2278..7b58430ee4c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdvangelistsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdvangelistsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/advangelists.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdviewConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdviewConfiguration.java index 40b81bf434f..58b17ef619f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdviewConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdviewConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adview.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdxcgConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdxcgConfiguration.java index 197ca9b4d0a..6e6c4659e36 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdxcgConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdxcgConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adxcg.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdyoulikeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdyoulikeConfiguration.java index 37f41f487d3..d1350a9f53a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdyoulikeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdyoulikeConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adyoulike.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AidemConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AidemConfiguration.java index 3e61efb79eb..7689a338302 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AidemConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AidemConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/aidem.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AjaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AjaConfiguration.java index 76894a12476..216aa69047e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AjaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AjaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/aja.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AlgorixConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AlgorixConfiguration.java index 57f7395f478..1082e4c0b5a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AlgorixConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AlgorixConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/algorix.yaml", diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AlkimiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AlkimiConfiguration.java index 70bb071c850..44f8e0d50d8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AlkimiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AlkimiConfiguration.java @@ -7,15 +7,13 @@ import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/alkimi.yaml", factory = YamlPropertySourceFactory.class) @@ -23,17 +21,6 @@ public class AlkimiConfiguration { private static final String BIDDER_NAME = "alkimi"; - @Value("${external-url}") - @NotBlank - private String externalUrl; - - @Autowired - private JacksonMapper mapper; - - @Autowired - @Qualifier("alkimiConfigurationProperties") - private BidderConfigurationProperties configProperties; - @Bean("alkimiConfigurationProperties") @ConfigurationProperties("adapters.alkimi") BidderConfigurationProperties configurationProperties() { @@ -41,9 +28,12 @@ BidderConfigurationProperties configurationProperties() { } @Bean - BidderDeps alkimiBidderDeps() { + BidderDeps alkimiBidderDeps(BidderConfigurationProperties alkimiConfigurationProperties, + @NotBlank @Value("${external-url}") String externalUrl, + JacksonMapper mapper) { + return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(configProperties) + .withConfig(alkimiConfigurationProperties) .usersyncerCreator(UsersyncerCreator.create(externalUrl)) .bidderCreator(config -> new AlkimiBidder(config.getEndpoint(), mapper)) .assemble(); diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AmxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AmxConfiguration.java index efdc07c829d..d90cafd1fa8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AmxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AmxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/amx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ApacdexConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ApacdexConfiguration.java index c65595c6055..1d8c5882416 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ApacdexConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ApacdexConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/apacdex.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AppnexusConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AppnexusConfiguration.java index 17d293b98bf..87ca781f346 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AppnexusConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AppnexusConfiguration.java @@ -16,7 +16,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.util.Map; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AppushConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AppushConfiguration.java index 977fd84a330..af0c97490cd 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AppushConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AppushConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/appush.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AudienceNetworkConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AudienceNetworkConfiguration.java index 3e984b575e3..49b0d3ff049 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AudienceNetworkConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AudienceNetworkConfiguration.java @@ -18,7 +18,7 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.function.Function; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AutomatadBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AutomatadBidderConfiguration.java index 95d564260dc..18f2e1a62bc 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AutomatadBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AutomatadBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/automatad.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AvocetConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AvocetConfiguration.java index 722e2f13d0b..87bb0b24f1a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AvocetConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AvocetConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/avocet.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AxisConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AxisConfiguration.java index 292df8b9edb..93b896371af 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AxisConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AxisConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/axis.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AxonixConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AxonixConfiguration.java index 69643f1bb45..8423eb76cf2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AxonixConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AxonixConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/axonix.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BeachfrontConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BeachfrontConfiguration.java index 71b24f5861a..e34cf171976 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BeachfrontConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BeachfrontConfiguration.java @@ -18,7 +18,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/beachfront.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BeintooConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BeintooConfiguration.java index b9d44061493..b7113c8bbcc 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BeintooConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BeintooConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/beintoo.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BematterfullConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BematterfullConfiguration.java index 9de51f3d6cc..bef7077d93c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BematterfullConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BematterfullConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bematterfull.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BetweenConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BetweenConfiguration.java index ab7fdeab33b..448104e62ba 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BetweenConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BetweenConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/between.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BeyondMediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BeyondMediaConfiguration.java index cf2c0729d52..541a70fa294 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BeyondMediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BeyondMediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/beyondmedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BidmachineConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BidmachineConfiguration.java index 8eed33412ae..d5171cff6fb 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BidmachineConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BidmachineConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bidmachine.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BidmyadzConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BidmyadzConfiguration.java index bcdcbe438e9..ebd9305906f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BidmyadzConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BidmyadzConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bidmyadz.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BidscubeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BidscubeConfiguration.java index 235c24cc161..389200d09c0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BidscubeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BidscubeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bidscube.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BidstackConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BidstackConfiguration.java index af6f47d68b9..1103ac66853 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BidstackConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BidstackConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bidstack.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BizzclickConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BizzclickConfiguration.java index 90b8491f55e..c65702aa9fa 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BizzclickConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BizzclickConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bizzclick.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BliinkBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BliinkBidderConfiguration.java index fcbbf49122e..6ce0d022f04 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BliinkBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BliinkBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bliink.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BlueSeaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BlueSeaConfiguration.java index aa988d6c75f..823396b8b5d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BlueSeaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BlueSeaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bluesea.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BmtmConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BmtmConfiguration.java index 91fd517a133..c9c7bcbebfa 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BmtmConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BmtmConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bmtm.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BoldwinConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BoldwinConfiguration.java index bb648cf6b0b..f062311c4fa 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BoldwinConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BoldwinConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/boldwin.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BraveConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BraveConfiguration.java index 5dc013e8f7b..de364ab4bc0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BraveConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BraveConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/brave.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java index de7e92ad89c..91b0c7646ec 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/ccx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CoinzillaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CoinzillaConfiguration.java index cd402e4ec76..896bd31ff10 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CoinzillaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CoinzillaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/coinzilla.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ColossusConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ColossusConfiguration.java index 4187c7649b5..8d466e2e842 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ColossusConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ColossusConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/colossus.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CompassConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CompassConfiguration.java index 3f45046b918..e638d721fd0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CompassConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CompassConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/compass.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ConnectAdConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ConnectAdConfiguration.java index ebf4225dedb..34e38d7cec3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ConnectAdConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ConnectAdConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/connectad.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ConsumableConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ConsumableConfiguration.java index 5de2e87645c..70a31dfdddf 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ConsumableConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ConsumableConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/consumable.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CpmStarConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CpmStarConfiguration.java index 33bd952d33f..b247970937b 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CpmStarConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CpmStarConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/cpmstar.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CriteoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CriteoConfiguration.java index 698f5c3b83a..5693167b62e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CriteoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CriteoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/criteo.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DatablocksConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DatablocksConfiguration.java index 49b28ee132a..9d5d4fd9b08 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DatablocksConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DatablocksConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/datablocks.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DecenteradsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DecenteradsConfiguration.java index 2e7da078a2c..c1eb0e2b1e3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DecenteradsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DecenteradsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/decenterads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DeepintentConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DeepintentConfiguration.java index 146989a2ef7..ac14dd71c2e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DeepintentConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DeepintentConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/deepintent.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DianomiBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DianomiBidderConfiguration.java index 7fe68311380..e9938a9d632 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DianomiBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DianomiBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/dianomi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DmxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DmxConfiguration.java index 506a4105a11..a80323c031c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DmxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DmxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/dmx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DxKultureBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DxKultureBidderConfiguration.java index e4ef4b92a64..658a2c8743c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DxKultureBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DxKultureBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/dxkulture.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/Edge226Configuration.java b/src/main/java/org/prebid/server/spring/config/bidder/Edge226Configuration.java index 754a07a970c..03ecfc2add9 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/Edge226Configuration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/Edge226Configuration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/edge226.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EmtvConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EmtvConfiguration.java index 6bd8f2125d1..3c5a934a8bc 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EmtvConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EmtvConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/emtv.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EmxDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EmxDigitalConfiguration.java index 0ecde28142a..64855592dbe 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EmxDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EmxDigitalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/emxdigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EplanningConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EplanningConfiguration.java index 491813e0596..f67ab6d9ff5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EplanningConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EplanningConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/eplanning.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EpomConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EpomConfiguration.java index f3c011f4146..88776cd74ad 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EpomConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EpomConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/epom.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EpsilonConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EpsilonConfiguration.java index 3025a45289c..71e90054c01 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EpsilonConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EpsilonConfiguration.java @@ -17,8 +17,8 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Configuration @PropertySource(value = "classpath:/bidder-config/epsilon.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EvolutionConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EvolutionConfiguration.java index ef32fda4196..9757923928e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EvolutionConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EvolutionConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/evolution.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/FlippConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/FlippConfiguration.java index 1f3ab8db2d3..e2e36373073 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/FlippConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/FlippConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/flipp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/FreewheelSSPConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/FreewheelSSPConfiguration.java index d58278d9e64..0ac29fb2ad0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/FreewheelSSPConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/FreewheelSSPConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/freewheelssp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/FrvrAdnBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/FrvrAdnBidderConfiguration.java index 5c772da6eca..f4c903a4968 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/FrvrAdnBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/FrvrAdnBidderConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/frvradn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GammaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GammaConfiguration.java index 5f4e871d55f..141c4ddd313 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GammaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GammaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/gamma.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GamoshiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GamoshiConfiguration.java index 13bf512b415..15d37d3b5b8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GamoshiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GamoshiConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/gamoshi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GenericBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GenericBidderConfiguration.java index 0b5b46f2b81..23f1e2f2928 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GenericBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GenericBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/generic.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GlobalsunConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GlobalsunConfiguration.java index dfd0a7ffc18..2eca33cefcd 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GlobalsunConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GlobalsunConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/globalsun.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GothamAdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GothamAdsConfiguration.java index 029f9423886..97691f8f563 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GothamAdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GothamAdsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/gothamads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GridConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GridConfiguration.java index a39811d4e5e..f7ddefef701 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GridConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GridConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/grid.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GumgumConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GumgumConfiguration.java index 72b2f86ec71..7970022d1e3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GumgumConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GumgumConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/gumgum.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/HuaweiAdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/HuaweiAdsConfiguration.java index 9030d5934c7..ba69ed885b1 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/HuaweiAdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/HuaweiAdsConfiguration.java @@ -27,9 +27,9 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.time.Clock; import java.util.List; diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ImdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ImdsConfiguration.java index 3128eab5de9..020dd0e6936 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ImdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ImdsConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/imds.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ImpactifyConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ImpactifyConfiguration.java index 6daed5621b3..af1fe09228f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ImpactifyConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ImpactifyConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/impactify.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ImprovedigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ImprovedigitalConfiguration.java index 54631f271e0..4003ed66438 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ImprovedigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ImprovedigitalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/improvedigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java index 979ba6f7fcb..7b28f464742 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/infytv.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InmobiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InmobiConfiguration.java index 981654fc9a2..1b2f21ec06e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/InmobiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/InmobiConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/inmobi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InteractiveOffersConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InteractiveOffersConfiguration.java index fb2cf581f15..4dbc0a2ab0b 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/InteractiveOffersConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/InteractiveOffersConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/interactiveoffers.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/IntertechConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/IntertechConfiguration.java index 066560a4e17..a6a5ea7c736 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/IntertechConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/IntertechConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/intertech.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InvibesConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InvibesConfiguration.java index 2d864f17c14..2111af79fb2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/InvibesConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/InvibesConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/invibes.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/IqxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/IqxConfiguration.java index ff59d0298f0..189ad72adda 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/IqxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/IqxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/iqx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/IqzoneConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/IqzoneConfiguration.java index 87e7b5aabd1..4b9ddff193c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/IqzoneConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/IqzoneConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/iqzone.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/IxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/IxConfiguration.java index 9d6218b3293..49a1bdbea69 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/IxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/IxConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/ix.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/JixieConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/JixieConfiguration.java index 313fdeee64d..a3110e233ff 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/JixieConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/JixieConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/jixie.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KargoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KargoConfiguration.java index e434ebeb907..d01076cae25 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KargoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KargoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/kargo.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KayzenConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KayzenConfiguration.java index 555b75fa6e1..94e953d2506 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KayzenConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KayzenConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/kayzen.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KidozConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KidozConfiguration.java index 49e026b92c0..c7c5b689c0c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KidozConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KidozConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/kidoz.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KiviAdsBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KiviAdsBidderConfiguration.java index a2472886876..816ff86dac5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KiviAdsBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KiviAdsBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/kiviads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KrushmediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KrushmediaConfiguration.java index 581f3c3da33..4b271d5cfac 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KrushmediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KrushmediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/krushmedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LemmaDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LemmaDigitalConfiguration.java index c36ad73abc4..3cdc83faed4 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LemmaDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LemmaDigitalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/lemmadigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LiftoffConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LiftoffConfiguration.java index 70bab296c4e..0111858f8e5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LiftoffConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LiftoffConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/liftoff.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LimeLightDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LimeLightDigitalConfiguration.java index cedf0ec590a..a94fc4020a2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LimeLightDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LimeLightDigitalConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/limelightDigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LmKiviAdsBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LmKiviAdsBidderConfiguration.java index 568b922a644..cca3ccf4dfe 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LmKiviAdsBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LmKiviAdsBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/lmkiviads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LockerdomeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LockerdomeConfiguration.java index a4a9ccd5cae..b18f98fd753 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LockerdomeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LockerdomeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/lockerdome.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LoganConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LoganConfiguration.java index 7b218776294..424c64cd7a0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LoganConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LoganConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/logan.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LogicadConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LogicadConfiguration.java index 02a59440a50..5063fd1c040 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LogicadConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LogicadConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/logicad.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java index 9de12f3a137..a100493fbee 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/loopme.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LunamediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LunamediaConfiguration.java index cad75586f80..96076560f70 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LunamediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LunamediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/lunamedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MadvertiseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MadvertiseConfiguration.java index 2d1ff24a6ef..938bc20e96c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MadvertiseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MadvertiseConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/madvertise.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MarsmediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MarsmediaConfiguration.java index 53e9c19d7c9..99012d82a84 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MarsmediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MarsmediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/marsmedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MedianetConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MedianetConfiguration.java index 6f5a10c5e32..359f630febf 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MedianetConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MedianetConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/medianet.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MgidConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MgidConfiguration.java index 192ff7a9083..893e30c424f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MgidConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MgidConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/mgid.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MgidxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MgidxConfiguration.java index 521e0692120..f891d3f44d7 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MgidxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MgidxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/mgidx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MinuteMediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MinuteMediaConfiguration.java index 6584d277a2c..3b01a2f482a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MinuteMediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MinuteMediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/minutemedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MobfoxpbConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MobfoxpbConfiguration.java index fdebfa6fa42..bb8c80c037d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MobfoxpbConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MobfoxpbConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/mobfoxpb.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MobilefuseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MobilefuseConfiguration.java index 4c78c3310f8..6496f517007 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MobilefuseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MobilefuseConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/mobilefuse.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MotorikConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MotorikConfiguration.java index 690c6468e45..e68ba630872 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MotorikConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MotorikConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/motorik.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/NextMillenniumConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/NextMillenniumConfiguration.java index 320f0a249ec..16fbbb37aca 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/NextMillenniumConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/NextMillenniumConfiguration.java @@ -16,7 +16,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.util.List; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/NobidConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/NobidConfiguration.java index 840d5c647d3..52079d032ef 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/NobidConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/NobidConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/nobid.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OmsBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OmsBidderConfiguration.java index e9ac40cc76a..47cdeb08045 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OmsBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OmsBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/oms.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OnetagConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OnetagConfiguration.java index 8c5a86e9ec9..ce37fc92ce2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OnetagConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OnetagConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/onetag.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OpenWebConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OpenWebConfiguration.java index 2c3ed5daac1..370839be501 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OpenWebConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OpenWebConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/openweb.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OpenxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OpenxConfiguration.java index a936202776e..5e3886d5814 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OpenxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OpenxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/openx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OperaadsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OperaadsConfiguration.java index 9eae2d808af..8b5055b4c29 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OperaadsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OperaadsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/operaads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OrbidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OrbidderConfiguration.java index e41814195fd..0e9bbcb29a6 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OrbidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OrbidderConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/orbidder.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OutbrainConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OutbrainConfiguration.java index 1e5353a989a..194dd8ca14a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OutbrainConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OutbrainConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/outbrain.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PangleConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PangleConfiguration.java index e3ba1595664..2cd2c3b361c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PangleConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PangleConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pangle.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PgamSspConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PgamSspConfiguration.java index 80304cbc659..1e449c950d6 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PgamSspConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PgamSspConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pgamssp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PrecisoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PrecisoConfiguration.java index a83140b7868..dfa65428aac 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PrecisoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PrecisoConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/preciso.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PubmaticConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PubmaticConfiguration.java index 607b10b532a..2fa5477630f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PubmaticConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PubmaticConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pubmatic.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PubnativeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PubnativeConfiguration.java index 32409c06aaa..5e1ec608cc5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PubnativeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PubnativeConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pubnative.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PulsepointConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PulsepointConfiguration.java index bbf00524f65..91ca1b19220 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PulsepointConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PulsepointConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pulsepoint.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PwbidConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PwbidConfiguration.java index 24888ef7d7f..d076873bdf0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PwbidConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PwbidConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pwbid.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RelevantDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RelevantDigitalConfiguration.java index 15f39a644c1..b25ca14eb32 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RelevantDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RelevantDigitalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/relevantdigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ResetDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ResetDigitalConfiguration.java index 7111d8ad9ff..4e4de161f66 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ResetDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ResetDigitalConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/resetdigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RevcontentConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RevcontentConfiguration.java index 6435aa150c3..c21bf079b70 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RevcontentConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RevcontentConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/revcontent.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RichaudienceConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RichaudienceConfiguration.java index c343830ace4..fe8c2a00523 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RichaudienceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RichaudienceConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/richaudience.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RiseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RiseConfiguration.java index 87a2af115f0..c54c39cd6c8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RiseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RiseConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/rise.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RtbhouseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RtbhouseConfiguration.java index 3834fa0b878..2b99afafad9 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RtbhouseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RtbhouseConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/rtbhouse.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RubiconConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RubiconConfiguration.java index feb9f1c87c3..75a8a316d7a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RubiconConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RubiconConfiguration.java @@ -19,9 +19,9 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Configuration @PropertySource(value = "classpath:/bidder-config/rubicon.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SaLunamediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SaLunamediaConfiguration.java index f7d7248cbef..ab466600f26 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SaLunamediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SaLunamediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/salunamedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ScreencoreConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ScreencoreConfiguration.java index 74e1f39ff52..3cf155022e9 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ScreencoreConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ScreencoreConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/screencore.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SeedingAllianceBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SeedingAllianceBidderConfiguration.java index 5ba2c7ae1ae..426950a684a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SeedingAllianceBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SeedingAllianceBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/seedingAlliance.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SharethroughConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SharethroughConfiguration.java index dd0a0abcbf1..3e75a34f8cc 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SharethroughConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SharethroughConfiguration.java @@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sharethrough.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SilverPushConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SilverPushConfiguration.java index b26e78fcd64..b3dcb5baf90 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SilverPushConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SilverPushConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/silverpush.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SilvermobConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SilvermobConfiguration.java index 98acc635472..e26433fb580 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SilvermobConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SilvermobConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/silvermob.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SimpleWantedConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SimpleWantedConfiguration.java index 28c50df1619..0b72987e6f9 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SimpleWantedConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SimpleWantedConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smilewanted.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmaatoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmaatoConfiguration.java index 06ff89f6ee7..0851bd87d7d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmaatoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmaatoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.time.Clock; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmartadserverConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmartadserverConfiguration.java index 7cf0551db62..5264a6a3e77 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmartadserverConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmartadserverConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smartadserver.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmarthubConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmarthubConfiguration.java index a19e364b949..218f7f8ae96 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmarthubConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmarthubConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smarthub.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmartrtbConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmartrtbConfiguration.java index 33728c7499e..f0a5f22622c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmartrtbConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmartrtbConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smartrtb.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmartxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmartxConfiguration.java index ebf11d6a804..5b6c08b6dd3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmartxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmartxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smartx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmartyAdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmartyAdsConfiguration.java index 730d822633b..a5de7f27094 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmartyAdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmartyAdsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smartyads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SonobiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SonobiConfiguration.java index 039a57f74b5..eaab8a70ef5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SonobiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SonobiConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sonobi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SovrnConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SovrnConfiguration.java index 281987c0bc6..4de292e9184 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SovrnConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SovrnConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sovrn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SovrnXspConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SovrnXspConfiguration.java index 3dcd9a2a53e..a494790bb71 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SovrnXspConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SovrnXspConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sovrnXsp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SspbcBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SspbcBidderConfiguration.java index 8d2e8a01459..95ff7edcf08 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SspbcBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SspbcBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sspbc.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/StroeerCoreConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/StroeerCoreConfiguration.java index 242a52f941c..f33c72e5027 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/StroeerCoreConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/StroeerCoreConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/stroeercore.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TaboolaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TaboolaConfiguration.java index 99d30628a61..ef917b09bc5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TaboolaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TaboolaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/taboola.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TappxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TappxConfiguration.java index 846ad2f1057..352ec244ecd 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TappxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TappxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.time.Clock; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TeadsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TeadsConfiguration.java index 699cd016b9a..a1cb6c26c99 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TeadsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TeadsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/teads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TelariaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TelariaConfiguration.java index 2f12146901c..9be27f6bc33 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TelariaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TelariaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/telaria.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ThirtyThreeAcrossConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ThirtyThreeAcrossConfiguration.java index c114867c505..1a04588e973 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ThirtyThreeAcrossConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ThirtyThreeAcrossConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/thirtythreeacross.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TpmnAdnBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TpmnAdnBidderConfiguration.java index 224f0fab7bd..0a40807f424 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TpmnAdnBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TpmnAdnBidderConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/tpmn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TrafficGateConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TrafficGateConfiguration.java index 56a25a94d7e..33e0ecaa1e8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TrafficGateConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TrafficGateConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/trafficgate.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TripleliftConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TripleliftConfiguration.java index b730143bc95..301b26478c1 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TripleliftConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TripleliftConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/triplelift.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TripleliftNativeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TripleliftNativeConfiguration.java index c1a7ee5b1ca..11ef984aa78 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TripleliftNativeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TripleliftNativeConfiguration.java @@ -18,8 +18,8 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.List; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/UcfunnelConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/UcfunnelConfiguration.java index 3fc172aeab4..6e2e4067b7d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/UcfunnelConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/UcfunnelConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/ucfunnel.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/UndertoneConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/UndertoneConfiguration.java index 60a1dc415c5..a51380096ea 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/UndertoneConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/UndertoneConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/undertone.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/UnicornConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/UnicornConfiguration.java index 21d9e820f3d..7905fc384f0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/UnicornConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/UnicornConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/unicorn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/UnrulyConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/UnrulyConfiguration.java index e57d436165c..44ed956b391 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/UnrulyConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/UnrulyConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/unruly.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VideoHeroesConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VideoHeroesConfiguration.java index e7ef3ddfc65..f501af44cf4 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VideoHeroesConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VideoHeroesConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/videoheroes.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VideobyteConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VideobyteConfiguration.java index 59bf7326947..a25f213c6a1 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VideobyteConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VideobyteConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/videobyte.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VidoomyConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VidoomyConfiguration.java index aeaf95f1ccc..45806a99bf0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VidoomyConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VidoomyConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/vidoomy.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VisibleMeasuresConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VisibleMeasuresConfiguration.java index 21a4ecd20a5..9dfc739b5ff 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VisibleMeasuresConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VisibleMeasuresConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/visiblemeasures.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VisxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VisxConfiguration.java index 57fbb9c8987..a3585633163 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VisxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VisxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/visx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VoxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VoxConfiguration.java index 2524a5b2fce..0d0974c87d0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VoxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VoxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/vox.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VrtcalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VrtcalConfiguration.java index 1343e007a68..73e0b9bacc5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VrtcalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VrtcalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/vrtcal.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/XeworksBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/XeworksBidderConfiguration.java index ddedb314725..be4681a98e7 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/XeworksBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/XeworksBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/xeworks.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YahooAdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YahooAdsConfiguration.java index 14b0397a148..9cd3ed1249b 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YahooAdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YahooAdsConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yahooAds.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YandexConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YandexConfiguration.java index 629f8f63b11..5f1afa3398f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YandexConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YandexConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yandex.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YeahmobiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YeahmobiConfiguration.java index 8dc6c20d857..1bc55fd4ef8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YeahmobiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YeahmobiConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yeahmobi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YearxeroConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YearxeroConfiguration.java index 2a278e1d88a..1ce349de7dd 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YearxeroConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YearxeroConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yearxero.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YieldlabConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YieldlabConfiguration.java index 0d2dc0a31ad..5bf1f496477 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YieldlabConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YieldlabConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.time.Clock; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YieldmoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YieldmoConfiguration.java index 3562e02acfe..255e9676924 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YieldmoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YieldmoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yieldmo.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YieldoneConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YieldoneConfiguration.java index aa1c028b653..8e32a38e2d3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YieldoneConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YieldoneConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yieldone.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ZeroclickfraudConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ZeroclickfraudConfiguration.java index 87fb61aa20c..3430977f4db 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ZeroclickfraudConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ZeroclickfraudConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/zeroclickfraud.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java index b2bd0662251..a886d2bab8e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/zeta_global_ssp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/BidderConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/bidder/model/BidderConfigurationProperties.java index 63499df3804..0f5fde1d480 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/BidderConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/BidderConfigurationProperties.java @@ -10,9 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import javax.annotation.PostConstruct; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.annotation.PostConstruct; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/Debug.java b/src/main/java/org/prebid/server/spring/config/bidder/model/Debug.java index 2a88fc91e66..c1e44593d0d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/Debug.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/Debug.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/DefaultBidderConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/bidder/model/DefaultBidderConfigurationProperties.java index 99b0ca38829..7996a2e220c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/DefaultBidderConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/DefaultBidderConfigurationProperties.java @@ -4,7 +4,7 @@ import org.prebid.server.auction.versionconverter.OrtbVersion; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/MetaInfo.java b/src/main/java/org/prebid/server/spring/config/bidder/model/MetaInfo.java index 0e46906f528..c25236dd799 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/MetaInfo.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/MetaInfo.java @@ -4,8 +4,8 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.List; @Validated diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/Ortb.java b/src/main/java/org/prebid/server/spring/config/bidder/model/Ortb.java index e3153ff8654..9d22bbd1de1 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/Ortb.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/Ortb.java @@ -6,7 +6,7 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java index 6acd9c68ce0..e67debfad6c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncMethodConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncMethodConfigurationProperties.java index bba6fbc6826..fc9b685b339 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncMethodConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncMethodConfigurationProperties.java @@ -5,8 +5,8 @@ import org.prebid.server.bidder.UsersyncFormat; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java index e5b6198fb66..174bf82f35c 100644 --- a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java @@ -5,9 +5,9 @@ import org.prebid.server.spring.config.database.model.DatabasePoolType; import org.prebid.server.spring.config.database.model.DatabaseType; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Data @NoArgsConstructor diff --git a/src/main/java/org/prebid/server/spring/config/metrics/MetricsConfiguration.java b/src/main/java/org/prebid/server/spring/config/metrics/MetricsConfiguration.java index 999b80ef47a..db0d072ebaa 100644 --- a/src/main/java/org/prebid/server/spring/config/metrics/MetricsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/metrics/MetricsConfiguration.java @@ -11,7 +11,6 @@ import com.izettle.metrics.influxdb.InfluxDbHttpSender; import com.izettle.metrics.influxdb.InfluxDbReporter; import com.izettle.metrics.influxdb.InfluxDbSender; -import io.vertx.core.Vertx; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.ObjectUtils; @@ -20,8 +19,6 @@ import org.prebid.server.metric.Metrics; import org.prebid.server.metric.model.AccountMetricsVerbosityLevel; import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.prebid.server.vertx.CloseableAdapter; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -31,10 +28,9 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.annotation.PostConstruct; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -47,12 +43,6 @@ public class MetricsConfiguration { public static final String METRIC_REGISTRY_NAME = "metric-registry"; - @Autowired(required = false) - private List reporters = Collections.emptyList(); - - @Autowired - private Vertx vertx; - @Bean @ConditionalOnProperty(prefix = "metrics.graphite", name = "enabled", havingValue = "true") ScheduledReporter graphiteReporter(GraphiteProperties graphiteProperties, MetricRegistry metricRegistry) { @@ -128,13 +118,6 @@ AccountMetricsVerbosityResolver accountMetricsVerbosity(AccountsProperties accou accountsProperties.getDetailedVerbosity()); } - @PostConstruct - void registerReporterCloseHooks() { - reporters.stream() - .map(CloseableAdapter::new) - .forEach(closeable -> vertx.getOrCreateContext().addCloseHook(closeable)); - } - @Component @ConfigurationProperties(prefix = "metrics.graphite") @ConditionalOnProperty(prefix = "metrics.graphite", name = "enabled", havingValue = "true") diff --git a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java index 72a15515864..174db85731f 100644 --- a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java @@ -7,12 +7,12 @@ import io.prometheus.client.dropwizard.samplebuilder.SampleBuilder; import io.prometheus.client.vertx.MetricsHandler; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.core.net.SocketAddress; import io.vertx.ext.web.Router; import lombok.Data; import lombok.NoArgsConstructor; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.CounterType; import org.prebid.server.metric.Metrics; import org.prebid.server.metric.prometheus.NamespaceSubsystemSampleBuilder; @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.List; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusMapperConfiguration.java b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusMapperConfiguration.java index e9ea4ac3b29..ea7bb3989f7 100644 --- a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusMapperConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusMapperConfiguration.java @@ -11,7 +11,7 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/prebid/server/spring/config/model/CircuitBreakerProperties.java b/src/main/java/org/prebid/server/spring/config/model/CircuitBreakerProperties.java index cbc3e22f81e..969b5f35784 100644 --- a/src/main/java/org/prebid/server/spring/config/model/CircuitBreakerProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/CircuitBreakerProperties.java @@ -4,8 +4,8 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java b/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java index 914e1bcfc18..6e0373fba11 100644 --- a/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java @@ -8,9 +8,9 @@ import org.prebid.server.vertx.httpclient.HttpClient; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.time.Clock; @Validated diff --git a/src/main/java/org/prebid/server/spring/config/model/HttpClientCircuitBreakerProperties.java b/src/main/java/org/prebid/server/spring/config/model/HttpClientCircuitBreakerProperties.java index 26830122dda..9693e78bb93 100644 --- a/src/main/java/org/prebid/server/spring/config/model/HttpClientCircuitBreakerProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/HttpClientCircuitBreakerProperties.java @@ -5,8 +5,8 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/model/HttpClientProperties.java b/src/main/java/org/prebid/server/spring/config/model/HttpClientProperties.java index a2981e02849..06ec12bac87 100644 --- a/src/main/java/org/prebid/server/spring/config/model/HttpClientProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/HttpClientProperties.java @@ -4,8 +4,8 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/model/RemoteFileSyncerProperties.java b/src/main/java/org/prebid/server/spring/config/model/RemoteFileSyncerProperties.java index a354dd46b3e..5075b1dbdf7 100644 --- a/src/main/java/org/prebid/server/spring/config/model/RemoteFileSyncerProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/RemoteFileSyncerProperties.java @@ -4,9 +4,9 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/retry/ExponentialBackoffRetryPolicyConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/retry/ExponentialBackoffRetryPolicyConfigurationProperties.java index af6d94c490b..ca584979578 100644 --- a/src/main/java/org/prebid/server/spring/config/retry/ExponentialBackoffRetryPolicyConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/retry/ExponentialBackoffRetryPolicyConfigurationProperties.java @@ -4,8 +4,8 @@ import org.prebid.server.execution.retry.ExponentialBackoffRetryPolicy; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.Positive; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.Positive; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/retry/FixedIntervalRetryPolicyConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/retry/FixedIntervalRetryPolicyConfigurationProperties.java index 332d6c5787c..bc55c9f6c03 100644 --- a/src/main/java/org/prebid/server/spring/config/retry/FixedIntervalRetryPolicyConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/retry/FixedIntervalRetryPolicyConfigurationProperties.java @@ -4,7 +4,7 @@ import org.prebid.server.execution.retry.FixedIntervalRetryPolicy; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; +import jakarta.validation.constraints.Min; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java b/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java index 11d096d5666..41b695bb2c6 100644 --- a/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java +++ b/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java @@ -3,7 +3,7 @@ import io.vertx.core.Handler; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; -import io.vertx.ext.web.handler.AuthHandler; +import io.vertx.ext.web.handler.AuthenticationHandler; import io.vertx.ext.web.handler.BasicAuthHandler; import org.prebid.server.vertx.verticles.server.admin.AdminResource; @@ -30,7 +30,7 @@ public void bind(Router router) { } } - private AuthHandler securedAuthHandler() { + private AuthenticationHandler securedAuthHandler() { if (credentials == null) { throw new IllegalArgumentException("Credentials for admin endpoint is empty."); } diff --git a/src/main/java/org/prebid/server/spring/env/YamlPropertySourceFactory.java b/src/main/java/org/prebid/server/spring/env/YamlPropertySourceFactory.java index 6e599602b9e..fcff6e0a397 100644 --- a/src/main/java/org/prebid/server/spring/env/YamlPropertySourceFactory.java +++ b/src/main/java/org/prebid/server/spring/env/YamlPropertySourceFactory.java @@ -7,8 +7,8 @@ import org.springframework.core.io.support.EncodedResource; import org.springframework.core.io.support.PropertySourceFactory; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; diff --git a/src/main/java/org/prebid/server/util/HttpUtil.java b/src/main/java/org/prebid/server/util/HttpUtil.java index b848f1a4d41..005230166e7 100644 --- a/src/main/java/org/prebid/server/util/HttpUtil.java +++ b/src/main/java/org/prebid/server/util/HttpUtil.java @@ -6,11 +6,11 @@ import io.vertx.core.http.Cookie; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.Endpoint; import org.prebid.server.model.HttpRequestContext; @@ -185,7 +185,7 @@ public static boolean executeSafely(RoutingContext routingContext, responseConsumer.accept(response); return true; } catch (Exception e) { - logger.warn("Failed to send {0} response: {1}", endpoint, e.getMessage()); + logger.warn("Failed to send {} response: {}", endpoint, e.getMessage()); return false; } } diff --git a/src/main/java/org/prebid/server/util/VersionInfo.java b/src/main/java/org/prebid/server/util/VersionInfo.java index b163be55f3c..f7240ea38bb 100644 --- a/src/main/java/org/prebid/server/util/VersionInfo.java +++ b/src/main/java/org/prebid/server/util/VersionInfo.java @@ -1,11 +1,11 @@ package org.prebid.server.util; import com.fasterxml.jackson.annotation.JsonProperty; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.AllArgsConstructor; import lombok.Value; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.io.IOException; import java.util.regex.Matcher; @@ -31,7 +31,7 @@ public static VersionInfo create(String revisionFilePath, JacksonMapper jacksonM revision = jacksonMapper.mapper().readValue(ResourceUtil.readFromClasspath(revisionFilePath), Revision.class); } catch (IllegalArgumentException | IOException e) { - logger.error("Was not able to read revision file {0}. Reason: {1}", revisionFilePath, e.getMessage()); + logger.error("Was not able to read revision file {}. Reason: {}", revisionFilePath, e.getMessage()); return new VersionInfo(UNDEFINED, UNDEFINED); } final String pbsVersion = revision.getPbsVersion(); diff --git a/src/main/java/org/prebid/server/util/system/CpuLoadAverageStats.java b/src/main/java/org/prebid/server/util/system/CpuLoadAverageStats.java index 43ac4177b91..6be897cd1d4 100644 --- a/src/main/java/org/prebid/server/util/system/CpuLoadAverageStats.java +++ b/src/main/java/org/prebid/server/util/system/CpuLoadAverageStats.java @@ -1,5 +1,6 @@ package org.prebid.server.util.system; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.prebid.server.vertx.Initializable; import oshi.SystemInfo; @@ -30,9 +31,10 @@ public CpuLoadAverageStats(Vertx vertx, long measurementIntervalMillis) { } @Override - public void initialize() { + public void initialize(Promise initializePromise) { measureCpuLoad(); vertx.setPeriodic(measurementIntervalMillis, timerId -> measureCpuLoad()); + initializePromise.tryComplete(); } private void measureCpuLoad() { diff --git a/src/main/java/org/prebid/server/validation/RequestValidator.java b/src/main/java/org/prebid/server/validation/RequestValidator.java index 147ffd60208..4b0c1ddfe7f 100644 --- a/src/main/java/org/prebid/server/validation/RequestValidator.java +++ b/src/main/java/org/prebid/server/validation/RequestValidator.java @@ -33,7 +33,6 @@ import com.iab.openrtb.request.ntv.EventType; import com.iab.openrtb.request.ntv.PlacementType; import com.iab.openrtb.request.ntv.Protocol; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; @@ -42,6 +41,7 @@ import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.HttpRequestContext; diff --git a/src/main/java/org/prebid/server/validation/ResponseBidValidator.java b/src/main/java/org/prebid/server/validation/ResponseBidValidator.java index e3e405cb710..17132e1bc35 100644 --- a/src/main/java/org/prebid/server/validation/ResponseBidValidator.java +++ b/src/main/java/org/prebid/server/validation/ResponseBidValidator.java @@ -6,8 +6,6 @@ import com.iab.openrtb.request.Imp; import com.iab.openrtb.request.Site; import com.iab.openrtb.response.Bid; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -15,6 +13,8 @@ import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.response.BidType; diff --git a/src/main/java/org/prebid/server/vertx/CircuitBreaker.java b/src/main/java/org/prebid/server/vertx/CircuitBreaker.java index e62e3dddc98..104545470f5 100644 --- a/src/main/java/org/prebid/server/vertx/CircuitBreaker.java +++ b/src/main/java/org/prebid/server/vertx/CircuitBreaker.java @@ -6,8 +6,8 @@ import io.vertx.core.Handler; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.time.Clock; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/vertx/CloseableAdapter.java b/src/main/java/org/prebid/server/vertx/CloseableAdapter.java index 480e2e6b453..708796c63c7 100644 --- a/src/main/java/org/prebid/server/vertx/CloseableAdapter.java +++ b/src/main/java/org/prebid/server/vertx/CloseableAdapter.java @@ -1,8 +1,7 @@ package org.prebid.server.vertx; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; +import io.vertx.core.Promise; import java.io.Closeable; import java.io.IOException; @@ -14,19 +13,19 @@ */ public class CloseableAdapter implements io.vertx.core.Closeable { - private final Closeable adaptee; + private final Closeable closeable; - public CloseableAdapter(Closeable adaptee) { - this.adaptee = Objects.requireNonNull(adaptee); + public CloseableAdapter(Closeable closeable) { + this.closeable = Objects.requireNonNull(closeable); } @Override - public void close(Handler> completionHandler) { + public void close(Promise promise) { try { - adaptee.close(); - completionHandler.handle(Future.succeededFuture()); + closeable.close(); + promise.handle(Future.succeededFuture()); } catch (IOException e) { - completionHandler.handle(Future.failedFuture(e)); + promise.handle(Future.failedFuture(e)); } } } diff --git a/src/main/java/org/prebid/server/vertx/Initializable.java b/src/main/java/org/prebid/server/vertx/Initializable.java index 3c8bfd22c55..5c12c30e47d 100644 --- a/src/main/java/org/prebid/server/vertx/Initializable.java +++ b/src/main/java/org/prebid/server/vertx/Initializable.java @@ -1,6 +1,7 @@ package org.prebid.server.vertx; import io.vertx.core.Handler; +import io.vertx.core.Promise; /** * Denotes components requiring initialization after they have been created. @@ -11,5 +12,5 @@ @FunctionalInterface public interface Initializable { - void initialize(); + void initialize(Promise initializePromise); } diff --git a/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java b/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java index bfdd4337fc1..35dd808c97d 100644 --- a/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java +++ b/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java @@ -8,12 +8,15 @@ import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.RequestOptions; import org.prebid.server.exception.PreBidException; import org.prebid.server.vertx.httpclient.model.HttpClientResponse; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Objects; import java.util.concurrent.TimeoutException; -import java.util.function.Consumer; /** * Simple wrapper around {@link HttpClient} with general functionality. @@ -31,100 +34,79 @@ public BasicHttpClient(Vertx vertx, io.vertx.core.http.HttpClient httpClient) { @Override public Future request(HttpMethod method, String url, MultiMap headers, String body, long timeoutMs, long maxResponseSize) { - return request(method, url, headers, timeoutMs, maxResponseSize, body, - (HttpClientRequest httpClientRequest) -> httpClientRequest.end(body)); + + return request(method, url, headers, timeoutMs, maxResponseSize, body != null ? body.getBytes() : null); } @Override public Future request(HttpMethod method, String url, MultiMap headers, byte[] body, long timeoutMs, long maxResponseSize) { - return request(method, url, headers, timeoutMs, maxResponseSize, body, - (HttpClientRequest httpClientRequest) -> httpClientRequest.end(Buffer.buffer(body))); + + return request(method, url, headers, timeoutMs, maxResponseSize, body); } - private Future request(HttpMethod method, String url, MultiMap headers, - long timeoutMs, long maxResponseSize, T body, - Consumer requestBodySetter) { - final Promise promise = Promise.promise(); + private Future request(HttpMethod method, String url, MultiMap headers, + long timeoutMs, long maxResponseSize, byte[] body) { if (timeoutMs <= 0) { - failResponse(new TimeoutException("Timeout has been exceeded"), promise); - } else { - final HttpClientRequest httpClientRequest; - try { - httpClientRequest = httpClient.requestAbs(method, url); - } catch (Exception e) { - failResponse(e, promise); - return promise.future(); - } - - // Vert.x HttpClientRequest timeout doesn't aware of case when a part of the response body is received, - // but remaining part is delayed. So, overall request/response timeout is involved to fix it. - final long timerId = vertx.setTimer(timeoutMs, id -> handleTimeout(promise, timeoutMs, httpClientRequest)); - - httpClientRequest - .setFollowRedirects(true) - .handler(response -> handleResponse(response, promise, timerId, maxResponseSize)) - .exceptionHandler(exception -> failResponse(exception, promise, timerId)); - - if (headers != null) { - httpClientRequest.headers().addAll(headers); - } - - if (body != null) { - requestBodySetter.accept(httpClientRequest); - } else { - httpClientRequest.end(); - } + return Future.failedFuture(new TimeoutException("Timeout has been exceeded")); } - return promise.future(); - } - private void handleTimeout(Promise promise, - long timeoutMs, - HttpClientRequest httpClientRequest) { + final URL absoluteUrl; + try { + absoluteUrl = new URL(url); + } catch (MalformedURLException e) { + return Future.failedFuture(e); + } - if (!promise.future().isComplete()) { - failResponse( - new TimeoutException("Timeout period of %dms has been exceeded".formatted(timeoutMs)), promise); + final Promise responsePromise = Promise.promise(); + final long timerId = vertx.setTimer(timeoutMs, ignored -> + responsePromise.tryFail( + new TimeoutException("Timeout period of %dms has been exceeded".formatted(timeoutMs)))); + + final RequestOptions options = new RequestOptions() + .setFollowRedirects(true) + .setConnectTimeout(timeoutMs) + .setMethod(method) + .setAbsoluteURI(absoluteUrl) + .setHeaders(headers); + + final Future requestFuture = makeRequest(options); + + requestFuture + .compose(request -> body != null ? request.send(Buffer.buffer(body)) : request.send()) + .compose(response -> toInternalResponse(response, maxResponseSize)) + .onSuccess(responsePromise::tryComplete) + .onFailure(responsePromise::tryFail); + + return responsePromise.future() + .onComplete(ignored -> vertx.cancelTimer(timerId)) + .onFailure(ignored -> requestFuture.onSuccess(HttpClientRequest::reset)); + } - // Explicitly close connection, inspired by https://github.com/eclipse-vertx/vert.x/issues/2745 - httpClientRequest.reset(); + private Future makeRequest(RequestOptions options) { + try { + return httpClient.request(options); + } catch (Throwable e) { + return Future.failedFuture(e); } } - private void handleResponse(io.vertx.core.http.HttpClientResponse response, - Promise promise, long timerId, long maxResponseSize) { + private Future toInternalResponse(io.vertx.core.http.HttpClientResponse response, + long maxResponseSize) { + final String contentLength = response.getHeader(HttpHeaders.CONTENT_LENGTH); final long responseBodySize = contentLength != null ? Long.parseLong(contentLength) : 0; if (responseBodySize > maxResponseSize) { - failResponse( - new PreBidException( - "Response size %d exceeded %d bytes limit".formatted(responseBodySize, maxResponseSize)), - promise, - timerId); - return; + return Future.failedFuture(new PreBidException( + "Response size %d exceeded %d bytes limit".formatted(responseBodySize, maxResponseSize))); } - response - .bodyHandler(buffer -> successResponse(buffer.toString(), response, promise, timerId)) - .exceptionHandler(exception -> failResponse(exception, promise, timerId)); - } - - private void successResponse(String body, io.vertx.core.http.HttpClientResponse response, - Promise promise, long timerId) { - vertx.cancelTimer(timerId); - - promise.tryComplete(HttpClientResponse.of(response.statusCode(), response.headers(), body)); - } - - private void failResponse(Throwable exception, Promise promise, long timerId) { - vertx.cancelTimer(timerId); - - failResponse(exception, promise); - } + return response.body() + .map(body -> HttpClientResponse.of( + response.statusCode(), + response.headers(), + body.toString(StandardCharsets.UTF_8))); - private static void failResponse(Throwable exception, Promise promise) { - promise.tryFail(exception); } } diff --git a/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java b/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java index ad957912dac..0843a04de12 100644 --- a/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java +++ b/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java @@ -5,10 +5,10 @@ import io.vertx.core.MultiMap; import io.vertx.core.Vertx; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.exception.PreBidException; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.CircuitBreaker; import org.prebid.server.vertx.httpclient.model.HttpClientResponse; @@ -127,11 +127,11 @@ private void circuitOpened(String name) { } private void circuitHalfOpened(String name) { - logger.warn("Http client request to {0} will try again, circuit half-opened.", name); + logger.warn("Http client request to {} will try again, circuit half-opened.", name); } private void circuitClosed(String name) { - logger.warn("Http client request to {0} becomes succeeded, circuit closed.", name); + logger.warn("Http client request to {} becomes succeeded, circuit closed.", name); } private static String nameFrom(String urlAsString) { diff --git a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java index 71fd24bd166..9988efbdb7f 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java @@ -5,12 +5,12 @@ import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.json.JsonArray; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.jdbc.JDBCClient; import io.vertx.ext.sql.ResultSet; import io.vertx.ext.sql.SQLConnection; import org.prebid.server.execution.Timeout; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import java.time.Clock; diff --git a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java index be662e057c9..fef375a741a 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java @@ -2,11 +2,11 @@ import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.sql.ResultSet; import org.prebid.server.execution.Timeout; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.CircuitBreaker; diff --git a/src/main/java/org/prebid/server/vertx/verticles/server/DaemonVerticle.java b/src/main/java/org/prebid/server/vertx/verticles/server/DaemonVerticle.java new file mode 100644 index 00000000000..fe954cd3354 --- /dev/null +++ b/src/main/java/org/prebid/server/vertx/verticles/server/DaemonVerticle.java @@ -0,0 +1,63 @@ +package org.prebid.server.vertx.verticles.server; + +import com.codahale.metrics.ScheduledReporter; +import io.vertx.core.AbstractVerticle; +import io.vertx.core.Closeable; +import io.vertx.core.Future; +import io.vertx.core.Promise; +import org.apache.commons.collections4.ListUtils; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; +import org.prebid.server.vertx.CloseableAdapter; +import org.prebid.server.vertx.Initializable; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; + +public class DaemonVerticle extends AbstractVerticle { + + private static final Logger logger = LoggerFactory.getLogger(DaemonVerticle.class); + + private final List initializables; + private final List closeables; + + public DaemonVerticle(List initializables, List reporters) { + this.initializables = ListUtils.emptyIfNull(initializables); + this.closeables = ListUtils.emptyIfNull(reporters).stream() + .map(CloseableAdapter::new) + .toList(); + } + + @Override + public void start(Promise startPromise) { + startPromise.handle(all(initializables, initializable -> initializable::initialize)); + } + + @Override + public void stop(Promise stopPromise) { + stopPromise.handle(all(closeables, closeable -> closeable::close)); + } + + private static Future all(Collection entries, + Function>> entryToPromiseConsumerMapper) { + + final List> entriesFutures = new ArrayList<>(); + + for (E entry : entries) { + final Promise entryPromise = Promise.promise(); + entriesFutures.add(entryPromise.future()); + + entryToPromiseConsumerMapper.apply(entry).accept(entryPromise); + } + + return Future.all(entriesFutures) + .onSuccess(r -> logger.info( + "Successfully started {} instance on thread: {}", + DaemonVerticle.class.getSimpleName(), + Thread.currentThread().getName())) + .mapEmpty(); + } +} diff --git a/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java b/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java index eed48d09cde..147de2210c4 100644 --- a/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java +++ b/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java @@ -5,12 +5,12 @@ import io.vertx.core.Promise; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.core.net.SocketAddress; import io.vertx.ext.web.Router; import org.apache.commons.lang3.ObjectUtils; import org.prebid.server.handler.ExceptionHandler; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.util.Objects; @@ -62,7 +62,7 @@ private void onServerStarted(AsyncResult result, Promise start if (result.succeeded()) { startPromise.tryComplete(); logger.info( - "Successfully started {0} instance on address: {1}, thread: {2}", + "Successfully started {} instance on address: {}, thread: {}", name, address, Thread.currentThread().getName()); diff --git a/src/test/groovy/org/prebid/server/functional/model/db/Account.groovy b/src/test/groovy/org/prebid/server/functional/model/db/Account.groovy index bb089280334..834cb57c114 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/Account.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/Account.groovy @@ -1,12 +1,12 @@ package org.prebid.server.functional.model.db import groovy.transform.ToString -import javax.persistence.Column -import javax.persistence.Convert -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id -import javax.persistence.Table +import jakarta.persistence.Column +import jakarta.persistence.Convert +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.Id +import jakarta.persistence.Table import org.prebid.server.functional.model.AccountStatus import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.db.typeconverter.AccountConfigTypeConverter @@ -14,7 +14,7 @@ import org.prebid.server.functional.model.db.typeconverter.AccountStatusTypeConv import java.sql.Timestamp -import static javax.persistence.GenerationType.IDENTITY +import static jakarta.persistence.GenerationType.IDENTITY @Entity @Table(name = "accounts_account") diff --git a/src/test/groovy/org/prebid/server/functional/model/db/StoredImp.groovy b/src/test/groovy/org/prebid/server/functional/model/db/StoredImp.groovy index 9be9b7a237f..27f66fb03d6 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/StoredImp.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/StoredImp.groovy @@ -1,17 +1,17 @@ package org.prebid.server.functional.model.db import groovy.transform.ToString -import javax.persistence.Column -import javax.persistence.Convert -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id -import javax.persistence.Table +import jakarta.persistence.Column +import jakarta.persistence.Convert +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.Id +import jakarta.persistence.Table import org.prebid.server.functional.model.db.typeconverter.ImpConfigTypeConverter import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp -import static javax.persistence.GenerationType.IDENTITY +import static jakarta.persistence.GenerationType.IDENTITY @Entity @Table(name = "stored_imps") diff --git a/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy index 30a43912297..69264aa04eb 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy @@ -1,17 +1,17 @@ package org.prebid.server.functional.model.db import groovy.transform.ToString -import javax.persistence.Column -import javax.persistence.Convert -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id -import javax.persistence.Table +import jakarta.persistence.Column +import jakarta.persistence.Convert +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.Id +import jakarta.persistence.Table import org.prebid.server.functional.model.db.typeconverter.StoredRequestConfigTypeConverter import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.BidRequest -import static javax.persistence.GenerationType.IDENTITY +import static jakarta.persistence.GenerationType.IDENTITY @Entity @Table(name = "stored_requests") diff --git a/src/test/groovy/org/prebid/server/functional/model/db/StoredResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/db/StoredResponse.groovy index 51d59ce0959..b57e793d22e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/StoredResponse.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/StoredResponse.groovy @@ -1,18 +1,18 @@ package org.prebid.server.functional.model.db import groovy.transform.ToString -import javax.persistence.Column -import javax.persistence.Convert -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id -import javax.persistence.Table +import jakarta.persistence.Column +import jakarta.persistence.Convert +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.Id +import jakarta.persistence.Table import org.prebid.server.functional.model.db.typeconverter.StoredAuctionResponseConfigTypeConverter import org.prebid.server.functional.model.db.typeconverter.StoredBidResponseConfigTypeConverter import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.SeatBid -import static javax.persistence.GenerationType.IDENTITY +import static jakarta.persistence.GenerationType.IDENTITY @Entity @Table(name = "stored_responses") diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountConfigTypeConverter.groovy index da0a7e6d1ec..e12009cb569 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountStatusTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountStatusTypeConverter.groovy index 005aae09d1c..b18aa387203 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountStatusTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountStatusTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.AccountStatus class AccountStatusTypeConverter implements AttributeConverter { diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/ImpConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/ImpConfigTypeConverter.groovy index 5a7ac8bb54c..1dd3227b38c 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/ImpConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/ImpConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredAuctionResponseConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredAuctionResponseConfigTypeConverter.groovy index 2f920559c38..e9423f02def 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredAuctionResponseConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredAuctionResponseConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.response.auction.SeatBid import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredBidResponseConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredBidResponseConfigTypeConverter.groovy index 6a1ddb05da8..43120fcad65 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredBidResponseConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredBidResponseConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredRequestConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredRequestConfigTypeConverter.groovy index 8668b292d8c..3e968d39565 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredRequestConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredRequestConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/repository/EntityManagerUtil.groovy b/src/test/groovy/org/prebid/server/functional/repository/EntityManagerUtil.groovy index a7712d6430f..cb0a89e3a02 100644 --- a/src/test/groovy/org/prebid/server/functional/repository/EntityManagerUtil.groovy +++ b/src/test/groovy/org/prebid/server/functional/repository/EntityManagerUtil.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.repository -import javax.persistence.EntityManager +import jakarta.persistence.EntityManager import org.hibernate.SessionFactory import java.util.function.Consumer diff --git a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy index ca9efffb62a..fc1b4784c70 100644 --- a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy +++ b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy @@ -263,7 +263,6 @@ class PrebidServerService implements ObjectMapperWrapper { decode(response.asString(), new TypeReference>() {}) } - String sendPrometheusMetricsRequest() { def response = given(prometheusRequestSpecification).get(PROMETHEUS_METRICS_ENDPOINT) @@ -347,7 +346,7 @@ class PrebidServerService implements ObjectMapperWrapper { if (testEnd.isBefore(testStart)) { throw new IllegalArgumentException("The end time of the test is less than the start time") } - def formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") + def formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss") .withZone(ZoneId.from(UTC)) def logs = Arrays.asList(pbsContainer.logs.split("\n")) def filteredLogs = [] diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy index 0e5328dc3ae..404cf1b5b15 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy @@ -284,7 +284,7 @@ class BidderParamsSpec extends BaseSpec { then: "Response should contain error" assert response.ext?.errors[ErrorType.GENERIC]*.code == [999] - assert response.ext?.errors[ErrorType.GENERIC]*.message == ["no empty host accepted"] + assert response.ext?.errors[ErrorType.GENERIC]*.message == ["host name must not be empty"] } def "PBS should reject bidder when bidder params from request doesn't satisfy json-schema for auction request"() { diff --git a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java index 69f1f46a4af..be853e77049 100644 --- a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java +++ b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.junit.Before; import org.junit.Rule; @@ -93,7 +94,7 @@ public void initializeShouldFetchConfigAndSetPeriodicTimerForConfigUpdate() thro Future.succeededFuture(HttpClientResponse.of(200, null, mapper.writeValueAsString(pubstackConfig)))); // when - pubstackAnalyticsReporter.initialize(); + pubstackAnalyticsReporter.initialize(Promise.promise()); // then verify(vertx).setPeriodic(anyLong(), any()); @@ -114,7 +115,7 @@ public void initializeShouldFailUpdateSendBuffersAndSetTimerWhenEndpointFromRemo Future.succeededFuture(HttpClientResponse.of(200, null, mapper.writeValueAsString(pubstackConfig)))); // when and then - assertThatThrownBy(() -> pubstackAnalyticsReporter.initialize()) + assertThatThrownBy(() -> pubstackAnalyticsReporter.initialize(Promise.promise())) .hasMessage("[pubstack] Failed to create event report url for endpoint: invalid") .isInstanceOf(PreBidException.class); verify(auctionHandler).reportEvents(); @@ -133,8 +134,8 @@ public void initializeShouldNotUpdateEventsIfFetchedConfigIsSameAsPrevious() thr Future.succeededFuture(HttpClientResponse.of(200, null, mapper.writeValueAsString(pubstackConfig)))); // when - pubstackAnalyticsReporter.initialize(); - pubstackAnalyticsReporter.initialize(); + pubstackAnalyticsReporter.initialize(Promise.promise()); + pubstackAnalyticsReporter.initialize(Promise.promise()); // then verify(httpClient, times(2)).get(anyString(), anyLong()); @@ -152,7 +153,7 @@ public void initializeShouldNotSendEventsAndUpdateConfigsWhenResponseStatusIsNot Future.succeededFuture(HttpClientResponse.of(400, null, null))); // when - pubstackAnalyticsReporter.initialize(); + pubstackAnalyticsReporter.initialize(Promise.promise()); // then verify(vertx).setPeriodic(anyLong(), any()); @@ -168,7 +169,7 @@ public void initializeShouldNotSendEventsAndUpdateConfigsWhenCantParseResponse() Future.succeededFuture(HttpClientResponse.of(200, null, "{\"endpoint\" : {}}"))); // when - pubstackAnalyticsReporter.initialize(); + pubstackAnalyticsReporter.initialize(Promise.promise()); // then verify(vertx).setPeriodic(anyLong(), any()); diff --git a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java index 58a9386de55..f96251f16be 100644 --- a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java @@ -2652,7 +2652,8 @@ public void shouldPopulateBidResponseExtension() { ExtBidderError.of(3, "Failed to decode: Cannot deserialize value" + " of type `com.iab.openrtb.response.Response` from Array value " + "(token `JsonToken.START_ARRAY`)\n" - + " at [Source: (String)\"[]\"; line: 1, column: 1]"))), + + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION`" + + " disabled); line: 1, column: 1]"))), entry("cache", singletonList(ExtBidderError.of(999, "cacheError")))); assertThat(responseExt.getResponsetimemillis()).hasSize(2) @@ -3150,7 +3151,7 @@ public void shouldThrowExceptionWhenNativeRequestIsInvalid() throws JsonProcessi .extracting(error -> error.get(bidder1)) .extracting(extBidderErrors -> extBidderErrors.get(0)) .isEqualTo(ExtBidderError.of(3, "No content to map due to end-of-input\n" - + " at [Source: (String)\"\"; line: 1, column: 0]")); + + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1]")); } @Test diff --git a/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java b/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java index 361c0ed72b8..343d6debd50 100644 --- a/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java +++ b/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java @@ -4,6 +4,7 @@ import com.iab.openrtb.request.BidRequest; import io.vertx.core.Future; import io.vertx.core.Handler; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.junit.Before; import org.junit.Rule; @@ -399,7 +400,7 @@ private CurrencyConversionService createInitializedService(String url, clock, jacksonMapper)); - currencyService.initialize(); + currencyService.initialize(Promise.promise()); return currencyService; } diff --git a/src/test/java/org/prebid/server/auction/model/CachedDebugLogTest.java b/src/test/java/org/prebid/server/auction/model/CachedDebugLogTest.java index da586c970f2..c104aa79675 100644 --- a/src/test/java/org/prebid/server/auction/model/CachedDebugLogTest.java +++ b/src/test/java/org/prebid/server/auction/model/CachedDebugLogTest.java @@ -56,8 +56,8 @@ public void setHeadersShouldAddHeadersToLogBody() { - header1: value1 - header2: value2 + header1=value1 + header2=value2 """); } @@ -254,7 +254,7 @@ public void buildCacheBodyShouldLogRequestHeaderResponseAndErrors() { Errors: error1 error2 - headerkey: headervalue + headerkey=headervalue """); } @@ -284,7 +284,7 @@ public void buildCacheBodyShouldIgnoreDeprecatedXmlSymbolsInAllParts() { Errors: error1 error2 - headerkey: headervalue + headerkey=headervalue """); } @@ -316,7 +316,7 @@ public void buildCacheBodyShouldNotEscapeSymbolsIfPatternIsNull() { Errors: - : + = """); } diff --git a/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java index f406293ad38..4988a6f2792 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java @@ -490,7 +490,7 @@ public void fromRequestShouldCreateDebugCacheAndIncludeRequestWithHeaders() thro .containsSequence(""" {"device":{"ua":"123"}} - header1: value1 + header1=value1 """); } diff --git a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java index c279492e5ed..2628aabb755 100644 --- a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java @@ -401,9 +401,12 @@ public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCantBeParsed() { // then assertThat(result.getErrors()).hasSize(1) .containsExactly(BidderError.badServerResponse( - "Failed to decode: Unexpected end-of-input: expected close marker for Object (start marker at" - + " [Source: (String)\"{\"; line: 1, column: 1])\n at [Source: (String)\"{\"; line: 1, " - + "column: 2]")); + "Failed to decode: Unexpected end-of-input: expected close marker" + + " for Object (start marker at [Source: REDACTED " + + "(`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); " + + "line: 1, column: 1])\n" + + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled);" + + " line: 1, column: 2]")); } private static BidderCall givenHttpCall(String body) { diff --git a/src/test/java/org/prebid/server/execution/RemoteFileSyncerTest.java b/src/test/java/org/prebid/server/execution/RemoteFileSyncerTest.java index b1b728aa646..f64ad993014 100644 --- a/src/test/java/org/prebid/server/execution/RemoteFileSyncerTest.java +++ b/src/test/java/org/prebid/server/execution/RemoteFileSyncerTest.java @@ -2,9 +2,9 @@ import io.vertx.core.Future; import io.vertx.core.Handler; -import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.file.AsyncFile; +import io.vertx.core.file.CopyOptions; import io.vertx.core.file.FileProps; import io.vertx.core.file.FileSystem; import io.vertx.core.file.FileSystemException; @@ -33,7 +33,6 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -86,31 +85,31 @@ public class RemoteFileSyncerTest extends VertxTest { @Before public void setUp() { when(vertx.fileSystem()).thenReturn(fileSystem); - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, 0, httpClient, vertx); } @Test public void shouldThrowNullPointerExceptionWhenIllegalArgumentsWhenNullArguments() { assertThatNullPointerException().isThrownBy( - () -> new RemoteFileSyncer(SOURCE_URL, null, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, + () -> new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, null, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx)); assertThatNullPointerException().isThrownBy( - () -> new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + () -> new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, null, vertx)); assertThatNullPointerException().isThrownBy( - () -> new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + () -> new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, null)); } @Test public void shouldThrowIllegalArgumentExceptionWhenIllegalArguments() { assertThatIllegalArgumentException().isThrownBy( - () -> new RemoteFileSyncer(null, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + () -> new RemoteFileSyncer(remoteFileProcessor, null, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx)); assertThatIllegalArgumentException().isThrownBy( - () -> new RemoteFileSyncer("bad url", FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, - UPDATE_INTERVAL, httpClient, vertx)); + () -> new RemoteFileSyncer(remoteFileProcessor, "bad url", FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + TIMEOUT, UPDATE_INTERVAL, httpClient, vertx)); } @Test @@ -120,7 +119,7 @@ public void creteShouldCreateDirWithWritePermissionIfDirNotExist() { when(fileSystem.existsBlocking(eq(DIR_PATH))).thenReturn(false); // when - new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, + new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); // then @@ -137,7 +136,7 @@ public void createShouldCreateDirWithWritePermissionIfItsNotDir() { when(fileProps.isDirectory()).thenReturn(false); // when - new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, + new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); // then @@ -152,205 +151,187 @@ public void createShouldThrowPreBidExceptionWhenPropsThrowException() { when(fileSystem.propsBlocking(eq(DIR_PATH))).thenThrow(FileSystemException.class); // when and then - assertThatThrownBy(() -> new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, - UPDATE_INTERVAL, httpClient, vertx)) + assertThatThrownBy(() -> new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, + RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx)) .isInstanceOf(PreBidException.class); } @Test public void syncForFilepathShouldNotTriggerServiceWhenCantCheckIfUsableFileExist() { // given - given(fileSystem.exists(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.failedFuture(new RuntimeException()))); + given(fileSystem.exists(anyString())) + .willReturn(Future.failedFuture(new RuntimeException())); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem).exists(eq(FILE_PATH), any()); + verify(fileSystem).exists(eq(FILE_PATH)); verifyNoInteractions(remoteFileProcessor); verifyNoInteractions(httpClient); } - @Test - public void syncForFilepathShouldRetryWhenRemoteFileProcessorIsFailed() { - // given - given(remoteFileProcessor.setDataPath(FILE_PATH)) - .willReturn(Future.failedFuture("Bad db file")); - - given(fileSystem.exists(any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(true))) - // Mock removal of file - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))); - - // when - remoteFileSyncer.sync(remoteFileProcessor); - - // then - verify(fileSystem, times(2)).exists(eq(FILE_PATH), any()); - verify(remoteFileProcessor).setDataPath(FILE_PATH); - verify(fileSystem).open(eq(TMP_FILE_PATH), any(), any()); - verifyNoInteractions(httpClient); - } - @Test public void syncForFilepathShouldNotUpdateWhenHeadRequestReturnInvalidHead() { // given - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); givenTriggerUpdate(); - given(httpClientResponse.getHeader(any(CharSequence.class))).willReturn("notnumber"); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientResponse.getHeader(HttpHeaders.CONTENT_LENGTH)) + .willReturn("notnumber"); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem, times(2)).exists(eq(FILE_PATH), any()); - verify(httpClient).headAbs(eq(SOURCE_URL), any()); + verify(fileSystem, times(2)).exists(eq(FILE_PATH)); + verify(httpClient).request(any()); verify(remoteFileProcessor).setDataPath(any()); verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); - verify(vertx, times(2)).setTimer(eq(UPDATE_INTERVAL), any()); + verify(vertx).setPeriodic(eq(UPDATE_INTERVAL), any()); verifyNoMoreInteractions(httpClient); } @Test public void syncForFilepathShouldNotUpdateWhenPropsIsFailed() { // given - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); givenTriggerUpdate(); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); given(httpClientResponse.getHeader(any(CharSequence.class))).willReturn(FILE_SIZE.toString()); - given(fileSystem.props(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.failedFuture(new IllegalArgumentException("ERROR")))); + given(fileSystem.props(anyString())) + .willReturn(Future.failedFuture(new IllegalArgumentException("ERROR"))); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem, times(2)).exists(eq(FILE_PATH), any()); - verify(httpClient).headAbs(eq(SOURCE_URL), any()); + verify(fileSystem, times(2)).exists(eq(FILE_PATH)); + verify(httpClient).request(any()); verify(httpClientResponse).getHeader(eq(HttpHeaders.CONTENT_LENGTH)); - verify(fileSystem).props(eq(FILE_PATH), any()); + verify(fileSystem).props(eq(FILE_PATH)); verify(remoteFileProcessor).setDataPath(any()); - verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); - verify(vertx, times(2)).setTimer(eq(UPDATE_INTERVAL), any()); + verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(CopyOptions.class)); + verify(vertx).setPeriodic(eq(UPDATE_INTERVAL), any()); verifyNoMoreInteractions(httpClient); } @Test public void syncForFilepathShouldNotUpdateServiceWhenSizeEqualsContentLength() { // given - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); givenTriggerUpdate(); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); given(httpClientResponse.getHeader(any(CharSequence.class))).willReturn(FILE_SIZE.toString()); - given(fileSystem.props(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(fileProps))); + given(fileSystem.props(anyString())) + .willReturn(Future.succeededFuture(fileProps)); doReturn(FILE_SIZE).when(fileProps).size(); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem, times(2)).exists(eq(FILE_PATH), any()); - verify(httpClient).headAbs(eq(SOURCE_URL), any()); + verify(fileSystem, times(2)).exists(eq(FILE_PATH)); + verify(httpClient).request(any()); verify(httpClientResponse).getHeader(eq(HttpHeaders.CONTENT_LENGTH)); - verify(fileSystem).props(eq(FILE_PATH), any()); + verify(fileSystem).props(eq(FILE_PATH)); verify(remoteFileProcessor).setDataPath(any()); - verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); - verify(vertx, times(2)).setTimer(eq(UPDATE_INTERVAL), any()); + verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(CopyOptions.class)); + verify(vertx).setPeriodic(eq(UPDATE_INTERVAL), any()); verifyNoMoreInteractions(httpClient); } @Test public void syncForFilepathShouldUpdateServiceWhenSizeNotEqualsContentLength() { // given - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer( + remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); givenTriggerUpdate(); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientResponse.pipeTo(any())).willReturn(Future.succeededFuture()); given(httpClientResponse.getHeader(any(CharSequence.class))).willReturn(FILE_SIZE.toString()); - given(fileSystem.props(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(fileProps))); + given(fileSystem.props(anyString())) + .willReturn(Future.succeededFuture(fileProps)); - doAnswer(invocation -> { - invocation.getArgument(1, Promise.class).complete(); - return null; - }).when(fileSystem).delete(anyString(), any()); + given(fileSystem.delete(anyString())) + .willReturn(Future.succeededFuture()); doReturn(123L).when(fileProps).size(); - // Download - final long timerId = 22L; - when(vertx.setTimer(eq(TIMEOUT), any())).thenReturn(timerId); - when(asyncFile.flush()).thenReturn(asyncFile); - - given(fileSystem.open(anyString(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(asyncFile), 2)); - - given(httpClient.getAbs(any(), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(httpClientResponse, httpClientRequest, 1)); + given(fileSystem.open(anyString(), any())) + .willReturn(Future.succeededFuture(asyncFile)); - given(httpClientResponse.endHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(null, 0)); + given(fileSystem.move(anyString(), any(), any(CopyOptions.class))) + .willReturn(Future.succeededFuture()); - doAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(), 0)) - .when(asyncFile).close(any()); - - given(fileSystem.move(anyString(), any(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(), 3)); + given(remoteFileProcessor.setDataPath(anyString())).willReturn(Future.succeededFuture()); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(httpClient).headAbs(eq(SOURCE_URL), any()); + verify(httpClient, times(2)).request(any()); verify(httpClientResponse).getHeader(eq(HttpHeaders.CONTENT_LENGTH)); - verify(fileSystem).props(eq(FILE_PATH), any()); + verify(fileSystem).props(eq(FILE_PATH)); // Download - verify(fileSystem).open(eq(TMP_FILE_PATH), any(), any()); - verify(vertx).setTimer(eq(TIMEOUT), any()); - verify(httpClient).getAbs(eq(SOURCE_URL), any()); - verify(httpClientResponse).endHandler(any()); - verify(asyncFile).close(any()); - verify(vertx).cancelTimer(timerId); + verify(fileSystem).open(eq(TMP_FILE_PATH), any()); + verify(asyncFile).close(); verify(remoteFileProcessor, times(2)).setDataPath(any()); - verify(vertx, times(2)).setTimer(eq(UPDATE_INTERVAL), any()); - verify(fileSystem).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); + verify(vertx).setPeriodic(eq(UPDATE_INTERVAL), any()); + verify(fileSystem).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(CopyOptions.class)); verifyNoMoreInteractions(httpClient); } @Test public void syncForFilepathShouldRetryAfterFailedDownload() { // given - given(fileSystem.exists(any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))); + given(fileSystem.exists(any())) + .willReturn(Future.succeededFuture(false)); - given(fileSystem.open(any(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.failedFuture(new RuntimeException()), 2)); + given(fileSystem.open(any(), any())) + .willReturn(Future.failedFuture(new RuntimeException())); + given(fileSystem.delete(any())) + .willReturn(Future.succeededFuture()); given(vertx.setTimer(eq(RETRY_INTERVAL), any())) .willAnswer(withReturnObjectAndPassObjectToHandler(0L, 10L, 1)); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then verify(vertx, times(RETRY_COUNT)).setTimer(eq(RETRY_INTERVAL), any()); - verify(fileSystem, times(RETRY_COUNT + 1)).open(eq(TMP_FILE_PATH), any(), any()); + verify(fileSystem, times(RETRY_COUNT + 1)).open(eq(TMP_FILE_PATH), any()); verifyNoInteractions(httpClient); verifyNoInteractions(remoteFileProcessor); @@ -359,12 +340,13 @@ public void syncForFilepathShouldRetryAfterFailedDownload() { @Test public void syncForFilepathShouldRetryWhenFileOpeningFailed() { // then - given(fileSystem.exists(any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(true))); + given(fileSystem.exists(any())) + .willReturn(Future.succeededFuture(false)); - given(fileSystem.open(any(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.failedFuture(new RuntimeException()), 2)); + given(fileSystem.open(any(), any())) + .willReturn(Future.failedFuture(new RuntimeException())); + given(fileSystem.delete(any())) + .willReturn(Future.succeededFuture()); given(vertx.setTimer(eq(RETRY_INTERVAL), any())) .willAnswer(withReturnObjectAndPassObjectToHandler(0L, 10L, 1)); @@ -376,11 +358,11 @@ public void syncForFilepathShouldRetryWhenFileOpeningFailed() { given(remoteFileProcessor.setDataPath(anyString())).willReturn(Future.succeededFuture()); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then verify(vertx, times(RETRY_COUNT)).setTimer(eq(RETRY_INTERVAL), any()); - verify(fileSystem, times(RETRY_COUNT + 1)).delete(eq(TMP_FILE_PATH), any()); + verify(fileSystem, times(RETRY_COUNT + 1)).delete(eq(TMP_FILE_PATH)); verifyNoInteractions(httpClient); verifyNoInteractions(remoteFileProcessor); @@ -389,42 +371,33 @@ public void syncForFilepathShouldRetryWhenFileOpeningFailed() { @Test public void syncForFilepathShouldDownloadFilesAndNotUpdateWhenUpdatePeriodIsNotSet() { // given - final long timerId = 22L; - when(vertx.setTimer(eq(TIMEOUT), any())).thenReturn(timerId); - when(asyncFile.flush()).thenReturn(asyncFile); - given(remoteFileProcessor.setDataPath(anyString())).willReturn(Future.succeededFuture()); - given(fileSystem.exists(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))); + given(fileSystem.exists(anyString())) + .willReturn(Future.succeededFuture(false)); - given(fileSystem.open(anyString(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(asyncFile), 2)); + given(fileSystem.open(any(), any())) + .willReturn(Future.succeededFuture(asyncFile)); - given(httpClient.getAbs(any(), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(httpClientResponse, httpClientRequest, 1)); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientResponse.pipeTo(asyncFile)) + .willReturn(Future.succeededFuture()); - given(httpClientResponse.endHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(null, 0)); - - doAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(), 0)) - .when(asyncFile).close(any()); - - given(fileSystem.move(anyString(), any(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(), 3)); + given(fileSystem.move(anyString(), anyString(), any(CopyOptions.class))) + .willReturn(Future.succeededFuture()); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem).open(eq(TMP_FILE_PATH), any(), any()); - verify(vertx).setTimer(eq(TIMEOUT), any()); - verify(httpClient).getAbs(eq(SOURCE_URL), any()); - verify(httpClientResponse).endHandler(any()); - verify(asyncFile).close(any()); - verify(vertx).cancelTimer(timerId); + verify(fileSystem).open(eq(TMP_FILE_PATH), any()); + verify(httpClient).request(any()); + verify(asyncFile).close(); verify(remoteFileProcessor).setDataPath(any()); - verify(fileSystem).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); + verify(fileSystem).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(CopyOptions.class)); verify(vertx, never()).setTimer(eq(UPDATE_INTERVAL), any()); verifyNoMoreInteractions(httpClient); } @@ -432,54 +405,48 @@ public void syncForFilepathShouldDownloadFilesAndNotUpdateWhenUpdatePeriodIsNotS @Test public void syncForFilepathShouldRetryWhenTimeoutIsReached() { // given - given(fileSystem.exists(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(true))); + given(fileSystem.exists(anyString())) + .willReturn(Future.succeededFuture(false)); - given(fileSystem.open(anyString(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(asyncFile), 2)); + given(fileSystem.open(anyString(), any())) + .willReturn(Future.succeededFuture(asyncFile)); given(vertx.setTimer(eq(RETRY_INTERVAL), any())) .willAnswer(withReturnObjectAndPassObjectToHandler(0L, 10L, 1)); - given(fileSystem.delete(any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture())); - - given(httpClient.getAbs(any(), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(httpClientResponse, httpClientRequest, 1)); + given(fileSystem.delete(any())) + .willReturn(Future.succeededFuture()); - given(vertx.setTimer(eq(TIMEOUT), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(null, 22L, 1)); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientResponse.pipeTo(asyncFile)) + .willReturn(Future.failedFuture("Timeout")); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then verify(vertx, times(RETRY_COUNT)).setTimer(eq(RETRY_INTERVAL), any()); - verify(fileSystem, times(RETRY_COUNT + 1)).open(eq(TMP_FILE_PATH), any(), any()); + verify(fileSystem, times(RETRY_COUNT + 1)).open(eq(TMP_FILE_PATH), any()); // Response handled - verify(httpClient, times(RETRY_COUNT + 1)).getAbs(eq(SOURCE_URL), any()); - verify(vertx, times(RETRY_COUNT + 1)).setTimer(eq(TIMEOUT), any()); + verify(httpClient, times(RETRY_COUNT + 1)).request(any()); verify(asyncFile, times(RETRY_COUNT + 1)).close(); verifyNoInteractions(remoteFileProcessor); } private void givenTriggerUpdate() { - given(fileSystem.exists(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(true))); + given(fileSystem.exists(anyString())) + .willReturn(Future.succeededFuture(true)); given(remoteFileProcessor.setDataPath(anyString())).willReturn(Future.succeededFuture()); - given(vertx.setTimer(eq(UPDATE_INTERVAL), any())) + given(vertx.setPeriodic(eq(UPDATE_INTERVAL), any())) .willAnswer(withReturnObjectAndPassObjectToHandler(123L, 123L, 1)) .willReturn(123L); - - given(httpClient.headAbs(anyString(), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(httpClientResponse, httpClientRequest, 1)); - - given(httpClientRequest.exceptionHandler(any())).willReturn(httpClientRequest); } @SuppressWarnings("unchecked") @@ -504,4 +471,3 @@ private static Answer withReturnObjectAndPassObjectToHandler(T ob }; } } - diff --git a/src/test/java/org/prebid/server/it/ApplicationTest.java b/src/test/java/org/prebid/server/it/ApplicationTest.java index ac40c02648c..d870ca41bf2 100644 --- a/src/test/java/org/prebid/server/it/ApplicationTest.java +++ b/src/test/java/org/prebid/server/it/ApplicationTest.java @@ -420,14 +420,14 @@ public void vtrackShouldReturnJsonWithUids() throws JSONException, IOException { public void optionsRequestShouldRespondWithOriginalPolicyHeaders() { // when final Response response = given(SPEC) - .header("Origin", "origin.com") + .header("Origin", "http://origin.com") .header("Access-Control-Request-Method", "GET") .when() .options("/"); // then assertThat(response.header("Access-Control-Allow-Credentials")).isEqualTo("true"); - assertThat(response.header("Access-Control-Allow-Origin")).isEqualTo("origin.com"); + assertThat(response.header("Access-Control-Allow-Origin")).isEqualTo("http://origin.com"); assertThat(response.header("Access-Control-Allow-Methods")).contains(asList("HEAD", "OPTIONS", "GET", "POST")); assertThat(response.header("Access-Control-Allow-Headers")) .isEqualTo("Origin,Accept,X-Requested-With,Content-Type"); diff --git a/src/test/java/org/prebid/server/log/ConditionalLoggerTest.java b/src/test/java/org/prebid/server/log/ConditionalLoggerTest.java index 7623c7e273c..afff7a5d44f 100644 --- a/src/test/java/org/prebid/server/log/ConditionalLoggerTest.java +++ b/src/test/java/org/prebid/server/log/ConditionalLoggerTest.java @@ -1,7 +1,6 @@ package org.prebid.server.log; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; diff --git a/src/test/java/org/prebid/server/log/CriteriaTest.java b/src/test/java/org/prebid/server/log/CriteriaTest.java index dd24d167fa0..fd11bf1fc55 100644 --- a/src/test/java/org/prebid/server/log/CriteriaTest.java +++ b/src/test/java/org/prebid/server/log/CriteriaTest.java @@ -1,6 +1,5 @@ package org.prebid.server.log; -import io.vertx.core.logging.Logger; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; diff --git a/src/test/java/org/prebid/server/log/HttpInteractionLoggerTest.java b/src/test/java/org/prebid/server/log/HttpInteractionLoggerTest.java index 9903e65b05a..6578a7edc82 100644 --- a/src/test/java/org/prebid/server/log/HttpInteractionLoggerTest.java +++ b/src/test/java/org/prebid/server/log/HttpInteractionLoggerTest.java @@ -4,7 +4,6 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.logging.Logger; import io.vertx.ext.web.RoutingContext; import org.junit.Before; import org.junit.Rule; @@ -68,7 +67,7 @@ public void maybeLogOpenrtb2AuctionShouldLogWithExpectedParams() { // then verify(logger) - .info("Requested URL: \"{0}\", request body: \"{1}\", response status: \"{2}\", response body: \"{3}\"", + .info("Requested URL: \"{}\", request body: \"{}\", response status: \"{}\", response body: \"{}\"", "example.com", "{}", 200, @@ -198,7 +197,7 @@ public void maybeLogOpenrtb2AmpShouldLogWithExpectedParams() { // then verify(logger) - .info("Requested URL: \"{0}\", response status: \"{1}\", response body: \"{2}\"", + .info("Requested URL: \"{}\", response status: \"{}\", response body: \"{}\"", "example.com", 200, "responseBody"); @@ -292,7 +291,7 @@ public void maybeLogBidderRequestShouldLogWithExpectedParams() { target.maybeLogBidderRequest(givenAuctionContext, givenBidderRequest); // then - verify(logger).info("Request body to {0}: \"{1}\"", "bidderName", "{}"); + verify(logger).info("Request body to {}: \"{}\"", "bidderName", "{}"); } @Test diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java index 0ed1dd87a52..e10cd145d78 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java @@ -87,8 +87,8 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedC // then assertThat(result.getStoredIdToRequest()).isEmpty(); assertThat(result.getStoredIdToImp()).isEmpty(); - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Error occurred while mapping stored request data"); + assertThat(result.getErrors()) + .containsExactly("No stored request found for id: reqId"); } @Test @@ -257,7 +257,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH } @Test - public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedColumnType() { + public void mapWithoutParamsShouldReturnEmptyStoredResultWhenResultSetHasInvalidDataType() { // given given(resultSet.getResults()).willReturn(singletonList( new JsonArray(asList("accountId", "id1", "data", 123)))); @@ -268,8 +268,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH // then assertThat(result.getStoredIdToRequest()).isEmpty(); assertThat(result.getStoredIdToImp()).isEmpty(); - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Error occurred while mapping stored request data"); + assertThat(result.getErrors()).isEmpty(); } @Test diff --git a/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java b/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java index 547d1484199..a858af44d74 100644 --- a/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java +++ b/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.vertx.core.Future; import io.vertx.core.Handler; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.junit.Before; import org.junit.Rule; @@ -171,7 +172,7 @@ private static void createAndInitService(CacheNotificationListener notificationL Vertx vertx, HttpClient httpClient) { final HttpPeriodicRefreshService httpPeriodicRefreshService = new HttpPeriodicRefreshService( url, refreshPeriod, timeout, notificationListener, vertx, httpClient, jacksonMapper); - httpPeriodicRefreshService.initialize(); + httpPeriodicRefreshService.initialize(Promise.promise()); } @SuppressWarnings("unchecked") diff --git a/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java b/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java index 5e49e305238..9857d048ad9 100644 --- a/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java +++ b/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java @@ -2,6 +2,7 @@ import io.vertx.core.Future; import io.vertx.core.Handler; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.junit.Before; import org.junit.Rule; @@ -157,7 +158,7 @@ private void createAndInitService(long refresh) { metrics, clock); - jdbcPeriodicRefreshService.initialize(); + jdbcPeriodicRefreshService.initialize(Promise.promise()); } @SuppressWarnings("unchecked") diff --git a/src/test/java/org/prebid/server/vertx/CloseableAdapterTest.java b/src/test/java/org/prebid/server/vertx/CloseableAdapterTest.java index 52c6a7b41da..80b438ee21f 100644 --- a/src/test/java/org/prebid/server/vertx/CloseableAdapterTest.java +++ b/src/test/java/org/prebid/server/vertx/CloseableAdapterTest.java @@ -1,8 +1,7 @@ package org.prebid.server.vertx; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; +import io.vertx.core.Promise; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; @@ -26,7 +25,7 @@ public class CloseableAdapterTest { @Mock private Closeable closeable; @Mock - private Handler> completionHandler; + private Promise completionPromise; @Test public void creationShouldFailOnNullArguments() { @@ -36,10 +35,10 @@ public void creationShouldFailOnNullArguments() { @Test public void closeShouldInvokeHandlerWithSuccededFuture() { // when - new CloseableAdapter(closeable).close(completionHandler); + new CloseableAdapter(closeable).close(completionPromise); // then - verify(completionHandler).handle(eq(Future.succeededFuture())); + verify(completionPromise).handle(eq(Future.succeededFuture())); } @Test @@ -49,9 +48,9 @@ public void closeShouldInvokeHandlerWithFailedFutureIfIOExceptionThrown() throws willThrow(exception).given(closeable).close(); // when - new CloseableAdapter(closeable).close(completionHandler); + new CloseableAdapter(closeable).close(completionPromise); // then - verify(completionHandler).handle(argThat(future -> future.failed() && future.cause() == exception)); + verify(completionPromise).handle(argThat(future -> future.failed() && future.cause() == exception)); } } diff --git a/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java b/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java index a11a4cb2265..8ea24bdb5cf 100644 --- a/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java +++ b/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java @@ -1,13 +1,13 @@ package org.prebid.server.vertx.httpclient; import io.vertx.core.Future; -import io.vertx.core.Handler; import io.vertx.core.MultiMap; import io.vertx.core.Vertx; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.RequestOptions; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; @@ -15,14 +15,15 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import org.mockito.stubbing.Answer; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; +import java.net.MalformedURLException; import java.net.ServerSocket; import java.net.Socket; import java.util.concurrent.CountDownLatch; @@ -30,11 +31,10 @@ import java.util.concurrent.TimeoutException; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @RunWith(VertxUnitRunner.class) @@ -56,45 +56,41 @@ public class BasicHttpClientTest { @Before public void setUp() { - given(wrappedHttpClient.requestAbs(any(), any())).willReturn(httpClientRequest); - - given(httpClientRequest.setFollowRedirects(anyBoolean())).willReturn(httpClientRequest); - given(httpClientRequest.handler(any())).willReturn(httpClientRequest); - given(httpClientRequest.exceptionHandler(any())).willReturn(httpClientRequest); - given(httpClientRequest.headers()).willReturn(MultiMap.caseInsensitiveMultiMap()); - - given(httpClientResponse.bodyHandler(any())).willReturn(httpClientResponse); - given(httpClientResponse.exceptionHandler(any())).willReturn(httpClientResponse); + given(wrappedHttpClient.request(any())).willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()).willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientRequest.send(any(Buffer.class))).willReturn(Future.succeededFuture(httpClientResponse)); httpClient = new BasicHttpClient(vertx, wrappedHttpClient); } @Test public void requestShouldPerformHttpRequestWithExpectedParams() { - // given - final MultiMap headers = mock(MultiMap.class); - given(httpClientRequest.headers()).willReturn(headers); - - // when - httpClient.request(HttpMethod.POST, "url", headers, "body", 500L); + // given and when + httpClient.request(HttpMethod.POST, "http://www.example.com", MultiMap.caseInsensitiveMultiMap(), "body", 500L); // then - verify(wrappedHttpClient).requestAbs(eq(HttpMethod.POST), eq("url")); - verify(httpClientRequest.headers()).addAll(eq(headers)); - verify(httpClientRequest).end(eq("body")); + final ArgumentCaptor requestOptionsArgumentCaptor = + ArgumentCaptor.forClass(RequestOptions.class); + verify(wrappedHttpClient).request(requestOptionsArgumentCaptor.capture()); + + final RequestOptions expectedRequestOptions = new RequestOptions() + .setFollowRedirects(true) + .setConnectTimeout(500L) + .setMethod(HttpMethod.POST) + .setAbsoluteURI("http://www.example.com") + .setHeaders(MultiMap.caseInsensitiveMultiMap()); + assertThat(requestOptionsArgumentCaptor.getValue().toJson()).isEqualTo(expectedRequestOptions.toJson()); + + verify(httpClientRequest).send(eq(Buffer.buffer("body".getBytes()))); } @Test public void requestShouldSucceedIfHttpRequestSucceeds() { // given - given(httpClientRequest.handler(any())) - .willAnswer(withSelfAndPassObjectToHandler(httpClientResponse)); - - given(httpClientResponse.bodyHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(Buffer.buffer("response"))); + given(httpClientResponse.body()).willReturn(Future.succeededFuture(Buffer.buffer("response"))); // when - final Future future = httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); + final Future future = httpClient.request(HttpMethod.GET, "http://www.example.com", null, (String) null, 1L); // then assertThat(future.succeeded()).isTrue(); @@ -102,34 +98,34 @@ public void requestShouldSucceedIfHttpRequestSucceeds() { @Test public void requestShouldAllowFollowingRedirections() { - // when - httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); + // given and when + httpClient.request(HttpMethod.POST, "http://www.example.com", MultiMap.caseInsensitiveMultiMap(), "body", 500L); // then - verify(httpClientRequest).setFollowRedirects(true); + final ArgumentCaptor requestOptionsArgumentCaptor = + ArgumentCaptor.forClass(RequestOptions.class); + verify(wrappedHttpClient).request(requestOptionsArgumentCaptor.capture()); + assertTrue(requestOptionsArgumentCaptor.getValue().getFollowRedirects()); } @Test public void requestShouldFailIfInvalidUrlPassed() { - // given - given(wrappedHttpClient.requestAbs(any(), any())).willThrow(new RuntimeException("error")); - - // when + // given and when final Future future = httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); // then assertThat(future.failed()).isTrue(); - assertThat(future.cause()).hasMessage("error"); + assertThat(future.cause()).isInstanceOf(MalformedURLException.class); } @Test public void requestShouldFailIfHttpRequestFails() { // given - given(httpClientRequest.exceptionHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(new RuntimeException("Request exception"))); + given(wrappedHttpClient.request(any())) + .willReturn(Future.failedFuture("Request exception")); // when - final Future future = httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); + final Future future = httpClient.request(HttpMethod.GET, "http://www.example.com", null, (String) null, 1L); // then assertThat(future.failed()).isTrue(); @@ -139,14 +135,11 @@ public void requestShouldFailIfHttpRequestFails() { @Test public void requestShouldFailIfHttpResponseFails() { // given - given(httpClientRequest.handler(any())) - .willAnswer(withSelfAndPassObjectToHandler(httpClientResponse)); - - given(httpClientResponse.exceptionHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(new RuntimeException("Response exception"))); + given(wrappedHttpClient.request(any())) + .willReturn(Future.failedFuture("Response exception")); // when - final Future future = httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); + final Future future = httpClient.request(HttpMethod.GET, "http://example.coom", null, (String) null, 1L); // then assertThat(future.failed()).isTrue(); @@ -254,13 +247,4 @@ private static void sleep(long millis) { throw new RuntimeException(e); } } - - @SuppressWarnings("unchecked") - private static Answer withSelfAndPassObjectToHandler(T obj) { - return inv -> { - // invoking handler right away passing mock to it - ((Handler) inv.getArgument(0)).handle(obj); - return inv.getMock(); - }; - } } From 2fea8e5fa17f7fdb6ebfea6f0029898620fc2f8a Mon Sep 17 00:00:00 2001 From: SerhiiNahornyi Date: Thu, 18 Apr 2024 17:09:09 +0200 Subject: [PATCH 02/62] Core: Java upgrade (#3126) --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 2 +- .github/workflows/docker-image-publish.yml | 2 +- .github/workflows/pr-functional-tests.yml | 2 +- .github/workflows/pr-java-ci.yml | 2 +- .../workflows/pr-module-functional-tests.yml | 2 +- .github/workflows/release-asset-publish.yml | 2 +- Dockerfile | 2 +- Dockerfile-modules | 2 +- extra/bundle/pom.xml | 2 +- extra/modules/pom.xml | 4 +-- extra/pom.xml | 4 +-- pom.xml | 22 ++++++++----- .../prebid/server/bidder/adot/AdotBidder.java | 2 +- .../server/bidder/algorix/AlgorixBidder.java | 6 ++-- .../java/org/prebid/server/util/HttpUtil.java | 11 +++++++ src/main/resources/bidder-config/adot.yaml | 2 +- src/main/resources/bidder-config/algorix.yaml | 2 +- .../bidder/HttpBidderRequesterTest.java | 31 +++++++++---------- .../server/bidder/adot/AdotBidderTest.java | 2 +- .../bidder/algorix/AlgorixBidderTest.java | 2 +- 21 files changed, 61 insertions(+), 47 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 74747d3fe15..f64a14137d4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,3 +1,3 @@ # From https://github.com/microsoft/vscode-dev-containers/blob/master/containers/go/.devcontainer/Dockerfile -ARG VARIANT="17-jdk-bookworm" +ARG VARIANT="21-jdk-bookworm" FROM mcr.microsoft.com/vscode/devcontainers/java:${VARIANT} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d167be89720..d9a309d3661 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "dockerfile": "Dockerfile", "args": { // Update the VARIANT arg to pick a version of Java - "VARIANT": "17-jdk-bookworm", + "VARIANT": "21-jdk-bookworm", } }, "containerEnv": { diff --git a/.github/workflows/docker-image-publish.yml b/.github/workflows/docker-image-publish.yml index 63d1961388d..4249a8370a9 100644 --- a/.github/workflows/docker-image-publish.yml +++ b/.github/workflows/docker-image-publish.yml @@ -19,7 +19,7 @@ jobs: packages: write strategy: matrix: - java: [ 17 ] + java: [ 21 ] dockerfile-path: [Dockerfile, extra/Dockerfile] include: - dockerfile-path: Dockerfile diff --git a/.github/workflows/pr-functional-tests.yml b/.github/workflows/pr-functional-tests.yml index 610c6693193..e3ac3ffcd10 100644 --- a/.github/workflows/pr-functional-tests.yml +++ b/.github/workflows/pr-functional-tests.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - java: [ 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/pr-java-ci.yml b/.github/workflows/pr-java-ci.yml index 79a904c3636..3ead6423d9f 100644 --- a/.github/workflows/pr-java-ci.yml +++ b/.github/workflows/pr-java-ci.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - java: [ 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/pr-module-functional-tests.yml b/.github/workflows/pr-module-functional-tests.yml index d8f1e925a07..d87fbe4857a 100644 --- a/.github/workflows/pr-module-functional-tests.yml +++ b/.github/workflows/pr-module-functional-tests.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - java: [ 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release-asset-publish.yml b/.github/workflows/release-asset-publish.yml index 1de13751c3a..fb1057d8ee8 100644 --- a/.github/workflows/release-asset-publish.yml +++ b/.github/workflows/release-asset-publish.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v4 - name: Set up JDK diff --git a/Dockerfile b/Dockerfile index d69d5346506..b1fab501fa9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM amazoncorretto:17 +FROM amazoncorretto:21 WORKDIR /app/prebid-server diff --git a/Dockerfile-modules b/Dockerfile-modules index a9cbfe71b31..d3338d2c376 100644 --- a/Dockerfile-modules +++ b/Dockerfile-modules @@ -1,4 +1,4 @@ -FROM amazoncorretto:17 +FROM amazoncorretto:21 WORKDIR /app/prebid-server diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 30748f5061f..2c66f1b22f2 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -17,7 +17,7 @@ UTF-8 UTF-8 - 17 + 21 ${java.version} ${java.version} 2.5.6 diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 6a0d60bc391..0d442c3d4ef 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -25,7 +25,7 @@ UTF-8 UTF-8 - 17 + 21 ${java.version} ${java.version} @@ -34,7 +34,7 @@ 4.13.2 4.7.0 - 3.10.1 + 3.11.0 2.22.2 diff --git a/extra/pom.xml b/extra/pom.xml index 0afb89a0b85..7b8a60f2108 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -17,8 +17,8 @@ UTF-8 UTF-8 - 17 - 17 + 21 + 21 4.5.5 1.18.30 3.0.0-M6 diff --git a/pom.xml b/pom.xml index 638bf87e9f5..753fd5f064b 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ UTF-8 UTF-8 - 17 + 21 ${java.version} ${java.version} Dockerfile @@ -64,7 +64,7 @@ 5.4.0 2.2.220 2.4-M2-groovy-4.0 - 3.0.14 + 4.0.15 1.17.4 5.14.0 1.9.9.1 @@ -76,11 +76,11 @@ 1.2.0 0.8.11 2.2.4 - 3.10.1 + 3.11.0 2.22.2 ${maven-surefire-plugin.version} 0.40.2 - 1.13.1 + 3.0.2 false true false @@ -523,15 +523,21 @@ spock-core ${spock.version} test + + + org.apache.groovy + groovy + + - org.codehaus.groovy + org.apache.groovy groovy ${groovy.version} test - org.codehaus.groovy + org.apache.groovy groovy-yaml ${groovy.version} test @@ -949,8 +955,8 @@ org.apache.maven.plugins maven-compiler-plugin - 17 - 17 + 21 + 21 diff --git a/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java b/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java index 54b8cf8cf12..1c406402069 100644 --- a/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java +++ b/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java @@ -39,7 +39,7 @@ public class AdotBidder implements Bidder { private static final List ALLOWED_BID_TYPES = Arrays.asList(BidType.banner, BidType.video, BidType.xNative); private static final String PRICE_MACRO = "${AUCTION_PRICE}"; - private static final String PUBLISHER_MACRO = "{PUBLISHER_PATH}"; + private static final String PUBLISHER_MACRO = "{{PUBLISHER_PATH}}"; private static final TypeReference> ADOT_EXT_TYPE_REFERENCE = new TypeReference<>() { }; diff --git a/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java b/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java index 43549c101e8..0ddf5827f9a 100644 --- a/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java +++ b/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java @@ -46,9 +46,9 @@ public class AlgorixBidder implements Bidder { new TypeReference<>() { }; - private static final String URL_REGION_MACRO = "{HOST}"; - private static final String URL_SID_MACRO = "{SID}"; - private static final String URL_TOKEN_MACRO = "{TOKEN}"; + private static final String URL_REGION_MACRO = "{{HOST}}"; + private static final String URL_SID_MACRO = "{{SID}}"; + private static final String URL_TOKEN_MACRO = "{{TOKEN}}"; private static final int FIRST_INDEX = 0; diff --git a/src/main/java/org/prebid/server/util/HttpUtil.java b/src/main/java/org/prebid/server/util/HttpUtil.java index 005230166e7..9a21fcc0681 100644 --- a/src/main/java/org/prebid/server/util/HttpUtil.java +++ b/src/main/java/org/prebid/server/util/HttpUtil.java @@ -74,6 +74,8 @@ public final class HttpUtil { public static final CharSequence SEC_CH_UA = HttpHeaders.createOptimized("Sec-CH-UA"); public static final CharSequence SEC_CH_UA_MOBILE = HttpHeaders.createOptimized("Sec-CH-UA-Mobile"); public static final CharSequence SEC_CH_UA_PLATFORM = HttpHeaders.createOptimized("Sec-CH-UA-Platform"); + public static final String MACROS_OPEN = "{{"; + public static final String MACROS_CLOSE = "}}"; private HttpUtil() { } @@ -82,6 +84,10 @@ private HttpUtil() { * Checks the input string for using as URL. */ public static String validateUrl(String url) { + if (containsMacrosses(url)) { + return url; + } + try { return new URL(url).toString(); } catch (MalformedURLException e) { @@ -89,6 +95,11 @@ public static String validateUrl(String url) { } } + // TODO: We need our own way to work with url macrosses + private static boolean containsMacrosses(String url) { + return StringUtils.contains(url, MACROS_OPEN) && StringUtils.contains(url, MACROS_CLOSE); + } + /** * Returns encoded URL for the given value. *

diff --git a/src/main/resources/bidder-config/adot.yaml b/src/main/resources/bidder-config/adot.yaml index 91a975e521f..fa4a5a5f489 100644 --- a/src/main/resources/bidder-config/adot.yaml +++ b/src/main/resources/bidder-config/adot.yaml @@ -1,6 +1,6 @@ adapters: adot: - endpoint: https://dsp.adotmob.com/headerbidding{PUBLISHER_PATH}/bidrequest + endpoint: https://dsp.adotmob.com/headerbidding{{PUBLISHER_PATH}}/bidrequest meta-info: maintainer-email: admin@we-are-adot.com app-media-types: diff --git a/src/main/resources/bidder-config/algorix.yaml b/src/main/resources/bidder-config/algorix.yaml index 70c56825fdd..f76db6420ce 100644 --- a/src/main/resources/bidder-config/algorix.yaml +++ b/src/main/resources/bidder-config/algorix.yaml @@ -1,6 +1,6 @@ adapters: algorix: - endpoint: https://{HOST}.svr-algorix.com/rtb/sa?sid={SID}&token={TOKEN} + endpoint: https://{{HOST}}.svr-algorix.com/rtb/sa?sid={{SID}}&token={{TOKEN}} meta-info: maintainer-email: prebid@algorix.co app-media-types: diff --git a/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java b/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java index 6a7aeeb25bd..35bd07a6881 100644 --- a/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java +++ b/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java @@ -48,7 +48,6 @@ import java.time.ZoneId; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.UnaryOperator; @@ -359,10 +358,9 @@ public void shouldReturnBidsCreatedByMakeBids() { // given givenSuccessfulBidderMakeHttpRequests(); - final List bids = asList( - BidderBid.of(Bid.builder().impid("1").build(), null, null), - BidderBid.of(Bid.builder().impid("2").build(), null, null)); - given(bidder.makeBids(any(), any())).willReturn(Result.of(bids, emptyList())); + final List bids = emptyList(); + given(bidder.makeBidderResponse(any(), any())) + .willReturn(CompositeBidderResponse.withBids(bids, null)); final BidderRequest bidderRequest = BidderRequest.builder() .bidder("bidder") @@ -383,8 +381,6 @@ public void shouldReturnBidsCreatedByMakeBids() { .result(); // then - verify(bidder, times(1)).makeBids(any(), any()); - verify(bidder, times(1)).makeBidderResponse(any(), any()); assertThat(bidderSeatBid.getBids()).hasSameElementsAs(bids); } @@ -727,20 +723,23 @@ public void shouldReturnRecordBidRejections() throws JsonProcessingException { } @Test - public void shouldNotReturnSensitiveHeadersInFullDebugInfo() { + public void shouldNotReturnSensitiveHeadersInFullDebugInfo() + throws JsonProcessingException { // given final MultiMap headers = MultiMap.caseInsensitiveMultiMap(); headers.add("headerKey", "headerValue"); headers.add("Authorization", "authorizationValue"); + final BidRequest givenBidRequest = givenBidRequest(identity()); + final byte[] requestBody = mapper.writeValueAsBytes(givenBidRequest); given(bidder.makeHttpRequests(any())).willReturn(Result.of(singletonList( givenSimpleHttpRequest(httpRequestBuilder -> httpRequestBuilder .uri("uri1") - .headers(headers))), + .headers(headers) + .payload(givenBidRequest) + .body(requestBody))), emptyList())); - given(requestEnricher.enrichHeaders(anyString(), any(), any(), any(), any())).willReturn(headers); - givenHttpClientReturnsResponses( - HttpClientResponse.of(200, null, "responseBody1")); + given(requestEnricher.enrichHeaders(anyString(), any(), any(), any(), any())).willReturn(headers); final BidderRequest bidderRequest = BidderRequest.builder() .bidder("bidder") @@ -749,12 +748,11 @@ public void shouldNotReturnSensitiveHeadersInFullDebugInfo() { // when final BidderSeatBid bidderSeatBid = - target - .requestBids( + target.requestBids( bidder, bidderRequest, bidRejectionTracker, - timeout, + expiredTimeout, CaseInsensitiveMultiMap.empty(), bidderAliases, true) @@ -763,8 +761,7 @@ public void shouldNotReturnSensitiveHeadersInFullDebugInfo() { // then assertThat(bidderSeatBid.getHttpCalls()) .extracting(ExtHttpCall::getRequestheaders) - .flatExtracting(Map::keySet) - .containsExactly("headerKey"); + .containsExactly(singletonMap("headerKey", singletonList("headerValue"))); } @Test diff --git a/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java b/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java index fb05f8387c9..fea318e7022 100644 --- a/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java @@ -37,7 +37,7 @@ public class AdotBidderTest extends VertxTest { - private static final String ENDPOINT_URL = "https://test.endpoint{PUBLISHER_PATH}.com"; + private static final String ENDPOINT_URL = "https://test.endpoint{{PUBLISHER_PATH}}.com"; private final AdotBidder target = new AdotBidder(ENDPOINT_URL, jacksonMapper); diff --git a/src/test/java/org/prebid/server/bidder/algorix/AlgorixBidderTest.java b/src/test/java/org/prebid/server/bidder/algorix/AlgorixBidderTest.java index 3ffe4ba86ff..72748cc8d35 100644 --- a/src/test/java/org/prebid/server/bidder/algorix/AlgorixBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/algorix/AlgorixBidderTest.java @@ -42,7 +42,7 @@ */ public class AlgorixBidderTest extends VertxTest { - private static final String ENDPOINT_URL = "https://{HOST}.svr-algorix.com/rtb/sa?sid={SID}&token={TOKEN}"; + private static final String ENDPOINT_URL = "https://{{HOST}}.svr-algorix.com/rtb/sa?sid={{SID}}&token={{TOKEN}}"; private final AlgorixBidder target = new AlgorixBidder(ENDPOINT_URL, jacksonMapper); From 9cd583c8cc7c39d512baeb6f5c8d5c3649c78f1b Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Wed, 24 Apr 2024 14:35:27 +0200 Subject: [PATCH 03/62] Async DB Clients (#3118) --- pom.xml | 7 +- .../server/health/DatabaseHealthChecker.java | 14 +- .../settings/JdbcApplicationSettings.java | 76 +- .../helper/JdbcStoredDataResultMapper.java | 44 +- .../JdbcStoredResponseResultMapper.java | 31 +- .../helper/ParametrizedQueryHelper.java | 16 + .../helper/ParametrizedQueryMySqlHelper.java | 34 + .../ParametrizedQueryPostgresHelper.java | 45 ++ .../config/HealthCheckerConfiguration.java | 6 +- .../spring/config/SettingsConfiguration.java | 3 + .../database/DatabaseConfiguration.java | 180 ++--- .../server/vertx/jdbc/BasicJdbcClient.java | 88 +-- .../jdbc/CircuitBreakerSecuredJdbcClient.java | 5 +- .../prebid/server/vertx/jdbc/JdbcClient.java | 5 +- .../health/DatabaseHealthCheckerTest.java | 62 +- ...ntActivityRulesConfigDeserializerTest.java | 5 +- ...tringAsListOfIntegersDeserializerTest.java | 13 +- .../settings/JdbcApplicationSettingsTest.java | 650 ++++-------------- .../JdbcStoredDataResultMapperTest.java | 196 ++++-- .../JdbcStoredResponseResultMapperTest.java | 78 ++- .../ParametrizedQueryMySqlHelperTest.java | 106 +++ .../ParametrizedQueryPostgresHelperTest.java | 106 +++ .../vertx/jdbc/BasicJdbcClientTest.java | 150 ++-- .../CircuitBreakerSecuredJdbcClientTest.java | 56 +- 24 files changed, 988 insertions(+), 988 deletions(-) create mode 100644 src/main/java/org/prebid/server/settings/helper/ParametrizedQueryHelper.java create mode 100644 src/main/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelper.java create mode 100644 src/main/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelper.java create mode 100644 src/test/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelperTest.java create mode 100644 src/test/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelperTest.java diff --git a/pom.xml b/pom.xml index 753fd5f064b..79ae15fa03f 100644 --- a/pom.xml +++ b/pom.xml @@ -162,7 +162,12 @@ io.vertx - vertx-jdbc-client + vertx-mysql-client + ${vertx.version} + + + io.vertx + vertx-pg-client ${vertx.version} diff --git a/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java b/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java index e27a72dd0db..6949aba2d12 100644 --- a/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java +++ b/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java @@ -1,9 +1,7 @@ package org.prebid.server.health; -import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.sql.SQLConnection; +import io.vertx.sqlclient.Pool; import org.prebid.server.health.model.Status; import org.prebid.server.health.model.StatusResponse; @@ -15,13 +13,13 @@ public class DatabaseHealthChecker extends PeriodicHealthChecker { private static final String NAME = "database"; - private final JDBCClient jdbcClient; + private final Pool pool; private StatusResponse status; - public DatabaseHealthChecker(Vertx vertx, JDBCClient jdbcClient, long refreshPeriod) { + public DatabaseHealthChecker(Vertx vertx, Pool pool, long refreshPeriod) { super(vertx, refreshPeriod); - this.jdbcClient = Objects.requireNonNull(jdbcClient); + this.pool = Objects.requireNonNull(pool); } @Override @@ -36,9 +34,7 @@ public String name() { @Override void updateStatus() { - final Promise connectionPromise = Promise.promise(); - jdbcClient.getConnection(connectionPromise); - connectionPromise.future().onComplete(result -> + pool.getConnection().onComplete(result -> status = StatusResponse.of( result.succeeded() ? Status.UP.name() : Status.DOWN.name(), ZonedDateTime.now(Clock.systemUTC()))); diff --git a/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java b/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java index a922c3af898..6dd9f507ffa 100644 --- a/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java @@ -1,8 +1,9 @@ package org.prebid.server.settings; import io.vertx.core.Future; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.PreBidException; @@ -11,9 +12,11 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.settings.helper.JdbcStoredDataResultMapper; import org.prebid.server.settings.helper.JdbcStoredResponseResultMapper; +import org.prebid.server.settings.helper.ParametrizedQueryHelper; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredResponseDataResult; +import org.prebid.server.util.ObjectUtil; import org.prebid.server.vertx.jdbc.JdbcClient; import java.util.ArrayList; @@ -23,7 +26,6 @@ import java.util.Objects; import java.util.Set; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.IntStream; /** @@ -36,14 +38,9 @@ */ public class JdbcApplicationSettings implements ApplicationSettings { - private static final String ACCOUNT_ID_PLACEHOLDER = "%ACCOUNT_ID%"; - private static final String REQUEST_ID_PLACEHOLDER = "%REQUEST_ID_LIST%"; - private static final String IMP_ID_PLACEHOLDER = "%IMP_ID_LIST%"; - private static final String RESPONSE_ID_PLACEHOLDER = "%RESPONSE_ID_LIST%"; - private static final String QUERY_PARAM_PLACEHOLDER = "?"; - private final JdbcClient jdbcClient; private final JacksonMapper mapper; + private final ParametrizedQueryHelper parametrizedQueryHelper; /** * Query to select account by ids. @@ -86,6 +83,7 @@ public class JdbcApplicationSettings implements ApplicationSettings { public JdbcApplicationSettings(JdbcClient jdbcClient, JacksonMapper mapper, + ParametrizedQueryHelper parametrizedQueryHelper, String selectAccountQuery, String selectStoredRequestsQuery, String selectAmpStoredRequestsQuery, @@ -93,8 +91,9 @@ public JdbcApplicationSettings(JdbcClient jdbcClient, this.jdbcClient = Objects.requireNonNull(jdbcClient); this.mapper = Objects.requireNonNull(mapper); - this.selectAccountQuery = Objects.requireNonNull(selectAccountQuery) - .replace(ACCOUNT_ID_PLACEHOLDER, QUERY_PARAM_PLACEHOLDER); + this.parametrizedQueryHelper = Objects.requireNonNull(parametrizedQueryHelper); + this.selectAccountQuery = parametrizedQueryHelper.replaceAccountIdPlaceholder( + Objects.requireNonNull(selectAccountQuery)); this.selectStoredRequestsQuery = Objects.requireNonNull(selectStoredRequestsQuery); this.selectAmpStoredRequestsQuery = Objects.requireNonNull(selectAmpStoredRequestsQuery); this.selectStoredResponsesQuery = Objects.requireNonNull(selectStoredResponsesQuery); @@ -109,7 +108,7 @@ public Future getAccountById(String accountId, Timeout timeout) { return jdbcClient.executeQuery( selectAccountQuery, Collections.singletonList(accountId), - result -> mapToModelOrError(result, row -> toAccount(row.getString(0))), + result -> mapToModelOrError(result, this::toAccount), timeout) .compose(result -> failedIfNull(result, accountId, "Account")); } @@ -120,14 +119,15 @@ public Future> getCategories(String primaryAdServer, String } /** - * Transforms the first row of {@link ResultSet} to required object or returns null. + * Transforms the first row of {@link RowSet} to required object or returns null. *

* Note: mapper should never throws exception in case of using * {@link org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient}. */ - private T mapToModelOrError(ResultSet result, Function mapper) { - return result != null && CollectionUtils.isNotEmpty(result.getResults()) - ? mapper.apply(result.getResults().get(0)) + private T mapToModelOrError(RowSet rowSet, Function mapper) { + final RowIterator rowIterator = rowSet != null ? rowSet.iterator() : null; + return rowIterator != null && rowIterator.hasNext() + ? mapper.apply(rowIterator.next()) : null; } @@ -141,7 +141,8 @@ private static Future failedIfNull(T value, String id, String errorPrefix : Future.failedFuture(new PreBidException("%s not found: %s".formatted(errorPrefix, id))); } - private Account toAccount(String source) { + private Account toAccount(Row row) { + final String source = ObjectUtil.getIfNotNull(row.getValue(0), Object::toString); try { return source != null ? mapper.decodeValue(source, Account.class) : null; } catch (DecodeException e) { @@ -185,11 +186,15 @@ public Future getVideoStoredData(String accountId, Set */ @Override public Future getStoredResponses(Set responseIds, Timeout timeout) { - final String queryResolvedWithParameters = selectStoredResponsesQuery.replaceAll(RESPONSE_ID_PLACEHOLDER, - parameterHolders(responseIds.size())); + final String queryResolvedWithParameters = parametrizedQueryHelper.replaceStoredResponseIdPlaceholders( + selectStoredResponsesQuery, + responseIds.size()); final List idsQueryParameters = new ArrayList<>(); - IntStream.rangeClosed(1, StringUtils.countMatches(selectStoredResponsesQuery, RESPONSE_ID_PLACEHOLDER)) + final int responseIdPlaceholderCount = StringUtils.countMatches( + selectStoredResponsesQuery, + ParametrizedQueryHelper.RESPONSE_ID_PLACEHOLDER); + IntStream.rangeClosed(1, responseIdPlaceholderCount) .forEach(i -> idsQueryParameters.addAll(responseIds)); return jdbcClient.executeQuery(queryResolvedWithParameters, idsQueryParameters, @@ -208,12 +213,16 @@ private Future fetchStoredData(String query, String accountId, StoredDataResult.of(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList())); } else { final List idsQueryParameters = new ArrayList<>(); - IntStream.rangeClosed(1, StringUtils.countMatches(query, REQUEST_ID_PLACEHOLDER)) + IntStream.rangeClosed(1, StringUtils.countMatches(query, ParametrizedQueryHelper.REQUEST_ID_PLACEHOLDER)) .forEach(i -> idsQueryParameters.addAll(requestIds)); - IntStream.rangeClosed(1, StringUtils.countMatches(query, IMP_ID_PLACEHOLDER)) + IntStream.rangeClosed(1, StringUtils.countMatches(query, ParametrizedQueryHelper.IMP_ID_PLACEHOLDER)) .forEach(i -> idsQueryParameters.addAll(impIds)); - final String parametrizedQuery = createParametrizedQuery(query, requestIds.size(), impIds.size()); + final String parametrizedQuery = parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders( + query, + requestIds.size(), + impIds.size()); + future = jdbcClient.executeQuery(parametrizedQuery, idsQueryParameters, result -> JdbcStoredDataResultMapper.map(result, accountId, requestIds, impIds), timeout); @@ -221,25 +230,4 @@ private Future fetchStoredData(String query, String accountId, return future; } - - /** - * Creates parametrized query from query and variable templates, by replacing templateVariable - * with appropriate number of "?" placeholders. - */ - private static String createParametrizedQuery(String query, int requestIdsSize, int impIdsSize) { - return query - .replace(REQUEST_ID_PLACEHOLDER, parameterHolders(requestIdsSize)) - .replace(IMP_ID_PLACEHOLDER, parameterHolders(impIdsSize)); - } - - /** - * Returns string for parametrized placeholder. - */ - private static String parameterHolders(int paramsSize) { - return paramsSize == 0 - ? "NULL" - : IntStream.range(0, paramsSize) - .mapToObj(i -> QUERY_PARAM_PLACEHOLDER) - .collect(Collectors.joining(",")); - } } diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java b/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java index 6ea14d294d0..c7e9ec820f8 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java @@ -1,14 +1,15 @@ package org.prebid.server.settings.helper; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; -import org.apache.commons.collections4.CollectionUtils; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; import org.prebid.server.exception.PreBidException; import org.prebid.server.log.Logger; import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredDataType; import org.prebid.server.settings.model.StoredItem; +import org.prebid.server.util.ObjectUtil; import java.util.ArrayList; import java.util.Collections; @@ -19,7 +20,7 @@ import java.util.Set; /** - * Utility class for mapping {@link ResultSet} to {@link StoredDataResult}. + * Utility class for mapping {@link RowSet} to {@link StoredDataResult}. */ public class JdbcStoredDataResultMapper { @@ -29,9 +30,9 @@ private JdbcStoredDataResultMapper() { } /** - * Maps {@link ResultSet} to {@link StoredDataResult} and creates an error for each missing ID and add it to result. + * Maps {@link RowSet} to {@link StoredDataResult} and creates an error for each missing ID and add it to result. * - * @param resultSet - incoming Result Set representing a result of SQL query + * @param rowSet - incoming Row Set representing a result of SQL query * @param accountId - an account ID extracted from request * @param requestIds - a specified set of stored requests' IDs. Adds error for each ID missing in result set * @param impIds - a specified set of stored imps' IDs. Adds error for each ID missing in result set @@ -40,13 +41,17 @@ private JdbcStoredDataResultMapper() { * Note: mapper should never throws exception in case of using * {@link org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient}. */ - public static StoredDataResult map(ResultSet resultSet, String accountId, Set requestIds, + public static StoredDataResult map(RowSet rowSet, + String accountId, + Set requestIds, Set impIds) { final Map storedIdToRequest; final Map storedIdToImp; final List errors = new ArrayList<>(); - if (resultSet == null || CollectionUtils.isEmpty(resultSet.getResults())) { + final RowIterator rowIterator = rowSet != null ? rowSet.iterator() : null; + + if (rowIterator == null || !rowIterator.hasNext()) { storedIdToRequest = Collections.emptyMap(); storedIdToImp = Collections.emptyMap(); @@ -64,17 +69,24 @@ public static StoredDataResult map(ResultSet resultSet, String accountId, Set> requestIdToStoredItems = new HashMap<>(); final Map> impIdToStoredItems = new HashMap<>(); - for (JsonArray result : resultSet.getResults()) { + while (rowIterator.hasNext()) { + final Row row = rowIterator.next(); + if (row.toJson().size() < 4) { + final String message = "Error occurred while mapping stored request data: some columns are missing"; + logger.error(message); + errors.add(message); + return StoredDataResult.of(Collections.emptyMap(), Collections.emptyMap(), errors); + } final String fetchedAccountId; final String id; final String data; final String typeAsString; try { - fetchedAccountId = result.getString(0); - id = result.getString(1); - data = result.getString(2); - typeAsString = result.getString(3); - } catch (IndexOutOfBoundsException | ClassCastException e) { + fetchedAccountId = row.getString(0); + id = row.getString(1); + data = ObjectUtil.getIfNotNull(row.getValue(2), Object::toString); + typeAsString = ObjectUtil.getIfNotNull(row.getValue(3), Object::toString); + } catch (ClassCastException e) { final String message = "Error occurred while mapping stored request data"; logger.error(message, e); errors.add(message); @@ -109,10 +121,10 @@ public static StoredDataResult map(ResultSet resultSet, String accountId, Set} representing a result of SQL query. * @return - a {@link StoredDataResult} object. */ - public static StoredDataResult map(ResultSet resultSet) { + public static StoredDataResult map(RowSet resultSet) { return map(resultSet, null, Collections.emptySet(), Collections.emptySet()); } diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java b/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java index 4d6b5208cbd..6b6cc4462ae 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java @@ -1,8 +1,8 @@ package org.prebid.server.settings.helper; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; -import org.apache.commons.collections4.CollectionUtils; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; import org.prebid.server.settings.model.StoredResponseDataResult; import java.util.ArrayList; @@ -17,26 +17,29 @@ public class JdbcStoredResponseResultMapper { private JdbcStoredResponseResultMapper() { } - public static StoredResponseDataResult map(ResultSet resultSet, Set responseIds) { + public static StoredResponseDataResult map(RowSet rowSet, Set responseIds) { final Map storedIdToResponse = new HashMap<>(responseIds.size()); final List errors = new ArrayList<>(); - if (resultSet == null || CollectionUtils.isEmpty(resultSet.getResults())) { + final RowIterator rowIterator = rowSet != null ? rowSet.iterator() : null; + if (rowIterator == null || !rowIterator.hasNext()) { handleEmptyResultError(responseIds, errors); - } else { - try { - for (JsonArray result : resultSet.getResults()) { - storedIdToResponse.put(result.getString(0), result.getString(1)); - } - } catch (IndexOutOfBoundsException e) { + return StoredResponseDataResult.of(storedIdToResponse, errors); + } + + while (rowIterator.hasNext()) { + final Row row = rowIterator.next(); + if (row.toJson().size() < 2) { errors.add("Result set column number is less than expected"); return StoredResponseDataResult.of(Collections.emptyMap(), errors); } - errors.addAll(responseIds.stream().filter(id -> !storedIdToResponse.containsKey(id)) - .map(id -> "No stored response found for id: " + id) - .toList()); + storedIdToResponse.put(row.getString(0), row.getString(1)); } + errors.addAll(responseIds.stream().filter(id -> !storedIdToResponse.containsKey(id)) + .map(id -> "No stored response found for id: " + id) + .toList()); + return StoredResponseDataResult.of(storedIdToResponse, errors); } diff --git a/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryHelper.java b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryHelper.java new file mode 100644 index 00000000000..1d7660e0b76 --- /dev/null +++ b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryHelper.java @@ -0,0 +1,16 @@ +package org.prebid.server.settings.helper; + +public interface ParametrizedQueryHelper { + + String ACCOUNT_ID_PLACEHOLDER = "%ACCOUNT_ID%"; + String REQUEST_ID_PLACEHOLDER = "%REQUEST_ID_LIST%"; + String IMP_ID_PLACEHOLDER = "%IMP_ID_LIST%"; + String RESPONSE_ID_PLACEHOLDER = "%RESPONSE_ID_LIST%"; + + String replaceAccountIdPlaceholder(String query); + + String replaceStoredResponseIdPlaceholders(String query, int idsNumber); + + String replaceRequestAndImpIdPlaceholders(String query, int requestIdNumber, int impIdNumber); + +} diff --git a/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelper.java b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelper.java new file mode 100644 index 00000000000..e6e6336afc8 --- /dev/null +++ b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelper.java @@ -0,0 +1,34 @@ +package org.prebid.server.settings.helper; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class ParametrizedQueryMySqlHelper implements ParametrizedQueryHelper { + + private static final String PARAMETER_PLACEHOLDER = "?"; + + @Override + public String replaceAccountIdPlaceholder(String query) { + return query.replace(ACCOUNT_ID_PLACEHOLDER, PARAMETER_PLACEHOLDER); + } + + @Override + public String replaceStoredResponseIdPlaceholders(String query, int idsNumber) { + return query.replaceAll(RESPONSE_ID_PLACEHOLDER, parameterHolders(idsNumber)); + } + + @Override + public String replaceRequestAndImpIdPlaceholders(String query, int requestIdNumber, int impIdNumber) { + return query + .replace(REQUEST_ID_PLACEHOLDER, parameterHolders(requestIdNumber)) + .replace(IMP_ID_PLACEHOLDER, parameterHolders(impIdNumber)); + } + + private static String parameterHolders(int paramsSize) { + return paramsSize == 0 + ? "NULL" + : IntStream.range(0, paramsSize) + .mapToObj(i -> PARAMETER_PLACEHOLDER) + .collect(Collectors.joining(",")); + } +} diff --git a/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelper.java b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelper.java new file mode 100644 index 00000000000..c380b8e91df --- /dev/null +++ b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelper.java @@ -0,0 +1,45 @@ +package org.prebid.server.settings.helper; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class ParametrizedQueryPostgresHelper implements ParametrizedQueryHelper { + + private static final Pattern PLACEHOLDER_PATTERN = + Pattern.compile("(%s)|(%s)".formatted(REQUEST_ID_PLACEHOLDER, IMP_ID_PLACEHOLDER)); + + @Override + public String replaceAccountIdPlaceholder(String query) { + return query.replace(ACCOUNT_ID_PLACEHOLDER, "$1"); + } + + @Override + public String replaceStoredResponseIdPlaceholders(String query, int idsNumber) { + return query.replaceAll(RESPONSE_ID_PLACEHOLDER, parameterHolders(idsNumber, 0)); + } + + @Override + public String replaceRequestAndImpIdPlaceholders(String query, int requestIdNumber, int impIdNumber) { + final Matcher matcher = PLACEHOLDER_PATTERN.matcher(query); + + int i = 0; + final StringBuilder queryBuilder = new StringBuilder(); + while (matcher.find()) { + final int paramsNumber = matcher.group(1) != null ? requestIdNumber : impIdNumber; + matcher.appendReplacement(queryBuilder, parameterHolders(paramsNumber, i)); + i += paramsNumber; + } + matcher.appendTail(queryBuilder); + return queryBuilder.toString(); + } + + private static String parameterHolders(int paramsSize, int start) { + return paramsSize == 0 + ? "NULL" + : IntStream.range(start, start + paramsSize) + .mapToObj(i -> "\\$" + (i + 1)) + .collect(Collectors.joining(",")); + } +} diff --git a/src/main/java/org/prebid/server/spring/config/HealthCheckerConfiguration.java b/src/main/java/org/prebid/server/spring/config/HealthCheckerConfiguration.java index 9f6669141f8..93eaeb48030 100644 --- a/src/main/java/org/prebid/server/spring/config/HealthCheckerConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/HealthCheckerConfiguration.java @@ -1,7 +1,7 @@ package org.prebid.server.spring.config; import io.vertx.core.Vertx; -import io.vertx.ext.jdbc.JDBCClient; +import io.vertx.sqlclient.Pool; import org.prebid.server.execution.TimeoutFactory; import org.prebid.server.geolocation.GeoLocationService; import org.prebid.server.health.ApplicationChecker; @@ -24,10 +24,10 @@ public class HealthCheckerConfiguration { @Bean @ConditionalOnProperty(prefix = "health-check.database", name = "enabled", havingValue = "true") HealthChecker databaseChecker(Vertx vertx, - JDBCClient jdbcClient, + Pool pool, @Value("${health-check.database.refresh-period-ms}") long refreshPeriod) { - return new DatabaseHealthChecker(vertx, jdbcClient, refreshPeriod); + return new DatabaseHealthChecker(vertx, pool, refreshPeriod); } @Bean diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 5a6dcac39a5..4929a67fca4 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -21,6 +21,7 @@ import org.prebid.server.settings.HttpApplicationSettings; import org.prebid.server.settings.JdbcApplicationSettings; import org.prebid.server.settings.SettingsCache; +import org.prebid.server.settings.helper.ParametrizedQueryHelper; import org.prebid.server.settings.service.HttpPeriodicRefreshService; import org.prebid.server.settings.service.JdbcPeriodicRefreshService; import org.prebid.server.spring.config.database.DatabaseConfiguration; @@ -77,12 +78,14 @@ JdbcApplicationSettings jdbcApplicationSettings( @Value("${settings.database.stored-requests-query}") String storedRequestsQuery, @Value("${settings.database.amp-stored-requests-query}") String ampStoredRequestsQuery, @Value("${settings.database.stored-responses-query}") String storedResponsesQuery, + ParametrizedQueryHelper parametrizedQueryHelper, JdbcClient jdbcClient, JacksonMapper jacksonMapper) { return new JdbcApplicationSettings( jdbcClient, jacksonMapper, + parametrizedQueryHelper, accountQuery, storedRequestsQuery, ampStoredRequestsQuery, diff --git a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java index 065241e7aab..56f2f045245 100644 --- a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java @@ -1,9 +1,16 @@ package org.prebid.server.spring.config.database; import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; -import io.vertx.ext.jdbc.JDBCClient; +import io.vertx.mysqlclient.MySQLBuilder; +import io.vertx.mysqlclient.MySQLConnectOptions; +import io.vertx.pgclient.PgBuilder; +import io.vertx.pgclient.PgConnectOptions; +import io.vertx.sqlclient.Pool; +import io.vertx.sqlclient.PoolOptions; import org.prebid.server.metric.Metrics; +import org.prebid.server.settings.helper.ParametrizedQueryHelper; +import org.prebid.server.settings.helper.ParametrizedQueryMySqlHelper; +import org.prebid.server.settings.helper.ParametrizedQueryPostgresHelper; import org.prebid.server.spring.config.database.model.ConnectionPoolSettings; import org.prebid.server.spring.config.database.model.DatabaseAddress; import org.prebid.server.spring.config.database.properties.DatabaseConfigurationProperties; @@ -11,7 +18,6 @@ import org.prebid.server.vertx.ContextRunner; import org.prebid.server.vertx.jdbc.BasicJdbcClient; import org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient; -import org.prebid.server.vertx.jdbc.JdbcClient; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -21,48 +27,12 @@ import org.springframework.validation.annotation.Validated; import java.time.Clock; +import java.util.concurrent.TimeUnit; @Configuration @ConditionalOnExpression("'${settings.database.type}' == 'postgres' or '${settings.database.type}' == 'mysql'") public class DatabaseConfiguration { - @Bean - @ConditionalOnProperty(name = "settings.database.type", havingValue = "postgres") - DatabaseUrlFactory postgresUrlFactory() { - return "jdbc:postgresql://%s:%d/%s?ssl=false&socketTimeout=1&tcpKeepAlive=true"::formatted; - } - - @Bean - @ConditionalOnProperty(name = "settings.database.type", havingValue = "mysql") - DatabaseUrlFactory mySqlUrlFactory() { - return "jdbc:mysql://%s:%d/%s?useSSL=false&socketTimeout=1000&tcpKeepAlive=true"::formatted; - } - - @Bean - @ConditionalOnProperty(name = "settings.database.provider-class", havingValue = "hikari") - ConnectionPoolConfigurationFactory hikariConfigurationFactory() { - return (url, connectionPoolSettings) -> new JsonObject() - .put("jdbcUrl", url + "&allowPublicKeyRetrieval=true") - .put("username", connectionPoolSettings.getUser()) - .put("password", connectionPoolSettings.getPassword()) - .put("minimumIdle", connectionPoolSettings.getPoolSize()) - .put("maximumPoolSize", connectionPoolSettings.getPoolSize()) - .put("provider_class", "io.vertx.ext.jdbc.spi.impl.HikariCPDataSourceProvider"); - } - - @Bean - @ConditionalOnProperty(name = "settings.database.provider-class", havingValue = "c3p0") - ConnectionPoolConfigurationFactory c3p0ConfigurationFactory() { - return (url, connectionPoolSettings) -> new JsonObject() - .put("url", url) - .put("user", connectionPoolSettings.getUser()) - .put("password", connectionPoolSettings.getPassword()) - .put("initial_pool_size", connectionPoolSettings.getPoolSize()) - .put("min_pool_size", connectionPoolSettings.getPoolSize()) - .put("max_pool_size", connectionPoolSettings.getPoolSize()) - .put("provider_class", "io.vertx.ext.jdbc.spi.impl.C3P0DataSourceProvider"); - } - @Bean DatabaseAddress databaseAddress(DatabaseConfigurationProperties databaseConfigurationProperties) { return DatabaseAddress.of( @@ -81,31 +51,78 @@ ConnectionPoolSettings connectionPoolSettings(DatabaseConfigurationProperties da } @Bean - JDBCClient vertxJdbcClient(Vertx vertx, - DatabaseAddress databaseAddress, - ConnectionPoolSettings connectionPoolSettings, - DatabaseUrlFactory urlFactory, - ConnectionPoolConfigurationFactory configurationFactory) { - - final String databaseUrl = urlFactory.createUrl( - databaseAddress.getHost(), databaseAddress.getPort(), databaseAddress.getDatabaseName()); - - final JsonObject connectionPoolConfigurationProperties = configurationFactory.create( - databaseUrl, connectionPoolSettings); - final JsonObject databaseConfigurationProperties = new JsonObject() - .put("driver_class", connectionPoolSettings.getDatabaseType().jdbcDriver); - databaseConfigurationProperties.mergeIn(connectionPoolConfigurationProperties); - - return JDBCClient.createShared(vertx, databaseConfigurationProperties); + @ConfigurationProperties(prefix = "settings.database") + @Validated + public DatabaseConfigurationProperties databaseConfigurationProperties() { + return new DatabaseConfigurationProperties(); } @Bean - @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "false", - matchIfMissing = true) - BasicJdbcClient basicJdbcClient( - Vertx vertx, JDBCClient vertxJdbcClient, Metrics metrics, Clock clock, ContextRunner contextRunner) { + @ConditionalOnProperty(name = "settings.database.type", havingValue = "mysql") + ParametrizedQueryHelper mysqlParametrizedQueryHelper() { + return new ParametrizedQueryMySqlHelper(); + } + + @Bean + @ConditionalOnProperty(name = "settings.database.type", havingValue = "postgres") + ParametrizedQueryHelper postgresParametrizedQueryHelper() { + return new ParametrizedQueryPostgresHelper(); + } + + @Bean + @ConditionalOnProperty(name = "settings.database.type", havingValue = "mysql") + Pool mysqlConnectionPool(Vertx vertx, + DatabaseAddress databaseAddress, + ConnectionPoolSettings connectionPoolSettings) { + + final MySQLConnectOptions sqlConnectOptions = new MySQLConnectOptions() + .setHost(databaseAddress.getHost()) + .setPort(databaseAddress.getPort()) + .setDatabase(databaseAddress.getDatabaseName()) + .setUser(connectionPoolSettings.getUser()) + .setPassword(connectionPoolSettings.getPassword()) + .setSsl(false) + .setTcpKeepAlive(true) + .setIdleTimeout(1) + .setIdleTimeoutUnit(TimeUnit.SECONDS); + + final PoolOptions poolOptions = new PoolOptions() + .setMaxSize(connectionPoolSettings.getPoolSize()); + + return MySQLBuilder + .pool() + .with(poolOptions) + .connectingTo(sqlConnectOptions) + .using(vertx) + .build(); + } - return createBasicJdbcClient(vertx, vertxJdbcClient, metrics, clock, contextRunner); + @Bean + @ConditionalOnProperty(name = "settings.database.type", havingValue = "postgres") + Pool postgresConnectionPool(Vertx vertx, + DatabaseAddress databaseAddress, + ConnectionPoolSettings connectionPoolSettings) { + + final PgConnectOptions sqlConnectOptions = new PgConnectOptions() + .setHost(databaseAddress.getHost()) + .setPort(databaseAddress.getPort()) + .setDatabase(databaseAddress.getDatabaseName()) + .setUser(connectionPoolSettings.getUser()) + .setPassword(connectionPoolSettings.getPassword()) + .setSsl(false) + .setTcpKeepAlive(true) + .setIdleTimeout(1) + .setIdleTimeoutUnit(TimeUnit.SECONDS); + + final PoolOptions poolOptions = new PoolOptions() + .setMaxSize(connectionPoolSettings.getPoolSize()); + + return PgBuilder + .pool() + .with(poolOptions) + .connectingTo(sqlConnectOptions) + .using(vertx) + .build(); } @Bean @@ -115,35 +132,44 @@ CircuitBreakerProperties databaseCircuitBreakerProperties() { return new CircuitBreakerProperties(); } + @Bean + @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "false", + matchIfMissing = true) + BasicJdbcClient basicJdbcClient(Pool pool, Metrics metrics, Clock clock, ContextRunner contextRunner) { + + return createBasicJdbcClient(pool, metrics, clock, contextRunner); + } + @Bean @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "true") - CircuitBreakerSecuredJdbcClient circuitBreakerSecuredJdbcClient( + CircuitBreakerSecuredJdbcClient circuitBreakerSecuredAsyncDatabaseClient( Vertx vertx, - JDBCClient vertxJdbcClient, + Pool pool, Metrics metrics, Clock clock, ContextRunner contextRunner, @Qualifier("databaseCircuitBreakerProperties") CircuitBreakerProperties circuitBreakerProperties) { - final JdbcClient jdbcClient = createBasicJdbcClient(vertx, vertxJdbcClient, metrics, clock, contextRunner); - return new CircuitBreakerSecuredJdbcClient(vertx, jdbcClient, metrics, - circuitBreakerProperties.getOpeningThreshold(), circuitBreakerProperties.getOpeningIntervalMs(), - circuitBreakerProperties.getClosingIntervalMs(), clock); + final BasicJdbcClient jdbcClient = createBasicJdbcClient(pool, metrics, clock, contextRunner); + return new CircuitBreakerSecuredJdbcClient( + vertx, + jdbcClient, + metrics, + circuitBreakerProperties.getOpeningThreshold(), + circuitBreakerProperties.getOpeningIntervalMs(), + circuitBreakerProperties.getClosingIntervalMs(), + clock); } - private static BasicJdbcClient createBasicJdbcClient( - Vertx vertx, JDBCClient vertxJdbcClient, Metrics metrics, Clock clock, ContextRunner contextRunner) { - final BasicJdbcClient basicJdbcClient = new BasicJdbcClient(vertx, vertxJdbcClient, metrics, clock); + private static BasicJdbcClient createBasicJdbcClient(Pool pool, + Metrics metrics, + Clock clock, + ContextRunner contextRunner) { + + final BasicJdbcClient basicJdbcClient = new BasicJdbcClient(pool, metrics, clock); contextRunner.runBlocking(promise -> basicJdbcClient.initialize().onComplete(promise)); return basicJdbcClient; } - - @Bean - @ConfigurationProperties(prefix = "settings.database") - @Validated - public DatabaseConfigurationProperties databaseConfigurationProperties() { - return new DatabaseConfigurationProperties(); - } } diff --git a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java index 9988efbdb7f..6b6effa79a3 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java @@ -1,13 +1,11 @@ package org.prebid.server.vertx.jdbc; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.sql.ResultSet; -import io.vertx.ext.sql.SQLConnection; +import io.vertx.sqlclient.Pool; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowSet; +import io.vertx.sqlclient.SqlConnection; +import io.vertx.sqlclient.Tuple; import org.prebid.server.execution.Timeout; import org.prebid.server.log.Logger; import org.prebid.server.log.LoggerFactory; @@ -16,24 +14,23 @@ import java.time.Clock; import java.util.List; import java.util.Objects; +import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Function; /** - * Wrapper over {@link JDBCClient} that supports setting query timeout in milliseconds. + * Wrapper over {@link Pool} that supports setting query timeout in milliseconds. */ public class BasicJdbcClient implements JdbcClient { private static final Logger logger = LoggerFactory.getLogger(BasicJdbcClient.class); - private final Vertx vertx; - private final JDBCClient jdbcClient; + private final Pool pool; private final Metrics metrics; private final Clock clock; - public BasicJdbcClient(Vertx vertx, JDBCClient jdbcClient, Metrics metrics, Clock clock) { - this.vertx = Objects.requireNonNull(vertx); - this.jdbcClient = Objects.requireNonNull(jdbcClient); + public BasicJdbcClient(Pool pool, Metrics metrics, Clock clock) { + this.pool = Objects.requireNonNull(pool); this.metrics = Objects.requireNonNull(metrics); this.clock = Objects.requireNonNull(clock); } @@ -45,49 +42,41 @@ public BasicJdbcClient(Vertx vertx, JDBCClient jdbcClient, Metrics metrics, Cloc * Must be called on Vertx event loop thread. */ public Future initialize() { - final Promise connectionPromise = Promise.promise(); - jdbcClient.getConnection(connectionPromise); - return connectionPromise.future() + return pool.getConnection() .recover(BasicJdbcClient::logConnectionError) .mapEmpty(); } @Override - public Future executeQuery(String query, List params, Function mapper, + public Future executeQuery(String query, + List params, + Function, T> mapper, Timeout timeout) { + final long remainingTimeout = timeout.remaining(); if (remainingTimeout <= 0) { return Future.failedFuture(timeoutException()); } final long startTime = clock.millis(); - final Promise queryResultPromise = Promise.promise(); - - // timeout implementation is inspired by this answer: - // https://groups.google.com/d/msg/vertx/eSf3AQagGGU/K7pztnjLc_EJ - final long timerId = vertx.setTimer(remainingTimeout, id -> timedOutResult(queryResultPromise, startTime)); - final Promise connectionPromise = Promise.promise(); - jdbcClient.getConnection(connectionPromise); - connectionPromise.future() + return pool.getConnection() .recover(BasicJdbcClient::logConnectionError) .compose(connection -> makeQuery(connection, query, params)) - .onComplete(result -> handleResult(result, queryResultPromise, timerId, startTime)); - - return queryResultPromise.future().map(mapper); + .timeout(remainingTimeout, TimeUnit.MILLISECONDS) + .recover(this::handleFailure) + .onComplete(result -> metrics.updateDatabaseQueryTimeMetric(clock.millis() - startTime)) + .map(mapper); } - /** - * Fails result {@link Promise} with timeout exception. - */ - private void timedOutResult(Promise queryResultPromise, long startTime) { - // no need for synchronization since timer is fired on the same event loop thread - if (!queryResultPromise.future().isComplete()) { - metrics.updateDatabaseQueryTimeMetric(clock.millis() - startTime); - queryResultPromise.fail(timeoutException()); + private Future> handleFailure(Throwable throwable) { + if (throwable instanceof TimeoutException) { + return Future.failedFuture(timeoutException()); } + + return Future.failedFuture(throwable); } - private static Future logConnectionError(Throwable exception) { + private static Future logConnectionError(Throwable exception) { logger.warn("Cannot connect to database", exception); return Future.failedFuture(exception); } @@ -95,29 +84,8 @@ private static Future logConnectionError(Throwable exception) { /** * Performs query to DB. */ - private static Future makeQuery(SQLConnection connection, String query, List params) { - final Promise resultSetPromise = Promise.promise(); - connection.queryWithParams(query, new JsonArray(params), - ar -> { - connection.close(); - resultSetPromise.handle(ar); - }); - return resultSetPromise.future(); - } - - /** - * Propagates responded {@link ResultSet} (or failure) to result {@link Promise}. - */ - private void handleResult( - AsyncResult result, Promise queryResultPromise, long timerId, long startTime) { - - vertx.cancelTimer(timerId); - - // check is to avoid harmless exception if timeout exceeds before successful result becomes ready - if (!queryResultPromise.future().isComplete()) { - metrics.updateDatabaseQueryTimeMetric(clock.millis() - startTime); - queryResultPromise.handle(result); - } + private static Future> makeQuery(SqlConnection connection, String query, List params) { + return connection.preparedQuery(query).execute(Tuple.tuple(params)).onComplete(ignored -> connection.close()); } private static TimeoutException timeoutException() { diff --git a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java index fef375a741a..f85fa351941 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java @@ -2,7 +2,8 @@ import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.ext.sql.ResultSet; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowSet; import org.prebid.server.execution.Timeout; import org.prebid.server.log.ConditionalLogger; import org.prebid.server.log.Logger; @@ -57,7 +58,7 @@ public CircuitBreakerSecuredJdbcClient(Vertx vertx, @Override public Future executeQuery(String query, List params, - Function mapper, + Function, T> mapper, Timeout timeout) { return breaker.execute(promise -> jdbcClient.executeQuery(query, params, mapper, timeout).onComplete(promise)); diff --git a/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java index b447ea98dc9..3fc7754b038 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java @@ -1,7 +1,8 @@ package org.prebid.server.vertx.jdbc; import io.vertx.core.Future; -import io.vertx.ext.sql.ResultSet; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowSet; import org.prebid.server.execution.Timeout; import java.util.List; @@ -17,5 +18,5 @@ public interface JdbcClient { * Executes query with parameters and returns {@link Future} eventually holding result mapped to a model * object by provided mapper. */ - Future executeQuery(String query, List params, Function mapper, Timeout timeout); + Future executeQuery(String query, List params, Function, T> mapper, Timeout timeout); } diff --git a/src/test/java/org/prebid/server/health/DatabaseHealthCheckerTest.java b/src/test/java/org/prebid/server/health/DatabaseHealthCheckerTest.java index c4b3836aee2..1a26ea5bb2e 100644 --- a/src/test/java/org/prebid/server/health/DatabaseHealthCheckerTest.java +++ b/src/test/java/org/prebid/server/health/DatabaseHealthCheckerTest.java @@ -3,15 +3,13 @@ import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.Vertx; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.sql.SQLClient; +import io.vertx.sqlclient.Pool; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import org.mockito.stubbing.Answer; import org.prebid.server.health.model.StatusResponse; import java.time.Clock; @@ -38,50 +36,47 @@ public class DatabaseHealthCheckerTest { @Mock private Vertx vertx; @Mock - private JDBCClient jdbcClient; - @Mock - private SQLClient sqlClient; + private Pool pool; - private DatabaseHealthChecker databaseHealthCheck; + private DatabaseHealthChecker target; @Before public void setUp() { - databaseHealthCheck = new DatabaseHealthChecker(vertx, jdbcClient, TEST_REFRESH_PERIOD); + target = new DatabaseHealthChecker(vertx, pool, TEST_REFRESH_PERIOD); } @Test public void creationShouldFailWithNullArguments() { - assertThatNullPointerException().isThrownBy(() -> new DatabaseHealthChecker(null, jdbcClient, 0)); + assertThatNullPointerException().isThrownBy(() -> new DatabaseHealthChecker(null, pool, 0)); assertThatNullPointerException().isThrownBy(() -> new DatabaseHealthChecker(vertx, null, TEST_REFRESH_PERIOD)); } @Test public void creationShouldFailWhenRefreshPeriodIsZeroOrNegative() { - assertThatIllegalArgumentException().isThrownBy(() -> new DatabaseHealthChecker(vertx, jdbcClient, 0)); - assertThatIllegalArgumentException().isThrownBy(() -> new DatabaseHealthChecker(vertx, jdbcClient, -1)); + assertThatIllegalArgumentException().isThrownBy(() -> new DatabaseHealthChecker(vertx, pool, 0)); + assertThatIllegalArgumentException().isThrownBy(() -> new DatabaseHealthChecker(vertx, pool, -1)); } @Test public void getCheckNameShouldReturnExpectedResult() { - assertThat(databaseHealthCheck.name()).isEqualTo(DATABASE_CHECK_NAME); + assertThat(target.name()).isEqualTo(DATABASE_CHECK_NAME); } @Test public void getLastStatusShouldReturnNullStatusIfCheckWasNotInitialized() { - assertThat(databaseHealthCheck.status()).isNull(); + assertThat(target.status()).isNull(); } @Test public void getLastStatusShouldReturnStatusUpAndLastUpdatedAfterTestTime() { // given - given(jdbcClient.getConnection(any())) - .willAnswer(withSelfAndPassObjectToHandler(0, sqlClient, Future.succeededFuture())); + given(pool.getConnection()).willReturn(Future.succeededFuture()); // when - databaseHealthCheck.updateStatus(); + target.updateStatus(); // then - final StatusResponse lastStatus = databaseHealthCheck.status(); + final StatusResponse lastStatus = target.status(); assertThat(lastStatus.getStatus()).isEqualTo("UP"); assertThat(lastStatus.getLastUpdated()).isAfter(TEST_TIME_STRING); } @@ -89,14 +84,13 @@ public void getLastStatusShouldReturnStatusUpAndLastUpdatedAfterTestTime() { @Test public void getLastStatusShouldReturnStatusDownAndLastUpdatedAfterTestTime() { // given - given(jdbcClient.getConnection(any())) - .willAnswer(withSelfAndPassObjectToHandler(0, sqlClient, Future.failedFuture("fail"))); + given(pool.getConnection()).willReturn(Future.failedFuture("fail")); // when - databaseHealthCheck.updateStatus(); + target.updateStatus(); // then - final StatusResponse lastStatus = databaseHealthCheck.status(); + final StatusResponse lastStatus = target.status(); assertThat(lastStatus.getStatus()).isEqualTo("DOWN"); assertThat(lastStatus.getLastUpdated()).isAfter(TEST_TIME_STRING); } @@ -104,26 +98,18 @@ public void getLastStatusShouldReturnStatusDownAndLastUpdatedAfterTestTime() { @Test public void initializeShouldMakeOneInitialRequestAndTwoScheduledRequests() { // given - given(vertx.setPeriodic(anyLong(), any())) - .willAnswer(withSelfAndPassObjectToHandler(1, 0L, 1L, 2L)); - given(jdbcClient.getConnection(any())) - .willAnswer(withSelfAndPassObjectToHandler(0, sqlClient, Future.succeededFuture())); + given(vertx.setPeriodic(anyLong(), any())).willAnswer(inv -> { + final Handler handler = inv.getArgument(1); + handler.handle(1L); + handler.handle(2L); + return 0L; + }); + given(pool.getConnection()).willReturn(Future.succeededFuture()); // when - databaseHealthCheck.initialize(); + target.initialize(); // then - verify(jdbcClient, times(3)).getConnection(any()); - } - - @SuppressWarnings("unchecked") - private Answer withSelfAndPassObjectToHandler(int arg, Object result, T... objects) { - return inv -> { - // invoking handler right away passing mock to it - for (T obj : objects) { - ((Handler) inv.getArgument(arg)).handle(obj); - } - return result; - }; + verify(pool, times(3)).getConnection(); } } diff --git a/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java b/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java index 5d6b3584a50..946a62d81b3 100644 --- a/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java +++ b/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; -import com.mchange.util.AssertException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -52,7 +51,7 @@ public void deserializeShouldThrowExceptionOnWrongJsonToken() throws IOException // given given(parser.getCurrentToken()).willReturn(JsonToken.VALUE_FALSE); given(parser.getCurrentName()).willReturn("FIELD"); - doThrow(AssertException.class) + doThrow(RuntimeException.class) .when(context) .reportWrongTokenException( eq(JsonToken.class), @@ -60,7 +59,7 @@ public void deserializeShouldThrowExceptionOnWrongJsonToken() throws IOException eq("Failed to parse field FIELD to array with a reason: Expected array.")); // when and then - assertThatExceptionOfType(AssertException.class) + assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> target.deserialize(parser, context)); } diff --git a/src/test/java/org/prebid/server/json/deserializer/CommaSeparatedStringAsListOfIntegersDeserializerTest.java b/src/test/java/org/prebid/server/json/deserializer/CommaSeparatedStringAsListOfIntegersDeserializerTest.java index 3677135e632..3a12f27e5ca 100644 --- a/src/test/java/org/prebid/server/json/deserializer/CommaSeparatedStringAsListOfIntegersDeserializerTest.java +++ b/src/test/java/org/prebid/server/json/deserializer/CommaSeparatedStringAsListOfIntegersDeserializerTest.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; -import com.mchange.util.AssertException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -44,7 +43,7 @@ public void deserializeShouldThrowExceptionOnWrongJsonToken() throws IOException // given given(parser.getCurrentToken()).willReturn(JsonToken.VALUE_FALSE); given(parser.getCurrentName()).willReturn("FIELD"); - doThrow(AssertException.class) + doThrow(RuntimeException.class) .when(context) .reportWrongTokenException( eq(JsonToken.class), @@ -54,7 +53,7 @@ public void deserializeShouldThrowExceptionOnWrongJsonToken() throws IOException Expected comma-separated string.""")); // when and then - assertThatExceptionOfType(AssertException.class) + assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> commaSeparatedStringAsListOfIntegersDeserializer.deserialize(parser, context)); } @@ -64,7 +63,7 @@ public void deserializeShouldThrowExceptionOnNullValue() throws IOException { given(parser.getCurrentToken()).willReturn(JsonToken.VALUE_STRING); given(parser.getValueAsString()).willReturn(null); given(parser.getCurrentName()).willReturn("FIELD"); - doThrow(AssertException.class) + doThrow(RuntimeException.class) .when(context) .reportWrongTokenException( eq(JsonToken.class), @@ -74,7 +73,7 @@ public void deserializeShouldThrowExceptionOnNullValue() throws IOException { Expected comma-separated string.""")); // when and then - assertThatExceptionOfType(AssertException.class) + assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> commaSeparatedStringAsListOfIntegersDeserializer.deserialize(parser, context)); } @@ -84,7 +83,7 @@ public void deserializeShouldThrowExceptionOnInvalidValue() throws IOException { given(parser.getCurrentToken()).willReturn(JsonToken.VALUE_STRING); given(parser.getValueAsString()).willReturn("invalid"); given(parser.getCurrentName()).willReturn("FIELD"); - doThrow(AssertException.class) + doThrow(RuntimeException.class) .when(context) .reportPropertyInputMismatch( eq(JsonToken.class), @@ -94,7 +93,7 @@ public void deserializeShouldThrowExceptionOnInvalidValue() throws IOException { NumberFormatException""")); // when and then - assertThatExceptionOfType(AssertException.class) + assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> commaSeparatedStringAsListOfIntegersDeserializer.deserialize(parser, context)); } diff --git a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java index b53b6943324..1871046b5d6 100644 --- a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java @@ -1,16 +1,8 @@ package org.prebid.server.settings; import io.vertx.core.Future; -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.unit.Async; -import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,45 +13,26 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.Timeout; import org.prebid.server.execution.TimeoutFactory; -import org.prebid.server.metric.Metrics; -import org.prebid.server.metric.model.AccountMetricsVerbosityLevel; +import org.prebid.server.settings.helper.ParametrizedQueryHelper; import org.prebid.server.settings.model.Account; -import org.prebid.server.settings.model.AccountAnalyticsConfig; -import org.prebid.server.settings.model.AccountAuctionConfig; -import org.prebid.server.settings.model.AccountAuctionEventConfig; -import org.prebid.server.settings.model.AccountBidValidationConfig; -import org.prebid.server.settings.model.AccountCookieSyncConfig; -import org.prebid.server.settings.model.AccountCoopSyncConfig; -import org.prebid.server.settings.model.AccountEventsConfig; -import org.prebid.server.settings.model.AccountGdprConfig; -import org.prebid.server.settings.model.AccountMetricsConfig; -import org.prebid.server.settings.model.AccountPrivacyConfig; -import org.prebid.server.settings.model.AccountStatus; -import org.prebid.server.settings.model.BidValidationEnforcement; -import org.prebid.server.settings.model.EnabledForRequestType; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredResponseDataResult; -import org.prebid.server.vertx.jdbc.BasicJdbcClient; import org.prebid.server.vertx.jdbc.JdbcClient; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; import java.time.Clock; import java.time.Instant; import java.time.ZoneId; -import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; @RunWith(VertxUnitRunner.class) public class JdbcApplicationSettingsTest extends VertxTest { @@ -67,8 +40,6 @@ public class JdbcApplicationSettingsTest extends VertxTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); - private static final String JDBC_URL = "jdbc:h2:mem:test"; - private static final String SELECT_ACCOUNT_QUERY = "SELECT config FROM accounts_account where uuid = %ACCOUNT_ID% LIMIT 1"; @@ -79,578 +50,227 @@ public class JdbcApplicationSettingsTest extends VertxTest { + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + "WHERE impid IN (%IMP_ID_LIST%)"; - private static final String SELECT_UNION_QUERY = - "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " - + "WHERE reqid IN (%REQUEST_ID_LIST%) " - + "UNION ALL " - + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " - + "WHERE reqid IN (%REQUEST_ID_LIST%) " - + "UNION ALL " - + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " - + "WHERE impid IN (%IMP_ID_LIST%) " - + "UNION ALL " - + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " - + "WHERE impid IN (%IMP_ID_LIST%)"; - - private static final String SELECT_FROM_ONE_COLUMN_TABLE_QUERY = "SELECT reqid FROM one_column_table " - + "WHERE reqid IN (%REQUEST_ID_LIST%)"; - private static final String SELECT_RESPONSE_QUERY = "SELECT responseId, responseData FROM stored_responses " + "WHERE responseId IN (%RESPONSE_ID_LIST%)"; - private static final String SELECT_ONE_COLUMN_RESPONSE_QUERY = "SELECT responseId FROM stored_responses " - + "WHERE responseId IN (%RESPONSE_ID_LIST%)"; - - private static Connection connection; - - private Vertx vertx; @Mock - private Metrics metrics; + private ParametrizedQueryHelper parametrizedQueryHelper; - private Clock clock; + @Mock + private JdbcClient jdbcClient; - private JdbcApplicationSettings jdbcApplicationSettings; + private JdbcApplicationSettings target; private Timeout timeout; - @BeforeClass - public static void beforeClass() throws SQLException { - connection = DriverManager.getConnection(JDBC_URL); - connection.createStatement().execute( - "CREATE TABLE accounts_account (" - + "id SERIAL PRIMARY KEY, " - + "uuid varchar(40) NOT NULL, " - + "config varchar(4096)" - + ");"); - connection.createStatement().execute("CREATE TABLE stored_requests (id SERIAL PRIMARY KEY, " - + "accountId varchar(40) NOT NULL, reqid varchar(40) NOT NULL, requestData varchar(512));"); - connection.createStatement().execute("CREATE TABLE stored_requests2 (id SERIAL PRIMARY KEY, " - + "accountId varchar(40) NOT NULL, reqid varchar(40) NOT NULL, requestData varchar(512));"); - connection.createStatement().execute("CREATE TABLE stored_imps (id SERIAL PRIMARY KEY, " - + "accountId varchar(40) NOT NULL, impid varchar(40) NOT NULL, impData varchar(512));"); - connection.createStatement().execute("CREATE TABLE stored_imps2 (id SERIAL PRIMARY KEY, " - + "accountId varchar(40) NOT NULL, impid varchar(40) NOT NULL, impData varchar(512));"); - connection.createStatement().execute( - "CREATE TABLE stored_responses (id SERIAL PRIMARY KEY, responseId varchar(40) NOT NULL," - + " responseData varchar(512));"); - connection.createStatement().execute("CREATE TABLE one_column_table (id SERIAL PRIMARY KEY, reqid " - + "varchar(40) NOT NULL);"); - connection.createStatement().execute("insert into accounts_account (uuid, config) values (" - + "'1001'," - + "'{" - + "\"id\": \"1001\"," - + "\"status\": \"active\"," - + "\"auction\": {" - + "\"price-granularity\": \"med\"," - + "\"debug-allow\": true," - + "\"banner-cache-ttl\": 100," - + "\"video-cache-ttl\": 100," - + "\"truncate-target-attr\": 0," - + "\"default-integration\": \"web\"," - + "\"bid-validations\": {" - + "\"banner-creative-max-size\": \"enforce\"" - + "}," - + "\"events\": {" - + "\"enabled\": true" - + "}" - + "}," - + "\"privacy\": {" - + "\"gdpr\": {" - + "\"enabled\": true," - + "\"channel-enabled\": {\"amp\": true, \"app\": true, \"video\": true, \"web\": true, \"dooh\": true}" - + "}" - + "}," - + "\"metrics\": {\"verbosity-level\": \"detailed\"}," - + "\"analytics\": {" - + "\"auction-events\": {\"amp\": true}," - + "\"modules\": {\"some-analytics\": {\"supported-endpoints\": [\"auction\"]}}" - + "}," - + "\"cookie-sync\": {" - + "\"default-limit\": 5," - + "\"max-limit\": 8," - + "\"coop-sync\": {" - + "\"default\": true" - + "}" - + "}" - + "}'" - + ");"); - connection.createStatement().execute( - "insert into stored_requests (accountId, reqid, requestData) values ('1001', '1','value1');"); - connection.createStatement().execute( - "insert into stored_requests (accountId, reqid, requestData) values ('1001', '2','value2');"); - connection.createStatement().execute( - "insert into stored_requests2 (accountId, reqid, requestData) values ('1001', '3','value3');"); - connection.createStatement().execute( - "insert into stored_imps (accountId, impid, impData) values ('1001', '4','value4');"); - connection.createStatement().execute( - "insert into stored_imps (accountId, impid, impData) values ('1001', '5','value5');"); - connection.createStatement().execute( - "insert into stored_imps2 (accountId, impid, impData) values ('1001', '6','value6');"); - connection.createStatement().execute( - "insert into stored_responses (responseId, responseData) " - + "values ('1', 'response1');"); - connection.createStatement().execute( - "insert into stored_responses (responseId, responseData) " - + "values ('2', 'response2');"); - connection.createStatement().execute( - "insert into one_column_table (reqid) values ('3');"); - } - - @AfterClass - public static void afterClass() throws SQLException { - connection.close(); - } - @Before public void setUp() { - vertx = Vertx.vertx(); - clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); - timeout = new TimeoutFactory(clock).create(5000L); - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), + timeout = new TimeoutFactory(Clock.fixed(Instant.now(), ZoneId.systemDefault())).create(5000L); + given(parametrizedQueryHelper.replaceAccountIdPlaceholder(SELECT_ACCOUNT_QUERY)).willReturn("query"); + target = new JdbcApplicationSettings( + jdbcClient, jacksonMapper, + parametrizedQueryHelper, SELECT_ACCOUNT_QUERY, SELECT_QUERY, SELECT_QUERY, SELECT_RESPONSE_QUERY); } - @After - public void tearDown(TestContext context) { - vertx.close(context.asyncAssertSuccess()); - } - @Test - public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getAccountById("1001", timeout); - - // then - final Async async = context.async(); - final AccountAuctionEventConfig expectedEventsConfig = AccountAuctionEventConfig.builder().build(); - expectedEventsConfig.addEvent("amp", true); - future.onComplete(context.asyncAssertSuccess(account -> { - assertThat(account).isEqualTo(Account.builder() - .id("1001") - .status(AccountStatus.active) - .metrics(AccountMetricsConfig.of(AccountMetricsVerbosityLevel.detailed)) - .auction(AccountAuctionConfig.builder() - .priceGranularity("med") - .bannerCacheTtl(100) - .videoCacheTtl(100) - .truncateTargetAttr(0) - .defaultIntegration("web") - .debugAllow(true) - .bidValidations(AccountBidValidationConfig.of(BidValidationEnforcement.enforce)) - .events(AccountEventsConfig.of(true)) - .build()) - .privacy(AccountPrivacyConfig.builder() - .gdpr(AccountGdprConfig.builder() - .enabled(true) - .enabledForRequestType(EnabledForRequestType.of(true, true, true, true, true)) - .build()) - .build()) - .analytics(AccountAnalyticsConfig.of( - expectedEventsConfig, - singletonMap( - "some-analytics", - mapper.createObjectNode() - .set("supported-endpoints", mapper.createArrayNode().add("auction"))))) - .cookieSync(AccountCookieSyncConfig.of(5, 8, null, AccountCoopSyncConfig.of(true))) - .build()); - async.complete(); - })); - } - - @Test - public void getAccountByIdShouldFailIfAccountNotFound(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getAccountById("non-existing", timeout); - - // then - final Async async = context.async(); - future.onComplete(context.asyncAssertFailure(exception -> { - assertThat(exception).isInstanceOf(PreBidException.class) - .hasMessage("Account not found: non-existing"); - async.complete(); - })); - } - - @Test - public void getStoredDataShouldReturnExpectedResult(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getStoredData( - "1001", new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); - - // then - final Async async = context.async(); - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - final Map expectedImps = new HashMap<>(); - expectedImps.put("4", "value4"); - expectedImps.put("5", "value5"); - future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult) - .isEqualTo(StoredDataResult.of(expectedRequests, expectedImps, emptyList())); - async.complete(); - })); - } - - @Test - public void getAmpStoredDataShouldReturnExpectedResult(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getAmpStoredData( - "1001", new HashSet<>(asList("1", "2")), new HashSet<>(asList("3", "4")), timeout); - - // then - final Async async = context.async(); - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult) - .isEqualTo(StoredDataResult.of(expectedRequests, emptyMap(), emptyList())); - async.complete(); - })); - } - - @Test - public void getVideoStoredDataShouldReturnExpectedResult(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getVideoStoredData("1001", - new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); - - // then - final Async async = context.async(); - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - final Map expectedImps = new HashMap<>(); - expectedImps.put("4", "value4"); - expectedImps.put("5", "value5"); - future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult) - .isEqualTo(StoredDataResult.of(expectedRequests, expectedImps, emptyList())); - async.complete(); - })); - } - - @Test - public void getVideoStoredDataShouldReturnStoredRequests(TestContext context) { + public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_UNION_QUERY, - SELECT_UNION_QUERY, - SELECT_RESPONSE_QUERY); + final Account givenAccount = Account.builder().build(); + given(jdbcClient.executeQuery( + eq("query"), + eq(List.of("1001")), + any(), + eq(timeout))) + .willReturn(Future.succeededFuture(givenAccount)); // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getVideoStoredData("1001", new HashSet<>(asList("1", "2", "3")), - new HashSet<>(asList("4", "5", "6")), timeout); + final Future future = target.getAccountById("1001", timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - expectedRequests.put("3", "value3"); - final Map expectedImps = new HashMap<>(); - expectedImps.put("4", "value4"); - expectedImps.put("5", "value5"); - expectedImps.put("6", "value6"); - assertThat(storedRequestResult).isEqualTo( - StoredDataResult.of(expectedRequests, expectedImps, emptyList())); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenAccount); } @Test - public void getStoredDataUnionSelectByIdShouldReturnStoredRequests(TestContext context) { + public void getAccountByIdShouldFailIfAccountNotFound() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_UNION_QUERY, - SELECT_UNION_QUERY, - SELECT_RESPONSE_QUERY); + given(jdbcClient.executeQuery( + eq("query"), + eq(List.of("non-existing")), + any(), + eq(timeout))) + .willReturn(Future.succeededFuture(null)); // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", new HashSet<>(asList("1", "2", "3")), - new HashSet<>(asList("4", "5", "6")), timeout); + final Future future = target.getAccountById("non-existing", timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - expectedRequests.put("3", "value3"); - final Map expectedImps = new HashMap<>(); - expectedImps.put("4", "value4"); - expectedImps.put("5", "value5"); - expectedImps.put("6", "value6"); - assertThat(storedRequestResult).isEqualTo( - StoredDataResult.of(expectedRequests, expectedImps, emptyList())); - async.complete(); - })); + assertThat(future.failed()).isTrue(); + assertThat(future.cause()).hasMessage("Account not found: non-existing"); } @Test - public void getAmpStoredDataUnionSelectByIdShouldReturnStoredRequests(TestContext context) { + public void getStoredDataShouldReturnExpectedResult() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_UNION_QUERY, - SELECT_UNION_QUERY, - SELECT_RESPONSE_QUERY); + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 2)) + .willReturn("query"); - // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", new HashSet<>(asList("1", "2", "3")), - new HashSet<>(asList("4", "5", "6")), timeout); - - // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - expectedRequests.put("3", "value3"); - assertThat(storedRequestResult).isEqualTo( - StoredDataResult.of(expectedRequests, emptyMap(), emptyList())); - async.complete(); - })); - } + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1", "2", "value2"), + Map.of("4", "value4", "5", "value5"), + emptyList()); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - @Test - public void getStoredDataShouldReturnResultWithErrorIfNoStoredRequestFound(TestContext context) { // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), timeout); + final Future future = target.getStoredData( + "1001", new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), - singletonList("No stored request found for id: 3"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getStoredDataShouldReturnResultWithErrorIfNoStoredImpFound(TestContext context) { - // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", emptySet(), new HashSet<>(asList("4", "6")), timeout); + public void getAmpStoredDataShouldReturnExpectedResult() { + // given + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 0)) + .willReturn("query"); - // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), singletonMap("4", "value4"), - singletonList("No stored imp found for id: 6"))); - async.complete(); - })); - } + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1", "2", "value2"), + Map.of(), + emptyList()); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - @Test - public void getAmpStoredDataShouldReturnResultWithErrorIfNoStoredRequestFound(TestContext context) { // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), - timeout); + final Future future = target.getAmpStoredData( + "1001", new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), - singletonList("No stored request found for id: 3"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getStoredDataShouldReturnErrorIfResultContainsLessColumnsThanExpected(TestContext context) { + public void getVideoStoredDataShouldReturnExpectedResult() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_FROM_ONE_COLUMN_TABLE_QUERY, - SELECT_FROM_ONE_COLUMN_TABLE_QUERY, - SELECT_RESPONSE_QUERY); + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 2)) + .willReturn("query"); + + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1", "2", "value2"), + Map.of("4", "value4", "5", "value5"), + emptyList()); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", new HashSet<>(asList("1", "2", "3")), emptySet(), - timeout); + final Future future = target.getVideoStoredData("1001", + new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), - singletonList("Error occurred while mapping stored request data"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getAmpStoredDataShouldReturnErrorIfResultContainsLessColumnsThanExpected(TestContext context) { + public void getStoredDataShouldReturnResultWithError() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_FROM_ONE_COLUMN_TABLE_QUERY, - SELECT_FROM_ONE_COLUMN_TABLE_QUERY, - SELECT_RESPONSE_QUERY); + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 0)) + .willReturn("query"); - // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", new HashSet<>(asList("1", "2", "3")), emptySet(), - timeout); + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1"), + Map.of(), + List.of("No stored request found for id: 3")); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), - singletonList("Error occurred while mapping stored request data"))); - async.complete(); - })); - } - - @Test - public void getStoredDataShouldReturnErrorAndEmptyResult(TestContext context) { // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", new HashSet<>(asList("3", "4")), - new HashSet<>(asList("6", "7")), timeout); + final Future future = + target.getStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), - singletonList("No stored requests for ids [3, 4] and stored imps for ids [6, 7] were found"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getAmpStoredDataShouldReturnErrorAndEmptyResult(TestContext context) { - // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", new HashSet<>(asList("3", "4")), emptySet(), - timeout); + public void getAmpStoredDataShouldReturnResultWithError() { + // given + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 0)) + .willReturn("query"); - // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), - singletonList("No stored requests for ids [3, 4] were found"))); - async.complete(); - })); - } + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1"), + Map.of(), + List.of("No stored request found for id: 3")); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - @Test - public void getAmpStoredDataShouldIgnoreImpIdsArgument(TestContext context) { // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", singleton("1"), singleton("4"), timeout); + final Future future = + target.getAmpStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), - emptyList())); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getStoredResponseShouldReturnExpectedResult(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getStoredResponses( - new HashSet<>(asList("1", "2")), timeout); + public void getVideoStoredDataShouldReturnResultWithError() { + // given + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 0)) + .willReturn("query"); - // then - final Async async = context.async(); - final Map expectedResponses = new HashMap<>(); - expectedResponses.put("1", "response1"); - expectedResponses.put("2", "response2"); - - future.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { - assertThat(storedResponseDataResult) - .isEqualTo(StoredResponseDataResult.of(expectedResponses, emptyList())); - async.complete(); - })); - } + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1"), + Map.of(), + List.of("No stored request found for id: 3")); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - @Test - public void getStoredResponseShouldReturnResultWithErrorIfNotAllStoredResponsesWereFound(TestContext context) { // when - final Future storedResponseDataResultFuture = - jdbcApplicationSettings.getStoredResponses(new HashSet<>(asList("1", "3")), timeout); + final Future future = + target.getVideoStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), timeout); // then - final Async async = context.async(); - storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { - assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(singletonMap("1", "response1"), - singletonList("No stored response found for id: 3"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getStoredResponseShouldReturnErrorIfResultContainsLessColumnsThanExpected(TestContext context) { + public void getStoredResponseShouldReturnExpectedResult() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_QUERY, - SELECT_QUERY, - SELECT_ONE_COLUMN_RESPONSE_QUERY); + given(parametrizedQueryHelper.replaceStoredResponseIdPlaceholders(SELECT_RESPONSE_QUERY, 2)) + .willReturn("query"); - // when - final Future storedResponseDataResultFuture = - jdbcApplicationSettings.getStoredResponses(new HashSet<>(asList("1", "2", "3")), timeout); + final StoredResponseDataResult givenStoredResponseResult = StoredResponseDataResult.of( + Map.of("1", "response1"), + List.of("No stored response found for id: 2")); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredResponseResult)); - // then - final Async async = context.async(); - storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { - assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(emptyMap(), - singletonList("Result set column number is less than expected"))); - async.complete(); - })); - } - - @Test - public void getStoredResponseShouldReturnErrorAndEmptyResult(TestContext context) { // when - final Future storedResponseDataResultFuture = - jdbcApplicationSettings.getStoredResponses(new HashSet<>(asList("3", "4")), timeout); + final Future future = target.getStoredResponses( + new HashSet<>(asList("1", "2")), timeout); // then - final Async async = context.async(); - storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { - assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(emptyMap(), - singletonList("No stored responses were found for ids: 3,4"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredResponseResult); } @Test public void getCategoriesShouldReturnFailedFutureWithUnsupportedPrebidException() { // given and when - final Future> result = jdbcApplicationSettings.getCategories("adServer", "publisher", + final Future> result = target.getCategories("adServer", "publisher", timeout); // then @@ -658,14 +278,4 @@ public void getCategoriesShouldReturnFailedFutureWithUnsupportedPrebidException( assertThat(result.cause()).isInstanceOf(PreBidException.class) .hasMessage("Not supported"); } - - private JdbcClient jdbcClient() { - return new BasicJdbcClient(vertx, JDBCClient.createShared(vertx, - new JsonObject() - .put("jdbcUrl", JDBC_URL) - .put("driver_class", "org.h2.Driver") - .put("max_pool_size", 10) - .put("provider_class", "io.vertx.ext.jdbc.spi.impl.HikariCPDataSourceProvider")), - metrics, clock); - } } diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java index e10cd145d78..305335705d3 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java @@ -1,7 +1,10 @@ package org.prebid.server.settings.helper; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; +import io.vertx.core.json.JsonObject; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; +import lombok.Value; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; @@ -9,14 +12,17 @@ import org.mockito.junit.MockitoRule; import org.prebid.server.settings.model.StoredDataResult; -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.IntStream; + import static java.util.Collections.emptySet; import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; public class JdbcStoredDataResultMapperTest { @@ -24,15 +30,15 @@ public class JdbcStoredDataResultMapperTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private ResultSet resultSet; + private RowSet rowSet; @Test public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, null, emptySet(), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet, null, emptySet(), emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -44,11 +50,14 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult @Test public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResultForGivenIds() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, null, - singleton("reqId"), singleton("impId")); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + null, + singleton("reqId"), + singleton("impId")); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -60,29 +69,33 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult @Test public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasLessColumns() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data")))); + givenRowSet(givenRow("accountId", "id1", "data")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", - singleton("reqId"), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("reqId"), + emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); assertThat(result.getStoredIdToImp()).isEmpty(); assertThat(result.getErrors()).hasSize(1) - .containsOnly("Error occurred while mapping stored request data"); + .containsOnly("Error occurred while mapping stored request data: some columns are missing"); } @Test public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedColumnType() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data", 123)))); + givenRowSet(givenRow("accountId", "id1", "data", 123)); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", - singleton("reqId"), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("reqId"), + emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -94,13 +107,16 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedC @Test public void mapShouldSkipStoredResultWithInvalidType() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data1", "request")), - new JsonArray(asList("accountId", "id1", "data2", "invalid")))); + givenRowSet( + givenRow("accountId", "id1", "data1", "request"), + givenRow("accountId", "id1", "data2", "invalid")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", - singleton("id1"), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("id1"), + emptySet()); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -112,11 +128,13 @@ public void mapShouldSkipStoredResultWithInvalidType() { @Test public void mapShouldReturnStoredResultWithErrorForMissingId() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data1", "request")))); + givenRowSet(givenRow("accountId", "id1", "data1", "request")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", singleton("id1"), + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("id1"), singleton("id2")); // then @@ -130,13 +148,16 @@ public void mapShouldReturnStoredResultWithErrorForMissingId() { @Test public void mapShouldReturnEmptyStoredResultWithErrorsForMissingIdsIfAccountDiffers() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data1", "request")), - new JsonArray(asList("accountId", "id2", "data2", "imp")))); + givenRowSet( + givenRow("accountId", "id1", "data1", "request"), + givenRow("accountId", "id2", "data2", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "otherAccountId", - singleton("id1"), singleton("id2")); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "otherAccountId", + singleton("id1"), + singleton("id2")); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -150,13 +171,16 @@ public void mapShouldReturnEmptyStoredResultWithErrorsForMissingIdsIfAccountDiff @Test public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundButNoAccountIdIsDefined() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId1", "id1", "data1", "request")), - new JsonArray(asList("accountId2", "id1", "data2", "request")))); + givenRowSet( + givenRow("accountId1", "id1", "data1", "request"), + givenRow("accountId2", "id1", "data2", "request")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, null, - singleton("id1"), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + null, + singleton("id1"), + emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -168,15 +192,18 @@ public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundB @Test public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundButNoAccountIdIsDiffers() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId1", "id1", "data-accountId", "request")), - new JsonArray(asList("accountId2", "id1", "data-otherAccountId", "request")), - new JsonArray(asList("accountId1", "id2", "data-accountId", "imp")), - new JsonArray(asList("accountId2", "id2", "data-otherAccountId", "imp")))); + givenRowSet( + givenRow("accountId1", "id1", "data-accountId", "request"), + givenRow("accountId2", "id1", "data-otherAccountId", "request"), + givenRow("accountId1", "id2", "data-accountId", "imp"), + givenRow("accountId2", "id2", "data-otherAccountId", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "otherAccountId", - singleton("id1"), singleton("id2")); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "otherAccountId", + singleton("id1"), + singleton("id2")); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -190,15 +217,18 @@ public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundB @Test public void mapShouldReturnExpectedStoredResultForGivenAccount() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data-accountId", "request")), - new JsonArray(asList("otherAccountId", "id1", "data-otherAccountId", "request")), - new JsonArray(asList("accountId", "id2", "data-accountId", "imp")), - new JsonArray(asList("otherAccountId", "id2", "data-otherAccountId", "imp")))); + givenRowSet( + givenRow("accountId", "id1", "data-accountId", "request"), + givenRow("otherAccountId", "id1", "data-otherAccountId", "request"), + givenRow("accountId", "id2", "data-accountId", "imp"), + givenRow("otherAccountId", "id2", "data-otherAccountId", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", - singleton("id1"), singleton("id2")); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("id1"), + singleton("id2")); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -211,10 +241,10 @@ public void mapShouldReturnExpectedStoredResultForGivenAccount() { @Test public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -226,12 +256,12 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH @Test public void mapWithoutParamsShouldSkipStoredResultWithInvalidType() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data1", "request")), - new JsonArray(asList("accountId", "id2", "data2", "invalid")))); + givenRowSet( + givenRow("accountId", "id1", "data1", "request"), + givenRow("accountId", "id2", "data2", "invalid")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -243,27 +273,25 @@ public void mapWithoutParamsShouldSkipStoredResultWithInvalidType() { @Test public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetHasLessColumns() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data")))); + givenRowSet(givenRow("accountId", "id1", "data")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); assertThat(result.getStoredIdToImp()).isEmpty(); assertThat(result.getErrors()).hasSize(1) - .containsOnly("Error occurred while mapping stored request data"); + .containsOnly("Error occurred while mapping stored request data: some columns are missing"); } @Test public void mapWithoutParamsShouldReturnEmptyStoredResultWhenResultSetHasInvalidDataType() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data", 123)))); + givenRowSet(givenRow("accountId", "id1", "data", 123)); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -274,12 +302,12 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWhenResultSetHasInvalid @Test public void mapWithoutParamsShouldReturnExpectedStoredResult() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data1", "request")), - new JsonArray(asList("accountId", "id2", "data2", "imp")))); + givenRowSet( + givenRow("accountId", "id1", "data1", "request"), + givenRow("accountId", "id2", "data2", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -288,4 +316,34 @@ public void mapWithoutParamsShouldReturnExpectedStoredResult() { .containsOnly(entry("id2", "data2")); assertThat(result.getErrors()).isEmpty(); } + + private void givenRowSet(Row... rows) { + given(rowSet.iterator()).willReturn(CustomRowIterator.of(Arrays.asList(rows).iterator())); + } + + private Row givenRow(Object... values) { + final Row row = mock(Row.class); + given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + given(row.getValue(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + final JsonObject json = new JsonObject(); + IntStream.range(0, values.length).forEach(i -> json.put(String.valueOf(i), values[i])); + given(row.toJson()).willReturn(json); + return row; + } + + @Value(staticConstructor = "of") + private static class CustomRowIterator implements RowIterator { + + Iterator delegate; + + @Override + public boolean hasNext() { + return delegate.hasNext(); + } + + @Override + public Row next() { + return delegate.next(); + } + } } diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java index ba9d7e18d1f..3f6ee8ecd8e 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java @@ -1,7 +1,10 @@ package org.prebid.server.settings.helper; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; +import io.vertx.core.json.JsonObject; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; +import lombok.Value; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; @@ -10,15 +13,17 @@ import org.prebid.server.settings.model.StoredResponseDataResult; import java.util.AbstractMap; -import java.util.HashSet; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Set; +import java.util.stream.IntStream; -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; public class JdbcStoredResponseResultMapperTest { @@ -26,15 +31,15 @@ public class JdbcStoredResponseResultMapperTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private ResultSet resultSet; + private RowSet rowSet; @Test - public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetIsEmpty() { + public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetIsEmpty() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(resultSet, emptySet()); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, emptySet()); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -43,12 +48,12 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetIsEmpt } @Test - public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetHasLessColumns() { + public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetHasLessColumns() { // given - given(resultSet.getResults()).willReturn(singletonList(new JsonArray(singletonList("id1")))); + givenRowSet(givenRow("id1")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(resultSet, emptySet()); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, emptySet()); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -59,11 +64,10 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetHasLes @Test public void mapShouldReturnStoredResponseResultWithErrorForMissingID() { // given - given(resultSet.getResults()).willReturn(singletonList(new JsonArray(asList("id1", "data")))); + givenRowSet(givenRow("id1", "data")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper - .map(resultSet, new HashSet<>(asList("id1", "id2"))); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); // then assertThat(result.getIdToStoredResponses()).hasSize(1) @@ -73,12 +77,12 @@ public void mapShouldReturnStoredResponseResultWithErrorForMissingID() { } @Test - public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetHasEmptyResultForGivenIDs() { + public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetHasEmptyResultForGivenIDs() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(resultSet, singleton("id")); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, singleton("id")); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -89,17 +93,43 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetHasEmp @Test public void mapShouldReturnFilledStoredResponseResultWithoutErrors() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("id1", "data1")), - new JsonArray(asList("id2", "data2")))); + givenRowSet(givenRow("id1", "data1"), givenRow("id2", "data2")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(resultSet, - new HashSet<>(asList("id1", "id2"))); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); // then assertThat(result.getIdToStoredResponses()).hasSize(2) .contains(new AbstractMap.SimpleEntry<>("id1", "data1"), new AbstractMap.SimpleEntry<>("id2", "data2")); assertThat(result.getErrors()).isEmpty(); } + + private void givenRowSet(Row... rows) { + given(rowSet.iterator()).willReturn(CustomRowIterator.of(Arrays.asList(rows).iterator())); + } + + private Row givenRow(Object... values) { + final Row row = mock(Row.class); + given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + final JsonObject json = new JsonObject(); + IntStream.range(0, values.length).forEach(i -> json.put(String.valueOf(i), values[i])); + given(row.toJson()).willReturn(json); + return row; + } + + @Value(staticConstructor = "of") + private static class CustomRowIterator implements RowIterator { + + Iterator delegate; + + @Override + public boolean hasNext() { + return delegate.hasNext(); + } + + @Override + public Row next() { + return delegate.next(); + } + } } diff --git a/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelperTest.java b/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelperTest.java new file mode 100644 index 00000000000..f4d799250d0 --- /dev/null +++ b/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelperTest.java @@ -0,0 +1,106 @@ +package org.prebid.server.settings.helper; + +import org.junit.Test; +import org.prebid.server.VertxTest; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ParametrizedQueryMySqlHelperTest extends VertxTest { + + private final ParametrizedQueryMySqlHelper target = new ParametrizedQueryMySqlHelper(); + + @Test + public void replaceAccountIdPlaceholderShouldReplacePlaceholderWithWildCard() { + // when + final String result = target.replaceAccountIdPlaceholder("SELECT * FROM table WHERE id = %ACCOUNT_ID%"); + + // then + assertThat(result).isEqualTo("SELECT * FROM table WHERE id = ?"); + } + + @Test + public void replaceStoredResponseIdPlaceholdersShouldReplacePlaceholderWithWildCards() { + // when + final String result = target.replaceStoredResponseIdPlaceholders( + "SELECT responseId, responseData FROM stored_responses WHERE responseId IN (%RESPONSE_ID_LIST%)", + 3); + + // then + assertThat(result) + .isEqualTo("SELECT responseId, responseData FROM stored_responses WHERE responseId IN (?,?,?)"); + } + + @Test + public void replaceStoredResponseIdPlaceholdersShouldReplacePlaceholderWithNullWhenParamsNumberAreZero() { + // when + final String result = target.replaceStoredResponseIdPlaceholders( + "SELECT responseId, responseData FROM stored_responses WHERE responseId IN (%RESPONSE_ID_LIST%)", + 0); + + // then + assertThat(result) + .isEqualTo("SELECT responseId, responseData FROM stored_responses WHERE responseId IN (NULL)"); + } + + @Test + public void replaceRequestAndImpIdPlaceholdersShouldReplacePlaceholderWithWildCards() { + // when + final String result = target.replaceRequestAndImpIdPlaceholders( + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (%IMP_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (%IMP_ID_LIST%)", + 2, 3); + + // then + assertThat(result).isEqualTo("SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (?,?) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (?,?) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (?,?,?) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (?,?,?)"); + } + + @Test + public void replaceRequestAndImpIdPlaceholdersShouldReplacePlaceholderWithNullsWhenIdsNumberIsZero() { + // when + final String result = target.replaceRequestAndImpIdPlaceholders( + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (%IMP_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (%IMP_ID_LIST%)", + 0, 0); + + // then + assertThat(result).isEqualTo("SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (NULL)"); + } +} diff --git a/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelperTest.java b/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelperTest.java new file mode 100644 index 00000000000..e457b9c52e3 --- /dev/null +++ b/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelperTest.java @@ -0,0 +1,106 @@ +package org.prebid.server.settings.helper; + +import org.junit.Test; +import org.prebid.server.VertxTest; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ParametrizedQueryPostgresHelperTest extends VertxTest { + + private final ParametrizedQueryPostgresHelper target = new ParametrizedQueryPostgresHelper(); + + @Test + public void replaceAccountIdPlaceholderShouldReplacePlaceholderWithWildCard() { + // when + final String result = target.replaceAccountIdPlaceholder("SELECT * FROM table WHERE id = %ACCOUNT_ID%"); + + // then + assertThat(result).isEqualTo("SELECT * FROM table WHERE id = $1"); + } + + @Test + public void replaceStoredResponseIdPlaceholdersShouldReplacePlaceholderWithWildCards() { + // when + final String result = target.replaceStoredResponseIdPlaceholders( + "SELECT responseId, responseData FROM stored_responses WHERE responseId IN (%RESPONSE_ID_LIST%)", + 3); + + // then + assertThat(result) + .isEqualTo("SELECT responseId, responseData FROM stored_responses WHERE responseId IN ($1,$2,$3)"); + } + + @Test + public void replaceStoredResponseIdPlaceholdersShouldReplacePlaceholderWithNullWhenParamsNumberAreZero() { + // when + final String result = target.replaceStoredResponseIdPlaceholders( + "SELECT responseId, responseData FROM stored_responses WHERE responseId IN (%RESPONSE_ID_LIST%)", + 0); + + // then + assertThat(result) + .isEqualTo("SELECT responseId, responseData FROM stored_responses WHERE responseId IN (NULL)"); + } + + @Test + public void replaceRequestAndImpIdPlaceholdersShouldReplacePlaceholderWithWildCards() { + // when + final String result = target.replaceRequestAndImpIdPlaceholders( + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (%IMP_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (%IMP_ID_LIST%)", + 2, 3); + + // then + assertThat(result).isEqualTo("SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN ($1,$2) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN ($3,$4) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN ($5,$6,$7) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN ($8,$9,$10)"); + } + + @Test + public void replaceRequestAndImpIdPlaceholdersShouldReplacePlaceholderWithNullsWhenIdsNumberIsZero() { + // when + final String result = target.replaceRequestAndImpIdPlaceholders( + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (%IMP_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (%IMP_ID_LIST%)", + 0, 0); + + // then + assertThat(result).isEqualTo("SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (NULL)"); + } +} diff --git a/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java index 8dc39bd0161..79514bf1fec 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java @@ -1,17 +1,17 @@ package org.prebid.server.vertx.jdbc; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.sql.ResultSet; -import io.vertx.ext.sql.SQLConnection; +import io.vertx.sqlclient.Pool; +import io.vertx.sqlclient.PreparedQuery; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; +import io.vertx.sqlclient.SqlConnection; +import io.vertx.sqlclient.Tuple; +import lombok.Value; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; @@ -22,16 +22,17 @@ import java.time.Clock; import java.time.Instant; import java.time.ZoneId; +import java.util.Arrays; +import java.util.Iterator; import java.util.concurrent.TimeoutException; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static java.util.function.Function.identity; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNullPointerException; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.mock; @@ -44,14 +45,12 @@ public class BasicJdbcClientTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private Vertx vertx; - @Mock - private JDBCClient vertxJdbcClient; + private Pool pool; @Mock private Metrics metrics; private Clock clock; - private BasicJdbcClient jdbcClient; + private BasicJdbcClient target; private Timeout timeout; @@ -60,15 +59,14 @@ public void setUp() { clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); timeout = new TimeoutFactory(clock).create(500L); - jdbcClient = new BasicJdbcClient(vertx, vertxJdbcClient, metrics, clock); + target = new BasicJdbcClient(pool, metrics, clock); } @Test public void creationShouldFailOnNullArguments() { - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(null, null, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(vertx, null, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(vertx, vertxJdbcClient, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(vertx, vertxJdbcClient, metrics, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(null, null, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(pool, null, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(pool, metrics, null)); } @Test @@ -77,7 +75,7 @@ public void initializeShouldReturnEmptySucceededFutureIfConnectionCouldBeEstabli givenGetConnectionReturning(Future.succeededFuture()); // when - final Future future = jdbcClient.initialize(); + final Future future = target.initialize(); // then assertThat(future.succeeded()).isTrue(); @@ -90,7 +88,7 @@ public void initializeShouldReturnFailedFutureIfConnectionCouldNotBeEstablished( givenGetConnectionReturning(Future.failedFuture(new RuntimeException("Failed to open connection"))); // when - final Future future = jdbcClient.initialize(); + final Future future = target.initialize(); // then assertThat(future.failed()).isTrue(); @@ -100,39 +98,26 @@ public void initializeShouldReturnFailedFutureIfConnectionCouldNotBeEstablished( @Test public void executeQueryShouldReturnFailedFutureIfGlobalTimeoutAlreadyExpired() { // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), expiredTimeout()); + final Future> future = target.executeQuery("query", emptyList(), identity(), expiredTimeout()); // then assertThat(future.failed()).isTrue(); assertThat(future.cause()).isInstanceOf(TimeoutException.class) .hasMessage("Timed out while executing SQL query"); - verifyNoMoreInteractions(vertx, vertxJdbcClient); + verifyNoMoreInteractions(pool); } @Test - @SuppressWarnings("unchecked") public void executeQueryShouldReturnFailedFutureIfItTakesLongerThanRemainingTimeout() { // given - given(vertx.setTimer(anyLong(), any())).willAnswer(invocation -> { - ((Handler) invocation.getArgument(1)).handle(123L); - return 123L; - }); - - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); - - givenQueryReturning(connection, Future.succeededFuture(new ResultSet())); + givenQueryReturning(connection, Future.failedFuture(new TimeoutException("Some text"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future> future = target.executeQuery("query", emptyList(), identity(), timeout); // then - final ArgumentCaptor timeoutCaptor = ArgumentCaptor.forClass(Long.class); - verify(vertx).setTimer(timeoutCaptor.capture(), any()); - assertThat(timeoutCaptor.getValue()).isEqualTo(500L); - - verify(vertx).cancelTimer(eq(123L)); - assertThat(future.failed()).isTrue(); assertThat(future.cause()).isInstanceOf(TimeoutException.class) .hasMessage("Timed out while executing SQL query"); @@ -141,16 +126,12 @@ public void executeQueryShouldReturnFailedFutureIfItTakesLongerThanRemainingTime @Test public void executeQueryShouldReturnFailedFutureIfConnectionAcquisitionFails() { // given - given(vertx.setTimer(anyLong(), any())).willReturn(123L); - givenGetConnectionReturning(Future.failedFuture(new RuntimeException("Failed to acquire connection"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future> future = target.executeQuery("query", emptyList(), identity(), timeout); // then - verify(vertx).cancelTimer(eq(123L)); - assertThat(future.failed()).isTrue(); assertThat(future.cause()).isInstanceOf(RuntimeException.class).hasMessage("Failed to acquire connection"); } @@ -158,19 +139,15 @@ public void executeQueryShouldReturnFailedFutureIfConnectionAcquisitionFails() { @Test public void executeQueryShouldReturnFailedFutureIfQueryFails() { // given - given(vertx.setTimer(anyLong(), any())).willReturn(123L); - - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); givenQueryReturning(connection, Future.failedFuture(new RuntimeException("Failed to execute query"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future> future = target.executeQuery("query", emptyList(), identity(), timeout); // then - verify(vertx).cancelTimer(eq(123L)); - assertThat(future.failed()).isTrue(); assertThat(future.cause()).isInstanceOf(RuntimeException.class).hasMessage("Failed to execute query"); } @@ -178,21 +155,20 @@ public void executeQueryShouldReturnFailedFutureIfQueryFails() { @Test public void executeQueryShouldReturnSucceededFutureWithMappedQueryResult() { // given - given(vertx.setTimer(anyLong(), any())).willReturn(123L); - - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); - givenQueryReturning(connection, Future.succeededFuture( - new ResultSet().setResults(singletonList(new JsonArray().add("value"))))); + final RowSet rowSet = givenRowSet(givenRow("value")); + givenQueryReturning(connection, Future.succeededFuture(rowSet)); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), - resultSet -> resultSet.getResults().get(0).getString(0), timeout); + final Future future = target.executeQuery( + "query", + emptyList(), + rs -> rs.iterator().next().getString(0), + timeout); // then - verify(vertx).cancelTimer(eq(123L)); - assertThat(future.succeeded()).isTrue(); assertThat(future.result()).isEqualTo("value"); } @@ -200,13 +176,13 @@ public void executeQueryShouldReturnSucceededFutureWithMappedQueryResult() { @Test public void executeQueryShouldReportMetricsIfQueryFails() { // given - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); givenQueryReturning(connection, Future.failedFuture(new RuntimeException("Failed to execute query"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future> future = target.executeQuery("query", emptyList(), identity(), timeout); // then assertThat(future.failed()).isTrue(); @@ -216,13 +192,13 @@ public void executeQueryShouldReportMetricsIfQueryFails() { @Test public void executeQueryShouldReportMetricsIfQuerySucceeds() { // given - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); - givenQueryReturning(connection, Future.succeededFuture(new ResultSet().setResults(emptyList()))); + givenQueryReturning(connection, Future.succeededFuture(givenRowSet())); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), Object::toString, timeout); + final Future future = target.executeQuery("query", emptyList(), Object::toString, timeout); // then assertThat(future.succeeded()).isTrue(); @@ -230,22 +206,46 @@ public void executeQueryShouldReportMetricsIfQuerySucceeds() { } @SuppressWarnings("unchecked") - private void givenGetConnectionReturning(AsyncResult result) { - given(vertxJdbcClient.getConnection(any())).willAnswer(invocation -> { - ((Handler>) invocation.getArgument(0)).handle(result); - return null; - }); + private static void givenQueryReturning(SqlConnection connection, Future> result) { + final PreparedQuery> preparedQueryMock = mock(PreparedQuery.class); + given(connection.preparedQuery(anyString())).willReturn(preparedQueryMock); + given(preparedQueryMock.execute(any(Tuple.class))).willReturn(result); } - @SuppressWarnings("unchecked") - private static void givenQueryReturning(SQLConnection connection, AsyncResult result) { - given(connection.queryWithParams(anyString(), any(), any())).willAnswer(invocation -> { - ((Handler>) invocation.getArgument(2)).handle(result); - return null; - }); + private void givenGetConnectionReturning(Future result) { + given(pool.getConnection()).willReturn(result); } private Timeout expiredTimeout() { return new TimeoutFactory(clock).create(clock.instant().minusMillis(1500L).toEpochMilli(), 1000L); } + + private RowSet givenRowSet(Row... rows) { + final RowSet rowSet = mock(RowSet.class); + given(rowSet.iterator()).willReturn(CustomRowIterator.of(Arrays.asList(rows).iterator())); + return rowSet; + } + + private Row givenRow(Object... values) { + final Row row = mock(Row.class); + given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + given(row.getValue(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + return row; + } + + @Value(staticConstructor = "of") + private static class CustomRowIterator implements RowIterator { + + Iterator delegate; + + @Override + public boolean hasNext() { + return delegate.hasNext(); + } + + @Override + public Row next() { + return delegate.next(); + } + } } diff --git a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java index ea0e49fb1ce..a1e86429401 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java @@ -49,7 +49,7 @@ public class CircuitBreakerSecuredJdbcClientTest { @Mock private Metrics metrics; - private CircuitBreakerSecuredJdbcClient jdbcClient; + private CircuitBreakerSecuredJdbcClient target; private Timeout timeout; @@ -59,7 +59,7 @@ public void setUp() { clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); timeout = new TimeoutFactory(clock).create(500L); - jdbcClient = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 1, 100L, 200L, clock); + target = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 1, 100L, 200L, clock); } @After @@ -74,12 +74,14 @@ public void executeQueryShouldReturnResultIfCircuitIsClosedAndQuerySucceeded(Tes Future.succeededFuture("value"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), - resultSet -> resultSet.getResults().get(0).getString(0), timeout); + final Future future = target.executeQuery( + "query", + emptyList(), + rs -> rs.iterator().next().getString(0), + timeout); // then - future.onComplete(context.asyncAssertSuccess(result -> - assertThat(result).isEqualTo("value"))); + future.onComplete(context.asyncAssertSuccess(result -> assertThat(result).isEqualTo("value"))); } @Test @@ -89,7 +91,7 @@ public void executeQueryShouldReturnExceptionIfCircuitIsClosedAndQueryFails(Test Future.failedFuture(new RuntimeException("exception1")))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future future = target.executeQuery("query", emptyList(), identity(), timeout); // then future.onComplete(context.asyncAssertFailure(throwable -> @@ -103,8 +105,8 @@ public void executeQueryShouldNotExecuteQueryIfCircuitIsOpened(TestContext conte Future.failedFuture(new RuntimeException("exception1")))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)); // 2 call + final Future future = target.executeQuery("query", emptyList(), identity(), timeout) // 1 call + .recover(ignored -> target.executeQuery("query", emptyList(), identity(), timeout)); // 2 call // then future.onComplete(context.asyncAssertFailure(throwable -> { @@ -123,12 +125,12 @@ public void executeQueryShouldReturnExceptionIfCircuitIsHalfOpenedAndQueryFails( // when final Async async = context.async(); - jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call + target.executeQuery("query", emptyList(), identity(), timeout) // 1 call + .recover(ignored -> target.executeQuery("query", emptyList(), identity(), timeout)) // 2 call .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); // 3 call + final Future future = target.executeQuery("query", emptyList(), identity(), timeout); // 3 call // then future.onComplete(context.asyncAssertFailure(exception -> { @@ -148,13 +150,16 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded // when final Async async = context.async(); - jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call + target.executeQuery("query", emptyList(), identity(), timeout) // 1 call + .recover(ignored -> target.executeQuery("query", emptyList(), identity(), timeout)) // 2 call .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); - final Future future = jdbcClient.executeQuery("query", emptyList(), - resultSet -> resultSet.getResults().get(0).getString(0), timeout); // 3 call + final Future future = target.executeQuery( + "query", + emptyList(), + rs -> rs.iterator().next().getString(0), + timeout); // 3 call // then future.onComplete(context.asyncAssertSuccess(result -> { @@ -168,7 +173,7 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded @Test public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds(TestContext context) { // given - jdbcClient = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 2, 100L, 200L, clock); + target = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 2, 100L, 200L, clock); givenExecuteQueryReturning(asList( Future.failedFuture(new RuntimeException("exception1")), @@ -176,11 +181,11 @@ public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds // when final Async async = context.async(); - final Future future1 = jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call + final Future future1 = target.executeQuery("query", emptyList(), identity(), timeout) // 1 call .onComplete(ignored -> vertx.setTimer(101L, id -> async.complete())); async.await(); - final Future future2 = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); // 2 call + final Future future2 = target.executeQuery("query", emptyList(), identity(), timeout); // 2 call // then future1.onComplete(context.asyncAssertFailure(exception -> @@ -200,7 +205,7 @@ public void circuitBreakerGaugeShouldReportOpenedWhenCircuitOpen(TestContext con Future.failedFuture(new RuntimeException("exception1")))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future future = target.executeQuery("query", emptyList(), identity(), timeout); // then final ArgumentCaptor gaugeValueProviderCaptor = ArgumentCaptor.forClass(BooleanSupplier.class); @@ -220,13 +225,16 @@ public void circuitBreakerGaugeShouldReportClosedWhenCircuitClosed(TestContext c // when final Async async = context.async(); - jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call + target.executeQuery("query", emptyList(), identity(), timeout) // 1 call + .recover(ignored -> target.executeQuery("query", emptyList(), identity(), timeout)) // 2 call .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); - final Future future = jdbcClient.executeQuery("query", emptyList(), - resultSet -> resultSet.getResults().get(0).getString(0), timeout); // 3 call + final Future future = target.executeQuery( + "query", + emptyList(), + rs -> rs.iterator().next().getString(0), + timeout); // 3 call // then final ArgumentCaptor gaugeValueProviderCaptor = ArgumentCaptor.forClass(BooleanSupplier.class); From 0114262fce920ea8ec9ac19581ac06e6bd3c7e77 Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:36:32 +0300 Subject: [PATCH 04/62] Test: `PostgreSQL` container (#3134) --- docs/developers/functional-tests.md | 11 ++++- pom.xml | 6 +++ .../HibernateRepositoryService.groovy | 20 ++++++-- .../testcontainers/Dependencies.groovy | 10 +++- .../testcontainers/PbsConfig.groovy | 13 +++++ .../tests/postgres/PostgresBaseSpec.groovy | 38 ++++++++++++++ .../tests/postgres/PostgresDBSpec.groovy | 49 +++++++++++++++++++ .../{db_schema.sql => db_mysql_schema.sql} | 0 .../server/functional/db_psql_schema.sql | 47 ++++++++++++++++++ 9 files changed, 187 insertions(+), 7 deletions(-) create mode 100644 src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresBaseSpec.groovy create mode 100644 src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresDBSpec.groovy rename src/test/resources/org/prebid/server/functional/{db_schema.sql => db_mysql_schema.sql} (100%) create mode 100644 src/test/resources/org/prebid/server/functional/db_psql_schema.sql diff --git a/docs/developers/functional-tests.md b/docs/developers/functional-tests.md index fd216eb89c5..c9e827b370a 100644 --- a/docs/developers/functional-tests.md +++ b/docs/developers/functional-tests.md @@ -131,7 +131,16 @@ Container for mocking different calls from PBS: prebid cache, bidders, currency Container for Mysql database. -- Use `org/prebid/server/functional/db_schema.sql` script for scheme. +- Use `org/prebid/server/functional/db_mysql_schema.sql` script for scheme. +- DataBase: `prebid` +- Username: `prebid` +- Password: `prebid` + +#### PostgreSQLContainer + +Container for PostgreSQL database. + +- Use `org/prebid/server/functional/db_psql_schema.sql` script for scheme. - DataBase: `prebid` - Username: `prebid` - Password: `prebid` diff --git a/pom.xml b/pom.xml index 79ae15fa03f..e9f44e2b1b7 100644 --- a/pom.xml +++ b/pom.xml @@ -589,6 +589,12 @@ ${mockserver.version} test + + org.testcontainers + postgresql + ${testcontainers.version} + test + diff --git a/src/test/groovy/org/prebid/server/functional/repository/HibernateRepositoryService.groovy b/src/test/groovy/org/prebid/server/functional/repository/HibernateRepositoryService.groovy index 6b39354e62a..d6ee8d65c10 100644 --- a/src/test/groovy/org/prebid/server/functional/repository/HibernateRepositoryService.groovy +++ b/src/test/groovy/org/prebid/server/functional/repository/HibernateRepositoryService.groovy @@ -10,22 +10,28 @@ import org.prebid.server.functional.repository.dao.AccountDao import org.prebid.server.functional.repository.dao.StoredImpDao import org.prebid.server.functional.repository.dao.StoredRequestDao import org.prebid.server.functional.repository.dao.StoredResponseDao -import org.testcontainers.containers.MySQLContainer +import org.testcontainers.containers.JdbcDatabaseContainer +import org.testcontainers.containers.PostgreSQLContainer class HibernateRepositoryService { + private static final String MY_SQL_DIALECT = "org.hibernate.dialect.MySQLDialect" + private static final String POSTGRES_SQL_DIALECT = "org.hibernate.dialect.PostgreSQLDialect" + EntityManagerUtil entityManagerUtil AccountDao accountDao StoredImpDao storedImpDao StoredRequestDao storedRequestDao StoredResponseDao storedResponseDao - HibernateRepositoryService(MySQLContainer container) { + HibernateRepositoryService(JdbcDatabaseContainer container) { def jdbcUrl = container.jdbcUrl def user = container.username def pass = container.password def driver = container.driverClassName - SessionFactory sessionFactory = configureHibernate(jdbcUrl, user, pass, driver) + def dialect = container instanceof PostgreSQLContainer ? POSTGRES_SQL_DIALECT : MY_SQL_DIALECT + + SessionFactory sessionFactory = configureHibernate(jdbcUrl, dialect, user, pass, driver) entityManagerUtil = new EntityManagerUtil(sessionFactory) accountDao = new AccountDao(entityManagerUtil) @@ -34,10 +40,14 @@ class HibernateRepositoryService { storedResponseDao = new StoredResponseDao(entityManagerUtil) } - private static SessionFactory configureHibernate(String jdbcUrl, String user, String pass, String driver) { + private static SessionFactory configureHibernate(String jdbcUrl, + String dialect, + String user, + String pass, + String driver) { def properties = new Properties() properties.setProperty("hibernate.connection.url", jdbcUrl) - properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect") + properties.setProperty("hibernate.dialect", dialect) properties.setProperty("hibernate.connection.username", user) properties.setProperty("hibernate.connection.password", pass) properties.setProperty("hibernate.connection.driver_class", driver) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy index 0798be45cdf..53cbecf2289 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy @@ -4,6 +4,7 @@ import org.prebid.server.functional.testcontainers.container.NetworkServiceConta import org.prebid.server.functional.util.SystemProperties import org.testcontainers.containers.MySQLContainer import org.testcontainers.containers.Network +import org.testcontainers.containers.PostgreSQLContainer import org.testcontainers.lifecycle.Startables import static org.prebid.server.functional.util.SystemProperties.MOCKSERVER_VERSION @@ -20,7 +21,14 @@ class Dependencies { .withDatabaseName("prebid") .withUsername("prebid") .withPassword("prebid") - .withInitScript("org/prebid/server/functional/db_schema.sql") + .withInitScript("org/prebid/server/functional/db_mysql_schema.sql") + .withNetwork(network) + + static final PostgreSQLContainer postgresqlContainer = new PostgreSQLContainer<>("postgres:16.0") + .withDatabaseName("prebid") + .withUsername("prebid") + .withPassword("prebid") + .withInitScript("org/prebid/server/functional/db_psql_schema.sql") .withNetwork(network) static final NetworkServiceContainer networkServiceContainer = new NetworkServiceContainer(MOCKSERVER_VERSION) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy index 66cdb55f34b..65a9d8da533 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.testcontainers import org.testcontainers.containers.MySQLContainer +import org.testcontainers.containers.PostgreSQLContainer import static org.prebid.server.functional.testcontainers.Dependencies.networkServiceContainer import static org.prebid.server.functional.testcontainers.container.PrebidServerContainer.ADMIN_ENDPOINT_PASSWORD @@ -99,6 +100,18 @@ LIMIT 1 ].asImmutable() } + static Map getPostgreSqlConfig(PostgreSQLContainer postgres = Dependencies.postgresqlContainer) { + ["settings.database.type" : "postgres", + "settings.database.host" : postgres.getNetworkAliases().get(0), + "settings.database.port" : postgres.exposedPorts.get(0) as String, + "settings.database.dbname" : postgres.databaseName, + "settings.database.user" : postgres.username, + "settings.database.password" : postgres.password, + "settings.database.pool-size" : "2", // setting 2 here to leave some slack for the PBS + "settings.database.provider-class": "hikari" + ].asImmutable() + } + static Map getMetricConfig() { ["admin-endpoints.collected-metrics.enabled": "true"].asImmutable() } diff --git a/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresBaseSpec.groovy new file mode 100644 index 00000000000..05b5e054cc0 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresBaseSpec.groovy @@ -0,0 +1,38 @@ +package org.prebid.server.functional.tests.postgres + +import org.prebid.server.functional.repository.HibernateRepositoryService +import org.prebid.server.functional.repository.dao.AccountDao +import org.prebid.server.functional.repository.dao.StoredImpDao +import org.prebid.server.functional.repository.dao.StoredRequestDao +import org.prebid.server.functional.repository.dao.StoredResponseDao +import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.testcontainers.Dependencies +import org.prebid.server.functional.testcontainers.PbsConfig +import org.prebid.server.functional.tests.BaseSpec +import org.testcontainers.lifecycle.Startables + +class PostgresBaseSpec extends BaseSpec { + + protected static HibernateRepositoryService repository + protected static AccountDao accountDao + protected static StoredImpDao storedImpDao + protected static StoredRequestDao storedRequestDao + protected static StoredResponseDao storedResponseDao + + protected PrebidServerService pbsServiceWithPostgres + + void setup() { + Startables.deepStart(Dependencies.postgresqlContainer) + .join() + repository = new HibernateRepositoryService(Dependencies.postgresqlContainer) + accountDao = repository.accountDao + storedImpDao = repository.storedImpDao + storedRequestDao = repository.storedRequestDao + storedResponseDao = repository.storedResponseDao + pbsServiceWithPostgres = pbsServiceFactory.getService(PbsConfig.postgreSqlConfig) + } + + void cleanup() { + Dependencies.postgresqlContainer.stop() + } +} diff --git a/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresDBSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresDBSpec.groovy new file mode 100644 index 00000000000..fee381bad7c --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresDBSpec.groovy @@ -0,0 +1,49 @@ +package org.prebid.server.functional.tests.postgres + +import org.prebid.server.functional.model.db.Account +import org.prebid.server.functional.model.db.StoredImp +import org.prebid.server.functional.model.db.StoredRequest +import org.prebid.server.functional.model.db.StoredResponse +import org.prebid.server.functional.model.request.amp.AmpRequest +import org.prebid.server.functional.model.request.auction.BidRequest +import org.prebid.server.functional.model.request.auction.PrebidStoredRequest +import org.prebid.server.functional.model.request.auction.StoredAuctionResponse +import org.prebid.server.functional.model.response.auction.SeatBid +import org.prebid.server.functional.util.PBSUtils + +class PostgresDBSpec extends PostgresBaseSpec { + + def "PBS with postgresql should proceed with stored requests and responses correctly"() { + given: "Default AMP request" + def ampRequest = AmpRequest.defaultAmpRequest + + and: "Default stored request with specified stored response" + def storedResponseId = PBSUtils.randomNumber + def ampStoredRequest = BidRequest.defaultStoredRequest + ampStoredRequest.imp[0].ext.prebid.storedRequest = new PrebidStoredRequest(id: PBSUtils.randomString) + ampStoredRequest.imp[0].ext.prebid.storedAuctionResponse = new StoredAuctionResponse(id: storedResponseId) + + and: "Create and save account in the DB" + def account = new Account(uuid: ampRequest.account) + accountDao.save(account) + + and: "Save storedImp into DB" + def storedImp = StoredImp.getStoredImp(ampStoredRequest) + storedImpDao.save(storedImp) + + and: "Stored request in DB" + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + and: "Stored response in DB" + def storedAuctionResponse = SeatBid.getStoredResponse(ampStoredRequest) + def storedResponse = new StoredResponse(responseId: storedResponseId, storedAuctionResponse: storedAuctionResponse) + storedResponseDao.save(storedResponse) + + when: "PBS processes amp request" + def response = pbsServiceWithPostgres.sendAmpRequest(ampRequest) + + then: "PBS should not reject request" + assert response.ext?.debug?.httpcalls + } +} diff --git a/src/test/resources/org/prebid/server/functional/db_schema.sql b/src/test/resources/org/prebid/server/functional/db_mysql_schema.sql similarity index 100% rename from src/test/resources/org/prebid/server/functional/db_schema.sql rename to src/test/resources/org/prebid/server/functional/db_mysql_schema.sql diff --git a/src/test/resources/org/prebid/server/functional/db_psql_schema.sql b/src/test/resources/org/prebid/server/functional/db_psql_schema.sql new file mode 100644 index 00000000000..0ac5e5a0c43 --- /dev/null +++ b/src/test/resources/org/prebid/server/functional/db_psql_schema.sql @@ -0,0 +1,47 @@ +CREATE TABLE accounts_account +( + id SERIAL PRIMARY KEY, + uuid varchar(40) NOT NULL, + price_granularity varchar(6), + banner_cache_ttl integer, + video_cache_ttl integer, + events_enabled boolean, + tcf_config text, + truncate_target_attr smallint, + default_integration varchar(64), + analytics_config varchar(512), + bid_validations text, + status text, + config text, + updated_by integer, + updated_by_user varchar(64), + updated timestamp +); + +CREATE TABLE stored_requests +( + id SERIAL PRIMARY KEY, + accountId varchar(40), + reqId varchar(40), + requestData text +); + +CREATE TABLE stored_imps +( + id SERIAL PRIMARY KEY, + accountId varchar(40), + impId varchar(40), + impData text +); + +CREATE TABLE stored_responses +( + id SERIAL PRIMARY KEY, + resId varchar(40) NOT NULL, + storedAuctionResponse varchar(1024), + storedBidResponse varchar(1024) +); + +-- set session wait timeout to 1 minute +set statement_timeout to 60000; +commit; From ca491e5a181c4e1d81828032aeea0abd36871051 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:26:06 -0400 Subject: [PATCH 05/62] Bump IAB TCF decoder version (#3137) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e9f44e2b1b7..32711386616 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ 1.2.2 0.16.0 2.0.2 - 2.0.7 + 2.0.10 2.12.0 5.0.1 3.0.10 From fbf2922f569a336cf6974074569c3cb453eeeb89 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:50:43 +0200 Subject: [PATCH 06/62] Core: Fix Async DB clients (#3146) * Fix Async DB clients * Fix Func Tests * Remove property * Renamed everything with `jdbc` prefix to use more generic `database` prefix, since we don't use jdbc anymore. Removed unused provider class field from DatabaseType enum. * Fix import order --------- Co-authored-by: Alex Maltsev Co-authored-by: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> --- docs/config-app.md | 14 +++--- pom.xml | 6 --- .../server/settings/ApplicationSettings.java | 2 +- ....java => DatabaseApplicationSettings.java} | 41 ++++++++-------- ...va => DatabaseStoredDataResultMapper.java} | 13 ++--- ...> DatabaseStoredResponseResultMapper.java} | 9 ++-- ...va => DatabasePeriodicRefreshService.java} | 44 ++++++++--------- .../spring/config/SettingsConfiguration.java | 48 +++++++++---------- .../database/DatabaseConfiguration.java | 37 +++++++------- .../model/ConnectionPoolSettings.java | 2 + .../database/model/DatabasePoolType.java | 6 --- .../config/database/model/DatabaseType.java | 6 +-- .../DatabaseConfigurationProperties.java | 7 +-- .../BasicDatabaseClient.java} | 12 ++--- .../CircuitBreakerSecuredDatabaseClient.java} | 31 ++++++------ .../DatabaseClient.java} | 6 +-- src/main/resources/application.yaml | 2 +- src/main/resources/c3p0.properties | 8 ---- .../testcontainers/PbsConfig.groovy | 4 +- ...a => DatabaseApplicationSettingsTest.java} | 30 ++++++------ ...> DatabaseStoredDataResultMapperTest.java} | 33 +++++++------ ...tabaseStoredResponseResultMapperTest.java} | 14 +++--- ...> DatabasePeriodicRefreshServiceTest.java} | 24 +++++----- .../BasicDatabaseClientTest.java} | 14 +++--- ...cuitBreakerSecuredDatabaseClientTest.java} | 22 ++++----- 25 files changed, 212 insertions(+), 223 deletions(-) rename src/main/java/org/prebid/server/settings/{JdbcApplicationSettings.java => DatabaseApplicationSettings.java} (85%) rename src/main/java/org/prebid/server/settings/helper/{JdbcStoredDataResultMapper.java => DatabaseStoredDataResultMapper.java} (94%) rename src/main/java/org/prebid/server/settings/helper/{JdbcStoredResponseResultMapper.java => DatabaseStoredResponseResultMapper.java} (82%) rename src/main/java/org/prebid/server/settings/service/{JdbcPeriodicRefreshService.java => DatabasePeriodicRefreshService.java} (83%) delete mode 100644 src/main/java/org/prebid/server/spring/config/database/model/DatabasePoolType.java rename src/main/java/org/prebid/server/vertx/{jdbc/BasicJdbcClient.java => database/BasicDatabaseClient.java} (89%) rename src/main/java/org/prebid/server/vertx/{jdbc/CircuitBreakerSecuredJdbcClient.java => database/CircuitBreakerSecuredDatabaseClient.java} (65%) rename src/main/java/org/prebid/server/vertx/{jdbc/JdbcClient.java => database/DatabaseClient.java} (77%) delete mode 100644 src/main/resources/c3p0.properties rename src/test/java/org/prebid/server/settings/{JdbcApplicationSettingsTest.java => DatabaseApplicationSettingsTest.java} (90%) rename src/test/java/org/prebid/server/settings/helper/{JdbcStoredDataResultMapperTest.java => DatabaseStoredDataResultMapperTest.java} (89%) rename src/test/java/org/prebid/server/settings/helper/{JdbcStoredResponseResultMapperTest.java => DatabaseStoredResponseResultMapperTest.java} (83%) rename src/test/java/org/prebid/server/settings/service/{JdbcPeriodicRefreshServiceTest.java => DatabasePeriodicRefreshServiceTest.java} (85%) rename src/test/java/org/prebid/server/vertx/{jdbc/BasicJdbcClientTest.java => database/BasicDatabaseClientTest.java} (96%) rename src/test/java/org/prebid/server/vertx/{jdbc/CircuitBreakerSecuredJdbcClientTest.java => database/CircuitBreakerSecuredDatabaseClientTest.java} (92%) diff --git a/docs/config-app.md b/docs/config-app.md index 0ae973cf9f5..ee6bf32dbe3 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -294,8 +294,8 @@ For database data source available next options: - `settings.database.user` - database user. - `settings.database.password` - database password. - `settings.database.pool-size` - set the initial/min/max pool size of database connections. +- `settings.database.idle-connection-timeout` - Set the idle timeout, time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed and get back to the pool if no data is received nor sent within the timeout. - `settings.database.account-query` - the SQL query to fetch account. -- `settings.database.provider-class` - type of connection pool to be used: `hikari` or `c3p0`. - `settings.database.stored-requests-query` - the SQL query to fetch stored requests. - `settings.database.amp-stored-requests-query` - the SQL query to fetch AMP stored requests. - `settings.database.stored-responses-query` - the SQL query to fetch stored responses. @@ -346,14 +346,14 @@ available: `/cache/invalidate?account={accountId}` which remove account from the - `settings.in-memory-cache.http-update.amp-endpoint` - the url to fetch AMP stored request updates. - `settings.in-memory-cache.http-update.refresh-rate` - refresh period in ms for stored request updates. - `settings.in-memory-cache.http-update.timeout` - timeout for obtaining stored request updates. -- `settings.in-memory-cache.jdbc-update.init-query` - initial query for fetching all stored requests at the startup. -- `settings.in-memory-cache.jdbc-update.update-query` - a query for periodical update of stored requests, that should +- `settings.in-memory-cache.database-update.init-query` - initial query for fetching all stored requests at the startup. +- `settings.in-memory-cache.database-update.update-query` - a query for periodical update of stored requests, that should contain 'WHERE last_updated > ?' to fetch only the records that were updated since previous check. -- `settings.in-memory-cache.jdbc-update.amp-init-query` - initial query for fetching all AMP stored requests at the startup. -- `settings.in-memory-cache.jdbc-update.amp-update-query` - a query for periodical update of AMP stored requests, that should +- `settings.in-memory-cache.database-update.amp-init-query` - initial query for fetching all AMP stored requests at the startup. +- `settings.in-memory-cache.database-update.amp-update-query` - a query for periodical update of AMP stored requests, that should contain 'WHERE last_updated > ?' to fetch only the records that were updated since previous check. -- `settings.in-memory-cache.jdbc-update.refresh-rate` - refresh period in ms for stored request updates. -- `settings.in-memory-cache.jdbc-update.timeout` - timeout for obtaining stored request updates. +- `settings.in-memory-cache.database-update.refresh-rate` - refresh period in ms for stored request updates. +- `settings.in-memory-cache.database-update.timeout` - timeout for obtaining stored request updates. For targeting available next options: - `settings.targeting.truncate-attr-chars` - set the max length for names of targeting keywords (0 means no truncation). diff --git a/pom.xml b/pom.xml index 32711386616..0545e9ad7d9 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,6 @@ 2.0.2 2.0.10 2.12.0 - 5.0.1 3.0.10 3.21.7 3.17.3 @@ -354,11 +353,6 @@ geoip2 ${maxmind-client.version} - - com.zaxxer - HikariCP - ${hikari.version} - com.iabgpp iabgpp-encoder diff --git a/src/main/java/org/prebid/server/settings/ApplicationSettings.java b/src/main/java/org/prebid/server/settings/ApplicationSettings.java index 8a010991b2f..da414bef279 100644 --- a/src/main/java/org/prebid/server/settings/ApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/ApplicationSettings.java @@ -14,7 +14,7 @@ * stored requests and imps) from the source. * * @see FileApplicationSettings - * @see JdbcApplicationSettings + * @see DatabaseApplicationSettings * @see HttpApplicationSettings * @see CachingApplicationSettings * @see CompositeApplicationSettings diff --git a/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java b/src/main/java/org/prebid/server/settings/DatabaseApplicationSettings.java similarity index 85% rename from src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java rename to src/main/java/org/prebid/server/settings/DatabaseApplicationSettings.java index 6dd9f507ffa..9dad7f6a28b 100644 --- a/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/DatabaseApplicationSettings.java @@ -10,14 +10,15 @@ import org.prebid.server.execution.Timeout; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; -import org.prebid.server.settings.helper.JdbcStoredDataResultMapper; -import org.prebid.server.settings.helper.JdbcStoredResponseResultMapper; +import org.prebid.server.settings.helper.DatabaseStoredDataResultMapper; +import org.prebid.server.settings.helper.DatabaseStoredResponseResultMapper; import org.prebid.server.settings.helper.ParametrizedQueryHelper; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredResponseDataResult; import org.prebid.server.util.ObjectUtil; -import org.prebid.server.vertx.jdbc.JdbcClient; +import org.prebid.server.vertx.database.CircuitBreakerSecuredDatabaseClient; +import org.prebid.server.vertx.database.DatabaseClient; import java.util.ArrayList; import java.util.Collections; @@ -33,12 +34,12 @@ *

* Reads an application settings from the database source. *

- * In order to enable caching and reduce latency for read operations {@link JdbcApplicationSettings} + * In order to enable caching and reduce latency for read operations {@link DatabaseApplicationSettings} * can be decorated by {@link CachingApplicationSettings}. */ -public class JdbcApplicationSettings implements ApplicationSettings { +public class DatabaseApplicationSettings implements ApplicationSettings { - private final JdbcClient jdbcClient; + private final DatabaseClient databaseClient; private final JacksonMapper mapper; private final ParametrizedQueryHelper parametrizedQueryHelper; @@ -81,15 +82,15 @@ public class JdbcApplicationSettings implements ApplicationSettings { */ private final String selectStoredResponsesQuery; - public JdbcApplicationSettings(JdbcClient jdbcClient, - JacksonMapper mapper, - ParametrizedQueryHelper parametrizedQueryHelper, - String selectAccountQuery, - String selectStoredRequestsQuery, - String selectAmpStoredRequestsQuery, - String selectStoredResponsesQuery) { + public DatabaseApplicationSettings(DatabaseClient databaseClient, + JacksonMapper mapper, + ParametrizedQueryHelper parametrizedQueryHelper, + String selectAccountQuery, + String selectStoredRequestsQuery, + String selectAmpStoredRequestsQuery, + String selectStoredResponsesQuery) { - this.jdbcClient = Objects.requireNonNull(jdbcClient); + this.databaseClient = Objects.requireNonNull(databaseClient); this.mapper = Objects.requireNonNull(mapper); this.parametrizedQueryHelper = Objects.requireNonNull(parametrizedQueryHelper); this.selectAccountQuery = parametrizedQueryHelper.replaceAccountIdPlaceholder( @@ -105,7 +106,7 @@ public JdbcApplicationSettings(JdbcClient jdbcClient, */ @Override public Future getAccountById(String accountId, Timeout timeout) { - return jdbcClient.executeQuery( + return databaseClient.executeQuery( selectAccountQuery, Collections.singletonList(accountId), result -> mapToModelOrError(result, this::toAccount), @@ -122,7 +123,7 @@ public Future> getCategories(String primaryAdServer, String * Transforms the first row of {@link RowSet} to required object or returns null. *

* Note: mapper should never throws exception in case of using - * {@link org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient}. + * {@link CircuitBreakerSecuredDatabaseClient}. */ private T mapToModelOrError(RowSet rowSet, Function mapper) { final RowIterator rowIterator = rowSet != null ? rowSet.iterator() : null; @@ -197,8 +198,8 @@ public Future getStoredResponses(Set responseI IntStream.rangeClosed(1, responseIdPlaceholderCount) .forEach(i -> idsQueryParameters.addAll(responseIds)); - return jdbcClient.executeQuery(queryResolvedWithParameters, idsQueryParameters, - result -> JdbcStoredResponseResultMapper.map(result, responseIds), timeout); + return databaseClient.executeQuery(queryResolvedWithParameters, idsQueryParameters, + result -> DatabaseStoredResponseResultMapper.map(result, responseIds), timeout); } /** @@ -223,8 +224,8 @@ private Future fetchStoredData(String query, String accountId, requestIds.size(), impIds.size()); - future = jdbcClient.executeQuery(parametrizedQuery, idsQueryParameters, - result -> JdbcStoredDataResultMapper.map(result, accountId, requestIds, impIds), + future = databaseClient.executeQuery(parametrizedQuery, idsQueryParameters, + result -> DatabaseStoredDataResultMapper.map(result, accountId, requestIds, impIds), timeout); } diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java b/src/main/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapper.java similarity index 94% rename from src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java rename to src/main/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapper.java index c7e9ec820f8..00853194e65 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapper.java @@ -10,6 +10,7 @@ import org.prebid.server.settings.model.StoredDataType; import org.prebid.server.settings.model.StoredItem; import org.prebid.server.util.ObjectUtil; +import org.prebid.server.vertx.database.CircuitBreakerSecuredDatabaseClient; import java.util.ArrayList; import java.util.Collections; @@ -22,11 +23,11 @@ /** * Utility class for mapping {@link RowSet} to {@link StoredDataResult}. */ -public class JdbcStoredDataResultMapper { +public class DatabaseStoredDataResultMapper { - private static final Logger logger = LoggerFactory.getLogger(JdbcStoredDataResultMapper.class); + private static final Logger logger = LoggerFactory.getLogger(DatabaseStoredDataResultMapper.class); - private JdbcStoredDataResultMapper() { + private DatabaseStoredDataResultMapper() { } /** @@ -39,7 +40,7 @@ private JdbcStoredDataResultMapper() { * @return - a {@link StoredDataResult} object *

* Note: mapper should never throws exception in case of using - * {@link org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient}. + * {@link CircuitBreakerSecuredDatabaseClient}. */ public static StoredDataResult map(RowSet rowSet, String accountId, @@ -82,8 +83,8 @@ public static StoredDataResult map(RowSet rowSet, final String data; final String typeAsString; try { - fetchedAccountId = row.getString(0); - id = row.getString(1); + fetchedAccountId = ObjectUtil.getIfNotNull(row.getValue(0), Object::toString); + id = ObjectUtil.getIfNotNull(row.getValue(1), Object::toString); data = ObjectUtil.getIfNotNull(row.getValue(2), Object::toString); typeAsString = ObjectUtil.getIfNotNull(row.getValue(3), Object::toString); } catch (ClassCastException e) { diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java b/src/main/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapper.java similarity index 82% rename from src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java rename to src/main/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapper.java index 6b6cc4462ae..99896d72911 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapper.java @@ -4,6 +4,7 @@ import io.vertx.sqlclient.RowIterator; import io.vertx.sqlclient.RowSet; import org.prebid.server.settings.model.StoredResponseDataResult; +import org.prebid.server.util.ObjectUtil; import java.util.ArrayList; import java.util.Collections; @@ -12,9 +13,9 @@ import java.util.Map; import java.util.Set; -public class JdbcStoredResponseResultMapper { +public class DatabaseStoredResponseResultMapper { - private JdbcStoredResponseResultMapper() { + private DatabaseStoredResponseResultMapper() { } public static StoredResponseDataResult map(RowSet rowSet, Set responseIds) { @@ -33,7 +34,9 @@ public static StoredResponseDataResult map(RowSet rowSet, Set respo errors.add("Result set column number is less than expected"); return StoredResponseDataResult.of(Collections.emptyMap(), errors); } - storedIdToResponse.put(row.getString(0), row.getString(1)); + final String key = ObjectUtil.getIfNotNull(row.getValue(0), Object::toString); + final String value = ObjectUtil.getIfNotNull(row.getValue(1), Object::toString); + storedIdToResponse.put(key, value); } errors.addAll(responseIds.stream().filter(id -> !storedIdToResponse.containsKey(id)) diff --git a/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java b/src/main/java/org/prebid/server/settings/service/DatabasePeriodicRefreshService.java similarity index 83% rename from src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java rename to src/main/java/org/prebid/server/settings/service/DatabasePeriodicRefreshService.java index 13e76bc9c89..cc4b80ad870 100644 --- a/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java +++ b/src/main/java/org/prebid/server/settings/service/DatabasePeriodicRefreshService.java @@ -11,10 +11,10 @@ import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.CacheNotificationListener; -import org.prebid.server.settings.helper.JdbcStoredDataResultMapper; +import org.prebid.server.settings.helper.DatabaseStoredDataResultMapper; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.vertx.Initializable; -import org.prebid.server.vertx.jdbc.JdbcClient; +import org.prebid.server.vertx.database.DatabaseClient; import java.time.Clock; import java.time.Instant; @@ -42,9 +42,9 @@ * If data is not empty, depending on TYPE, it should be put to corresponding map with ID as a key and DATA as value. *

*/ -public class JdbcPeriodicRefreshService implements Initializable { +public class DatabasePeriodicRefreshService implements Initializable { - private static final Logger logger = LoggerFactory.getLogger(JdbcPeriodicRefreshService.class); + private static final Logger logger = LoggerFactory.getLogger(DatabasePeriodicRefreshService.class); /** * Example of initialize query: @@ -71,24 +71,24 @@ public class JdbcPeriodicRefreshService implements Initializable { private final MetricName cacheType; private final CacheNotificationListener cacheNotificationListener; private final Vertx vertx; - private final JdbcClient jdbcClient; + private final DatabaseClient databaseClient; private final TimeoutFactory timeoutFactory; private final Metrics metrics; private final Clock clock; private Instant lastUpdate; - public JdbcPeriodicRefreshService(String initQuery, - String updateQuery, - long refreshPeriod, - long timeout, - MetricName cacheType, - CacheNotificationListener cacheNotificationListener, - Vertx vertx, - JdbcClient jdbcClient, - TimeoutFactory timeoutFactory, - Metrics metrics, - Clock clock) { + public DatabasePeriodicRefreshService(String initQuery, + String updateQuery, + long refreshPeriod, + long timeout, + MetricName cacheType, + CacheNotificationListener cacheNotificationListener, + Vertx vertx, + DatabaseClient databaseClient, + TimeoutFactory timeoutFactory, + Metrics metrics, + Clock clock) { this.initQuery = Objects.requireNonNull(StringUtils.stripToNull(initQuery)); this.updateQuery = Objects.requireNonNull(StringUtils.stripToNull(updateQuery)); @@ -97,7 +97,7 @@ public JdbcPeriodicRefreshService(String initQuery, this.cacheType = Objects.requireNonNull(cacheType); this.cacheNotificationListener = Objects.requireNonNull(cacheNotificationListener); this.vertx = Objects.requireNonNull(vertx); - this.jdbcClient = Objects.requireNonNull(jdbcClient); + this.databaseClient = Objects.requireNonNull(databaseClient); this.timeoutFactory = Objects.requireNonNull(timeoutFactory); this.metrics = Objects.requireNonNull(metrics); this.clock = Objects.requireNonNull(clock); @@ -115,10 +115,10 @@ public void initialize(Promise initializePromise) { private void getAll() { final long startTime = clock.millis(); - jdbcClient.executeQuery( + databaseClient.executeQuery( initQuery, Collections.emptyList(), - JdbcStoredDataResultMapper::map, + DatabaseStoredDataResultMapper::map, createTimeout()) .map(storedDataResult -> handleResult(storedDataResult, Instant.now(clock), startTime, MetricName.initialize)) @@ -139,7 +139,7 @@ private Void handleResult(StoredDataResult storedDataResult, } private Future handleFailure(Throwable exception, long startTime, MetricName refreshType) { - logger.warn("Error occurred while request to jdbc refresh service", exception); + logger.warn("Error occurred while request to database refresh service", exception); metrics.updateSettingsCacheRefreshTime(cacheType, refreshType, clock.millis() - startTime); metrics.updateSettingsCacheRefreshErrorMetric(cacheType, refreshType); @@ -151,10 +151,10 @@ private void refresh() { final Instant updateTime = Instant.now(clock); final long startTime = clock.millis(); - jdbcClient.executeQuery( + databaseClient.executeQuery( updateQuery, Collections.singletonList(Date.from(lastUpdate)), - JdbcStoredDataResultMapper::map, + DatabaseStoredDataResultMapper::map, createTimeout()) .map(storedDataResult -> handleResult(invalidate(storedDataResult), updateTime, startTime, MetricName.update)) diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 4929a67fca4..538eaeb3159 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -16,17 +16,17 @@ import org.prebid.server.settings.ApplicationSettings; import org.prebid.server.settings.CachingApplicationSettings; import org.prebid.server.settings.CompositeApplicationSettings; +import org.prebid.server.settings.DatabaseApplicationSettings; import org.prebid.server.settings.EnrichingApplicationSettings; import org.prebid.server.settings.FileApplicationSettings; import org.prebid.server.settings.HttpApplicationSettings; -import org.prebid.server.settings.JdbcApplicationSettings; import org.prebid.server.settings.SettingsCache; import org.prebid.server.settings.helper.ParametrizedQueryHelper; +import org.prebid.server.settings.service.DatabasePeriodicRefreshService; import org.prebid.server.settings.service.HttpPeriodicRefreshService; -import org.prebid.server.settings.service.JdbcPeriodicRefreshService; import org.prebid.server.spring.config.database.DatabaseConfiguration; +import org.prebid.server.vertx.database.DatabaseClient; import org.prebid.server.vertx.httpclient.HttpClient; -import org.prebid.server.vertx.jdbc.JdbcClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -73,17 +73,17 @@ FileApplicationSettings fileApplicationSettings( static class DatabaseSettingsConfiguration { @Bean - JdbcApplicationSettings jdbcApplicationSettings( + DatabaseApplicationSettings databaseApplicationSettings( @Value("${settings.database.account-query}") String accountQuery, @Value("${settings.database.stored-requests-query}") String storedRequestsQuery, @Value("${settings.database.amp-stored-requests-query}") String ampStoredRequestsQuery, @Value("${settings.database.stored-responses-query}") String storedResponsesQuery, ParametrizedQueryHelper parametrizedQueryHelper, - JdbcClient jdbcClient, + DatabaseClient databaseClient, JacksonMapper jacksonMapper) { - return new JdbcApplicationSettings( - jdbcClient, + return new DatabaseApplicationSettings( + databaseClient, jacksonMapper, parametrizedQueryHelper, accountQuery, @@ -151,21 +151,21 @@ public HttpPeriodicRefreshService ampHttpPeriodicRefreshService( @Configuration @ConditionalOnProperty( - prefix = "settings.in-memory-cache.jdbc-update", + prefix = "settings.in-memory-cache.database-update", name = {"refresh-rate", "timeout", "init-query", "update-query", "amp-init-query", "amp-update-query"}) - static class JdbcPeriodicRefreshServiceConfiguration { + static class DatabasePeriodicRefreshServiceConfiguration { - @Value("${settings.in-memory-cache.jdbc-update.refresh-rate}") + @Value("${settings.in-memory-cache.database-update.refresh-rate}") long refreshPeriod; - @Value("${settings.in-memory-cache.jdbc-update.timeout}") + @Value("${settings.in-memory-cache.database-update.timeout}") long timeout; @Autowired Vertx vertx; @Autowired - JdbcClient jdbcClient; + DatabaseClient databaseClient; @Autowired TimeoutFactory timeoutFactory; @@ -177,12 +177,12 @@ static class JdbcPeriodicRefreshServiceConfiguration { Clock clock; @Bean - public JdbcPeriodicRefreshService jdbcPeriodicRefreshService( + public DatabasePeriodicRefreshService databasePeriodicRefreshService( @Qualifier("settingsCache") SettingsCache settingsCache, - @Value("${settings.in-memory-cache.jdbc-update.init-query}") String initQuery, - @Value("${settings.in-memory-cache.jdbc-update.update-query}") String updateQuery) { + @Value("${settings.in-memory-cache.database-update.init-query}") String initQuery, + @Value("${settings.in-memory-cache.database-update.update-query}") String updateQuery) { - return new JdbcPeriodicRefreshService( + return new DatabasePeriodicRefreshService( initQuery, updateQuery, refreshPeriod, @@ -190,19 +190,19 @@ public JdbcPeriodicRefreshService jdbcPeriodicRefreshService( MetricName.stored_request, settingsCache, vertx, - jdbcClient, + databaseClient, timeoutFactory, metrics, clock); } @Bean - public JdbcPeriodicRefreshService ampJdbcPeriodicRefreshService( + public DatabasePeriodicRefreshService ampDatabasePeriodicRefreshService( @Qualifier("ampSettingsCache") SettingsCache ampSettingsCache, - @Value("${settings.in-memory-cache.jdbc-update.amp-init-query}") String ampInitQuery, - @Value("${settings.in-memory-cache.jdbc-update.amp-update-query}") String ampUpdateQuery) { + @Value("${settings.in-memory-cache.database-update.amp-init-query}") String ampInitQuery, + @Value("${settings.in-memory-cache.database-update.amp-update-query}") String ampUpdateQuery) { - return new JdbcPeriodicRefreshService( + return new DatabasePeriodicRefreshService( ampInitQuery, ampUpdateQuery, refreshPeriod, @@ -210,7 +210,7 @@ public JdbcPeriodicRefreshService ampJdbcPeriodicRefreshService( MetricName.amp_stored_request, ampSettingsCache, vertx, - jdbcClient, + databaseClient, timeoutFactory, metrics, clock); @@ -226,12 +226,12 @@ static class CompositeSettingsConfiguration { @Bean CompositeApplicationSettings compositeApplicationSettings( @Autowired(required = false) FileApplicationSettings fileApplicationSettings, - @Autowired(required = false) JdbcApplicationSettings jdbcApplicationSettings, + @Autowired(required = false) DatabaseApplicationSettings databaseApplicationSettings, @Autowired(required = false) HttpApplicationSettings httpApplicationSettings) { final List applicationSettingsList = Stream.of(fileApplicationSettings, - jdbcApplicationSettings, + databaseApplicationSettings, httpApplicationSettings) .filter(Objects::nonNull) .toList(); diff --git a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java index 56f2f045245..ba322b34707 100644 --- a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java @@ -16,8 +16,8 @@ import org.prebid.server.spring.config.database.properties.DatabaseConfigurationProperties; import org.prebid.server.spring.config.model.CircuitBreakerProperties; import org.prebid.server.vertx.ContextRunner; -import org.prebid.server.vertx.jdbc.BasicJdbcClient; -import org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient; +import org.prebid.server.vertx.database.BasicDatabaseClient; +import org.prebid.server.vertx.database.CircuitBreakerSecuredDatabaseClient; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -45,6 +45,7 @@ DatabaseAddress databaseAddress(DatabaseConfigurationProperties databaseConfigur ConnectionPoolSettings connectionPoolSettings(DatabaseConfigurationProperties databaseConfigurationProperties) { return ConnectionPoolSettings.of( databaseConfigurationProperties.getPoolSize(), + databaseConfigurationProperties.getIdleConnectionTimeout(), databaseConfigurationProperties.getUser(), databaseConfigurationProperties.getPassword(), databaseConfigurationProperties.getType()); @@ -83,7 +84,8 @@ Pool mysqlConnectionPool(Vertx vertx, .setPassword(connectionPoolSettings.getPassword()) .setSsl(false) .setTcpKeepAlive(true) - .setIdleTimeout(1) + .setCachePreparedStatements(true) + .setIdleTimeout(connectionPoolSettings.getIdleTimeout()) .setIdleTimeoutUnit(TimeUnit.SECONDS); final PoolOptions poolOptions = new PoolOptions() @@ -111,7 +113,8 @@ Pool postgresConnectionPool(Vertx vertx, .setPassword(connectionPoolSettings.getPassword()) .setSsl(false) .setTcpKeepAlive(true) - .setIdleTimeout(1) + .setCachePreparedStatements(true) + .setIdleTimeout(connectionPoolSettings.getIdleTimeout()) .setIdleTimeoutUnit(TimeUnit.SECONDS); final PoolOptions poolOptions = new PoolOptions() @@ -135,14 +138,14 @@ CircuitBreakerProperties databaseCircuitBreakerProperties() { @Bean @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "false", matchIfMissing = true) - BasicJdbcClient basicJdbcClient(Pool pool, Metrics metrics, Clock clock, ContextRunner contextRunner) { + BasicDatabaseClient basicDatabaseClient(Pool pool, Metrics metrics, Clock clock, ContextRunner contextRunner) { - return createBasicJdbcClient(pool, metrics, clock, contextRunner); + return createBasicDatabaseClient(pool, metrics, clock, contextRunner); } @Bean @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "true") - CircuitBreakerSecuredJdbcClient circuitBreakerSecuredAsyncDatabaseClient( + CircuitBreakerSecuredDatabaseClient circuitBreakerSecuredAsyncDatabaseClient( Vertx vertx, Pool pool, Metrics metrics, @@ -150,10 +153,10 @@ CircuitBreakerSecuredJdbcClient circuitBreakerSecuredAsyncDatabaseClient( ContextRunner contextRunner, @Qualifier("databaseCircuitBreakerProperties") CircuitBreakerProperties circuitBreakerProperties) { - final BasicJdbcClient jdbcClient = createBasicJdbcClient(pool, metrics, clock, contextRunner); - return new CircuitBreakerSecuredJdbcClient( + final BasicDatabaseClient databaseClient = createBasicDatabaseClient(pool, metrics, clock, contextRunner); + return new CircuitBreakerSecuredDatabaseClient( vertx, - jdbcClient, + databaseClient, metrics, circuitBreakerProperties.getOpeningThreshold(), circuitBreakerProperties.getOpeningIntervalMs(), @@ -161,15 +164,15 @@ CircuitBreakerSecuredJdbcClient circuitBreakerSecuredAsyncDatabaseClient( clock); } - private static BasicJdbcClient createBasicJdbcClient(Pool pool, - Metrics metrics, - Clock clock, - ContextRunner contextRunner) { + private static BasicDatabaseClient createBasicDatabaseClient(Pool pool, + Metrics metrics, + Clock clock, + ContextRunner contextRunner) { - final BasicJdbcClient basicJdbcClient = new BasicJdbcClient(pool, metrics, clock); + final BasicDatabaseClient basicDatabaseClient = new BasicDatabaseClient(pool, metrics, clock); - contextRunner.runBlocking(promise -> basicJdbcClient.initialize().onComplete(promise)); + contextRunner.runBlocking(promise -> basicDatabaseClient.initialize().onComplete(promise)); - return basicJdbcClient; + return basicDatabaseClient; } } diff --git a/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java b/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java index a0ffb6fa5b0..10ca0eacf89 100644 --- a/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java +++ b/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java @@ -7,6 +7,8 @@ public class ConnectionPoolSettings { Integer poolSize; + Integer idleTimeout; + String user; String password; diff --git a/src/main/java/org/prebid/server/spring/config/database/model/DatabasePoolType.java b/src/main/java/org/prebid/server/spring/config/database/model/DatabasePoolType.java deleted file mode 100644 index d3337549654..00000000000 --- a/src/main/java/org/prebid/server/spring/config/database/model/DatabasePoolType.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.prebid.server.spring.config.database.model; - -public enum DatabasePoolType { - - hikari, c3p0 -} diff --git a/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java b/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java index 8c94c1c0ced..a521ea0c583 100644 --- a/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java +++ b/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java @@ -5,8 +5,6 @@ @AllArgsConstructor public enum DatabaseType { - postgres("org.postgresql.Driver"), - mysql("com.mysql.cj.jdbc.Driver"); - - public final String jdbcDriver; + postgres, + mysql; } diff --git a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java index 174bf82f35c..0f3e6ac8c79 100644 --- a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java @@ -2,12 +2,12 @@ import lombok.Data; import lombok.NoArgsConstructor; -import org.prebid.server.spring.config.database.model.DatabasePoolType; import org.prebid.server.spring.config.database.model.DatabaseType; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.PositiveOrZero; @Data @NoArgsConstructor @@ -18,6 +18,9 @@ public class DatabaseConfigurationProperties { @NotNull @Min(1) private Integer poolSize; + @NotNull + @PositiveOrZero + private Integer idleConnectionTimeout; @NotBlank private String host; @NotNull @@ -28,7 +31,5 @@ public class DatabaseConfigurationProperties { private String user; @NotBlank private String password; - @NotNull - private DatabasePoolType providerClass; } diff --git a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java b/src/main/java/org/prebid/server/vertx/database/BasicDatabaseClient.java similarity index 89% rename from src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java rename to src/main/java/org/prebid/server/vertx/database/BasicDatabaseClient.java index 6b6effa79a3..e5aa90aabb2 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/database/BasicDatabaseClient.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.sqlclient.Pool; @@ -21,15 +21,15 @@ /** * Wrapper over {@link Pool} that supports setting query timeout in milliseconds. */ -public class BasicJdbcClient implements JdbcClient { +public class BasicDatabaseClient implements DatabaseClient { - private static final Logger logger = LoggerFactory.getLogger(BasicJdbcClient.class); + private static final Logger logger = LoggerFactory.getLogger(BasicDatabaseClient.class); private final Pool pool; private final Metrics metrics; private final Clock clock; - public BasicJdbcClient(Pool pool, Metrics metrics, Clock clock) { + public BasicDatabaseClient(Pool pool, Metrics metrics, Clock clock) { this.pool = Objects.requireNonNull(pool); this.metrics = Objects.requireNonNull(metrics); this.clock = Objects.requireNonNull(clock); @@ -43,7 +43,7 @@ public BasicJdbcClient(Pool pool, Metrics metrics, Clock clock) { */ public Future initialize() { return pool.getConnection() - .recover(BasicJdbcClient::logConnectionError) + .recover(BasicDatabaseClient::logConnectionError) .mapEmpty(); } @@ -60,7 +60,7 @@ public Future executeQuery(String query, final long startTime = clock.millis(); return pool.getConnection() - .recover(BasicJdbcClient::logConnectionError) + .recover(BasicDatabaseClient::logConnectionError) .compose(connection -> makeQuery(connection, query, params)) .timeout(remainingTimeout, TimeUnit.MILLISECONDS) .recover(this::handleFailure) diff --git a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java b/src/main/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClient.java similarity index 65% rename from src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java rename to src/main/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClient.java index f85fa351941..bb4fa7d09c1 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClient.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.core.Vertx; @@ -18,26 +18,26 @@ import java.util.function.Function; /** - * JDBC Client wrapped by {@link CircuitBreaker} to achieve robust operating. + * Database Client wrapped by {@link CircuitBreaker} to achieve robust operating. */ -public class CircuitBreakerSecuredJdbcClient implements JdbcClient { +public class CircuitBreakerSecuredDatabaseClient implements DatabaseClient { - private static final Logger logger = LoggerFactory.getLogger(CircuitBreakerSecuredJdbcClient.class); + private static final Logger logger = LoggerFactory.getLogger(CircuitBreakerSecuredDatabaseClient.class); private static final ConditionalLogger conditionalLogger = new ConditionalLogger(logger); private static final int LOG_PERIOD_SECONDS = 5; - private final JdbcClient jdbcClient; + private final DatabaseClient databaseClient; private final CircuitBreaker breaker; - public CircuitBreakerSecuredJdbcClient(Vertx vertx, - JdbcClient jdbcClient, - Metrics metrics, - int openingThreshold, - long openingIntervalMs, - long closingIntervalMs, - Clock clock) { + public CircuitBreakerSecuredDatabaseClient(Vertx vertx, + DatabaseClient databaseClient, + Metrics metrics, + int openingThreshold, + long openingIntervalMs, + long closingIntervalMs, + Clock clock) { - this.jdbcClient = Objects.requireNonNull(jdbcClient); + this.databaseClient = Objects.requireNonNull(databaseClient); breaker = new CircuitBreaker( "db_cb", @@ -52,7 +52,7 @@ public CircuitBreakerSecuredJdbcClient(Vertx vertx, metrics.createDatabaseCircuitBreakerGauge(breaker::isOpen); - logger.info("Initialized JDBC client with Circuit Breaker"); + logger.info("Initialized database client with Circuit Breaker"); } @Override @@ -61,7 +61,8 @@ public Future executeQuery(String query, Function, T> mapper, Timeout timeout) { - return breaker.execute(promise -> jdbcClient.executeQuery(query, params, mapper, timeout).onComplete(promise)); + return breaker.execute( + promise -> databaseClient.executeQuery(query, params, mapper, timeout).onComplete(promise)); } private void circuitOpened() { diff --git a/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java b/src/main/java/org/prebid/server/vertx/database/DatabaseClient.java similarity index 77% rename from src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java rename to src/main/java/org/prebid/server/vertx/database/DatabaseClient.java index 3fc7754b038..87c9ada84c6 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/database/DatabaseClient.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.sqlclient.Row; @@ -9,10 +9,10 @@ import java.util.function.Function; /** - * Interface for asynchronous interaction with database over JDBC API. + * Interface for asynchronous interaction with database over database API. */ @FunctionalInterface -public interface JdbcClient { +public interface DatabaseClient { /** * Executes query with parameters and returns {@link Future} eventually holding result mapped to a model diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b31305ace9f..ce193e5cbc4 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -165,7 +165,7 @@ settings: enforce-valid-account: false database: pool-size: 20 - provider-class: c3p0 + idle-connection-timeout: 300 targeting: truncate-attr-chars: 20 default-account-config: > diff --git a/src/main/resources/c3p0.properties b/src/main/resources/c3p0.properties deleted file mode 100644 index 5a823a5deab..00000000000 --- a/src/main/resources/c3p0.properties +++ /dev/null @@ -1,8 +0,0 @@ -# can't turn off retries at all, that's why minimum value is 1 -c3p0.acquireRetryAttempts=1 -# don't wait before retrying -c3p0.acquireRetryDelay=0 -# how long to wait until connection becomes available -c3p0.checkoutTimeout=15000 -# how frequently to test idle pooled connections to avoid seeing broken or stale connections -c3p0.idleConnectionTestPeriod=300 diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy index 65a9d8da533..f5d934d245f 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy @@ -96,7 +96,7 @@ LIMIT 1 "settings.database.user" : mysql.username, "settings.database.password" : mysql.password, "settings.database.pool-size" : "2", // setting 2 here to leave some slack for the PBS - "settings.database.provider-class": "hikari" + "settings.database.idle-connection-timeout": "300" ].asImmutable() } @@ -108,7 +108,7 @@ LIMIT 1 "settings.database.user" : postgres.username, "settings.database.password" : postgres.password, "settings.database.pool-size" : "2", // setting 2 here to leave some slack for the PBS - "settings.database.provider-class": "hikari" + "settings.database.idle-connection-timeout": "300" ].asImmutable() } diff --git a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/DatabaseApplicationSettingsTest.java similarity index 90% rename from src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java rename to src/test/java/org/prebid/server/settings/DatabaseApplicationSettingsTest.java index 1871046b5d6..15ef34417a6 100644 --- a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/DatabaseApplicationSettingsTest.java @@ -17,7 +17,7 @@ import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredResponseDataResult; -import org.prebid.server.vertx.jdbc.JdbcClient; +import org.prebid.server.vertx.database.DatabaseClient; import java.time.Clock; import java.time.Instant; @@ -35,7 +35,7 @@ import static org.mockito.BDDMockito.given; @RunWith(VertxUnitRunner.class) -public class JdbcApplicationSettingsTest extends VertxTest { +public class DatabaseApplicationSettingsTest extends VertxTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -57,9 +57,9 @@ public class JdbcApplicationSettingsTest extends VertxTest { private ParametrizedQueryHelper parametrizedQueryHelper; @Mock - private JdbcClient jdbcClient; + private DatabaseClient databaseClient; - private JdbcApplicationSettings target; + private DatabaseApplicationSettings target; private Timeout timeout; @@ -67,8 +67,8 @@ public class JdbcApplicationSettingsTest extends VertxTest { public void setUp() { timeout = new TimeoutFactory(Clock.fixed(Instant.now(), ZoneId.systemDefault())).create(5000L); given(parametrizedQueryHelper.replaceAccountIdPlaceholder(SELECT_ACCOUNT_QUERY)).willReturn("query"); - target = new JdbcApplicationSettings( - jdbcClient, + target = new DatabaseApplicationSettings( + databaseClient, jacksonMapper, parametrizedQueryHelper, SELECT_ACCOUNT_QUERY, @@ -81,7 +81,7 @@ public void setUp() { public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated() { // given final Account givenAccount = Account.builder().build(); - given(jdbcClient.executeQuery( + given(databaseClient.executeQuery( eq("query"), eq(List.of("1001")), any(), @@ -99,7 +99,7 @@ public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated() { @Test public void getAccountByIdShouldFailIfAccountNotFound() { // given - given(jdbcClient.executeQuery( + given(databaseClient.executeQuery( eq("query"), eq(List.of("non-existing")), any(), @@ -124,7 +124,7 @@ public void getStoredDataShouldReturnExpectedResult() { Map.of("1", "value1", "2", "value2"), Map.of("4", "value4", "5", "value5"), emptyList()); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -146,7 +146,7 @@ public void getAmpStoredDataShouldReturnExpectedResult() { Map.of("1", "value1", "2", "value2"), Map.of(), emptyList()); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -168,7 +168,7 @@ public void getVideoStoredDataShouldReturnExpectedResult() { Map.of("1", "value1", "2", "value2"), Map.of("4", "value4", "5", "value5"), emptyList()); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -190,7 +190,7 @@ public void getStoredDataShouldReturnResultWithError() { Map.of("1", "value1"), Map.of(), List.of("No stored request found for id: 3")); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -212,7 +212,7 @@ public void getAmpStoredDataShouldReturnResultWithError() { Map.of("1", "value1"), Map.of(), List.of("No stored request found for id: 3")); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -234,7 +234,7 @@ public void getVideoStoredDataShouldReturnResultWithError() { Map.of("1", "value1"), Map.of(), List.of("No stored request found for id: 3")); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -255,7 +255,7 @@ public void getStoredResponseShouldReturnExpectedResult() { final StoredResponseDataResult givenStoredResponseResult = StoredResponseDataResult.of( Map.of("1", "response1"), List.of("No stored response found for id: 2")); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredResponseResult)); // when diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapperTest.java similarity index 89% rename from src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java rename to src/test/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapperTest.java index 305335705d3..88dab8b8267 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapperTest.java @@ -24,7 +24,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -public class JdbcStoredDataResultMapperTest { +public class DatabaseStoredDataResultMapperTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -38,7 +38,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet, null, emptySet(), emptySet()); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet, null, emptySet(), emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -53,7 +53,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, null, singleton("reqId"), @@ -72,7 +72,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasLessColumns givenRowSet(givenRow("accountId", "id1", "data")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("reqId"), @@ -91,7 +91,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedC givenRowSet(givenRow("accountId", "id1", "data", 123)); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("reqId"), @@ -112,7 +112,7 @@ public void mapShouldSkipStoredResultWithInvalidType() { givenRow("accountId", "id1", "data2", "invalid")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("id1"), @@ -131,7 +131,7 @@ public void mapShouldReturnStoredResultWithErrorForMissingId() { givenRowSet(givenRow("accountId", "id1", "data1", "request")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("id1"), @@ -153,7 +153,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorsForMissingIdsIfAccountDiff givenRow("accountId", "id2", "data2", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "otherAccountId", singleton("id1"), @@ -176,7 +176,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundB givenRow("accountId2", "id1", "data2", "request")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, null, singleton("id1"), @@ -199,7 +199,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundB givenRow("accountId2", "id2", "data-otherAccountId", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "otherAccountId", singleton("id1"), @@ -224,7 +224,7 @@ public void mapShouldReturnExpectedStoredResultForGivenAccount() { givenRow("otherAccountId", "id2", "data-otherAccountId", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("id1"), @@ -244,7 +244,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -261,7 +261,7 @@ public void mapWithoutParamsShouldSkipStoredResultWithInvalidType() { givenRow("accountId", "id2", "data2", "invalid")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -276,7 +276,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH givenRowSet(givenRow("accountId", "id1", "data")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -291,7 +291,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWhenResultSetHasInvalid givenRowSet(givenRow("accountId", "id1", "data", 123)); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -307,7 +307,7 @@ public void mapWithoutParamsShouldReturnExpectedStoredResult() { givenRow("accountId", "id2", "data2", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -323,7 +323,6 @@ private void givenRowSet(Row... rows) { private Row givenRow(Object... values) { final Row row = mock(Row.class); - given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); given(row.getValue(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); final JsonObject json = new JsonObject(); IntStream.range(0, values.length).forEach(i -> json.put(String.valueOf(i), values[i])); diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapperTest.java similarity index 83% rename from src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java rename to src/test/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapperTest.java index 3f6ee8ecd8e..693462b8c50 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapperTest.java @@ -25,7 +25,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -public class JdbcStoredResponseResultMapperTest { +public class DatabaseStoredResponseResultMapperTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -39,7 +39,7 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetIsEmpty() givenRowSet(); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, emptySet()); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, emptySet()); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -53,7 +53,7 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetHasLessCo givenRowSet(givenRow("id1")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, emptySet()); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, emptySet()); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -67,7 +67,7 @@ public void mapShouldReturnStoredResponseResultWithErrorForMissingID() { givenRowSet(givenRow("id1", "data")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); // then assertThat(result.getIdToStoredResponses()).hasSize(1) @@ -82,7 +82,7 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetHasEmptyR givenRowSet(); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, singleton("id")); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, singleton("id")); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -96,7 +96,7 @@ public void mapShouldReturnFilledStoredResponseResultWithoutErrors() { givenRowSet(givenRow("id1", "data1"), givenRow("id2", "data2")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); // then assertThat(result.getIdToStoredResponses()).hasSize(2) @@ -110,7 +110,7 @@ private void givenRowSet(Row... rows) { private Row givenRow(Object... values) { final Row row = mock(Row.class); - given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + given(row.getValue(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); final JsonObject json = new JsonObject(); IntStream.range(0, values.length).forEach(i -> json.put(String.valueOf(i), values[i])); given(row.toJson()).willReturn(json); diff --git a/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java b/src/test/java/org/prebid/server/settings/service/DatabasePeriodicRefreshServiceTest.java similarity index 85% rename from src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java rename to src/test/java/org/prebid/server/settings/service/DatabasePeriodicRefreshServiceTest.java index 9857d048ad9..2913f1e807b 100644 --- a/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java +++ b/src/test/java/org/prebid/server/settings/service/DatabasePeriodicRefreshServiceTest.java @@ -16,7 +16,7 @@ import org.prebid.server.metric.Metrics; import org.prebid.server.settings.CacheNotificationListener; import org.prebid.server.settings.model.StoredDataResult; -import org.prebid.server.vertx.jdbc.JdbcClient; +import org.prebid.server.vertx.database.DatabaseClient; import java.time.Clock; import java.time.Instant; @@ -37,7 +37,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -public class JdbcPeriodicRefreshServiceTest { +public class DatabasePeriodicRefreshServiceTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -47,7 +47,7 @@ public class JdbcPeriodicRefreshServiceTest { @Mock private Vertx vertx; @Mock - private JdbcClient jdbcClient; + private DatabaseClient databaseClient; private final Clock clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); private final TimeoutFactory timeoutFactory = new TimeoutFactory(clock); @Mock @@ -63,9 +63,9 @@ public void setUp() { final StoredDataResult updateResult = StoredDataResult.of(singletonMap("id1", "null"), singletonMap("id2", "changed_value"), emptyList()); - given(jdbcClient.executeQuery(eq("init_query"), anyList(), any(), any())) + given(databaseClient.executeQuery(eq("init_query"), anyList(), any(), any())) .willReturn(Future.succeededFuture(initialResult)); - given(jdbcClient.executeQuery(eq("update_query"), anyList(), any(), any())) + given(databaseClient.executeQuery(eq("update_query"), anyList(), any(), any())) .willReturn(Future.succeededFuture(updateResult)); } @@ -103,8 +103,8 @@ public void initializeShouldMakeOneInitialRequestAndTwoScheduledRequestsWithPara createAndInitService(1000); // then - verify(jdbcClient).executeQuery(eq("init_query"), eq(emptyList()), any(), any()); - verify(jdbcClient, times(2)).executeQuery(eq("update_query"), anyList(), any(), any()); + verify(databaseClient).executeQuery(eq("init_query"), eq(emptyList()), any(), any()); + verify(databaseClient, times(2)).executeQuery(eq("update_query"), anyList(), any(), any()); } @Test @@ -114,7 +114,7 @@ public void initializeShouldMakeOnlyOneInitialRequestIfRefreshPeriodIsNegative() // then verify(vertx, never()).setPeriodic(anyLong(), any()); - verify(jdbcClient).executeQuery(anyString(), anyList(), any(), any()); + verify(databaseClient).executeQuery(anyString(), anyList(), any(), any()); } @Test @@ -130,7 +130,7 @@ public void shouldUpdateTimerMetric() { @Test public void shouldUpdateTimerAndErrorMetric() { // given - given(jdbcClient.executeQuery(eq("init_query"), anyList(), any(), any())) + given(databaseClient.executeQuery(eq("init_query"), anyList(), any(), any())) .willReturn(Future.failedFuture("Query error")); // when @@ -145,7 +145,7 @@ public void shouldUpdateTimerAndErrorMetric() { private void createAndInitService(long refresh) { - final JdbcPeriodicRefreshService jdbcPeriodicRefreshService = new JdbcPeriodicRefreshService( + final DatabasePeriodicRefreshService databasePeriodicRefreshService = new DatabasePeriodicRefreshService( "init_query", "update_query", refresh, @@ -153,12 +153,12 @@ private void createAndInitService(long refresh) { MetricName.stored_request, cacheNotificationListener, vertx, - jdbcClient, + databaseClient, timeoutFactory, metrics, clock); - jdbcPeriodicRefreshService.initialize(Promise.promise()); + databasePeriodicRefreshService.initialize(Promise.promise()); } @SuppressWarnings("unchecked") diff --git a/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/database/BasicDatabaseClientTest.java similarity index 96% rename from src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java rename to src/test/java/org/prebid/server/vertx/database/BasicDatabaseClientTest.java index 79514bf1fec..941ac685520 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/database/BasicDatabaseClientTest.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.sqlclient.Pool; @@ -39,7 +39,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -public class BasicJdbcClientTest { +public class BasicDatabaseClientTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -50,7 +50,7 @@ public class BasicJdbcClientTest { private Metrics metrics; private Clock clock; - private BasicJdbcClient target; + private BasicDatabaseClient target; private Timeout timeout; @@ -59,14 +59,14 @@ public void setUp() { clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); timeout = new TimeoutFactory(clock).create(500L); - target = new BasicJdbcClient(pool, metrics, clock); + target = new BasicDatabaseClient(pool, metrics, clock); } @Test public void creationShouldFailOnNullArguments() { - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(null, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(pool, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(pool, metrics, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicDatabaseClient(null, null, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicDatabaseClient(pool, null, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicDatabaseClient(pool, metrics, null)); } @Test diff --git a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClientTest.java similarity index 92% rename from src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java rename to src/test/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClientTest.java index a1e86429401..ed415108260 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClientTest.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.core.Vertx; @@ -36,7 +36,7 @@ import static org.mockito.Mockito.verify; @RunWith(VertxUnitRunner.class) -public class CircuitBreakerSecuredJdbcClientTest { +public class CircuitBreakerSecuredDatabaseClientTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -45,11 +45,11 @@ public class CircuitBreakerSecuredJdbcClientTest { private Clock clock; @Mock - private JdbcClient wrappedJdbcClient; + private DatabaseClient wrappedDatabaseClient; @Mock private Metrics metrics; - private CircuitBreakerSecuredJdbcClient target; + private CircuitBreakerSecuredDatabaseClient target; private Timeout timeout; @@ -59,7 +59,7 @@ public void setUp() { clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); timeout = new TimeoutFactory(clock).create(500L); - target = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 1, 100L, 200L, clock); + target = new CircuitBreakerSecuredDatabaseClient(vertx, wrappedDatabaseClient, metrics, 1, 100L, 200L, clock); } @After @@ -112,7 +112,7 @@ public void executeQueryShouldNotExecuteQueryIfCircuitIsOpened(TestContext conte future.onComplete(context.asyncAssertFailure(throwable -> { assertThat(throwable).isInstanceOf(RuntimeException.class).hasMessage("open circuit"); - verify(wrappedJdbcClient) + verify(wrappedDatabaseClient) .executeQuery(any(), any(), any(), any()); // invoked only on 1 call })); } @@ -136,7 +136,7 @@ public void executeQueryShouldReturnExceptionIfCircuitIsHalfOpenedAndQueryFails( future.onComplete(context.asyncAssertFailure(exception -> { assertThat(exception).isInstanceOf(RuntimeException.class).hasMessage("exception1"); - verify(wrappedJdbcClient, times(2)) + verify(wrappedDatabaseClient, times(2)) .executeQuery(any(), any(), any(), any()); // invoked only on 1 & 3 calls })); } @@ -165,7 +165,7 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isEqualTo("value"); - verify(wrappedJdbcClient, times(2)) + verify(wrappedDatabaseClient, times(2)) .executeQuery(any(), any(), any(), any()); // invoked only on 1 & 3 calls })); } @@ -173,7 +173,7 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded @Test public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds(TestContext context) { // given - target = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 2, 100L, 200L, clock); + target = new CircuitBreakerSecuredDatabaseClient(vertx, wrappedDatabaseClient, metrics, 2, 100L, 200L, clock); givenExecuteQueryReturning(asList( Future.failedFuture(new RuntimeException("exception1")), @@ -194,7 +194,7 @@ public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds future2.onComplete(context.asyncAssertFailure(exception -> assertThat(exception).isInstanceOf(RuntimeException.class).hasMessage("exception2"))); - verify(wrappedJdbcClient, times(2)) + verify(wrappedDatabaseClient, times(2)) .executeQuery(any(), any(), any(), any()); } @@ -248,7 +248,7 @@ public void circuitBreakerGaugeShouldReportClosedWhenCircuitClosed(TestContext c @SuppressWarnings("unchecked") private void givenExecuteQueryReturning(List> results) { BDDMockito.BDDMyOngoingStubbing> given = - given(wrappedJdbcClient.executeQuery(any(), any(), any(), any())); + given(wrappedDatabaseClient.executeQuery(any(), any(), any(), any())); for (Future result : results) { given = given.willReturn((Future) result); } From 42c5b41d5d9d075ecb793936680b2c4f4be305f5 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:58:31 -0400 Subject: [PATCH 07/62] Consolidate Java version properties across all pom.xml files (#3147) --- extra/bundle/pom.xml | 1 - extra/modules/pom.xml | 1 - extra/pom.xml | 5 +++-- pom.xml | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 2c66f1b22f2..7f1adad0d6c 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -17,7 +17,6 @@ UTF-8 UTF-8 - 21 ${java.version} ${java.version} 2.5.6 diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 0d442c3d4ef..5091a3e3a65 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -25,7 +25,6 @@ UTF-8 UTF-8 - 21 ${java.version} ${java.version} diff --git a/extra/pom.xml b/extra/pom.xml index 7b8a60f2108..90192cc0325 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -15,10 +15,11 @@ + 21 UTF-8 UTF-8 - 21 - 21 + ${java.version} + ${java.version} 4.5.5 1.18.30 3.0.0-M6 diff --git a/pom.xml b/pom.xml index 0545e9ad7d9..17736c0daa2 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,6 @@ UTF-8 UTF-8 - 21 ${java.version} ${java.version} Dockerfile From 9cce446827820bf737d16c38736dda927a2dc56f Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Wed, 1 May 2024 07:52:56 -0400 Subject: [PATCH 08/62] Core: Async db client configuration (#3162) * Make prepared statement caching configurable * Bump the default stored request timeout from 50 to 100 ms to account for prepared statement usage --- docs/config-app.md | 2 ++ .../spring/config/database/DatabaseConfiguration.java | 8 ++++++-- .../config/database/model/ConnectionPoolSettings.java | 4 ++++ .../properties/DatabaseConfigurationProperties.java | 6 +++++- src/main/resources/application.yaml | 4 +++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index ee6bf32dbe3..9e9eed3ed2a 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -295,6 +295,8 @@ For database data source available next options: - `settings.database.password` - database password. - `settings.database.pool-size` - set the initial/min/max pool size of database connections. - `settings.database.idle-connection-timeout` - Set the idle timeout, time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed and get back to the pool if no data is received nor sent within the timeout. +- `settings.database.enable-prepared-statement-caching` - Enable caching of the prepared statements so that they can be reused. Defaults to `false`. Please be vary of the DB server limitations as cache instances is per-database-connection. +- `settings.database.max-prepared-statement-cache-size` - Set the maximum size of the prepared statement cache. Defaults to `256`. Has any effect only when `settings.database.enable-prepared-statement-caching` is set to `true`. Please note that the cache size is multiplied by `settings.database.pool-size`. - `settings.database.account-query` - the SQL query to fetch account. - `settings.database.stored-requests-query` - the SQL query to fetch stored requests. - `settings.database.amp-stored-requests-query` - the SQL query to fetch AMP stored requests. diff --git a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java index ba322b34707..6a1a1531f1c 100644 --- a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java @@ -46,6 +46,8 @@ ConnectionPoolSettings connectionPoolSettings(DatabaseConfigurationProperties da return ConnectionPoolSettings.of( databaseConfigurationProperties.getPoolSize(), databaseConfigurationProperties.getIdleConnectionTimeout(), + databaseConfigurationProperties.getEnablePreparedStatementCaching(), + databaseConfigurationProperties.getMaxPreparedStatementCacheSize(), databaseConfigurationProperties.getUser(), databaseConfigurationProperties.getPassword(), databaseConfigurationProperties.getType()); @@ -84,7 +86,8 @@ Pool mysqlConnectionPool(Vertx vertx, .setPassword(connectionPoolSettings.getPassword()) .setSsl(false) .setTcpKeepAlive(true) - .setCachePreparedStatements(true) + .setCachePreparedStatements(connectionPoolSettings.getEnablePreparedStatementCaching()) + .setPreparedStatementCacheMaxSize(connectionPoolSettings.getMaxPreparedStatementCacheSize()) .setIdleTimeout(connectionPoolSettings.getIdleTimeout()) .setIdleTimeoutUnit(TimeUnit.SECONDS); @@ -113,7 +116,8 @@ Pool postgresConnectionPool(Vertx vertx, .setPassword(connectionPoolSettings.getPassword()) .setSsl(false) .setTcpKeepAlive(true) - .setCachePreparedStatements(true) + .setCachePreparedStatements(connectionPoolSettings.getEnablePreparedStatementCaching()) + .setPreparedStatementCacheMaxSize(connectionPoolSettings.getMaxPreparedStatementCacheSize()) .setIdleTimeout(connectionPoolSettings.getIdleTimeout()) .setIdleTimeoutUnit(TimeUnit.SECONDS); diff --git a/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java b/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java index 10ca0eacf89..92f929564d6 100644 --- a/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java +++ b/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java @@ -9,6 +9,10 @@ public class ConnectionPoolSettings { Integer idleTimeout; + Boolean enablePreparedStatementCaching; + + Integer maxPreparedStatementCacheSize; + String user; String password; diff --git a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java index 0f3e6ac8c79..cd570100df3 100644 --- a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java @@ -21,6 +21,11 @@ public class DatabaseConfigurationProperties { @NotNull @PositiveOrZero private Integer idleConnectionTimeout; + @NotNull + private Boolean enablePreparedStatementCaching; + @NotNull + @Min(1) + private Integer maxPreparedStatementCacheSize; @NotBlank private String host; @NotNull @@ -32,4 +37,3 @@ public class DatabaseConfigurationProperties { @NotBlank private String password; } - diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index ce193e5cbc4..94a483a7797 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -114,7 +114,7 @@ auction: max: 5000 percent: 100 tmax-upstream-response-time: 30 - stored-requests-timeout-ms: 50 + stored-requests-timeout-ms: 100 timeout-notification: timeout-ms: 200 log-result: false @@ -166,6 +166,8 @@ settings: database: pool-size: 20 idle-connection-timeout: 300 + enable-prepared-statement-caching: false + max-prepared-statement-cache-size: 256 targeting: truncate-attr-chars: 20 default-account-config: > From c3f6d6dd8ba5e81c74db2f02c67065a1083812f7 Mon Sep 17 00:00:00 2001 From: bretg Date: Thu, 2 May 2024 05:44:08 -0400 Subject: [PATCH 09/62] Mobfoxpb: Update contact email (#3125) --- src/main/resources/bidder-config/mobfoxpb.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/mobfoxpb.yaml b/src/main/resources/bidder-config/mobfoxpb.yaml index f9d05c7e2c3..bed22ef4094 100644 --- a/src/main/resources/bidder-config/mobfoxpb.yaml +++ b/src/main/resources/bidder-config/mobfoxpb.yaml @@ -2,7 +2,7 @@ adapters: mobfoxpb: endpoint: http://bes.mobfox.com/?c=__route__&m=__method__&key=__key__ meta-info: - maintainer-email: platform@mobfox.com + maintainer-email: support@mobfox.com app-media-types: - banner - video From c4f9d6d7f1089aadb71ef9c22dd4965248bd4321 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Thu, 2 May 2024 05:45:19 -0400 Subject: [PATCH 10/62] Sharethrough: Add GDPR and GPP info to usersync url (#3115) --- src/main/resources/bidder-config/sharethrough.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/sharethrough.yaml b/src/main/resources/bidder-config/sharethrough.yaml index d108840dd26..36cc0f0127f 100644 --- a/src/main/resources/bidder-config/sharethrough.yaml +++ b/src/main/resources/bidder-config/sharethrough.yaml @@ -16,6 +16,6 @@ adapters: usersync: cookie-family-name: sharethrough redirect: - url: https://match.sharethrough.com/FGMrCMMc/v1?redirectUri={{redirect_url}} + url: https://match.sharethrough.com/FGMrCMMc/v1?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirectUri={{redirect_url}} support-cors: false uid-macro: '$UID' From 1fee46acea96b5826654cd34058bb5cc9931d4fb Mon Sep 17 00:00:00 2001 From: osulzhenko <125548596+osulzhenko@users.noreply.github.com> Date: Thu, 2 May 2024 13:55:08 +0300 Subject: [PATCH 11/62] Core: Add PostgreSQL SASL SCRAM-SHA-256 authentication support (#3141) --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 17736c0daa2..5edefec9fc8 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,7 @@ 3.21.7 3.17.3 1.0.7 + 2.1 4.13.2 @@ -183,6 +184,11 @@ vertx-auth-common ${vertx.version} + + com.ongres.scram + client + ${scram.version} + io.netty netty-transport-native-epoll From be2b0d6c2b6f915970ff658c3d0695a3e802257a Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Thu, 2 May 2024 14:00:16 +0300 Subject: [PATCH 12/62] CleanUp: Remove completed `TODO`s. (#3154) --- .../org/prebid/server/auction/GeoLocationServiceWrapper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java b/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java index ce1c33a1304..4c1a3b0b8cf 100644 --- a/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java +++ b/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java @@ -38,7 +38,6 @@ public GeoLocationServiceWrapper(GeoLocationService geoLocationService, this.metrics = Objects.requireNonNull(metrics); } - //todo: account settings will work as expected if the default account resolving refactoring is done public Future lookup(AuctionContext auctionContext) { final Account account = auctionContext.getAccount(); final Device device = auctionContext.getBidRequest().getDevice(); From dba8f6dbda91d02e980804898c21f628b9f971b4 Mon Sep 17 00:00:00 2001 From: bretg Date: Thu, 2 May 2024 08:03:27 -0400 Subject: [PATCH 13/62] Emxdigital: add geoscope to YAML (#3132) --- src/main/resources/bidder-config/emxdigital.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/bidder-config/emxdigital.yaml b/src/main/resources/bidder-config/emxdigital.yaml index 5862a06f4ba..34080708c3e 100644 --- a/src/main/resources/bidder-config/emxdigital.yaml +++ b/src/main/resources/bidder-config/emxdigital.yaml @@ -4,6 +4,10 @@ adapters: aliases: cadent_aperture_mx: enabled: false + # CadentAperture only operates in North America + geoscope: + - USA + - CAN meta-info: maintainer-email: contactaperturemx@cadent.tv app-media-types: From 7b5497447c4780da4df491ea778119b18f9b95ef Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 2 May 2024 15:24:49 +0200 Subject: [PATCH 14/62] Kargo: Adding GPP macros to bidder-info (#3108) --- src/main/resources/bidder-config/kargo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/kargo.yaml b/src/main/resources/bidder-config/kargo.yaml index 79532582447..164eb0a7916 100644 --- a/src/main/resources/bidder-config/kargo.yaml +++ b/src/main/resources/bidder-config/kargo.yaml @@ -15,6 +15,6 @@ adapters: usersync: cookie-family-name: kargo redirect: - url: https://crb.kargo.com/api/v1/dsync/PrebidServer?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&r={{redirect_url}} + url: https://crb.kargo.com/api/v1/dsync/PrebidServer?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&r={{redirect_url}} support-cors: false uid-macro: '$UID' From 7efacca2b0dc9e156fcc1008ad5af008a859f7ee Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 2 May 2024 15:26:16 +0200 Subject: [PATCH 15/62] Taboola: Fix gpp query param (#3107) --- src/main/resources/bidder-config/taboola.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/bidder-config/taboola.yaml b/src/main/resources/bidder-config/taboola.yaml index f7401931c3b..f5cc2bfeb62 100644 --- a/src/main/resources/bidder-config/taboola.yaml +++ b/src/main/resources/bidder-config/taboola.yaml @@ -15,11 +15,11 @@ adapters: userSync: cookie-family-name: taboola redirect: - url: https://trc.taboola.com/sg/ps/1/cm?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} + url: https://trc.taboola.com/sg/ps/1/cm?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirect={{redirect_url}} support-cors: false uid-macro: '' iframe: - url: https://cdn.taboola.com/scripts/ps-sync.html?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} + url: https://cdn.taboola.com/scripts/ps-sync.html?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirect={{redirect_url}} support-cors: false uid-macro: '' From 62a266ded277979cd07f0799588250d20c672cde Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 2 May 2024 15:49:25 +0200 Subject: [PATCH 16/62] Criteo: Add GPP macros (#3105) --- src/main/resources/bidder-config/criteo.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/bidder-config/criteo.yaml b/src/main/resources/bidder-config/criteo.yaml index cf10a5cf480..2fbbadbb116 100644 --- a/src/main/resources/bidder-config/criteo.yaml +++ b/src/main/resources/bidder-config/criteo.yaml @@ -14,10 +14,10 @@ adapters: usersync: cookie-family-name: criteo redirect: - url: https://ssp-sync.criteo.com/user-sync/redirect?gdprapplies={{gdpr}}&gdpr={{gdpr_consent}}&ccpa={{us_privacy}}&redir={{redirect_url}}&profile=230 + url: https://ssp-sync.criteo.com/user-sync/redirect?gdprapplies={{gdpr}}&gdpr={{gdpr_consent}}&ccpa={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redir={{redirect_url}}&profile=230 support-cors: false uid-macro: '${CRITEO_USER_ID}' iframe: - url: https://ssp-sync.criteo.com/user-sync/iframe?gdprapplies={{gdpr}}&gdpr={{gdpr_consent}}&ccpa={{us_privacy}}&redir={{redirect_url}}&profile=230 + url: https://ssp-sync.criteo.com/user-sync/iframe?gdprapplies={{gdpr}}&gdpr={{gdpr_consent}}&ccpa={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redir={{redirect_url}}&profile=230 support-cors: false uid-macro: '${CRITEO_USER_ID}' From ec2670f5b85cc28ec2d2cb2c8d115115eff4d1ee Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 2 May 2024 15:53:15 +0200 Subject: [PATCH 17/62] Rise: Add GPP macros (#3106) --- src/main/resources/bidder-config/rise.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/rise.yaml b/src/main/resources/bidder-config/rise.yaml index f85876dd998..12fc11eb92e 100644 --- a/src/main/resources/bidder-config/rise.yaml +++ b/src/main/resources/bidder-config/rise.yaml @@ -15,6 +15,6 @@ adapters: usersync: cookie-family-name: rise iframe: - url: https://pbs-cs.yellowblue.io/pbs-iframe?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} + url: https://pbs-cs.yellowblue.io/pbs-iframe?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirect={{redirect_url}} support-cors: false uid-macro: '[PBS_UID]' From 630067d71984b14dcf6cc8b2dba666984ebf3a05 Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Thu, 2 May 2024 16:58:06 +0300 Subject: [PATCH 18/62] Core: Add jitter for cache (#3135) --- docs/config-app.md | 1 + .../USCustomLogicModuleCreator.java | 2 +- .../settings/CachingApplicationSettings.java | 15 ++-- .../prebid/server/settings/SettingsCache.java | 82 +++++++++++++++++-- .../spring/config/SettingsConfiguration.java | 20 ++++- .../CachingApplicationSettingsTest.java | 9 +- .../server/settings/SettingsCacheTest.java | 2 +- 7 files changed, 109 insertions(+), 22 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index 9e9eed3ed2a..a2f3b7a891b 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -340,6 +340,7 @@ See [application settings](application-settings.md) for full reference of availa For caching available next options: - `settings.in-memory-cache.ttl-seconds` - how long (in seconds) data will be available in LRU cache. - `settings.in-memory-cache.cache-size` - the size of LRU cache. +- `settings.in-memory-cache.jitter-seconds` - jitter (in seconds) for `settings.in-memory-cache.ttl-seconds` parameter. - `settings.in-memory-cache.notification-endpoints-enabled` - if equals to `true` two additional endpoints will be available: [/storedrequests/openrtb2](endpoints/storedrequests/openrtb2.md) and [/storedrequests/amp](endpoints/storedrequests/amp.md). - `settings.in-memory-cache.account-invalidation-enabled` - if equals to `true` additional admin protected endpoints will be diff --git a/src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/uscustomlogic/USCustomLogicModuleCreator.java b/src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/uscustomlogic/USCustomLogicModuleCreator.java index 6d8a308fc1a..026e856a585 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/uscustomlogic/USCustomLogicModuleCreator.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/uscustomlogic/USCustomLogicModuleCreator.java @@ -55,7 +55,7 @@ public USCustomLogicModuleCreator(USCustomLogicGppReaderFactory gppReaderFactory this.metrics = Objects.requireNonNull(metrics); jsonLogicNodesCache = cacheTtl != null && cacheSize != null - ? SettingsCache.createCache(cacheTtl, cacheSize) + ? SettingsCache.createCache(cacheTtl, cacheSize, 0) : null; } diff --git a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java index 7fb363a0ff0..f6e8d1f4868 100644 --- a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java @@ -48,16 +48,21 @@ public CachingApplicationSettings(ApplicationSettings delegate, SettingsCache videoCache, Metrics metrics, int ttl, - int size) { + int size, + int jitter) { if (ttl <= 0 || size <= 0) { throw new IllegalArgumentException("ttl and size must be positive"); } + if (jitter < 0 || jitter >= ttl) { + throw new IllegalArgumentException("jitter must match the inequality: 0 <= jitter < ttl"); + } + this.delegate = Objects.requireNonNull(delegate); - this.accountCache = SettingsCache.createCache(ttl, size); - this.accountToErrorCache = SettingsCache.createCache(ttl, size); - this.adServerPublisherToErrorCache = SettingsCache.createCache(ttl, size); - this.categoryConfigCache = SettingsCache.createCache(ttl, size); + this.accountCache = SettingsCache.createCache(ttl, size, jitter); + this.accountToErrorCache = SettingsCache.createCache(ttl, size, jitter); + this.adServerPublisherToErrorCache = SettingsCache.createCache(ttl, size, jitter); + this.categoryConfigCache = SettingsCache.createCache(ttl, size, jitter); this.cache = Objects.requireNonNull(cache); this.ampCache = Objects.requireNonNull(ampCache); this.videoCache = Objects.requireNonNull(videoCache); diff --git a/src/main/java/org/prebid/server/settings/SettingsCache.java b/src/main/java/org/prebid/server/settings/SettingsCache.java index 1bba204db36..3e2446742b1 100644 --- a/src/main/java/org/prebid/server/settings/SettingsCache.java +++ b/src/main/java/org/prebid/server/settings/SettingsCache.java @@ -1,8 +1,10 @@ package org.prebid.server.settings; import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.Expiry; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; +import org.checkerframework.checker.index.qual.NonNegative; import org.prebid.server.settings.model.StoredItem; import java.util.Collections; @@ -10,7 +12,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.ThreadLocalRandom; /** * Just a simple wrapper over in-memory caches for requests and imps. @@ -20,17 +22,26 @@ public class SettingsCache implements CacheNotificationListener { private final Map> requestCache; private final Map> impCache; - public SettingsCache(int ttl, int size) { + public SettingsCache(int ttl, int size, int jitter) { if (ttl <= 0 || size <= 0) { throw new IllegalArgumentException("ttl and size must be positive"); } - requestCache = createCache(ttl, size); - impCache = createCache(ttl, size); + if (jitter < 0 || jitter >= ttl) { + throw new IllegalArgumentException("jitter must match the inequality: 0 <= jitter < ttl"); + } + + requestCache = createCache(ttl, size, jitter); + impCache = createCache(ttl, size, jitter); } - public static Map createCache(int ttl, int size) { + public static Map createCache(int ttlSeconds, int size, int jitterSeconds) { + final long expireAfterNanos = (long) (ttlSeconds * 1e9); + final long jitterNanos = jitterSeconds == 0 ? 0L : (long) (jitterSeconds * 1e9); + return Caffeine.newBuilder() - .expireAfterWrite(ttl, TimeUnit.SECONDS) + .expireAfter(jitterNanos == 0L + ? new StaticExpiry<>(expireAfterNanos) + : new ExpiryWithJitter<>(expireAfterNanos, jitterNanos)) .maximumSize(size) .build() .asMap(); @@ -53,7 +64,10 @@ void saveImpCache(String accountId, String impId, String impValue) { } private static void saveCachedValue(Map> cache, - String accountId, String id, String value) { + String accountId, + String id, + String value) { + final Set values = ObjectUtils.defaultIfNull(cache.get(id), new HashSet<>()); values.add(StoredItem.of(accountId, value)); cache.put(id, values); @@ -79,4 +93,58 @@ public void invalidate(List requests, List imps) { requests.forEach(requestCache.keySet()::remove); imps.forEach(impCache.keySet()::remove); } + + private static class StaticExpiry implements Expiry { + + private final long expireAfterNanos; + + private StaticExpiry(long expireAfterNanos) { + this.expireAfterNanos = expireAfterNanos; + } + + @Override + public long expireAfterCreate(K key, V value, long currentTime) { + return expireAfterNanos; + } + + @Override + public long expireAfterUpdate(K key, V value, long currentTime, @NonNegative long currentDuration) { + return expireAfterNanos; + } + + @Override + public long expireAfterRead(K key, V value, long currentTime, @NonNegative long currentDuration) { + return currentDuration; + } + } + + private static class ExpiryWithJitter implements Expiry { + + private final Expiry baseExpiry; + private final long jitterNanos; + + private ExpiryWithJitter(long baseExpireAfterNanos, long jitterNanos) { + this.baseExpiry = new StaticExpiry<>(baseExpireAfterNanos); + this.jitterNanos = jitterNanos; + } + + @Override + public long expireAfterCreate(K key, V value, long currentTime) { + return baseExpiry.expireAfterCreate(key, value, currentTime) + jitter(); + } + + @Override + public long expireAfterUpdate(K key, V value, long currentTime, @NonNegative long currentDuration) { + return baseExpiry.expireAfterUpdate(key, value, currentTime, currentDuration) + jitter(); + } + + @Override + public long expireAfterRead(K key, V value, long currentTime, @NonNegative long currentDuration) { + return baseExpiry.expireAfterRead(key, value, currentTime, currentDuration); + } + + private long jitter() { + return ThreadLocalRandom.current().nextLong(-jitterNanos, jitterNanos); + } + } } diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 538eaeb3159..1006403c9c4 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -284,7 +284,8 @@ CachingApplicationSettings cachingApplicationSettings( videoCache, metrics, cacheProperties.getTtlSeconds(), - cacheProperties.getCacheSize()); + cacheProperties.getCacheSize(), + cacheProperties.getJitterSeconds()); } } @@ -306,19 +307,28 @@ static class CacheConfiguration { @Bean @Qualifier("settingsCache") SettingsCache settingsCache(ApplicationSettingsCacheProperties cacheProperties) { - return new SettingsCache(cacheProperties.getTtlSeconds(), cacheProperties.getCacheSize()); + return new SettingsCache( + cacheProperties.getTtlSeconds(), + cacheProperties.getCacheSize(), + cacheProperties.getJitterSeconds()); } @Bean @Qualifier("ampSettingsCache") SettingsCache ampSettingsCache(ApplicationSettingsCacheProperties cacheProperties) { - return new SettingsCache(cacheProperties.getTtlSeconds(), cacheProperties.getCacheSize()); + return new SettingsCache( + cacheProperties.getTtlSeconds(), + cacheProperties.getCacheSize(), + cacheProperties.getJitterSeconds()); } @Bean @Qualifier("videoSettingCache") SettingsCache videoSettingCache(ApplicationSettingsCacheProperties cacheProperties) { - return new SettingsCache(cacheProperties.getTtlSeconds(), cacheProperties.getCacheSize()); + return new SettingsCache( + cacheProperties.getTtlSeconds(), + cacheProperties.getCacheSize(), + cacheProperties.getJitterSeconds()); } } @@ -336,5 +346,7 @@ private static class ApplicationSettingsCacheProperties { @NotNull @Min(1) private Integer cacheSize; + @Min(0) + private int jitterSeconds; } } diff --git a/src/test/java/org/prebid/server/settings/CachingApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/CachingApplicationSettingsTest.java index a51d3fbfef7..9bc9cb27157 100644 --- a/src/test/java/org/prebid/server/settings/CachingApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/CachingApplicationSettingsTest.java @@ -61,12 +61,13 @@ public void setUp() { target = new CachingApplicationSettings( delegateSettings, - new SettingsCache(360, 100), - new SettingsCache(360, 100), - new SettingsCache(360, 100), + new SettingsCache(360, 100, 0), + new SettingsCache(360, 100, 0), + new SettingsCache(360, 100, 0), metrics, 360, - 100); + 100, + 0); } @Test diff --git a/src/test/java/org/prebid/server/settings/SettingsCacheTest.java b/src/test/java/org/prebid/server/settings/SettingsCacheTest.java index cdf602d21fe..f185d40edd7 100644 --- a/src/test/java/org/prebid/server/settings/SettingsCacheTest.java +++ b/src/test/java/org/prebid/server/settings/SettingsCacheTest.java @@ -15,7 +15,7 @@ public class SettingsCacheTest { @Before public void setUp() { - settingsCache = new SettingsCache(10, 10); + settingsCache = new SettingsCache(10, 10, 0); } @Test From dd7e58347bcc818a22c8c606597fefd1c980d0f4 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Thu, 2 May 2024 10:23:49 -0400 Subject: [PATCH 19/62] Housekeeping: Remove PG leftovers (#3112) --- docs/config-app.md | 5 -- pom.xml | 31 +++-------- .../prebid/server/health/HealthMonitor.java | 38 ------------- .../spring/config/AopConfiguration.java | 52 ------------------ src/main/resources/application.yaml | 5 -- .../server/health/HealthMonitorTest.java | 54 ------------------- .../org/prebid/server/it/IntegrationTest.java | 3 -- .../server/it/test-application.properties | 1 - 8 files changed, 7 insertions(+), 182 deletions(-) delete mode 100644 src/main/java/org/prebid/server/health/HealthMonitor.java delete mode 100644 src/main/java/org/prebid/server/spring/config/AopConfiguration.java delete mode 100644 src/test/java/org/prebid/server/health/HealthMonitorTest.java diff --git a/docs/config-app.md b/docs/config-app.md index a2f3b7a891b..c27b8980f3e 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -204,11 +204,6 @@ Also, each bidder could have its own bidder-specific options. - `admin-endpoints.tracelog.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. - `admin-endpoints.tracelog.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` -- `admin-endpoints.e2eadmin.enabled` - if equals to `true` the endpoint will be available. -- `admin-endpoints.e2eadmin.path` - the server context path where the endpoint will be accessible. -- `admin-endpoints.e2eadmin.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. -- `admin-endpoints.e2eadmin.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` - - `admin-endpoints.collected-metrics.enabled` - if equals to `true` the endpoint will be available. - `admin-endpoints.collected-metrics.path` - the server context path where the endpoint will be accessible. - `admin-endpoints.collected-metrics.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. diff --git a/pom.xml b/pom.xml index 5edefec9fc8..2496ff6a6bc 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,6 @@ 4.11.0 3.24.2 2.35.1 - 4.2.0 9.4.53.v20231009 5.4.0 2.2.220 @@ -66,7 +65,6 @@ 4.0.15 1.17.4 5.14.0 - 1.9.9.1 1.12.14 @@ -127,10 +125,6 @@ org.springframework.boot spring-boot-starter - - org.springframework.boot - spring-boot-starter-aop - jakarta.annotation jakarta.annotation-api @@ -409,12 +403,6 @@ ${assertj.version} test - - org.awaitility - awaitility - ${awaitility.version} - test - org.springframework.boot spring-boot-starter-test @@ -619,6 +607,7 @@ false ${skipUnitTests} + ${surefire.jacoco.args} @@ -788,18 +777,22 @@ com/iab/openrtb/** **/proto/** **/model/** + **/functional/** org/prebid/server/spring/config/** - prepare-agent + before-unit-test-execution prepare-agent + + surefire.jacoco.args + - report + after-unit-test-execution report @@ -914,9 +907,6 @@ org.apache.maven.plugins maven-failsafe-plugin - - -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" - ${mockserver.version} ${project.version} @@ -953,13 +943,6 @@ - - - org.aspectj - aspectjweaver - ${aspectj.version} - - org.apache.maven.plugins diff --git a/src/main/java/org/prebid/server/health/HealthMonitor.java b/src/main/java/org/prebid/server/health/HealthMonitor.java deleted file mode 100644 index 3fc8a53ed2a..00000000000 --- a/src/main/java/org/prebid/server/health/HealthMonitor.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.prebid.server.health; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.concurrent.atomic.LongAdder; - -/** - * Used to gather statistics and calculate the health index indicator. - */ -public class HealthMonitor { - - private final LongAdder totalCounter = new LongAdder(); - - private final LongAdder successCounter = new LongAdder(); - - /** - * Increments total number of requests. - */ - public void incTotal() { - totalCounter.increment(); - } - - /** - * Increments succeeded number of requests. - */ - public void incSuccess() { - successCounter.increment(); - } - - /** - * Returns value between 0.0 ... 1.0 where 1.0 is indicated 100% healthy. - */ - public BigDecimal calculateHealthIndex() { - final BigDecimal success = BigDecimal.valueOf(successCounter.sumThenReset()); - final BigDecimal total = BigDecimal.valueOf(totalCounter.sumThenReset()); - return total.longValue() == 0 ? BigDecimal.ONE : success.divide(total, 2, RoundingMode.HALF_EVEN); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/AopConfiguration.java b/src/main/java/org/prebid/server/spring/config/AopConfiguration.java deleted file mode 100644 index 736ca55a494..00000000000 --- a/src/main/java/org/prebid/server/spring/config/AopConfiguration.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.prebid.server.spring.config; - -import io.vertx.core.Future; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.prebid.server.health.HealthMonitor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; - -@Configuration -public class AopConfiguration { - - @Bean - HealthMonitor healthMonitor() { - return new HealthMonitor(); - } - - @Aspect - @Component - static class HealthMonitorAspect { - - @Autowired - HealthMonitor healthMonitor; - - @Around(value = "execution(* org.prebid.server.vertx.httpclient.HttpClient.*(..)) " - + "|| execution(* org.prebid.server.settings.ApplicationSettings.*(..)) " - + "|| execution(* org.prebid.server.geolocation.GeoLocationService.*(..))") - public Future around(ProceedingJoinPoint joinPoint) { - try { - return ((Future) joinPoint.proceed()) - .map(this::handleSucceedRequest) - .recover(this::handleFailRequest); - } catch (Throwable e) { - throw new IllegalStateException("Error while processing health monitoring", e); - } - } - - private Future handleFailRequest(Throwable throwable) { - healthMonitor.incTotal(); - return Future.failedFuture(throwable); - } - - private T handleSucceedRequest(T result) { - healthMonitor.incTotal(); - healthMonitor.incSuccess(); - return result; - } - } -} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 94a483a7797..b899795f418 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -67,11 +67,6 @@ admin-endpoints: path: /pbs-admin/tracelog on-application-port: false protected: true - e2eadmin: - enabled: false - path: /pbs-admin/e2eAdmin/* - on-application-port: false - protected: true collected-metrics: enabled: false path: /collected-metrics diff --git a/src/test/java/org/prebid/server/health/HealthMonitorTest.java b/src/test/java/org/prebid/server/health/HealthMonitorTest.java deleted file mode 100644 index adf8f6fbe66..00000000000 --- a/src/test/java/org/prebid/server/health/HealthMonitorTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.prebid.server.health; - -import org.junit.Before; -import org.junit.Test; - -import java.math.BigDecimal; - -import static org.assertj.core.api.Assertions.assertThat; - -public class HealthMonitorTest { - - private HealthMonitor healthMonitor; - - @Before - public void setUp() { - healthMonitor = new HealthMonitor(); - } - - @Test - public void calculateHealthIndexShouldReturnFullHealthIfNoRequestsSubmitted() { - // when - final BigDecimal result = healthMonitor.calculateHealthIndex(); - - // then - assertThat(result).isEqualTo(BigDecimal.ONE); - } - - @Test - public void calculateHealthIndexShouldReturnExpectedResult() { - // when - healthMonitor.incTotal(); - healthMonitor.incTotal(); - healthMonitor.incTotal(); - healthMonitor.incSuccess(); - - final BigDecimal result = healthMonitor.calculateHealthIndex(); - - // then - assertThat(result).isEqualTo(new BigDecimal("0.33")); - } - - @Test - public void calculateHealthIndexShouldResetResult() { - // when - healthMonitor.incTotal(); - healthMonitor.incSuccess(); - healthMonitor.calculateHealthIndex(); - - final BigDecimal result = healthMonitor.calculateHealthIndex(); - - // then - assertThat(result).isEqualTo(BigDecimal.ONE); - } -} diff --git a/src/test/java/org/prebid/server/it/IntegrationTest.java b/src/test/java/org/prebid/server/it/IntegrationTest.java index 119537ba161..aa519ea5a30 100644 --- a/src/test/java/org/prebid/server/it/IntegrationTest.java +++ b/src/test/java/org/prebid/server/it/IntegrationTest.java @@ -73,8 +73,6 @@ public abstract class IntegrationTest extends VertxTest { private static final String HOST_AND_PORT = "localhost:" + WIREMOCK_PORT; private static final String CACHE_PATH = "/cache"; private static final String CACHE_ENDPOINT = "http://" + HOST_AND_PORT + CACHE_PATH; - private static final String USER_SERVICE_PATH = "/user-data-details"; - private static final String USER_SERVICE_ENDPOINT = "http://" + HOST_AND_PORT + USER_SERVICE_PATH; @BeforeClass public static void setUp() throws IOException { @@ -252,7 +250,6 @@ private static String replaceStaticInfo(String json) { .replaceAll("\\{\\{ cache.resource_url }}", CACHE_ENDPOINT + "?uuid=") .replaceAll("\\{\\{ cache.host }}", HOST_AND_PORT) .replaceAll("\\{\\{ cache.path }}", CACHE_PATH) - .replaceAll("\\{\\{ userservice_uri }}", USER_SERVICE_ENDPOINT) .replaceAll("\\{\\{ event.url }}", "http://localhost:8080/event?"); } diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 29114f9d3fb..28f6c7fc5b3 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -504,7 +504,6 @@ admin-endpoints.logging-changelevel.enabled=true admin-endpoints.logging-changelevel.protected=false admin-endpoints.tracelog.enabled=true admin-endpoints.tracelog.protected=false -admin-endpoints.e2eadmin.enabled=false status-response=ok analytics.log.enabled=true gdpr.host-vendor-id=1 From 7fab67c2a5573bdcc4fa8d5144c540dff8d8cda6 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Mon, 6 May 2024 14:50:59 +0200 Subject: [PATCH 20/62] Docs: Update properties description (#3151) --- docs/config-app.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index c27b8980f3e..ae8c5d937b5 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -346,10 +346,10 @@ available: `/cache/invalidate?account={accountId}` which remove account from the - `settings.in-memory-cache.http-update.timeout` - timeout for obtaining stored request updates. - `settings.in-memory-cache.database-update.init-query` - initial query for fetching all stored requests at the startup. - `settings.in-memory-cache.database-update.update-query` - a query for periodical update of stored requests, that should -contain 'WHERE last_updated > ?' to fetch only the records that were updated since previous check. +contain 'WHERE last_updated > ?' for MySQL and 'WHERE last_updated > $1' for Postgresql to fetch only the records that were updated since previous check. - `settings.in-memory-cache.database-update.amp-init-query` - initial query for fetching all AMP stored requests at the startup. - `settings.in-memory-cache.database-update.amp-update-query` - a query for periodical update of AMP stored requests, that should -contain 'WHERE last_updated > ?' to fetch only the records that were updated since previous check. +contain 'WHERE last_updated > ?' for MySQL and 'WHERE last_updated > $1' for Postgresql to fetch only the records that were updated since previous check. - `settings.in-memory-cache.database-update.refresh-rate` - refresh period in ms for stored request updates. - `settings.in-memory-cache.database-update.timeout` - timeout for obtaining stored request updates. From 00940b08ba0e3f66fb882472c98b6baeba51ff7b Mon Sep 17 00:00:00 2001 From: Serhii Kolomiiets <46626223+VeryExtraordinaryUsername@users.noreply.github.com> Date: Mon, 6 May 2024 22:00:11 +0300 Subject: [PATCH 21/62] Core: Finished transition period for HTTP properties (#2728) --- docs/config-app.md | 8 ++++---- docs/metrics.md | 2 +- .../ApplicationServerConfiguration.java | 17 ++++++++--------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index ae8c5d937b5..c99bdd63a2f 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -22,10 +22,10 @@ This parameter exists to allow to change the location of the directory Vert.x wi - `server.jks-password` - password for the keystore (if ssl is enabled). ## HTTP Server -- `http.max-headers-size` - set the maximum length of all headers, deprecated(use server.max-headers-size instead). -- `http.ssl` - enable SSL/TLS support, deprecated(use server.ssl instead). -- `http.jks-path` - path to the java keystore (if ssl is enabled), deprecated(use server.jks-path instead). -- `http.jks-password` - password for the keystore (if ssl is enabled), deprecated(use server.jks-password instead). +- `server.max-headers-size` - set the maximum length of all headers, deprecated(use server.max-headers-size instead). +- `server.ssl` - enable SSL/TLS support, deprecated(use server.ssl instead). +- `server.jks-path` - path to the java keystore (if ssl is enabled), deprecated(use server.jks-path instead). +- `server.jks-password` - password for the keystore (if ssl is enabled), deprecated(use server.jks-password instead). - `server.http.server-instances` - how many http server instances should be created. This parameter affects how many CPU cores will be utilized by the application. Rough assumption - one http server instance will keep 1 CPU core busy. - `server.http.enabled` - if set to `true` enables http server diff --git a/docs/metrics.md b/docs/metrics.md index f1af81cbd0a..2f92c1ca71f 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -11,7 +11,7 @@ Other available metrics not mentioned here can found at where: - `[IP]` should be equal to IP address of bound network interface on cluster node for Prebid Server (for example: `0.0.0.0`) -- `[PORT]` should be equal to `http.port` configuration property +- `[PORT]` should be equal to `server.http.port` configuration property ### HTTP client metrics - `vertx.http.clients.connections.{min,max,mean,p95,p99}` - how long connections live diff --git a/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java b/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java index 4740f025320..5c7d5b187d0 100644 --- a/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java @@ -86,10 +86,10 @@ public class ApplicationServerConfiguration { @ConditionalOnProperty(name = "server.http.enabled", havingValue = "true") VerticleDefinition httpApplicationServerVerticleDefinition( HttpServerOptions httpServerOptions, - @Value("#{'${http.port:${server.http.port}}'}") Integer port, + @Value("${server.http.port}") int port, Router applicationServerRouter, ExceptionHandler exceptionHandler, - @Value("#{'${vertx.http-server-instances:${server.http.server-instances}}'}") Integer instances) { + @Value("${server.http.server-instances}") int instances) { return VerticleDefinition.ofMultiInstance( () -> new ServerVerticle( @@ -120,15 +120,14 @@ VerticleDefinition unixSocketApplicationServerVerticleDefinition( instances); } - // TODO: remove support for properties with http prefix after transition period @Bean HttpServerOptions httpServerOptions( - @Value("#{'${http.max-headers-size:${server.max-headers-size:}}'}") int maxHeaderSize, - @Value("#{'${http.max-initial-line-length:${server.max-initial-line-length:}}'}") int maxInitialLineLength, - @Value("#{'${http.ssl:${server.ssl:}}'}") boolean ssl, - @Value("#{'${http.jks-path:${server.jks-path:}}'}") String jksPath, - @Value("#{'${http.jks-password:${server.jks-password:}}'}") String jksPassword, - @Value("#{'${http.idle-timeout:${server.idle-timeout}}'}") int idleTimeout, + @Value("${server.max-headers-size}") int maxHeaderSize, + @Value("${server.max-initial-line-length}") int maxInitialLineLength, + @Value("${server.ssl}") boolean ssl, + @Value("${server.jks-path}") String jksPath, + @Value("${server.jks-password}") String jksPassword, + @Value("${server.idle-timeout}") int idleTimeout, @Value("${server.enable-quickack:#{null}}") Optional enableQuickAck, @Value("${server.enable-reuseport:#{null}}") Optional enableReusePort) { From 988fcbe343c1984905f03157e1d321e9c9bddfb6 Mon Sep 17 00:00:00 2001 From: Serhii Kolomiiets <46626223+VeryExtraordinaryUsername@users.noreply.github.com> Date: Mon, 6 May 2024 22:01:38 +0300 Subject: [PATCH 22/62] Core: Finish transition period for alias resolving (#2644) --- .../prebid/server/auction/BidResponseCreator.java | 12 +----------- .../settings/model/AccountAuctionEventConfig.java | 11 +---------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/prebid/server/auction/BidResponseCreator.java b/src/main/java/org/prebid/server/auction/BidResponseCreator.java index c1ccc7922f9..273f9f7cbfc 100644 --- a/src/main/java/org/prebid/server/auction/BidResponseCreator.java +++ b/src/main/java/org/prebid/server/auction/BidResponseCreator.java @@ -35,7 +35,6 @@ import org.prebid.server.auction.model.MultiBidConfig; import org.prebid.server.auction.model.TargetingInfo; import org.prebid.server.auction.model.debug.DebugContext; -import org.prebid.server.auction.requestfactory.Ortb2ImplicitParametersResolver; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderError; @@ -1444,16 +1443,7 @@ private static String channelFromRequest(BidRequest bidRequest) { final ExtRequestPrebid prebid = ext != null ? ext.getPrebid() : null; final ExtRequestPrebidChannel channel = prebid != null ? prebid.getChannel() : null; - return channel != null ? recogniseChannelName(channel.getName()) : null; - } - - // TODO: remove alias resolving after transition period - private static String recogniseChannelName(String channelName) { - if (StringUtils.equalsIgnoreCase("pbjs", channelName)) { - return Ortb2ImplicitParametersResolver.WEB_CHANNEL; - } - - return channelName; + return channel != null ? channel.getName() : null; } private static boolean eventsAllowedByRequest(AuctionContext auctionContext) { diff --git a/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java b/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java index 3df397c63f8..9f9c7b18e54 100644 --- a/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java +++ b/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import lombok.Builder; import lombok.Value; -import org.apache.commons.lang3.StringUtils; import java.util.Collections; import java.util.HashMap; @@ -23,14 +22,6 @@ public Map getEvents() { @JsonAnySetter public void addEvent(String key, Boolean value) { - events.put(resolveKey(key), value); - } - - private static String resolveKey(String key) { - if (StringUtils.equalsIgnoreCase("pbjs", key)) { - return "web"; - } - - return key; + events.put(key, value); } } From dc42b0bc8ccdaf5df172fd2c69b1cd829416e351 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Tue, 7 May 2024 13:32:52 +0200 Subject: [PATCH 23/62] Core: Convert some bidders as Generic aliases (#2828) --- .../prebid/server/bidder/GenericBidder.java | 36 +-- .../server/bidder/adrino/AdrinoBidder.java | 65 ----- .../server/bidder/alkimi/AlkimiBidder.java | 2 - .../prebid/server/bidder/ccx/CcxBidder.java | 83 ------ .../server/bidder/infytv/InfytvBidder.java | 68 ----- .../server/bidder/loopme/LoopmeBidder.java | 83 ------ .../server/bidder/mgidx/MgidxBidder.java | 1 - .../prebid/server/bidder/oms/OmsBidder.java | 19 +- .../zeta_global_ssp/ZetaGlobalSspBidder.java | 90 ------- .../config/bidder/AdrinoConfiguration.java | 41 --- .../config/bidder/CcxConfiguration.java | 42 --- .../config/bidder/InfytvConfiguration.java | 42 --- .../config/bidder/LoopmeConfiguration.java | 41 --- .../bidder/ZetaGlobalSspConfiguration.java | 42 --- src/main/resources/bidder-config/adrino.yaml | 10 - src/main/resources/bidder-config/ccx.yaml | 15 -- src/main/resources/bidder-config/generic.yaml | 73 ++++++ src/main/resources/bidder-config/infytv.yaml | 11 - src/main/resources/bidder-config/loopme.yaml | 15 -- .../bidder-config/zeta_global_ssp.yaml | 20 -- ...a_global_ssp.json => zeta-global-ssp.json} | 0 .../testcontainers/PbsConfig.groovy | 24 +- .../bidder/adrino/AdrinoBidderTest.java | 196 -------------- .../server/bidder/ccx/CcxBidderTest.java | 244 ------------------ .../bidder/infytv/InfytvBidderTest.java | 136 ---------- .../bidder/loopme/LoopmeBidderTest.java | 187 -------------- .../ZetaGlobalSspBidderTest.java | 195 -------------- .../prebid/server/it/ZetaGlobalSspTest.java | 12 +- .../infytv/test-auction-infytv-request.json | 9 +- .../infytv/test-infytv-bid-request-1.json | 9 +- ...test-auction-zeta-global-ssp-request.json} | 2 +- ...est-auction-zeta-global-ssp-response.json} | 4 +- .../test-zeta-global-ssp-bid-request.json} | 0 .../test-zeta-global-ssp-bid-response.json} | 0 .../server/it/test-application.properties | 20 +- 35 files changed, 133 insertions(+), 1704 deletions(-) delete mode 100644 src/main/java/org/prebid/server/bidder/adrino/AdrinoBidder.java delete mode 100644 src/main/java/org/prebid/server/bidder/ccx/CcxBidder.java delete mode 100644 src/main/java/org/prebid/server/bidder/infytv/InfytvBidder.java delete mode 100644 src/main/java/org/prebid/server/bidder/loopme/LoopmeBidder.java delete mode 100644 src/main/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidder.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java delete mode 100644 src/main/resources/bidder-config/adrino.yaml delete mode 100644 src/main/resources/bidder-config/ccx.yaml delete mode 100644 src/main/resources/bidder-config/infytv.yaml delete mode 100644 src/main/resources/bidder-config/loopme.yaml delete mode 100644 src/main/resources/bidder-config/zeta_global_ssp.yaml rename src/main/resources/static/bidder-params/{zeta_global_ssp.json => zeta-global-ssp.json} (100%) delete mode 100644 src/test/java/org/prebid/server/bidder/adrino/AdrinoBidderTest.java delete mode 100644 src/test/java/org/prebid/server/bidder/ccx/CcxBidderTest.java delete mode 100644 src/test/java/org/prebid/server/bidder/infytv/InfytvBidderTest.java delete mode 100644 src/test/java/org/prebid/server/bidder/loopme/LoopmeBidderTest.java delete mode 100644 src/test/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidderTest.java rename src/test/resources/org/prebid/server/it/openrtb2/{zeta_global_ssp/test-auction-zeta_global_ssp-request.json => zetaglobalssp/test-auction-zeta-global-ssp-request.json} (94%) rename src/test/resources/org/prebid/server/it/openrtb2/{zeta_global_ssp/test-auction-zeta_global_ssp-response.json => zetaglobalssp/test-auction-zeta-global-ssp-response.json} (86%) rename src/test/resources/org/prebid/server/it/openrtb2/{zeta_global_ssp/test-zeta_global_ssp-bid-request.json => zetaglobalssp/test-zeta-global-ssp-bid-request.json} (100%) rename src/test/resources/org/prebid/server/it/openrtb2/{zeta_global_ssp/test-zeta_global_ssp-bid-response.json => zetaglobalssp/test-zeta-global-ssp-bid-response.json} (100%) diff --git a/src/main/java/org/prebid/server/bidder/GenericBidder.java b/src/main/java/org/prebid/server/bidder/GenericBidder.java index a929e3673c2..a708de0ca1b 100644 --- a/src/main/java/org/prebid/server/bidder/GenericBidder.java +++ b/src/main/java/org/prebid/server/bidder/GenericBidder.java @@ -2,10 +2,8 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; -import io.vertx.core.http.HttpMethod; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderCall; @@ -14,14 +12,16 @@ import org.prebid.server.bidder.model.Result; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; import org.prebid.server.util.BidderUtil; import org.prebid.server.util.HttpUtil; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; public class GenericBidder implements Bidder { @@ -35,15 +35,7 @@ public GenericBidder(String endpointUrl, JacksonMapper mapper) { @Override public final Result>> makeHttpRequests(BidRequest bidRequest) { - return Result.withValue( - HttpRequest.builder() - .method(HttpMethod.POST) - .uri(endpointUrl) - .headers(HttpUtil.headers()) - .body(mapper.encodeToBytes(bidRequest)) - .impIds(BidderUtil.impIds(bidRequest)) - .payload(bidRequest) - .build()); + return Result.withValue(BidderUtil.defaultRequest(bidRequest, endpointUrl, mapper)); } @Override @@ -64,29 +56,15 @@ private static List extractBids(BidRequest bidRequest, BidResponse bi } private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { + final Map impMap = bidRequest.getImp().stream() + .collect(Collectors.toMap(Imp::getId, Function.identity())); return bidResponse.getSeatbid().stream() .filter(Objects::nonNull) .map(SeatBid::getBid) .filter(Objects::nonNull) .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidType(bid, bidRequest.getImp()), bidResponse.getCur())) + .map(bid -> BidderBid.of(bid, BidderUtil.getBidType(bid, impMap), bidResponse.getCur())) .toList(); } - private static BidType getBidType(Bid bid, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(bid.getImpid())) { - if (imp.getBanner() != null) { - return BidType.banner; - } else if (imp.getVideo() != null) { - return BidType.video; - } else if (imp.getXNative() != null) { - return BidType.xNative; - } else if (imp.getAudio() != null) { - return BidType.audio; - } - } - } - return BidType.banner; - } } diff --git a/src/main/java/org/prebid/server/bidder/adrino/AdrinoBidder.java b/src/main/java/org/prebid/server/bidder/adrino/AdrinoBidder.java deleted file mode 100644 index 2e79b69f0aa..00000000000 --- a/src/main/java/org/prebid/server/bidder/adrino/AdrinoBidder.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.prebid.server.bidder.adrino; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class AdrinoBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public AdrinoBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public final Result>> makeHttpRequests(BidRequest request) { - return Result.withValue(BidderUtil.defaultRequest(request, endpointUrl, mapper)); - } - - @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(bidResponse)); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - return Collections.emptyList(); - } - return bidsFromResponse(bidResponse); - } - - private static List bidsFromResponse(BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, BidType.xNative, bidResponse.getCur())) - .toList(); - } -} diff --git a/src/main/java/org/prebid/server/bidder/alkimi/AlkimiBidder.java b/src/main/java/org/prebid/server/bidder/alkimi/AlkimiBidder.java index 9d729408634..03a05d1b1aa 100644 --- a/src/main/java/org/prebid/server/bidder/alkimi/AlkimiBidder.java +++ b/src/main/java/org/prebid/server/bidder/alkimi/AlkimiBidder.java @@ -36,8 +36,6 @@ public class AlkimiBidder implements Bidder { private final String endpointUrl; private final JacksonMapper mapper; - private static final String TYPE_BANNER = "Banner"; - private static final String TYPE_VIDEO = "Video"; private static final String PRICE_MACRO = "${AUCTION_PRICE}"; private static final TypeReference> ALKIMI_EXT_TYPE_REFERENCE = new TypeReference<>() { diff --git a/src/main/java/org/prebid/server/bidder/ccx/CcxBidder.java b/src/main/java/org/prebid/server/bidder/ccx/CcxBidder.java deleted file mode 100644 index 91fcdc71a1c..00000000000 --- a/src/main/java/org/prebid/server/bidder/ccx/CcxBidder.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.prebid.server.bidder.ccx; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class CcxBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public CcxBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public Result>> makeHttpRequests(BidRequest request) { - - return Result.withValue(BidderUtil.defaultRequest(request, endpointUrl, mapper)); - } - - @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(httpCall.getRequest().getPayload(), bidResponse)); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - return Collections.emptyList(); - } - return bidsFromResponse(bidRequest, bidResponse); - } - - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidType(bid, bidRequest.getImp()), bidResponse.getCur())) - .toList(); - } - - private static BidType getBidType(Bid bid, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(bid.getImpid())) { - if (imp.getBanner() != null) { - return BidType.banner; - } else if (imp.getVideo() != null) { - return BidType.video; - } - break; - } - } - return BidType.banner; - } - -} diff --git a/src/main/java/org/prebid/server/bidder/infytv/InfytvBidder.java b/src/main/java/org/prebid/server/bidder/infytv/InfytvBidder.java deleted file mode 100644 index 237c7b133fc..00000000000 --- a/src/main/java/org/prebid/server/bidder/infytv/InfytvBidder.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.prebid.server.bidder.infytv; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -public class InfytvBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public InfytvBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public Result>> makeHttpRequests(BidRequest bidRequest) { - return Result.withValue(BidderUtil.defaultRequest(bidRequest, endpointUrl, mapper)); - } - - @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(bidResponse)); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse("Bad Response, " + e.getMessage())); - } catch (PreBidException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - throw new PreBidException("Empty SeatBid array"); - } - return bidsFromResponse(bidResponse); - } - - private static List bidsFromResponse(BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(Objects::nonNull) - .map(bid -> BidderBid.of(bid, BidType.video, bidResponse.getCur())) - .toList(); - } -} diff --git a/src/main/java/org/prebid/server/bidder/loopme/LoopmeBidder.java b/src/main/java/org/prebid/server/bidder/loopme/LoopmeBidder.java deleted file mode 100644 index 20161acc420..00000000000 --- a/src/main/java/org/prebid/server/bidder/loopme/LoopmeBidder.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.prebid.server.bidder.loopme; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class LoopmeBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public LoopmeBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public Result>> makeHttpRequests(BidRequest request) { - - return Result.withValue(BidderUtil.defaultRequest(request, endpointUrl, mapper)); - } - - @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.of(extractBids(httpCall.getRequest().getPayload(), bidResponse), Collections.emptyList()); - } catch (DecodeException | PreBidException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - return Collections.emptyList(); - } - return bidsFromResponse(bidRequest, bidResponse); - } - - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidType(bid.getImpid(), bidRequest.getImp()), bidResponse.getCur())) - .toList(); - } - - private static BidType getBidType(String impId, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(impId)) { - if (imp.getBanner() != null) { - return BidType.banner; - } else if (imp.getVideo() != null) { - return BidType.video; - } else if (imp.getXNative() != null) { - return BidType.xNative; - } - } - } - return BidType.banner; - } -} diff --git a/src/main/java/org/prebid/server/bidder/mgidx/MgidxBidder.java b/src/main/java/org/prebid/server/bidder/mgidx/MgidxBidder.java index f8c4ee9a068..bb01db86928 100644 --- a/src/main/java/org/prebid/server/bidder/mgidx/MgidxBidder.java +++ b/src/main/java/org/prebid/server/bidder/mgidx/MgidxBidder.java @@ -42,7 +42,6 @@ public class MgidxBidder implements Bidder { private static final String PUBLISHER_PROPERTY = "publisher"; private static final String NETWORK_PROPERTY = "network"; private static final String BIDDER_PROPERTY = "bidder"; - private static final String PREBID_EXT = "prebid"; private final String endpointUrl; private final JacksonMapper mapper; diff --git a/src/main/java/org/prebid/server/bidder/oms/OmsBidder.java b/src/main/java/org/prebid/server/bidder/oms/OmsBidder.java index 94e9e47af80..9dfc6d158e3 100644 --- a/src/main/java/org/prebid/server/bidder/oms/OmsBidder.java +++ b/src/main/java/org/prebid/server/bidder/oms/OmsBidder.java @@ -3,7 +3,6 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; -import io.vertx.core.http.HttpMethod; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.model.BidderBid; @@ -34,35 +33,27 @@ public OmsBidder(String endpointUrl, JacksonMapper mapper) { @Override public final Result>> makeHttpRequests(BidRequest bidRequest) { - return Result.withValue( - HttpRequest.builder() - .method(HttpMethod.POST) - .uri(endpointUrl) - .headers(HttpUtil.headers()) - .body(mapper.encodeToBytes(bidRequest)) - .impIds(BidderUtil.impIds(bidRequest)) - .payload(bidRequest) - .build()); + return Result.withValue(BidderUtil.defaultRequest(bidRequest, endpointUrl, mapper)); } @Override public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { try { final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(httpCall.getRequest().getPayload(), bidResponse)); + return Result.withValues(extractBids(bidResponse)); } catch (DecodeException e) { return Result.withError(BidderError.badServerResponse(e.getMessage())); } } - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { + private static List extractBids(BidResponse bidResponse) { if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { return Collections.emptyList(); } - return bidsFromResponse(bidRequest, bidResponse); + return bidsFromResponse(bidResponse); } - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { + private static List bidsFromResponse(BidResponse bidResponse) { return bidResponse.getSeatbid().stream() .filter(Objects::nonNull) .map(SeatBid::getBid) diff --git a/src/main/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidder.java b/src/main/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidder.java deleted file mode 100644 index 804071d0a2b..00000000000 --- a/src/main/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidder.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.prebid.server.bidder.zeta_global_ssp; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import io.vertx.core.http.HttpMethod; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class ZetaGlobalSspBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public ZetaGlobalSspBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public Result>> makeHttpRequests(BidRequest bidRequest) { - return Result.withValue( - HttpRequest.builder() - .method(HttpMethod.POST) - .uri(endpointUrl) - .headers(HttpUtil.headers()) - .body(mapper.encodeToBytes(bidRequest)) - .impIds(BidderUtil.impIds(bidRequest)) - .payload(bidRequest) - .build()); - } - - @Override - public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(httpCall.getRequest().getPayload(), bidResponse)); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - return Collections.emptyList(); - } - return bidsFromResponse(bidRequest, bidResponse); - } - - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(Objects::nonNull) - .map(bid -> BidderBid.of(bid, getBidType(bid, bidRequest.getImp()), bidResponse.getCur())) - .toList(); - } - - private static BidType getBidType(Bid bid, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(bid.getImpid())) { - if (imp.getBanner() != null) { - return BidType.banner; - } else if (imp.getVideo() != null) { - return BidType.video; - } - } - } - return BidType.banner; - } -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java deleted file mode 100644 index 415835e1b10..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.adrino.AdrinoBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/adrino.yaml", factory = YamlPropertySourceFactory.class) -public class AdrinoConfiguration { - - private static final String BIDDER_NAME = "adrino"; - - @Bean("adrinoConfigurationProperties") - @ConfigurationProperties("adapters.adrino") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps adrinoBidderDeps(BidderConfigurationProperties adrinoConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(adrinoConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new AdrinoBidder(config.getEndpoint(), mapper)) - .assemble(); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java deleted file mode 100644 index 91b0c7646ec..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.ccx.CcxBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/ccx.yaml", factory = YamlPropertySourceFactory.class) -public class CcxConfiguration { - - private static final String BIDDER_NAME = "ccx"; - - @Bean("ccxConfigurationProperties") - @ConfigurationProperties("adapters.ccx") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps ccxBidderDeps( - BidderConfigurationProperties ccxConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(ccxConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new CcxBidder(config.getEndpoint(), mapper)) - .assemble(); - } - -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java deleted file mode 100644 index 7b28f464742..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.infytv.InfytvBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/infytv.yaml", factory = YamlPropertySourceFactory.class) -public class InfytvConfiguration { - - private static final String BIDDER_NAME = "infytv"; - - @Bean("infytvConfigurationProperties") - @ConfigurationProperties("adapters.infytv") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps infytvBidderDeps(BidderConfigurationProperties infytvConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(infytvConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new InfytvBidder(config.getEndpoint(), mapper)) - .assemble(); - } - -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java deleted file mode 100644 index a100493fbee..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.loopme.LoopmeBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/loopme.yaml", factory = YamlPropertySourceFactory.class) -public class LoopmeConfiguration { - - private static final String BIDDER_NAME = "loopme"; - - @Bean("loopmeConfigurationProperties") - @ConfigurationProperties("adapters.loopme") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps loopmeBidderDeps(BidderConfigurationProperties loopmeConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(loopmeConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new LoopmeBidder(loopmeConfigurationProperties.getEndpoint(), mapper)) - .assemble(); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java deleted file mode 100644 index a886d2bab8e..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.zeta_global_ssp.ZetaGlobalSspBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/zeta_global_ssp.yaml", factory = YamlPropertySourceFactory.class) -public class ZetaGlobalSspConfiguration { - - private static final String BIDDER_NAME = "zeta_global_ssp"; - - @Bean - @ConfigurationProperties("adapters.zeta-global-ssp") - BidderConfigurationProperties zetaGlobalSspConfigurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps zetaGlobalSspBidderDeps(BidderConfigurationProperties zetaGlobalSspConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(zetaGlobalSspConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new ZetaGlobalSspBidder(config.getEndpoint(), mapper)) - .assemble(); - } - -} diff --git a/src/main/resources/bidder-config/adrino.yaml b/src/main/resources/bidder-config/adrino.yaml deleted file mode 100644 index 122130ecbbd..00000000000 --- a/src/main/resources/bidder-config/adrino.yaml +++ /dev/null @@ -1,10 +0,0 @@ -adapters: - adrino: - endpoint: https://prd-prebid-bidder.adrino.io/openrtb/bid - meta-info: - maintainer-email: dev@adrino.pl - app-media-types: - site-media-types: - - native - supported-vendors: - vendor-id: 1072 diff --git a/src/main/resources/bidder-config/ccx.yaml b/src/main/resources/bidder-config/ccx.yaml deleted file mode 100644 index 5f4bba80bca..00000000000 --- a/src/main/resources/bidder-config/ccx.yaml +++ /dev/null @@ -1,15 +0,0 @@ -adapters: - ccx: - endpoint: https://delivery.clickonometrics.pl/ortb/prebid/bid - meta-info: - maintainer-email: it@clickonometrics.pl - site-media-types: - - banner - - video - vendor-id: 773 - usersync: - cookie-family-name: ccx - redirect: - url: https://sync.clickonometrics.pl/prebid/set-cookie?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&cb={{redirect_url}} - support-cors: false - uid-macro: '${USER_ID}' diff --git a/src/main/resources/bidder-config/generic.yaml b/src/main/resources/bidder-config/generic.yaml index 01f7c3fa45f..5c4ab6dd510 100644 --- a/src/main/resources/bidder-config/generic.yaml +++ b/src/main/resources/bidder-config/generic.yaml @@ -4,6 +4,79 @@ adapters: aliases: genericAlias: enabled: false + adrino: + enabled: false + endpoint: https://prd-prebid-bidder.adrino.io/openrtb/bid + meta-info: + maintainer-email: dev@adrino.pl + app-media-types: + site-media-types: + - native + supported-vendors: + vendor-id: 1072 + ccx: + enabled: false + endpoint: https://delivery.clickonometrics.pl/ortb/prebid/bid + meta-info: + maintainer-email: it@clickonometrics.pl + site-media-types: + - banner + - video + vendor-id: 773 + usersync: + enabled: true + cookie-family-name: ccx + redirect: + url: https://sync.clickonometrics.pl/prebid/set-cookie?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&cb={{redirect_url}} + support-cors: false + uid-macro: '${USER_ID}' + infytv: + enabled: false + endpoint: https://nxs.infy.tv/pbs/openrtb + meta-info: + maintainer-email: tech+hb@infy.tv + app-media-types: + - video + site-media-types: + - video + supported-vendors: + vendor-id: 0 + loopme: + enabled: false + endpoint: http://prebid-eu.loopmertb.com + meta-info: + maintainer-email: support@loopme.com + app-media-types: + - banner + - video + - native + site-media-types: + - banner + - video + - native + supported-vendors: + vendor-id: 109 + zeta-global-ssp: + enabled: false + endpoint: https://ssp.disqus.com/bid/prebid-server?sid=GET_SID_FROM_ZETA + endpoint-compression: gzip + meta-info: + maintainer-email: DL-Zeta-SSP@zetaglobal.com + app-media-types: + - banner + - video + site-media-types: + - banner + - video + supported-vendors: + vendor-id: 833 + usersync: + enabled: true + cookie-family-name: zeta-global-ssp + redirect: + url: https://ssp.disqus.com/redirectuser?sid=GET_SID_FROM_ZETA&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&r={{redirect_url}} + uid-macro: 'BUYERUID' + support-cors: false blue: enabled: false endpoint: https://prebid-us-east-1.getblue.io/?src=prebid diff --git a/src/main/resources/bidder-config/infytv.yaml b/src/main/resources/bidder-config/infytv.yaml deleted file mode 100644 index fdf66ff92ac..00000000000 --- a/src/main/resources/bidder-config/infytv.yaml +++ /dev/null @@ -1,11 +0,0 @@ -adapters: - infytv: - endpoint: https://nxs.infy.tv/pbs/openrtb - meta-info: - maintainer-email: tech+hb@infy.tv - app-media-types: - - video - site-media-types: - - video - supported-vendors: - vendor-id: 0 diff --git a/src/main/resources/bidder-config/loopme.yaml b/src/main/resources/bidder-config/loopme.yaml deleted file mode 100644 index 321c6898762..00000000000 --- a/src/main/resources/bidder-config/loopme.yaml +++ /dev/null @@ -1,15 +0,0 @@ -adapters: - loopme: - endpoint: http://prebid-eu.loopmertb.com - meta-info: - maintainer-email: support@loopme.com - app-media-types: - - banner - - video - - native - site-media-types: - - banner - - video - - native - supported-vendors: - vendor-id: 109 diff --git a/src/main/resources/bidder-config/zeta_global_ssp.yaml b/src/main/resources/bidder-config/zeta_global_ssp.yaml deleted file mode 100644 index 36926fb335b..00000000000 --- a/src/main/resources/bidder-config/zeta_global_ssp.yaml +++ /dev/null @@ -1,20 +0,0 @@ -adapters: - zeta-global-ssp: - endpoint: https://ssp.disqus.com/bid/prebid-server?sid=GET_SID_FROM_ZETA - endpoint-compression: gzip - meta-info: - maintainer-email: DL-Zeta-SSP@zetaglobal.com - app-media-types: - - banner - - video - site-media-types: - - banner - - video - supported-vendors: - vendor-id: 833 - usersync: - cookie-family-name: zeta_global_ssp - redirect: - url: https://ssp.disqus.com/redirectuser?sid=GET_SID_FROM_ZETA&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&r={{redirect_url}} - uid-macro: 'BUYERUID' - support-cors: false diff --git a/src/main/resources/static/bidder-params/zeta_global_ssp.json b/src/main/resources/static/bidder-params/zeta-global-ssp.json similarity index 100% rename from src/main/resources/static/bidder-params/zeta_global_ssp.json rename to src/main/resources/static/bidder-params/zeta-global-ssp.json diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy index f5d934d245f..7598fd4cfae 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy @@ -118,13 +118,23 @@ LIMIT 1 // due to a config validation we'll need to circumvent all future aliases this way static Map getBidderAliasConfig() { - ["adapters.generic.aliases.cwire.meta-info.site-media-types" : "", - "adapters.generic.aliases.blue.meta-info.app-media-types" : "", - "adapters.generic.aliases.blue.meta-info.site-media-types" : "", - "adapters.generic.aliases.adsinteractive.meta-info.app-media-types" : "", - "adapters.generic.aliases.adsinteractive.meta-info.site-media-types": "", - "adapters.generic.aliases.nativo.meta-info.app-media-types" : "", - "adapters.generic.aliases.nativo.meta-info.site-media-types" : ""] + ["adapters.generic.aliases.cwire.meta-info.site-media-types" : "", + "adapters.generic.aliases.blue.meta-info.app-media-types" : "", + "adapters.generic.aliases.blue.meta-info.site-media-types" : "", + "adapters.generic.aliases.adsinteractive.meta-info.app-media-types" : "", + "adapters.generic.aliases.adsinteractive.meta-info.site-media-types" : "", + "adapters.generic.aliases.nativo.meta-info.app-media-types" : "", + "adapters.generic.aliases.nativo.meta-info.site-media-types" : "", + "adapters.generic.aliases.infytv.meta-info.app-media-types" : "", + "adapters.generic.aliases.infytv.meta-info.site-media-types" : "", + "adapters.generic.aliases.loopme.meta-info.app-media-types" : "", + "adapters.generic.aliases.loopme.meta-info.site-media-types" : "", + "adapters.generic.aliases.zeta-global-ssp.meta-info.app-media-types" : "", + "adapters.generic.aliases.zeta-global-ssp.meta-info.site-media-types": "", + "adapters.generic.aliases.ccx.meta-info.app-media-types" : "", + "adapters.generic.aliases.ccx.meta-info.site-media-types" : "", + "adapters.generic.aliases.adrino.meta-info.app-media-types" : "", + "adapters.generic.aliases.adrino.meta-info.site-media-types" : ""] } private PbsConfig() {} diff --git a/src/test/java/org/prebid/server/bidder/adrino/AdrinoBidderTest.java b/src/test/java/org/prebid/server/bidder/adrino/AdrinoBidderTest.java deleted file mode 100644 index f1f58954407..00000000000 --- a/src/test/java/org/prebid/server/bidder/adrino/AdrinoBidderTest.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.prebid.server.bidder.adrino; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import io.vertx.core.MultiMap; -import io.vertx.core.http.HttpMethod; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.adrino.ExtImpAdrino; -import org.prebid.server.proto.openrtb.ext.response.BidType; - -import java.util.List; -import java.util.Set; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.prebid.server.util.HttpUtil.ACCEPT_HEADER; -import static org.prebid.server.util.HttpUtil.APPLICATION_JSON_CONTENT_TYPE; -import static org.prebid.server.util.HttpUtil.CONTENT_TYPE_HEADER; -import static org.prebid.server.util.HttpUtil.headers; -import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; - -public class AdrinoBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "https://prd-prebid-bidder.adrino.io/openrtb/bid"; - - private final AdrinoBidder target = new AdrinoBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void makeHttpRequestsShouldReturnHttpRequestWithCorrectBodyHeadersAndMethod() { - // given - final BidRequest bidRequest = BidRequest.builder() - .id("test-request-id") - .imp(List.of(Imp.builder().id("imp_id").build())) - .build(); - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - final MultiMap expectedHeaders = headers() - .set(CONTENT_TYPE_HEADER, APPLICATION_JSON_CONTENT_TYPE) - .set(ACCEPT_HEADER, APPLICATION_JSON_VALUE); - final Result>> expectedResult = Result.withValue(HttpRequest.builder() - .method(HttpMethod.POST) - .uri(ENDPOINT_URL) - .headers(expectedHeaders) - .impIds(Set.of("imp_id")) - .body(jacksonMapper.encodeToBytes(bidRequest)) - .payload(bidRequest) - .build()); - assertThat(result.getValue()).usingRecursiveComparison().isEqualTo(expectedResult.getValue()); - assertThat(result.getErrors()).isEmpty(); - } - - @Test - public void makeHttpRequestShouldReturnSingleHttpRequestsWhenTwoImpsHasDifferentSourceId() { - // given - final BidRequest bidRequest = BidRequest.builder() - .imp(asList(Imp.builder() - .xNative(Native.builder().build()) - .ext(mapper.valueToTree( - ExtPrebid.of(null, ExtImpAdrino.of("test")))) - .build(), - Imp.builder() - .xNative(Native.builder().build()) - .ext(mapper.valueToTree( - ExtPrebid.of(null, ExtImpAdrino.of("test")))) - .build())) - .build(); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1); - } - - @Test - public void makeBidsShouldReturnExpectedResult() throws JsonProcessingException { - // given - final Bid bid = Bid.builder().id("impId").build(); - final String response = mapper.writeValueAsString(BidResponse.builder() - .cur("PLN") - .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bid)) - .build())) - .build()); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1).element(0).satisfies(bidderBid -> { - assertThat(bidderBid.getBid()).isEqualTo(bid); - assertThat(bidderBid.getType()).isEqualTo(BidType.xNative); - assertThat(bidderBid.getBidCurrency()).isEqualTo("PLN"); - }); - } - - @Test - public void makeBidsShouldReturnEmptyResponseWhenWhereIsNoBid() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(null); - final BidRequest bidRequest = BidRequest.builder() - .imp(singletonList(Imp.builder().id("impId").build())) - .build(); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnBidsFromDifferentSeatBidsInResponse() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(BidResponse.builder() - .seatbid(asList( - SeatBid.builder() - .bid(singletonList(Bid.builder().id("bidId1").impid("impId1").build())) - .build(), - SeatBid.builder() - .bid(singletonList(Bid.builder().id("bidId2").impid("impId2").build())) - .build())) - .build()); - final BidRequest bidRequest = BidRequest.builder() - .imp(asList(Imp.builder().id("impId1").build(), Imp.builder().id("impId2").build())) - .build(); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(BidderBid::getBid) - .extracting(Bid::getId).containsExactly("bidId1", "bidId2"); - } - - @Test - public void makeBidsShouldReturnEmptyBidderBidAndErrorListsIfSeatBidIsNotPresentInResponse() - throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(BidResponse.builder().build()); - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, BidRequest.builder().build()); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCanNotBeParsed() { - // given - final BidderCall httpCall = givenHttpCall("{"); - - // when - final Result> result = target.makeBids(httpCall, BidRequest.builder().build()); - - // then - assertThat(result.getErrors()).hasSize(1).element(0).satisfies(bidderError -> { - assertThat(bidderError.getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(bidderError.getMessage()).startsWith("Failed to decode:"); - }); - } - - private static BidderCall givenHttpCall(String body) { - return BidderCall.succeededHttp(null, HttpResponse.of(204, null, body), null); - } -} diff --git a/src/test/java/org/prebid/server/bidder/ccx/CcxBidderTest.java b/src/test/java/org/prebid/server/bidder/ccx/CcxBidderTest.java deleted file mode 100644 index d88f12400fb..00000000000 --- a/src/test/java/org/prebid/server/bidder/ccx/CcxBidderTest.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.prebid.server.bidder.ccx; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.Audio; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.request.Video; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.ccx.ExtImpCcx; - -import java.util.List; -import java.util.function.Function; -import java.util.function.UnaryOperator; - -import static java.util.Collections.singletonList; -import static java.util.function.UnaryOperator.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; -import static org.prebid.server.proto.openrtb.ext.response.BidType.video; - -public class CcxBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "https://randomurl.com"; - - private final CcxBidder target = new CcxBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void creationShouldFailOnInvalidEndpointUrl() { - assertThatIllegalArgumentException().isThrownBy(() -> new CcxBidder("invalid_url", jacksonMapper)); - } - - @Test - public void makeHttpRequestsShouldCreateExpectedUrl() { - // given - final BidRequest bidRequest = givenBidRequest(identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getUri) - .containsExactly("https://randomurl.com"); - } - - @Test - public void makeHttpRequestsShouldHaveTheSameIncomingAndOutGoingBidRequest() { - // given - final BidRequest bidRequest = givenBidRequest(impCustomizer -> impCustomizer - .ext(mapper.valueToTree(ExtPrebid.of(null, - ExtImpCcx.of(123456789))))); - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getExt) - .containsExactly(mapper.valueToTree(ExtPrebid.of(null, - ExtImpCcx.of(123456789)))); - } - - @Test - public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { - // given - final BidderCall httpCall = givenHttpCall(null, "invalid"); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).hasSize(1) - .allSatisfy(error -> { - assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(error.getMessage()).startsWith("Failed to decode: Unrecognized token"); - }); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, mapper.writeValueAsString(null)); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().build())); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnBannerBidIfBannerIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.banner(Banner.builder().build())), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnVideoBidIfVideoIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.video(Video.builder().build())), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), video, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfNativeIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.xNative(Native.builder().build())), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfAudioIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.audio(Audio.builder().build())), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfBannerAndVideoAndAudioAndNativeIsAbsentInRequestImp() - throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(identity()), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), banner, "USD")); - } - - private static BidRequest givenBidRequest(UnaryOperator impCustomizer) { - return givenBidRequest(identity(), impCustomizer); - } - - private static BidRequest givenBidRequest( - Function bidRequestCustomizer, - Function impCustomizer) { - return bidRequestCustomizer.apply(BidRequest.builder() - .imp(singletonList(givenImp(impCustomizer)))) - .build(); - } - - private static Imp givenImp(Function impCustomizer) { - return impCustomizer.apply(Imp.builder() - .id("123") - .ext(mapper.valueToTree(ExtPrebid.of(null, - ExtImpCcx.of(123456789))))) - .build(); - } - - private static BidResponse givenBidResponse(Function bidCustomizer) { - return BidResponse.builder() - .cur("USD") - .seatbid(singletonList(SeatBid.builder().bid(singletonList(bidCustomizer.apply(Bid.builder()).build())) - .build())) - .build(); - } - - private static Bid givenBid() { - return Bid.builder().impid("123").build(); - } - - private static BidderCall givenHttpCall(BidRequest bidRequest, String body) { - return BidderCall.succeededHttp( - HttpRequest.builder().payload(bidRequest).build(), - HttpResponse.of(200, null, body), - null); - } - -} diff --git a/src/test/java/org/prebid/server/bidder/infytv/InfytvBidderTest.java b/src/test/java/org/prebid/server/bidder/infytv/InfytvBidderTest.java deleted file mode 100644 index ce62b2efca0..00000000000 --- a/src/test/java/org/prebid/server/bidder/infytv/InfytvBidderTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.prebid.server.bidder.infytv; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import io.vertx.core.MultiMap; -import io.vertx.core.http.HttpMethod; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.proto.openrtb.ext.response.BidType; - -import java.util.List; -import java.util.Set; -import java.util.function.UnaryOperator; - -import static java.util.Collections.singletonList; -import static java.util.function.UnaryOperator.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.prebid.server.util.HttpUtil.ACCEPT_HEADER; -import static org.prebid.server.util.HttpUtil.APPLICATION_JSON_CONTENT_TYPE; -import static org.prebid.server.util.HttpUtil.CONTENT_TYPE_HEADER; -import static org.prebid.server.util.HttpUtil.headers; -import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; - -public class InfytvBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "https://nxs.infy.tv/pbs/openrtb"; - - private final InfytvBidder target = new InfytvBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void creationShouldFailOnInvalidEndpointUrl() { - assertThatIllegalArgumentException().isThrownBy(() -> new InfytvBidder("invalid_url", jacksonMapper)); - } - - @Test - public void makeHttpRequestsShouldReturnExpectedHttpRequest() { - // given - final BidRequest bidRequest = givenBidRequest(identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - final MultiMap expectedHeaders = headers() - .set(CONTENT_TYPE_HEADER, APPLICATION_JSON_CONTENT_TYPE) - .set(ACCEPT_HEADER, APPLICATION_JSON_VALUE); - final Result>> expectedResult = Result.withValue(HttpRequest.builder() - .method(HttpMethod.POST) - .uri(ENDPOINT_URL) - .headers(expectedHeaders) - .impIds(Set.of("IMP_ID")) - .body(jacksonMapper.encodeToBytes(bidRequest)) - .payload(bidRequest) - .build()); - assertThat(result.getValue()).usingRecursiveComparison().isEqualTo(expectedResult.getValue()); - assertThat(result.getErrors()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnExpectedResult() throws JsonProcessingException { - // given - final Bid bid = Bid.builder().id("impId").build(); - final String response = mapper.writeValueAsString(BidResponse.builder() - .cur("PLN") - .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bid)) - .build())) - .build()); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).allSatisfy(bidderBid -> { - assertThat(bidderBid.getBid()).isEqualTo(bid); - assertThat(bidderBid.getType()).isEqualTo(BidType.video); - assertThat(bidderBid.getBidCurrency()).isEqualTo("PLN"); - }); - } - - @Test - public void makeBidsShouldReturnErrorWhenThereIsNoBid() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(null); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getValue()).isEmpty(); - assertThat(result.getErrors()).isNotEmpty(); - assertThat(result.getErrors()) - .containsExactly(BidderError.badServerResponse("Empty SeatBid array")); - } - - @Test - public void makeBidsShouldReturnErrorWhenResponseCanNotBeParsed() { - // given - final BidderCall httpCall = givenHttpCall("{"); - - // when - final Result> result = target.makeBids(httpCall, BidRequest.builder().build()); - - // then - assertThat(result.getErrors()).allSatisfy(bidderError -> { - assertThat(bidderError.getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(bidderError.getMessage()).startsWith("Bad Response,"); - }); - } - - private static BidRequest givenBidRequest(UnaryOperator bidRequestCustomizer) { - return bidRequestCustomizer.apply( - BidRequest.builder().imp(List.of(Imp.builder().id("IMP_ID").build()))).build(); - } - - private static BidderCall givenHttpCall(String body) { - return BidderCall.succeededHttp(null, HttpResponse.of(204, null, body), null); - } - -} diff --git a/src/test/java/org/prebid/server/bidder/loopme/LoopmeBidderTest.java b/src/test/java/org/prebid/server/bidder/loopme/LoopmeBidderTest.java deleted file mode 100644 index 7fd6fca1073..00000000000 --- a/src/test/java/org/prebid/server/bidder/loopme/LoopmeBidderTest.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.prebid.server.bidder.loopme; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.request.Video; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.loopme.ExtImpLoopme; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; - -import static java.util.Collections.singletonList; -import static java.util.function.Function.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; -import static org.prebid.server.proto.openrtb.ext.response.BidType.video; -import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative; - -public class LoopmeBidderTest extends VertxTest { - - public static final String ENDPOINT_URL = "https://test.endpoint.com"; - - private final LoopmeBidder target = new LoopmeBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void makeHttpRequestsShouldMakeOneRequestWithAllImps() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - requestBuilder -> requestBuilder.imp(Arrays.asList( - givenImp(identity()), - givenImp(identity())))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getPayload) - .flatExtracting(BidRequest::getImp) - .hasSize(2); - } - - @Test - public void makeBidsShouldReturnBannerBidByDefault() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - BidRequest.builder().imp(singletonList(Imp.builder().id("123").build())).build(), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnVideoBidIfNoBannerAndHasVideo() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - BidRequest.builder() - .imp(singletonList(Imp.builder().video(Video.builder().build()).id("123").build())) - .build(), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfHasBothBannerAndVideo() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - BidRequest.builder() - .imp(singletonList(givenImp(identity()))) - .build(), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnNativeBidIfNativeIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - BidRequest.builder() - .imp(singletonList(Imp.builder().id("123").xNative(Native.builder().build()).build())) - .build(), - mapper.writeValueAsString( - givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), xNative, "USD")); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, mapper.writeValueAsString(null)); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().build())); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - private static BidRequest givenBidRequest( - Function impCustomizer, - Function requestCustomizer) { - return requestCustomizer.apply(BidRequest.builder() - .imp(singletonList(givenImp(impCustomizer)))) - .build(); - } - - private static Imp givenImp(Function impCustomizer) { - return impCustomizer.apply(Imp.builder() - .id("123")) - .banner(Banner.builder().build()) - .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpLoopme.of("somePubId")))) - .build(); - } - - private static BidResponse givenBidResponse(Function bidCustomizer) { - return BidResponse.builder() - .cur("USD") - .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bidCustomizer.apply(Bid.builder()).build())) - .build())) - .build(); - } - - private static BidderCall givenHttpCall(BidRequest bidRequest, String body) { - return BidderCall.succeededHttp(HttpRequest.builder().payload(bidRequest).build(), - HttpResponse.of(200, null, body), null); - } -} diff --git a/src/test/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidderTest.java b/src/test/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidderTest.java deleted file mode 100644 index 0b94d701d2e..00000000000 --- a/src/test/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidderTest.java +++ /dev/null @@ -1,195 +0,0 @@ -package org.prebid.server.bidder.zeta_global_ssp; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Video; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; - -import java.util.List; -import java.util.function.Function; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static java.util.function.Function.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; -import static org.prebid.server.proto.openrtb.ext.response.BidType.video; - -public class ZetaGlobalSspBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "https://test.endpoint.com"; - - private final ZetaGlobalSspBidder target = new ZetaGlobalSspBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void creationShouldFailOnInvalidEndpointUrl() { - assertThatIllegalArgumentException().isThrownBy(() -> new ZetaGlobalSspBidder("invalid_url", jacksonMapper)); - } - - @Test - public void makeHttpRequestsShouldReturnExpectedBidRequest() { - // given - final BidRequest bidRequest = givenBidRequest(identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .containsExactly(bidRequest); - } - - @Test - public void makeHttpRequestsShouldMakeOneRequestForMultipleImps() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - requestBuilder -> requestBuilder.imp(asList( - givenImp(identity()), - givenImp(identity()).toBuilder().id("2").build()))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .flatExtracting(BidRequest::getImp).hasSize(2); - } - - @Test - public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { - // given - final BidderCall httpCall = givenHttpCall(null, "invalid"); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, mapper.writeValueAsString(null)); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().build())); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnBannerBidByDefault() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.banner(null).video(null)), - mapper.writeValueAsString(givenBidResponse(Bid.builder().impid("123").build()))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnVideoBidIfNoBannerAndHasVideo() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.banner(null).video(Video.builder().build())), - mapper.writeValueAsString(givenBidResponse(Bid.builder().impid("123").build()))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfHasBothBannerAndVideo() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(identity()), - mapper.writeValueAsString(givenBidResponse(Bid.builder().impid("123").build()))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); - } - - private static BidRequest givenBidRequest( - Function impCustomizer, - Function requestCustomizer) { - - return requestCustomizer.apply(BidRequest.builder().imp(singletonList(givenImp(impCustomizer)))).build(); - } - - private static BidRequest givenBidRequest(Function impCustomizer) { - return givenBidRequest(impCustomizer, identity()); - } - - private static Imp givenImp(Function impCustomizer) { - return impCustomizer.apply(Imp.builder() - .id("123") - .banner(Banner.builder().build()) - .video(Video.builder().build())) - .build(); - } - - private static BidderCall givenHttpCall(BidRequest bidRequest, String body) { - return BidderCall.succeededHttp(HttpRequest.builder().payload(bidRequest).build(), - HttpResponse.of(200, null, body), null); - } - - private static BidResponse givenBidResponse(Bid... bids) { - return BidResponse.builder() - .cur("USD") - .seatbid(singletonList(SeatBid.builder() - .bid(List.of(bids)) - .build())) - .build(); - } -} diff --git a/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java b/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java index 7556d13e67f..074e503b50e 100644 --- a/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java +++ b/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java @@ -21,18 +21,18 @@ public class ZetaGlobalSspTest extends IntegrationTest { @Test public void openrtb2AuctionShouldRespondWithBidsFromZetaGlobalSsp() throws IOException, JSONException { // given - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/zeta_global_ssp-exchange")) + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/zeta-global-ssp-exchange")) .withRequestBody(equalToJson( - jsonFrom("openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json"))) + jsonFrom("openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json"))) .willReturn(aResponse().withBody( - jsonFrom("openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json")))); + jsonFrom("openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json")))); // when - final Response response = responseFor("openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json", + final Response response = responseFor("openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json", Endpoint.openrtb2_auction); // then - assertJsonEquals("openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json", response, - singletonList("zeta_global_ssp")); + assertJsonEquals("openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json", response, + singletonList("zeta-global-ssp")); } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-auction-infytv-request.json b/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-auction-infytv-request.json index 0084cddf231..fd7310654e6 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-auction-infytv-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-auction-infytv-request.json @@ -3,9 +3,12 @@ "imp": [ { "id": "imp_id", - "banner": { - "w": 300, - "h": 250 + "video": { + "mimes": [ + "video/mp4" + ], + "w": 640, + "h": 480 }, "ext": { "infytv": { diff --git a/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-infytv-bid-request-1.json b/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-infytv-bid-request-1.json index 26854e41f45..26770d4ac7c 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-infytv-bid-request-1.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-infytv-bid-request-1.json @@ -4,9 +4,12 @@ { "id": "imp_id", "secure": 1, - "banner": { - "w": 300, - "h": 250 + "video": { + "mimes": [ + "video/mp4" + ], + "w": 640, + "h": 480 }, "ext": { "tid": "${json-unit.any-string}", diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json similarity index 94% rename from src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json rename to src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json index 0a3824d6e31..3ed84b4e1ee 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json @@ -12,7 +12,7 @@ ] }, "ext": { - "zeta_global_ssp": {} + "zeta-global-ssp": {} } } ], diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json similarity index 86% rename from src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json rename to src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json index 802e057bc7a..afb9594d84b 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json @@ -21,14 +21,14 @@ } } ], - "seat": "zeta_global_ssp", + "seat": "zeta-global-ssp", "group": 0 } ], "cur": "USD", "ext": { "responsetimemillis": { - "zeta_global_ssp": "{{ zeta_global_ssp.response_time_ms }}" + "zeta-global-ssp": "{{ zeta-global-ssp.response_time_ms }}" }, "prebid": { "auctiontimestamp": 1000 diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json similarity index 100% rename from src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json rename to src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json similarity index 100% rename from src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json rename to src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 28f6c7fc5b3..8112a071772 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -4,6 +4,16 @@ adapters.generic.aliases.genericAlias.enabled=true adapters.generic.aliases.genericAlias.endpoint=http://localhost:8090/genericAlias-exchange adapters.generic.aliases.nativo.enabled=true adapters.generic.aliases.nativo.endpoint=http://localhost:8090/nativo-exchange +adapters.generic.aliases.adrino.enabled=true +adapters.generic.aliases.adrino.endpoint=http://localhost:8090/adrino-exchange +adapters.generic.aliases.ccx.enabled=true +adapters.generic.aliases.ccx.endpoint=http://localhost:8090/ccx-exchange +adapters.generic.aliases.infytv.enabled=true +adapters.generic.aliases.infytv.endpoint=http://localhost:8090/infytv-exchange +adapters.generic.aliases.loopme.enabled=true +adapters.generic.aliases.loopme.endpoint=http://localhost:8090/loopme-exchange +adapters.generic.aliases.zeta-global-ssp.enabled=true +adapters.generic.aliases.zeta-global-ssp.endpoint=http://localhost:8090/zeta-global-ssp-exchange adapters.aceex.enabled=true adapters.aceex.endpoint=http://localhost:8090/aceex-exchange adapters.acuityads.enabled=true @@ -15,8 +25,6 @@ adapters.adf.endpoint=http://localhost:8090/adf-exchange adapters.adf.aliases.adform.enabled=true adapters.adgeneration.enabled=true adapters.adgeneration.endpoint=http://localhost:8090/adgeneration-exchange -adapters.adrino.enabled=true -adapters.adrino.endpoint=http://localhost:8090/adrino-exchange adapters.adhese.enabled=true adapters.adhese.endpoint=http://localhost:8090/adhese-exchange adapters.adkerneladn.enabled=true @@ -123,8 +131,6 @@ adapters.boldwin.enabled=true adapters.boldwin.endpoint=http://localhost:8090/boldwin-exchange adapters.brave.enabled=true adapters.brave.endpoint=http://localhost:8090/brave-exchange -adapters.ccx.enabled=true -adapters.ccx.endpoint=http://localhost:8090/ccx-exchange adapters.connectad.enabled=true adapters.connectad.endpoint=http://localhost:8090/connectad-exchange adapters.compass.enabled=true @@ -201,8 +207,6 @@ adapters.impactify.enabled=true adapters.impactify.endpoint=http://localhost:8090/impactify-exchange adapters.improvedigital.enabled=true adapters.improvedigital.endpoint=http://localhost:8090/improvedigital-exchange -adapters.infytv.enabled=true -adapters.infytv.endpoint=http://localhost:8090/infytv-exchange adapters.intertech.enabled=true adapters.intertech.endpoint=http://localhost:8090/intertech-exchange adapters.iqx.enabled=true @@ -249,8 +253,6 @@ adapters.lockerdome.enabled=true adapters.lockerdome.endpoint=http://localhost:8090/lockerdome-exchange adapters.logan.enabled=true adapters.logan.endpoint=http://localhost:8090/logan-exchange -adapters.loopme.enabled=true -adapters.loopme.endpoint=http://localhost:8090/loopme-exchange adapters.logicad.enabled=true adapters.logicad.endpoint=http://localhost:8090/logicad-exchange adapters.lunamedia.enabled=true @@ -445,8 +447,6 @@ adapters.zeroclickfraud.enabled=true adapters.zeroclickfraud.endpoint=http://{{Host}}/zeroclickfraud-exchange?sid={{SourceId}} adapters.aax.enabled=true adapters.aax.endpoint=http://localhost:8090/aax-exchange -adapters.zeta_global_ssp.enabled=true -adapters.zeta_global_ssp.endpoint=http://localhost:8090/zeta_global_ssp-exchange adapters.zmaticoo.enabled=true adapters.zmaticoo.endpoint=http://localhost:8090/zmaticoo-exchange adapters.yearxero.enabled=true From fd8ec64794bb78392cc9c083f59f12d6d2652cc6 Mon Sep 17 00:00:00 2001 From: bretg Date: Tue, 7 May 2024 09:07:29 -0400 Subject: [PATCH 24/62] Mgidx: Update mgidx endpoints info (#3174) --- src/main/resources/bidder-config/mgidx.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/mgidx.yaml b/src/main/resources/bidder-config/mgidx.yaml index 7c1b74aaae3..4989dc43461 100644 --- a/src/main/resources/bidder-config/mgidx.yaml +++ b/src/main/resources/bidder-config/mgidx.yaml @@ -1,6 +1,6 @@ adapters: mgidX: - # We have the following regional endpoint domains: 'us-east-x' and 'eu' + # We have the following regional endpoint domains: 'us-east-x' and 'eu-x' # Please deploy this config in each of your datacenters with the appropriate regional subdomain endpoint: https://REGION.mgid.com/pserver meta-info: From 0a43967fe593d14b26f5fa71a14ce70450092acd Mon Sep 17 00:00:00 2001 From: osulzhenko <125548596+osulzhenko@users.noreply.github.com> Date: Tue, 7 May 2024 16:09:08 +0300 Subject: [PATCH 25/62] Tests: Extend skipUnitTests attributes for module tests (#3173) --- extra/modules/pom.xml | 6 +++--- extra/pom.xml | 3 +++ pom.xml | 3 --- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 5091a3e3a65..865b928cb79 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -32,9 +32,6 @@ 3.23.1 4.13.2 4.7.0 - - 3.11.0 - 2.22.2 @@ -113,6 +110,9 @@ org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} + + ${skipUnitTests} + diff --git a/extra/pom.xml b/extra/pom.xml index 90192cc0325..d6b22c6383f 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -23,6 +23,9 @@ 4.5.5 1.18.30 3.0.0-M6 + 3.11.0 + 2.22.2 + false diff --git a/pom.xml b/pom.xml index 2496ff6a6bc..d24b162dfbb 100644 --- a/pom.xml +++ b/pom.xml @@ -73,14 +73,11 @@ 1.2.0 0.8.11 2.2.4 - 3.11.0 - 2.22.2 ${maven-surefire-plugin.version} 0.40.2 3.0.2 false true - false 1.6.2 3.0.0 0.6.1 From e5744d053e7245a5edde0491a08b03c2a499ac2d Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Tue, 7 May 2024 16:40:13 +0300 Subject: [PATCH 26/62] Core: Change account properties names. (#3152) --- docs/config-app.md | 6 +++--- docs/metrics.md | 2 +- .../auction/VideoStoredRequestProcessor.java | 8 ++++---- .../Ortb2ImplicitParametersResolver.java | 16 +++++++-------- .../requestfactory/Ortb2RequestFactory.java | 20 +++++++++---------- .../BlacklistedAccountException.java | 8 -------- .../exception/BlacklistedAppException.java | 8 -------- .../BlocklistedAccountException.java | 8 ++++++++ .../exception/BlocklistedAppException.java | 8 ++++++++ .../server/handler/openrtb2/AmpHandler.java | 15 +++++++------- .../handler/openrtb2/AuctionHandler.java | 16 +++++++-------- .../org/prebid/server/metric/MetricName.java | 4 ++-- .../spring/config/ServiceConfiguration.java | 14 ++++++------- .../validation/VideoRequestValidator.java | 12 ++++++----- src/main/resources/application.yaml | 4 ++-- .../Ortb2ImplicitParametersResolverTest.java | 6 +++--- .../Ortb2RequestFactoryTest.java | 18 ++++++++--------- .../handler/openrtb2/AmpHandlerTest.java | 16 +++++++-------- .../handler/openrtb2/AuctionHandlerTest.java | 20 +++++++++---------- .../org/prebid/server/metric/MetricsTest.java | 8 ++++---- .../validation/VideoRequestValidatorTest.java | 2 +- 21 files changed, 111 insertions(+), 108 deletions(-) delete mode 100644 src/main/java/org/prebid/server/exception/BlacklistedAccountException.java delete mode 100644 src/main/java/org/prebid/server/exception/BlacklistedAppException.java create mode 100644 src/main/java/org/prebid/server/exception/BlocklistedAccountException.java create mode 100644 src/main/java/org/prebid/server/exception/BlocklistedAppException.java diff --git a/docs/config-app.md b/docs/config-app.md index c99bdd63a2f..5e3ee1192d4 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -75,8 +75,8 @@ Removes and downloads file again if depending service cant process probably corr - `default-request.file.path` - path to a JSON file containing the default request ## Auction (OpenRTB) -- `auction.blacklisted-accounts` - comma separated list of blacklisted account IDs. -- `auction.blacklisted-apps` - comma separated list of blacklisted applications IDs, requests from which should not be processed. +- `auction.blocklisted-accounts` - comma separated list of blocklisted account IDs. +- `auction.blocklisted-apps` - comma separated list of blocklisted applications IDs, requests from which should not be processed. - `auction.max-timeout-ms` - maximum operation timeout for OpenRTB Auction requests. Deprecated. - `auction.biddertmax.min` - minimum operation timeout for OpenRTB Auction requests. - `auction.biddertmax.max` - maximum operation timeout for OpenRTB Auction requests. @@ -104,7 +104,7 @@ Removes and downloads file again if depending service cant process probably corr ## Video - `auction.video.stored-required` - flag forces to merge with stored request -- `auction.blacklisted-accounts` - comma separated list of blacklisted account IDs. +- `auction.blocklisted-accounts` - comma separated list of blocklisted account IDs. - `video.stored-requests-timeout-ms` - timeout for stored requests fetching. - `auction.ad-server-currency` - default currency for video auction, if its value was not specified in request. Important note: PBS uses ISO-4217 codes for the representation of currencies. - `auction.video.escape-log-cache-regex` - regex to remove from cache debug log xml. diff --git a/docs/metrics.md b/docs/metrics.md index 2f92c1ca71f..11f2165978c 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -44,7 +44,7 @@ where `[DATASOURCE]` is a data source name, `DEFAULT_DS` by defaul. - `imps_video` - number of video impressions - `imps_native` - number of native impressions - `imps_audio` - number of audio impressions -- `requests.(ok|badinput|err|networkerr|blacklisted_account|blacklisted_app).(openrtb2-web|openrtb-app|amp|legacy)` - number of requests broken down by status and type +- `requests.(ok|badinput|err|networkerr|blocklisted_account|blocklisted_app).(openrtb2-web|openrtb-app|amp|legacy)` - number of requests broken down by status and type - `bidder-cardinality..requests` - number of requests targeting `` of bidders - `connection_accept_errors` - number of errors occurred while establishing HTTP connection - `db_query_time` - timer tracking how long did it take for database client to obtain the result for a query diff --git a/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java b/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java index 6b6cb533c72..84ebacc7416 100644 --- a/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java +++ b/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java @@ -59,7 +59,7 @@ public class VideoStoredRequestProcessor { private static final String DEFAULT_CURRENCY = "USD"; private final boolean enforceStoredRequest; - private final List blacklistedAccounts; + private final List blocklistedAccounts; private final long defaultTimeout; private final String currency; private final BidRequest defaultBidRequest; @@ -71,7 +71,7 @@ public class VideoStoredRequestProcessor { private final JsonMerger jsonMerger; public VideoStoredRequestProcessor(boolean enforceStoredRequest, - List blacklistedAccounts, + List blocklistedAccounts, long defaultTimeout, String adServerCurrency, String defaultBidRequestPath, @@ -84,7 +84,7 @@ public VideoStoredRequestProcessor(boolean enforceStoredRequest, JsonMerger jsonMerger) { this.enforceStoredRequest = enforceStoredRequest; - this.blacklistedAccounts = Objects.requireNonNull(blacklistedAccounts); + this.blocklistedAccounts = Objects.requireNonNull(blocklistedAccounts); this.defaultTimeout = defaultTimeout; this.currency = StringUtils.isBlank(adServerCurrency) ? DEFAULT_CURRENCY : adServerCurrency; this.defaultBidRequest = readBidRequest( @@ -147,7 +147,7 @@ private WithPodErrors toBidRequestWithPodErrors(StoredDataResult sto String storedBidRequestId) { final BidRequestVideo mergedStoredRequest = mergeBidRequest(videoRequest, storedBidRequestId, storedResult); - validator.validateStoredBidRequest(mergedStoredRequest, enforceStoredRequest, blacklistedAccounts); + validator.validateStoredBidRequest(mergedStoredRequest, enforceStoredRequest, blocklistedAccounts); final Podconfig podconfig = mergedStoredRequest.getPodconfig(); final Video video = mergedStoredRequest.getVideo(); diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java index 0fdf6497141..b11f92592ef 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java @@ -33,7 +33,7 @@ import org.prebid.server.auction.model.Endpoint; import org.prebid.server.auction.model.IpAddress; import org.prebid.server.auction.model.SecBrowsingTopic; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.identity.IdGenerator; @@ -91,7 +91,7 @@ public class Ortb2ImplicitParametersResolver { private final boolean shouldCacheOnlyWinningBids; private final boolean generateBidRequestId; private final String adServerCurrency; - private final List blacklistedApps; + private final List blocklistedApps; private final ExtRequestPrebidServer serverInfo; private final ImplicitParametersExtractor paramsExtractor; private final TimeoutResolver timeoutResolver; @@ -104,7 +104,7 @@ public class Ortb2ImplicitParametersResolver { public Ortb2ImplicitParametersResolver(boolean shouldCacheOnlyWinningBids, boolean generateBidRequestId, String adServerCurrency, - List blacklistedApps, + List blocklistedApps, String externalUrl, Integer hostVendorId, String datacenterRegion, @@ -119,7 +119,7 @@ public Ortb2ImplicitParametersResolver(boolean shouldCacheOnlyWinningBids, this.shouldCacheOnlyWinningBids = shouldCacheOnlyWinningBids; this.generateBidRequestId = generateBidRequestId; this.adServerCurrency = validateCurrency(Objects.requireNonNull(adServerCurrency)); - this.blacklistedApps = Objects.requireNonNull(blacklistedApps); + this.blocklistedApps = Objects.requireNonNull(blocklistedApps); this.serverInfo = ExtRequestPrebidServer.of(externalUrl, hostVendorId, datacenterRegion, null); this.paramsExtractor = Objects.requireNonNull(paramsExtractor); this.timeoutResolver = Objects.requireNonNull(timeoutResolver); @@ -153,7 +153,7 @@ public BidRequest resolve(BidRequest bidRequest, String endpoint, boolean hasStoredBidRequest) { - checkBlacklistedApp(bidRequest); + checkBlocklistedApp(bidRequest); final HttpRequestContext httpRequest = auctionContext.getHttpRequest(); @@ -211,12 +211,12 @@ public static boolean isImpExtBidder(String field) { return !IMP_EXT_NON_BIDDER_FIELDS.contains(field); } - private void checkBlacklistedApp(BidRequest bidRequest) { + private void checkBlocklistedApp(BidRequest bidRequest) { final App app = bidRequest.getApp(); final String appId = app != null ? app.getId() : null; - if (StringUtils.isNotBlank(appId) && blacklistedApps.contains(appId)) { - throw new BlacklistedAppException( + if (StringUtils.isNotBlank(appId) && blocklistedApps.contains(appId)) { + throw new BlocklistedAppException( "Prebid-server does not process requests from App ID: " + appId); } } diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java index 761bd1d8434..d738477edbf 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java @@ -26,7 +26,7 @@ import org.prebid.server.auction.model.TimeoutContext; import org.prebid.server.auction.model.debug.DebugContext; import org.prebid.server.cookie.UidsCookieService; -import org.prebid.server.exception.BlacklistedAccountException; +import org.prebid.server.exception.BlocklistedAccountException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -89,7 +89,7 @@ public class Ortb2RequestFactory { private final int timeoutAdjustmentFactor; private final double logSamplingRate; - private final List blacklistedAccounts; + private final List blocklistedAccounts; private final UidsCookieService uidsCookieService; private final ActivityInfrastructureCreator activityInfrastructureCreator; private final RequestValidator requestValidator; @@ -105,7 +105,7 @@ public class Ortb2RequestFactory { public Ortb2RequestFactory(int timeoutAdjustmentFactor, double logSamplingRate, - List blacklistedAccounts, + List blocklistedAccounts, UidsCookieService uidsCookieService, ActivityInfrastructureCreator activityInfrastructureCreator, RequestValidator requestValidator, @@ -125,7 +125,7 @@ public Ortb2RequestFactory(int timeoutAdjustmentFactor, this.timeoutAdjustmentFactor = timeoutAdjustmentFactor; this.logSamplingRate = logSamplingRate; - this.blacklistedAccounts = Objects.requireNonNull(blacklistedAccounts); + this.blocklistedAccounts = Objects.requireNonNull(blocklistedAccounts); this.uidsCookieService = Objects.requireNonNull(uidsCookieService); this.activityInfrastructureCreator = Objects.requireNonNull(activityInfrastructureCreator); this.requestValidator = Objects.requireNonNull(requestValidator); @@ -180,7 +180,7 @@ private Future fetchAccount(AuctionContext auctionContext, boolean isLo final HttpRequestContext httpRequest = auctionContext.getHttpRequest(); return findAccountIdFrom(bidRequest, isLookupStoredRequest) - .map(this::validateIfAccountBlacklisted) + .map(this::validateIfAccountBlocklisted) .compose(accountId -> loadAccount(timeout, httpRequest, accountId)); } @@ -423,13 +423,13 @@ private Future findAccountIdFrom(BidRequest bidRequest, boolean isLookup .map(storedAuctionResult -> accountIdFrom(storedAuctionResult.bidRequest())); } - private String validateIfAccountBlacklisted(String accountId) { - if (CollectionUtils.isNotEmpty(blacklistedAccounts) + private String validateIfAccountBlocklisted(String accountId) { + if (CollectionUtils.isNotEmpty(blocklistedAccounts) && StringUtils.isNotBlank(accountId) - && blacklistedAccounts.contains(accountId)) { + && blocklistedAccounts.contains(accountId)) { - throw new BlacklistedAccountException( - "Prebid-server has blacklisted Account ID: %s, please reach out to the prebid server host." + throw new BlocklistedAccountException( + "Prebid-server has blocklisted Account ID: %s, please reach out to the prebid server host." .formatted(accountId)); } return accountId; diff --git a/src/main/java/org/prebid/server/exception/BlacklistedAccountException.java b/src/main/java/org/prebid/server/exception/BlacklistedAccountException.java deleted file mode 100644 index afe1fdc4d2a..00000000000 --- a/src/main/java/org/prebid/server/exception/BlacklistedAccountException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.prebid.server.exception; - -public class BlacklistedAccountException extends RuntimeException { - - public BlacklistedAccountException(String message) { - super(message); - } -} diff --git a/src/main/java/org/prebid/server/exception/BlacklistedAppException.java b/src/main/java/org/prebid/server/exception/BlacklistedAppException.java deleted file mode 100644 index 53707383798..00000000000 --- a/src/main/java/org/prebid/server/exception/BlacklistedAppException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.prebid.server.exception; - -public class BlacklistedAppException extends RuntimeException { - - public BlacklistedAppException(String message) { - super(message); - } -} diff --git a/src/main/java/org/prebid/server/exception/BlocklistedAccountException.java b/src/main/java/org/prebid/server/exception/BlocklistedAccountException.java new file mode 100644 index 00000000000..6f88b7b0a04 --- /dev/null +++ b/src/main/java/org/prebid/server/exception/BlocklistedAccountException.java @@ -0,0 +1,8 @@ +package org.prebid.server.exception; + +public class BlocklistedAccountException extends RuntimeException { + + public BlocklistedAccountException(String message) { + super(message); + } +} diff --git a/src/main/java/org/prebid/server/exception/BlocklistedAppException.java b/src/main/java/org/prebid/server/exception/BlocklistedAppException.java new file mode 100644 index 00000000000..7774a02334b --- /dev/null +++ b/src/main/java/org/prebid/server/exception/BlocklistedAppException.java @@ -0,0 +1,8 @@ +package org.prebid.server.exception; + +public class BlocklistedAppException extends RuntimeException { + + public BlocklistedAppException(String message) { + super(message); + } +} diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java index b6fb1ea046c..f238694a593 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java @@ -28,8 +28,8 @@ import org.prebid.server.auction.requestfactory.AmpRequestFactory; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.exception.BlacklistedAccountException; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAccountException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidAccountConfigException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; @@ -322,11 +322,12 @@ private void handleResult(AsyncResult> respo status = HttpResponseStatus.UNAUTHORIZED; body = message; - } else if (exception instanceof BlacklistedAppException - || exception instanceof BlacklistedAccountException) { - metricRequestStatus = exception instanceof BlacklistedAccountException - ? MetricName.blacklisted_account : MetricName.blacklisted_app; - final String message = "Blacklisted: " + exception.getMessage(); + } else if (exception instanceof BlocklistedAppException + || exception instanceof BlocklistedAccountException) { + metricRequestStatus = exception instanceof BlocklistedAccountException + ? MetricName.blocklisted_account + : MetricName.blocklisted_app; + final String message = "Blocklisted: " + exception.getMessage(); logger.debug(message); errorMessages = Collections.singletonList(message); diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java index 4bbc18c53c3..e6523345399 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java @@ -15,8 +15,8 @@ import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.auction.requestfactory.AuctionRequestFactory; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.exception.BlacklistedAccountException; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAccountException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidAccountConfigException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -180,12 +180,12 @@ private void handleResult(AsyncResult responseResult, status = HttpResponseStatus.UNAUTHORIZED; body = message; - } else if (exception instanceof BlacklistedAppException - || exception instanceof BlacklistedAccountException) { - metricRequestStatus = exception instanceof BlacklistedAccountException - ? MetricName.blacklisted_account - : MetricName.blacklisted_app; - final String message = "Blacklisted: " + exception.getMessage(); + } else if (exception instanceof BlocklistedAppException + || exception instanceof BlocklistedAccountException) { + metricRequestStatus = exception instanceof BlocklistedAccountException + ? MetricName.blocklisted_account + : MetricName.blocklisted_app; + final String message = "Blocklisted: " + exception.getMessage(); logger.debug(message); errorMessages = Collections.singletonList(message); diff --git a/src/main/java/org/prebid/server/metric/MetricName.java b/src/main/java/org/prebid/server/metric/MetricName.java index dec0f38534a..fc9d3c251c3 100644 --- a/src/main/java/org/prebid/server/metric/MetricName.java +++ b/src/main/java/org/prebid/server/metric/MetricName.java @@ -62,8 +62,8 @@ public enum MetricName { nobid, gotbids, badinput, - blacklisted_account, - blacklisted_app, + blocklisted_account, + blocklisted_app, badserverresponse, failedtorequestbids, timeout, diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index edf2f45b665..c3cfbdd2747 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -277,7 +277,7 @@ Ortb2ImplicitParametersResolver ortb2ImplicitParametersResolver( @Value("${auction.cache.only-winning-bids}") boolean cacheOnlyWinningBids, @Value("${settings.generate-storedrequest-bidrequest-id}") boolean generateBidRequestId, @Value("${auction.ad-server-currency}") String adServerCurrency, - @Value("${auction.blacklisted-apps}") String blacklistedAppsString, + @Value("${auction.blocklisted-apps}") String blocklistedAppsString, @Value("${external-url}") String externalUrl, @Value("${gdpr.host-vendor-id:#{null}}") Integer hostVendorId, @Value("${datacenter-region}") String datacenterRegion, @@ -293,7 +293,7 @@ Ortb2ImplicitParametersResolver ortb2ImplicitParametersResolver( cacheOnlyWinningBids, generateBidRequestId, adServerCurrency, - splitToList(blacklistedAppsString), + splitToList(blocklistedAppsString), externalUrl, hostVendorId, datacenterRegion, @@ -356,7 +356,7 @@ SetuidGppService setuidGppService(GppService gppService) { @Bean Ortb2RequestFactory openRtb2RequestFactory( @Value("${auction.biddertmax.percent}") int timeoutAdjustmentFactor, - @Value("${auction.blacklisted-accounts}") String blacklistedAccountsString, + @Value("${auction.blocklisted-accounts}") String blocklistedAccountsString, UidsCookieService uidsCookieService, ActivityInfrastructureCreator activityInfrastructureCreator, RequestValidator requestValidator, @@ -370,12 +370,12 @@ Ortb2RequestFactory openRtb2RequestFactory( PriceFloorProcessor priceFloorProcessor, Metrics metrics) { - final List blacklistedAccounts = splitToList(blacklistedAccountsString); + final List blocklistedAccounts = splitToList(blocklistedAccountsString); return new Ortb2RequestFactory( timeoutAdjustmentFactor, logSamplingRate, - blacklistedAccounts, + blocklistedAccounts, uidsCookieService, activityInfrastructureCreator, requestValidator, @@ -505,7 +505,7 @@ VideoResponseFactory videoResponseFactory(JacksonMapper mapper) { @Bean VideoStoredRequestProcessor videoStoredRequestProcessor( @Value("${video.stored-request-required}") boolean enforceStoredRequest, - @Value("${auction.blacklisted-accounts}") String blacklistedAccountsString, + @Value("${auction.blocklisted-accounts}") String blocklistedAccountsString, @Value("${video.stored-requests-timeout-ms}") long defaultTimeoutMs, @Value("${auction.ad-server-currency:#{null}}") String adServerCurrency, @Value("${default-request.file.path:#{null}}") String defaultBidRequestPath, @@ -519,7 +519,7 @@ VideoStoredRequestProcessor videoStoredRequestProcessor( return new VideoStoredRequestProcessor( enforceStoredRequest, - splitToList(blacklistedAccountsString), + splitToList(blocklistedAccountsString), defaultTimeoutMs, adServerCurrency, defaultBidRequestPath, diff --git a/src/main/java/org/prebid/server/validation/VideoRequestValidator.java b/src/main/java/org/prebid/server/validation/VideoRequestValidator.java index 354db143e0a..be8c553d735 100644 --- a/src/main/java/org/prebid/server/validation/VideoRequestValidator.java +++ b/src/main/java/org/prebid/server/validation/VideoRequestValidator.java @@ -25,8 +25,10 @@ public class VideoRequestValidator { /** * Throws {@link InvalidRequestException} in case of invalid {@link BidRequestVideo}. */ - public void validateStoredBidRequest(BidRequestVideo bidRequestVideo, boolean enforceStoredRequest, - List blacklistedAccounts) { + public void validateStoredBidRequest(BidRequestVideo bidRequestVideo, + boolean enforceStoredRequest, + List blocklistedAccounts) { + if (enforceStoredRequest && StringUtils.isBlank(bidRequestVideo.getStoredrequestid())) { throw new InvalidRequestException("request missing required field: storedrequestid"); } @@ -44,7 +46,7 @@ public void validateStoredBidRequest(BidRequestVideo bidRequestVideo, boolean en } } - validateSiteAndApp(bidRequestVideo.getSite(), bidRequestVideo.getApp(), blacklistedAccounts); + validateSiteAndApp(bidRequestVideo.getSite(), bidRequestVideo.getApp(), blocklistedAccounts); validateVideo(bidRequestVideo.getVideo()); } @@ -53,7 +55,7 @@ private static boolean isZeroOrNegativeDuration(List durationRangeSec) .anyMatch(duration -> duration <= 0); } - private void validateSiteAndApp(Site site, App app, List blacklistedAccounts) { + private void validateSiteAndApp(Site site, App app, List blocklistedAccounts) { if (app == null && site == null) { throw new InvalidRequestException("request missing required field: site or app"); } else if (app != null && site != null) { @@ -64,7 +66,7 @@ private void validateSiteAndApp(Site site, App app, List blacklistedAcco final String appId = app.getId(); if (StringUtils.isNotBlank(appId)) { - if (blacklistedAccounts.contains(appId)) { + if (blocklistedAccounts.contains(appId)) { throw new InvalidRequestException("Prebid-server does not process requests from App ID: " + appId); } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b899795f418..ea6fd14e6dc 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -102,8 +102,8 @@ adapter-defaults: allow: true auction: ad-server-currency: USD - blacklisted-accounts: - blacklisted-apps: + blocklisted-accounts: + blocklisted-apps: biddertmax: min: 50 max: 5000 diff --git a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolverTest.java b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolverTest.java index 022cb2f33e3..bee92aea095 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolverTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolverTest.java @@ -34,7 +34,7 @@ import org.prebid.server.auction.model.IpAddress; import org.prebid.server.auction.model.SecBrowsingTopic; import org.prebid.server.auction.model.debug.DebugContext; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.identity.IdGenerator; @@ -2469,14 +2469,14 @@ public void shouldPassExtPrebidServer() { } @Test - public void shouldReturnFailedFutureWhenAppIdIsBlacklisted() { + public void shouldReturnFailedFutureWhenAppIdIsBlocklisted() { // given final BidRequest bidRequest = BidRequest.builder() .app(App.builder().id("bad_app").build()) .build(); // when and then - assertThatExceptionOfType(BlacklistedAppException.class) + assertThatExceptionOfType(BlocklistedAppException.class) .isThrownBy(() -> target.resolve(bidRequest, auctionContext, ENDPOINT, false)) .withMessage("Prebid-server does not process requests from App ID: bad_app"); } diff --git a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java index 8791ac5eabf..98f172faee3 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java @@ -33,7 +33,7 @@ import org.prebid.server.cookie.UidsCookie; import org.prebid.server.cookie.UidsCookieService; import org.prebid.server.cookie.proto.Uids; -import org.prebid.server.exception.BlacklistedAccountException; +import org.prebid.server.exception.BlocklistedAccountException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -100,7 +100,7 @@ public class Ortb2RequestFactoryTest extends VertxTest { - private static final List BLACKLISTED_ACCOUNTS = singletonList("bad_acc"); + private static final List BLOCKLISTED_ACCOUNTS = singletonList("bad_acc"); @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -262,7 +262,7 @@ public void fetchAccountShouldReturnFailedFutureIfAccountIsInactive() { } @Test - public void fetchAccountShouldReturnFailedFutureWhenAccountIdIsBlacklisted() { + public void fetchAccountShouldReturnFailedFutureWhenAccountIdIsBlocklisted() { // given final BidRequest bidRequest = givenBidRequest(builder -> builder .site(Site.builder() @@ -279,8 +279,8 @@ public void fetchAccountShouldReturnFailedFutureWhenAccountIdIsBlacklisted() { // then assertThat(result.failed()).isTrue(); assertThat(result.cause()) - .isInstanceOf(BlacklistedAccountException.class) - .hasMessage("Prebid-server has blacklisted Account ID: bad_acc, please reach out to the prebid " + .isInstanceOf(BlocklistedAccountException.class) + .hasMessage("Prebid-server has blocklisted Account ID: bad_acc, please reach out to the prebid " + "server host."); } @@ -482,7 +482,7 @@ public void shouldFetchAccountFromStoredIfStoredLookupIsTrueAndAccountIsNotFound } @Test - public void shouldFetchAccountFromStoredAndReturnFailedFutureWhenAccountIdIsBlacklisted() { + public void shouldFetchAccountFromStoredAndReturnFailedFutureWhenAccountIdIsBlocklisted() { // given final BidRequest receivedBidRequest = givenBidRequest(identity()); @@ -507,8 +507,8 @@ public void shouldFetchAccountFromStoredAndReturnFailedFutureWhenAccountIdIsBlac assertThat(result.failed()).isTrue(); assertThat(result.cause()) - .isInstanceOf(BlacklistedAccountException.class) - .hasMessage("Prebid-server has blacklisted Account ID: bad_acc, please reach out to the prebid " + .isInstanceOf(BlocklistedAccountException.class) + .hasMessage("Prebid-server has blocklisted Account ID: bad_acc, please reach out to the prebid " + "server host."); } @@ -1613,7 +1613,7 @@ private void givenTarget(int timeoutAdjustmentFactor) { target = new Ortb2RequestFactory( timeoutAdjustmentFactor, 0.01, - BLACKLISTED_ACCOUNTS, + BLOCKLISTED_ACCOUNTS, uidsCookieService, activityInfrastructureCreator, requestValidator, diff --git a/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java b/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java index 502f13fccc6..a64ea4b05dc 100644 --- a/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java @@ -35,8 +35,8 @@ import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.exception.BlacklistedAccountException; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAccountException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidAccountConfigException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -281,10 +281,10 @@ public void shouldRespondWithBadRequestIfRequestIsInvalid() { } @Test - public void shouldRespondWithBadRequestIfRequestHasBlacklistedAccount() { + public void shouldRespondWithBadRequestIfRequestHasBlocklistedAccount() { // given given(ampRequestFactory.fromRequest(any(), anyLong())) - .willReturn(Future.failedFuture(new BlacklistedAccountException("Blacklisted account"))); + .willReturn(Future.failedFuture(new BlocklistedAccountException("Blocklisted account"))); // when ampHandler.handle(routingContext); @@ -298,14 +298,14 @@ public void shouldRespondWithBadRequestIfRequestHasBlacklistedAccount() { tuple("AMP-Access-Control-Allow-Source-Origin", "http://example.com"), tuple("Access-Control-Expose-Headers", "AMP-Access-Control-Allow-Source-Origin"), tuple("x-prebid", "pbs-java/1.00")); - verify(httpResponse).end(eq("Blacklisted: Blacklisted account")); + verify(httpResponse).end(eq("Blocklisted: Blocklisted account")); } @Test - public void shouldRespondWithBadRequestIfRequestHasBlacklistedApp() { + public void shouldRespondWithBadRequestIfRequestHasBlocklistedApp() { // given given(ampRequestFactory.fromRequest(any(), anyLong())) - .willReturn(Future.failedFuture(new BlacklistedAppException("Blacklisted app"))); + .willReturn(Future.failedFuture(new BlocklistedAppException("Blocklisted app"))); // when ampHandler.handle(routingContext); @@ -319,7 +319,7 @@ public void shouldRespondWithBadRequestIfRequestHasBlacklistedApp() { tuple("AMP-Access-Control-Allow-Source-Origin", "http://example.com"), tuple("Access-Control-Expose-Headers", "AMP-Access-Control-Allow-Source-Origin"), tuple("x-prebid", "pbs-java/1.00")); - verify(httpResponse).end(eq("Blacklisted: Blacklisted app")); + verify(httpResponse).end(eq("Blocklisted: Blocklisted app")); } @Test diff --git a/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java b/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java index 14f83a310f9..da34965c6ef 100644 --- a/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java @@ -26,8 +26,8 @@ import org.prebid.server.auction.model.TimeoutContext; import org.prebid.server.auction.requestfactory.AuctionRequestFactory; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.exception.BlacklistedAccountException; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAccountException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidAccountConfigException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -238,19 +238,19 @@ public void shouldComputeTimeoutBasedOnRequestProcessingStartTime() { } @Test - public void shouldRespondWithServiceUnavailableIfBidRequestHasAccountBlacklisted() { + public void shouldRespondWithServiceUnavailableIfBidRequestHasAccountBlocklisted() { // given given(auctionRequestFactory.fromRequest(any(), anyLong())) - .willReturn(Future.failedFuture(new BlacklistedAccountException("Blacklisted account"))); + .willReturn(Future.failedFuture(new BlocklistedAccountException("Blocklisted account"))); // when auctionHandler.handle(routingContext); // then verify(httpResponse).setStatusCode(eq(403)); - verify(httpResponse).end(eq("Blacklisted: Blacklisted account")); + verify(httpResponse).end(eq("Blocklisted: Blocklisted account")); - verify(metrics).updateRequestTypeMetric(eq(MetricName.openrtb2web), eq(MetricName.blacklisted_account)); + verify(metrics).updateRequestTypeMetric(eq(MetricName.openrtb2web), eq(MetricName.blocklisted_account)); } @Test @@ -270,19 +270,19 @@ public void shouldRespondWithBadRequestIfBidRequestHasAccountWithInvalidConfig() } @Test - public void shouldRespondWithServiceUnavailableIfBidRequestHasAppBlacklisted() { + public void shouldRespondWithServiceUnavailableIfBidRequestHasAppBlocklisted() { // given given(auctionRequestFactory.fromRequest(any(), anyLong())) - .willReturn(Future.failedFuture(new BlacklistedAppException("Blacklisted app"))); + .willReturn(Future.failedFuture(new BlocklistedAppException("Blocklisted app"))); // when auctionHandler.handle(routingContext); // then verify(httpResponse).setStatusCode(eq(403)); - verify(httpResponse).end(eq("Blacklisted: Blacklisted app")); + verify(httpResponse).end(eq("Blocklisted: Blocklisted app")); - verify(metrics).updateRequestTypeMetric(eq(MetricName.openrtb2web), eq(MetricName.blacklisted_app)); + verify(metrics).updateRequestTypeMetric(eq(MetricName.openrtb2web), eq(MetricName.blocklisted_app)); } @Test diff --git a/src/test/java/org/prebid/server/metric/MetricsTest.java b/src/test/java/org/prebid/server/metric/MetricsTest.java index e06847c7386..b320e2e8d53 100644 --- a/src/test/java/org/prebid/server/metric/MetricsTest.java +++ b/src/test/java/org/prebid/server/metric/MetricsTest.java @@ -388,16 +388,16 @@ public void updateRequestTimeMetricShouldUpdateMetric() { public void updateRequestTypeMetricShouldIncrementMetric() { // when metrics.updateRequestTypeMetric(MetricName.openrtb2web, MetricName.ok); - metrics.updateRequestTypeMetric(MetricName.openrtb2web, MetricName.blacklisted_account); - metrics.updateRequestTypeMetric(MetricName.openrtb2app, MetricName.blacklisted_app); + metrics.updateRequestTypeMetric(MetricName.openrtb2web, MetricName.blocklisted_account); + metrics.updateRequestTypeMetric(MetricName.openrtb2app, MetricName.blocklisted_app); metrics.updateRequestTypeMetric(MetricName.openrtb2app, MetricName.err); metrics.updateRequestTypeMetric(MetricName.amp, MetricName.badinput); metrics.updateRequestTypeMetric(MetricName.amp, MetricName.networkerr); // then assertThat(metricRegistry.counter("requests.ok.openrtb2-web").getCount()).isOne(); - assertThat(metricRegistry.counter("requests.blacklisted_account.openrtb2-web").getCount()).isOne(); - assertThat(metricRegistry.counter("requests.blacklisted_app.openrtb2-app").getCount()).isOne(); + assertThat(metricRegistry.counter("requests.blocklisted_account.openrtb2-web").getCount()).isOne(); + assertThat(metricRegistry.counter("requests.blocklisted_app.openrtb2-app").getCount()).isOne(); assertThat(metricRegistry.counter("requests.err.openrtb2-app").getCount()).isOne(); assertThat(metricRegistry.counter("requests.badinput.amp").getCount()).isOne(); assertThat(metricRegistry.counter("requests.networkerr.amp").getCount()).isOne(); diff --git a/src/test/java/org/prebid/server/validation/VideoRequestValidatorTest.java b/src/test/java/org/prebid/server/validation/VideoRequestValidatorTest.java index 615b117a3ab..51985f786b3 100644 --- a/src/test/java/org/prebid/server/validation/VideoRequestValidatorTest.java +++ b/src/test/java/org/prebid/server/validation/VideoRequestValidatorTest.java @@ -123,7 +123,7 @@ public void validateStoredBidRequestShouldThrowExceptionWhenSiteHaveNoId() { } @Test - public void validateStoredBidRequestShouldThrowExceptionWhenAppHaveBlacklistedAccount() { + public void validateStoredBidRequestShouldThrowExceptionWhenAppHaveBlocklistedAccount() { // given final BidRequestVideo requestVideo = givenBidRequestVideo( requestBuilder -> requestBuilder.site(null).app(App.builder().id("BAD").build()), From e4b97d0148c6acc5e5edbc8c8122072656b5e5d2 Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Tue, 7 May 2024 17:43:36 +0300 Subject: [PATCH 27/62] Core: Set `strict-app-site-dooh` to `true` (#3153) --- src/main/resources/application.yaml | 2 +- .../server/functional/tests/MetricsSpec.groovy | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index ea6fd14e6dc..e85b4a9de5c 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -125,7 +125,7 @@ auction: secure-markup: skip host-schain-node: category-mapping-enabled: false - strict-app-site-dooh: false + strict-app-site-dooh: true video: stored-request-required: false stored-requests-timeout-ms: 90 diff --git a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy index ae3795ca1f8..c1740646811 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Dooh import org.prebid.server.functional.model.request.auction.Site import org.prebid.server.functional.model.response.auction.BidResponse +import org.prebid.server.functional.service.PrebidServerService import static org.prebid.server.functional.model.config.AccountMetricsVerbosityLevel.BASIC import static org.prebid.server.functional.model.config.AccountMetricsVerbosityLevel.DETAILED @@ -16,8 +17,11 @@ import static org.prebid.server.functional.model.request.auction.DistributionCha class MetricsSpec extends BaseSpec { + private final PrebidServerService softPrebidService = pbsServiceFactory.getService(['auction.strict-app-site-dooh': 'false']) + def setup() { flushMetrics(defaultPbsService) + flushMetrics(softPrebidService) } def "PBS should not populate account metric when verbosity level is none"() { @@ -113,7 +117,7 @@ class MetricsSpec extends BaseSpec { assert !metrics["account.${accountId}.requests.type.openrtb2-app" as String] } - def "PBS should ignore site distribution channel and update only dooh metrics when presented dooh and site in request"() { + def "PBS with soft setup should ignore site distribution channel and update only dooh metrics when presented dooh and site in request"() { given: "Default bid request with dooh and site" def bidRequest = BidRequest.defaultBidRequest.tap { dooh = Dooh.defaultDooh @@ -126,7 +130,7 @@ class MetricsSpec extends BaseSpec { accountDao.save(account) when: "Requesting PBS auction" - defaultPbsService.sendAuctionRequest(bidRequest) + softPrebidService.sendAuctionRequest(bidRequest) then: "Bidder request should have only dooh data" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -134,7 +138,7 @@ class MetricsSpec extends BaseSpec { assert !bidderRequest.site and: "Metrics processed across site should be updated" - def metrics = defaultPbsService.sendCollectedMetricsRequest() + def metrics = softPrebidService.sendCollectedMetricsRequest() assert metrics["account.${accountId}.requests.type.openrtb2-dooh" as String] == 1 assert metrics["adapter.generic.requests.type.openrtb2-dooh" as String] == 1 @@ -146,7 +150,7 @@ class MetricsSpec extends BaseSpec { assert !metrics["account.${accountId}.requests.type.openrtb2-app" as String] } - def "PBS should ignore other distribution channel and update only app metrics when presented app ant other channels in request"() { + def "PBS with soft setup should ignore other distribution channel and update only app metrics when presented app ant other channels in request"() { given: "Account in the DB" def accountId = bidRequest.app.publisher.id def accountMetricsConfig = new AccountConfig(metrics: new AccountMetricsConfig(verbosityLevel: DETAILED)) @@ -154,7 +158,7 @@ class MetricsSpec extends BaseSpec { accountDao.save(account) when: "Requesting PBS auction" - defaultPbsService.sendAuctionRequest(bidRequest) + softPrebidService.sendAuctionRequest(bidRequest) then: "Bidder request should have only site data" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -163,7 +167,7 @@ class MetricsSpec extends BaseSpec { assert !bidderRequest.dooh and: "Metrics processed across site should be updated" - def metrics = defaultPbsService.sendCollectedMetricsRequest() + def metrics = softPrebidService.sendCollectedMetricsRequest() assert metrics["account.${accountId}.requests.type.openrtb2-app" as String] == 1 assert metrics["adapter.generic.requests.type.openrtb2-app" as String] == 1 From e895d458ec0d973145b44805d13d09e77a65f173 Mon Sep 17 00:00:00 2001 From: Alex Maltsev Date: Tue, 7 May 2024 17:46:33 +0300 Subject: [PATCH 28/62] Core: Fix source text in jackson error output (#3121) --- .../java/org/prebid/server/json/ObjectMapperProvider.java | 5 ++++- .../org/prebid/server/auction/BidResponseCreatorTest.java | 5 ++--- .../server/bidder/adtelligent/AdtelligentBidderTest.java | 7 ++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/prebid/server/json/ObjectMapperProvider.java b/src/main/java/org/prebid/server/json/ObjectMapperProvider.java index 96189d6706f..fc1bcea0611 100644 --- a/src/main/java/org/prebid/server/json/ObjectMapperProvider.java +++ b/src/main/java/org/prebid/server/json/ObjectMapperProvider.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.StreamReadFeature; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; @@ -17,7 +18,9 @@ public final class ObjectMapperProvider { MAPPER = JsonMapper.builder().configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true) - .enable(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN).build() + .enable(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN) + .enable(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION) + .build() .setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE) .setSerializationInclusion(JsonInclude.Include.NON_NULL) .registerModule(new BlackbirdModule()) diff --git a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java index f96251f16be..58a9386de55 100644 --- a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java @@ -2652,8 +2652,7 @@ public void shouldPopulateBidResponseExtension() { ExtBidderError.of(3, "Failed to decode: Cannot deserialize value" + " of type `com.iab.openrtb.response.Response` from Array value " + "(token `JsonToken.START_ARRAY`)\n" - + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION`" - + " disabled); line: 1, column: 1]"))), + + " at [Source: (String)\"[]\"; line: 1, column: 1]"))), entry("cache", singletonList(ExtBidderError.of(999, "cacheError")))); assertThat(responseExt.getResponsetimemillis()).hasSize(2) @@ -3151,7 +3150,7 @@ public void shouldThrowExceptionWhenNativeRequestIsInvalid() throws JsonProcessi .extracting(error -> error.get(bidder1)) .extracting(extBidderErrors -> extBidderErrors.get(0)) .isEqualTo(ExtBidderError.of(3, "No content to map due to end-of-input\n" - + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1]")); + + " at [Source: (String)\"\"; line: 1, column: 0]")); } @Test diff --git a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java index 2628aabb755..73622242460 100644 --- a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java @@ -402,11 +402,8 @@ public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCantBeParsed() { assertThat(result.getErrors()).hasSize(1) .containsExactly(BidderError.badServerResponse( "Failed to decode: Unexpected end-of-input: expected close marker" - + " for Object (start marker at [Source: REDACTED " - + "(`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); " - + "line: 1, column: 1])\n" - + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled);" - + " line: 1, column: 2]")); + + " for Object (start marker at [Source: (String)\"{\"; line: 1, column: 1])\n" + + " at [Source: (String)\"{\"; line: 1, column: 2]")); } private static BidderCall givenHttpCall(String body) { From bc76b28ac2ebed83954dd9089b8cd005336d730c Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Tue, 7 May 2024 17:56:52 +0300 Subject: [PATCH 29/62] Core: Always merge account config for purpose1 (#3155) --- .../java/org/prebid/server/privacy/gdpr/Tcf2Service.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/prebid/server/privacy/gdpr/Tcf2Service.java b/src/main/java/org/prebid/server/privacy/gdpr/Tcf2Service.java index f2369e6247f..3134f33e91d 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/Tcf2Service.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/Tcf2Service.java @@ -100,21 +100,23 @@ private Future> permissionsForInternal(Collection vendorPermissionsByType = toVendorPermissionsByType(vendorPermissions, accountGdprConfig); - // TODO: always merge account config for purpose1 with next major release return versionedVendorListService.forConsent(tcfConsent) .compose(vendorGvlPermissions -> processSupportedPurposeStrategies( tcfConsent, wrapWithGVL(vendorPermissionsByType, vendorGvlPermissions), mergedPurposes, - purposeOneTreatmentInterpretation), + mergedPurposeOneTreatmentInterpretation), ignored -> processDowngradedSupportedPurposeStrategies( tcfConsent, wrapWithGVL(vendorPermissionsByType, Collections.emptyMap()), mergedPurposes, - mergePurposeOneTreatmentInterpretation(accountGdprConfig))) + mergedPurposeOneTreatmentInterpretation)) .map(ignored -> enforcePurpose4IfRequired(mergedPurposes, vendorPermissionsByType)) .map(ignored -> processSupportedSpecialFeatureStrategies( tcfConsent, From d5af622b2bdab526e1752a3afe62be24c7c6e45b Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Wed, 8 May 2024 13:26:17 +0300 Subject: [PATCH 30/62] Core: Remove deprecated `auction.max-timeout-ms` property (#3158) --- docs/config-app.md | 1 - .../spring/config/ServiceConfiguration.java | 16 +--------------- .../server/functional/tests/AuctionSpec.groovy | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index 5e3ee1192d4..f162efff719 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -77,7 +77,6 @@ Removes and downloads file again if depending service cant process probably corr ## Auction (OpenRTB) - `auction.blocklisted-accounts` - comma separated list of blocklisted account IDs. - `auction.blocklisted-apps` - comma separated list of blocklisted applications IDs, requests from which should not be processed. -- `auction.max-timeout-ms` - maximum operation timeout for OpenRTB Auction requests. Deprecated. - `auction.biddertmax.min` - minimum operation timeout for OpenRTB Auction requests. - `auction.biddertmax.max` - maximum operation timeout for OpenRTB Auction requests. - `auction.biddertmax.percent` - adjustment factor for `request.tmax` for bidders. diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index c3cfbdd2747..719f9aee0df 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -239,24 +239,10 @@ SupplyChainResolver schainResolver( @Bean TimeoutResolver auctionTimeoutResolver( @Value("${auction.biddertmax.min}") long minTimeout, - @Value("${auction.max-timeout-ms:#{0}}") long maxTimeoutDeprecated, @Value("${auction.biddertmax.max:#{0}}") long maxTimeout, @Value("${auction.tmax-upstream-response-time}") long upstreamResponseTime) { - return new TimeoutResolver( - minTimeout, - resolveMaxTimeout(maxTimeoutDeprecated, maxTimeout), - upstreamResponseTime); - } - - // TODO: Remove after transition period - private static long resolveMaxTimeout(long maxTimeoutDeprecated, long maxTimeout) { - if (maxTimeout != 0) { - return maxTimeout; - } - - logger.warn("Usage of deprecated property: auction.max-timeout-ms. Use auction.biddertmax.max instead."); - return maxTimeoutDeprecated; + return new TimeoutResolver(minTimeout, maxTimeout, upstreamResponseTime); } @Bean diff --git a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy index cfab2bafde1..268c66e182e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy @@ -45,7 +45,7 @@ class AuctionSpec extends BaseSpec { private static final boolean CORS_SUPPORT = false private static final UserSyncInfo.Type USER_SYNC_TYPE = REDIRECT private static final int DEFAULT_TIMEOUT = getRandomTimeout() - private static final Map PBS_CONFIG = ["auction.max-timeout-ms" : MAX_TIMEOUT as String, + private static final Map PBS_CONFIG = ["auction.biddertmax.max" : MAX_TIMEOUT as String, "auction.default-timeout-ms": DEFAULT_TIMEOUT as String] private static final Map GENERIC_CONFIG = [ "adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL, From 6aabd8b65a87006b2516e0ce4918b14d82b11ccf Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Wed, 8 May 2024 07:37:45 -0400 Subject: [PATCH 31/62] Dependencies: Bump IAB GPP library (#3127) --- pom.xml | 2 +- .../privacy/PrivacySection.java | 24 +- .../reader/USCaliforniaGppReader.java | 34 +- .../reader/USColoradoGppReader.java | 32 +- .../reader/USConnecticutGppReader.java | 32 +- .../uscustomlogic/reader/USUtahGppReader.java | 30 +- .../reader/USVirginiaGppReader.java | 28 +- .../reader/USMappedCaliforniaGppReader.java | 30 +- .../reader/USMappedColoradoGppReader.java | 30 +- .../reader/USMappedConnecticutGppReader.java | 32 +- .../usnat/reader/USMappedUtahGppReader.java | 28 +- .../reader/USMappedVirginiaGppReader.java | 26 +- .../usnat/reader/USNationalGppReader.java | 42 +- .../model/config/GppModuleConfig.groovy | 2 +- .../config/UsNationalPrivacySection.groovy | 61 +- .../model/request/GppSectionId.groovy | 24 +- .../tests/privacy/ActivityTraceLogSpec.groovy | 15 +- .../tests/privacy/GppAmpSpec.groovy | 6 +- .../tests/privacy/GppAuctionSpec.groovy | 8 +- .../tests/privacy/GppCookieSyncSpec.groovy | 4 +- .../privacy/GppFetchBidActivitiesSpec.groovy | 321 ++++----- .../tests/privacy/GppSetUidSpec.groovy | 8 +- .../privacy/GppSyncUserActivitiesSpec.groovy | 512 ++++++++------ .../GppTransmitEidsActivitiesSpec.groovy | 598 +++++++++++------ ...GppTransmitPreciseGeoActivitiesSpec.groovy | 373 ++++++----- .../GppTransmitUfpdActivitiesSpec.groovy | 628 ++++++++++++------ .../tests/privacy/PrivacyBaseSpec.groovy | 4 +- .../util/privacy/gpp/GppConsent.groovy | 28 +- ...aV1Consent.groovy => UsCaV1Consent.groovy} | 40 +- ...oV1Consent.groovy => UsCoV1Consent.groovy} | 40 +- ...tV1Consent.groovy => UsCtV1Consent.groovy} | 38 +- ...V1Consent.groovy => UsNatV1Consent.groovy} | 50 +- ...tV1Consent.groovy => UsUtV1Consent.groovy} | 36 +- ...UspV1Consent.groovy => UsV1Consent.groovy} | 8 +- ...aV1Consent.groovy => UsVaV1Consent.groovy} | 32 +- .../reader/USCaliforniaGppReaderTest.java | 44 +- .../reader/USColoradoGppReaderTest.java | 44 +- .../reader/USConnecticutGppReaderTest.java | 44 +- .../reader/USUtahGppReaderTest.java | 44 +- .../reader/USVirginiaGppReaderTest.java | 44 +- .../USMappedCaliforniaGppReaderTest.java | 46 +- .../reader/USMappedColoradoGppReaderTest.java | 48 +- .../USMappedConnecticutGppReaderTest.java | 48 +- .../reader/USMappedUtahGppReaderTest.java | 48 +- .../reader/USMappedVirginiaGppReaderTest.java | 48 +- .../usnat/reader/USNationalGppReaderTest.java | 44 +- .../gpp/model/GppContextCreatorTest.java | 2 +- 47 files changed, 2124 insertions(+), 1586 deletions(-) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspCaV1Consent.groovy => UsCaV1Consent.groovy} (56%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspCoV1Consent.groovy => UsCoV1Consent.groovy} (55%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspCtV1Consent.groovy => UsCtV1Consent.groovy} (56%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspNatV1Consent.groovy => UsNatV1Consent.groovy} (54%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspUtV1Consent.groovy => UsUtV1Consent.groovy} (54%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspV1Consent.groovy => UsV1Consent.groovy} (80%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspVaV1Consent.groovy => UsVaV1Consent.groovy} (56%) diff --git a/pom.xml b/pom.xml index d24b162dfbb..aee1ffd7d5e 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ 2.0.2 2.0.10 2.12.0 - 3.0.10 + 3.2.0 3.21.7 3.17.3 1.0.7 diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/PrivacySection.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/PrivacySection.java index a35982c532d..3e081a6310e 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/PrivacySection.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/PrivacySection.java @@ -1,22 +1,22 @@ package org.prebid.server.activity.infrastructure.privacy; -import com.iab.gpp.encoder.section.UspCaV1; -import com.iab.gpp.encoder.section.UspCoV1; -import com.iab.gpp.encoder.section.UspCtV1; -import com.iab.gpp.encoder.section.UspNatV1; -import com.iab.gpp.encoder.section.UspUtV1; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsCaV1; +import com.iab.gpp.encoder.section.UsCoV1; +import com.iab.gpp.encoder.section.UsCtV1; +import com.iab.gpp.encoder.section.UsNatV1; +import com.iab.gpp.encoder.section.UsUtV1; +import com.iab.gpp.encoder.section.UsVaV1; import java.util.Set; public enum PrivacySection { - NATIONAL(UspNatV1.ID), - CALIFORNIA(UspCaV1.ID), - VIRGINIA(UspVaV1.ID), - COLORADO(UspCoV1.ID), - UTAH(UspUtV1.ID), - CONNECTICUT(UspCtV1.ID); + NATIONAL(UsNatV1.ID), + CALIFORNIA(UsCaV1.ID), + VIRGINIA(UsVaV1.ID), + COLORADO(UsCoV1.ID), + UTAH(UsUtV1.ID), + CONNECTICUT(UsCtV1.ID); public static final Set US_PRIVACY_SECTIONS = Set.of( NATIONAL, diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReader.java index 5ac3e9601a5..963f50ab2b1 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCaV1; +import com.iab.gpp.encoder.section.UsCaV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -9,20 +9,20 @@ public class USCaliforniaGppReader implements USCustomLogicGppReader { - private final UspCaV1 consent; + private final UsCaV1 consent; public USCaliforniaGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCaV1Section() : null; + consent = gppModel != null ? gppModel.getUsCaV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getGpc); } @Override @@ -32,17 +32,17 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSaleOptOutNotice); } @Override @@ -52,12 +52,12 @@ public Integer getSharingNotice() { @Override public Integer getSharingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSharingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSharingOptOut); } @Override public Integer getSharingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSharingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSharingOptOutNotice); } @Override @@ -72,12 +72,12 @@ public Integer getTargetedAdvertisingOptOutNotice() { @Override public Integer getSensitiveDataLimitUseNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSensitiveDataLimitUseNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSensitiveDataLimitUseNotice); } @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSensitiveDataProcessing); } @Override @@ -87,26 +87,26 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public List getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getKnownChildSensitiveDataConsents); } @Override public Integer getPersonalDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getPersonalDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getPersonalDataConsents); } @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReader.java index 8a6d1c457e4..bdc3889f6e0 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReader.java @@ -2,7 +2,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCoV1; +import com.iab.gpp.encoder.section.UsCoV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -10,20 +10,20 @@ public class USColoradoGppReader implements USCustomLogicGppReader { - private final UspCoV1 consent; + private final UsCoV1 consent; public USColoradoGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCoV1Section() : null; + consent = gppModel != null ? gppModel.getUsCoV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getGpc); } @Override @@ -33,22 +33,22 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSharingNotice); } @Override @@ -63,12 +63,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -78,7 +78,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSensitiveDataProcessing); } @Override @@ -88,7 +88,7 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public Integer getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getKnownChildSensitiveDataConsents); } @Override @@ -98,16 +98,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReader.java index 9c617577099..d7d588926f8 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCtV1; +import com.iab.gpp.encoder.section.UsCtV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -9,20 +9,20 @@ public class USConnecticutGppReader implements USCustomLogicGppReader { - private final UspCtV1 consent; + private final UsCtV1 consent; public USConnecticutGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCtV1Section() : null; + consent = gppModel != null ? gppModel.getUsCtV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getGpc); } @Override @@ -32,22 +32,22 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSharingNotice); } @Override @@ -62,12 +62,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -77,7 +77,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSensitiveDataProcessing); } @Override @@ -87,7 +87,7 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public List getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getKnownChildSensitiveDataConsents); } @Override @@ -97,16 +97,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReader.java index d9c768c7dc3..3f34d024b35 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspUtV1; +import com.iab.gpp.encoder.section.UsUtV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -9,15 +9,15 @@ public class USUtahGppReader implements USCustomLogicGppReader { - private final UspUtV1 consent; + private final UsUtV1 consent; public USUtahGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspUtV1Section() : null; + consent = gppModel != null ? gppModel.getUsUtV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getVersion); } @Override @@ -37,17 +37,17 @@ public Boolean getGpcSegmentIncluded() { @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSharingNotice); } @Override @@ -62,12 +62,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -77,17 +77,17 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSensitiveDataProcessing); } @Override public Integer getSensitiveDataProcessingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSensitiveDataProcessingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSensitiveDataProcessingOptOutNotice); } @Override public Integer getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getKnownChildSensitiveDataConsents); } @Override @@ -97,16 +97,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReader.java index a07986e4160..cccb0186946 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsVaV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -9,15 +9,15 @@ public class USVirginiaGppReader implements USCustomLogicGppReader { - private final UspVaV1 consent; + private final UsVaV1 consent; public USVirginiaGppReader(GppModel gppModel) { - this.consent = gppModel != null ? gppModel.getUspVaV1Section() : null; + this.consent = gppModel != null ? gppModel.getUsVaV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getVersion); } @Override @@ -37,17 +37,17 @@ public Boolean getGpcSegmentIncluded() { @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSharingNotice); } @Override @@ -62,12 +62,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -77,7 +77,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSensitiveDataProcessing); } @Override @@ -87,7 +87,7 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public Integer getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getKnownChildSensitiveDataConsents); } @Override @@ -97,16 +97,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReader.java index 637685b774e..81878e5d908 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCaV1; +import com.iab.gpp.encoder.section.UsCaV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -15,20 +15,20 @@ public class USMappedCaliforniaGppReader implements USNatGppReader, USCustomLogi private static final List DEFAULT_SENSITIVE_DATA = Collections.nCopies(12, null); private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); - private final UspCaV1 consent; + private final UsCaV1 consent; public USMappedCaliforniaGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCaV1Section() : null; + consent = gppModel != null ? gppModel.getUsCaV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getGpc); } @Override @@ -38,17 +38,17 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSaleOptOutNotice); } @Override @@ -58,12 +58,12 @@ public Integer getSharingNotice() { @Override public Integer getSharingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSharingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSharingOptOut); } @Override public Integer getSharingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSharingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSharingOptOutNotice); } @Override @@ -78,7 +78,7 @@ public Integer getTargetedAdvertisingOptOutNotice() { @Override public Integer getSensitiveDataLimitUseNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSensitiveDataLimitUseNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSensitiveDataLimitUseNotice); } @Override @@ -117,21 +117,21 @@ public List getKnownChildSensitiveDataConsents() { @Override public Integer getPersonalDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getPersonalDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getPersonalDataConsents); } @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReader.java index 6ea4eefce91..b9505a7c458 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCoV1; +import com.iab.gpp.encoder.section.UsCoV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -13,20 +13,20 @@ public class USMappedColoradoGppReader implements USNatGppReader, USCustomLogicG private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); private static final List NON_CHILD_SENSITIVE_DATA = List.of(0, 0); - private final UspCoV1 consent; + private final UsCoV1 consent; public USMappedColoradoGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCoV1Section() : null; + consent = gppModel != null ? gppModel.getUsCoV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getGpc); } @Override @@ -36,22 +36,22 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSharingNotice); } @Override @@ -66,12 +66,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -81,7 +81,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSensitiveDataProcessing); } @Override @@ -108,16 +108,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReader.java index 10a24f3f26f..8309e75ebc1 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCtV1; +import com.iab.gpp.encoder.section.UsCtV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -15,20 +15,20 @@ public class USMappedConnecticutGppReader implements USNatGppReader, USCustomLog private static final List MIXED_CHILD_SENSITIVE_DATA = List.of(2, 1); private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); - private final UspCtV1 consent; + private final UsCtV1 consent; public USMappedConnecticutGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCtV1Section() : null; + consent = gppModel != null ? gppModel.getUsCtV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getGpc); } @Override @@ -38,22 +38,22 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSharingNotice); } @Override @@ -68,12 +68,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -83,7 +83,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSensitiveDataProcessing); } @Override @@ -94,7 +94,7 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public List getKnownChildSensitiveDataConsents() { final List originalData = ObjectUtil.getIfNotNull( - consent, UspCtV1::getKnownChildSensitiveDataConsents); + consent, UsCtV1::getKnownChildSensitiveDataConsents); final Integer first = originalData != null ? originalData.get(0) : null; final Integer second = originalData != null ? originalData.get(1) : null; @@ -116,16 +116,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReader.java index d808c96784f..527a87288f7 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspUtV1; +import com.iab.gpp.encoder.section.UsUtV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -17,15 +17,15 @@ public class USMappedUtahGppReader implements USNatGppReader, USCustomLogicGppRe private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); private static final List NON_CHILD_SENSITIVE_DATA = List.of(0, 0); - private final UspUtV1 consent; + private final UsUtV1 consent; public USMappedUtahGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspUtV1Section() : null; + consent = gppModel != null ? gppModel.getUsUtV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getVersion); } @Override @@ -45,17 +45,17 @@ public Boolean getGpcSegmentIncluded() { @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSharingNotice); } @Override @@ -70,12 +70,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -86,7 +86,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { final List originalData = Optional.ofNullable(consent) - .map(UspUtV1::getSensitiveDataProcessing) + .map(UsUtV1::getSensitiveDataProcessing) .orElse(DEFAULT_SENSITIVE_DATA_PROCESSING); final List data = new ArrayList<>(DEFAULT_SENSITIVE_DATA_PROCESSING); @@ -104,7 +104,7 @@ public List getSensitiveDataProcessing() { @Override public Integer getSensitiveDataProcessingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSensitiveDataProcessingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSensitiveDataProcessingOptOutNotice); } @Override @@ -126,16 +126,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReader.java index 97abfef6331..739762666ea 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsVaV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -13,15 +13,15 @@ public class USMappedVirginiaGppReader implements USNatGppReader, USCustomLogicG private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); private static final List NON_CHILD_SENSITIVE_DATA = List.of(0, 0); - private final UspVaV1 consent; + private final UsVaV1 consent; public USMappedVirginiaGppReader(GppModel gppModel) { - this.consent = gppModel != null ? gppModel.getUspVaV1Section() : null; + this.consent = gppModel != null ? gppModel.getUsVaV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getVersion); } @Override @@ -41,17 +41,17 @@ public Boolean getGpcSegmentIncluded() { @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSharingNotice); } @Override @@ -66,12 +66,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -81,7 +81,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSensitiveDataProcessing); } @Override @@ -108,16 +108,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReader.java index 8e5332fd979..11dec8ebbc2 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspNatV1; +import com.iab.gpp.encoder.section.UsNatV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -10,20 +10,20 @@ public class USNationalGppReader implements USNatGppReader, USCustomLogicGppReader { - private final UspNatV1 consent; + private final UsNatV1 consent; public USNationalGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspNatV1Section() : null; + consent = gppModel != null ? gppModel.getUsNatV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getGpc); } @Override @@ -37,81 +37,81 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSharingNotice); } @Override public Integer getSharingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSharingOptOut); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSharingOptOut); } @Override public Integer getSharingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSharingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSharingOptOutNotice); } @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getTargetedAdvertisingOptOutNotice); } @Override public Integer getSensitiveDataLimitUseNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSensitiveDataLimitUseNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSensitiveDataLimitUseNotice); } @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSensitiveDataProcessing); } @Override public Integer getSensitiveDataProcessingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSensitiveDataProcessingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSensitiveDataProcessingOptOutNotice); } @Override public List getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getKnownChildSensitiveDataConsents); } @Override public Integer getPersonalDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getPersonalDataConsents); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getPersonalDataConsents); } @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getMspaOptOutOptionMode); } } diff --git a/src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy b/src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy index 3ac38525dc7..be7a710ce44 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy @@ -12,7 +12,7 @@ class GppModuleConfig { List skipSids static GppModuleConfig getDefaultModuleConfig(ActivityConfig activityConfig = ActivityConfig.configWithDefaultRestrictRules, - List sids = [GppSectionId.USP_NAT_V1], + List sids = [GppSectionId.US_NAT_V1], Boolean normalizeFlags = true) { new GppModuleConfig().tap { it.activityConfig = [activityConfig] diff --git a/src/test/groovy/org/prebid/server/functional/model/config/UsNationalPrivacySection.groovy b/src/test/groovy/org/prebid/server/functional/model/config/UsNationalPrivacySection.groovy index caab68873e0..d5733707955 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/UsNationalPrivacySection.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/UsNationalPrivacySection.groovy @@ -1,40 +1,39 @@ package org.prebid.server.functional.model.config import com.fasterxml.jackson.annotation.JsonValue -import com.iab.gpp.encoder.field.UspNatV1Field -import org.prebid.server.functional.util.PBSUtils +import com.iab.gpp.encoder.field.UsNatV1Field enum UsNationalPrivacySection { - SHARING_NOTICE(UspNatV1Field.SHARING_NOTICE), - SALE_OPT_OUT_NOTICE(UspNatV1Field.SALE_OPT_OUT_NOTICE), - SHARING_OPT_OUT_NOTICE(UspNatV1Field.SHARING_OPT_OUT_NOTICE), - TARGETED_ADVERTISING_OPT_OUT_NOTICE(UspNatV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE), - SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE(UspNatV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE), - SENSITIVE_DATA_LIMIT_USE_NOTICE(UspNatV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE), - SALE_OPT_OUT(UspNatV1Field.SALE_OPT_OUT), - SHARING_OPT_OUT(UspNatV1Field.SHARING_OPT_OUT), - TARGETED_ADVERTISING_OPT_OUT(UspNatV1Field.TARGETED_ADVERTISING_OPT_OUT), - SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 1), - SENSITIVE_DATA_RELIGIOUS_BELIEFS(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 2), - SENSITIVE_DATA_HEALTH_INFO(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 3), - SENSITIVE_DATA_ORIENTATION(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 4), - SENSITIVE_DATA_CITIZENSHIP_STATUS(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 5), - SENSITIVE_DATA_GENETIC_ID(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 6), - SENSITIVE_DATA_BIOMETRIC_ID(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 7), - SENSITIVE_DATA_GEOLOCATION(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 8), - SENSITIVE_DATA_ID_NUMBERS(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 9), - SENSITIVE_DATA_ACCOUNT_INFO(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 10), - SENSITIVE_DATA_UNION_MEMBERSHIP(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 11), - SENSITIVE_DATA_COMMUNICATION_CONTENTS(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 12), - SENSITIVE_DATA_PROCESSING_ALL(UspNatV1Field.SENSITIVE_DATA_PROCESSING + "*"), - CHILD_CONSENTS_FROM_13_TO_16(UspNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS + 1), - CHILD_CONSENTS_BELOW_13(UspNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS + 2), - PERSONAL_DATA_CONSENTS(UspNatV1Field.PERSONAL_DATA_CONSENTS), - MSPA_COVERED_TRANSACTION(UspNatV1Field.MSPA_COVERED_TRANSACTION), - MSPA_OPT_OUT_OPTION_MODE(UspNatV1Field.MSPA_OPT_OUT_OPTION_MODE), - MSPA_SERVICE_PROVIDER_MODE(UspNatV1Field.MSPA_SERVICE_PROVIDER_MODE), - GPC(UspNatV1Field.GPC); + SHARING_NOTICE(UsNatV1Field.SHARING_NOTICE), + SALE_OPT_OUT_NOTICE(UsNatV1Field.SALE_OPT_OUT_NOTICE), + SHARING_OPT_OUT_NOTICE(UsNatV1Field.SHARING_OPT_OUT_NOTICE), + TARGETED_ADVERTISING_OPT_OUT_NOTICE(UsNatV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE), + SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE(UsNatV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE), + SENSITIVE_DATA_LIMIT_USE_NOTICE(UsNatV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE), + SALE_OPT_OUT(UsNatV1Field.SALE_OPT_OUT), + SHARING_OPT_OUT(UsNatV1Field.SHARING_OPT_OUT), + TARGETED_ADVERTISING_OPT_OUT(UsNatV1Field.TARGETED_ADVERTISING_OPT_OUT), + SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 1), + SENSITIVE_DATA_RELIGIOUS_BELIEFS(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 2), + SENSITIVE_DATA_HEALTH_INFO(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 3), + SENSITIVE_DATA_ORIENTATION(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 4), + SENSITIVE_DATA_CITIZENSHIP_STATUS(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 5), + SENSITIVE_DATA_GENETIC_ID(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 6), + SENSITIVE_DATA_BIOMETRIC_ID(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 7), + SENSITIVE_DATA_GEOLOCATION(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 8), + SENSITIVE_DATA_ID_NUMBERS(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 9), + SENSITIVE_DATA_ACCOUNT_INFO(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 10), + SENSITIVE_DATA_UNION_MEMBERSHIP(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 11), + SENSITIVE_DATA_COMMUNICATION_CONTENTS(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 12), + SENSITIVE_DATA_PROCESSING_ALL(UsNatV1Field.SENSITIVE_DATA_PROCESSING + "*"), + CHILD_CONSENTS_FROM_13_TO_16(UsNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS + 1), + CHILD_CONSENTS_BELOW_13(UsNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS + 2), + PERSONAL_DATA_CONSENTS(UsNatV1Field.PERSONAL_DATA_CONSENTS), + MSPA_COVERED_TRANSACTION(UsNatV1Field.MSPA_COVERED_TRANSACTION), + MSPA_OPT_OUT_OPTION_MODE(UsNatV1Field.MSPA_OPT_OUT_OPTION_MODE), + MSPA_SERVICE_PROVIDER_MODE(UsNatV1Field.MSPA_SERVICE_PROVIDER_MODE), + GPC(UsNatV1Field.GPC); @JsonValue final String value diff --git a/src/test/groovy/org/prebid/server/functional/model/request/GppSectionId.groovy b/src/test/groovy/org/prebid/server/functional/model/request/GppSectionId.groovy index d71d60d8aa5..f3866eb24cd 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/GppSectionId.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/GppSectionId.groovy @@ -4,13 +4,13 @@ import com.fasterxml.jackson.annotation.JsonValue import com.iab.gpp.encoder.section.HeaderV1 import com.iab.gpp.encoder.section.TcfCaV1 import com.iab.gpp.encoder.section.TcfEuV2 -import com.iab.gpp.encoder.section.UspCaV1 -import com.iab.gpp.encoder.section.UspCoV1 -import com.iab.gpp.encoder.section.UspCtV1 -import com.iab.gpp.encoder.section.UspNatV1 -import com.iab.gpp.encoder.section.UspUtV1 +import com.iab.gpp.encoder.section.UsCaV1 +import com.iab.gpp.encoder.section.UsCoV1 +import com.iab.gpp.encoder.section.UsCtV1 +import com.iab.gpp.encoder.section.UsNatV1 +import com.iab.gpp.encoder.section.UsUtV1 +import com.iab.gpp.encoder.section.UsVaV1 import com.iab.gpp.encoder.section.UspV1 -import com.iab.gpp.encoder.section.UspVaV1 enum GppSectionId { @@ -18,12 +18,12 @@ enum GppSectionId { HEADER_V1(HeaderV1.ID), TCF_CA_V1(TcfCaV1.ID), USP_V1(UspV1.ID), - USP_NAT_V1(UspNatV1.ID), - USP_CA_V1(UspCaV1.ID), - USP_VA_V1(UspVaV1.ID), - USP_CO_V1(UspCoV1.ID), - USP_UT_V1(UspUtV1.ID), - USP_CT_V1(UspCtV1.ID) + US_NAT_V1(UsNatV1.ID), + US_CA_V1(UsCaV1.ID), + US_VA_V1(UsVaV1.ID), + US_CO_V1(UsCoV1.ID), + US_UT_V1(UsUtV1.ID), + US_CT_V1(UsCtV1.ID) @JsonValue final Integer value diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy index 041738cc5ab..87c7689b4ab 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy @@ -15,13 +15,13 @@ import org.prebid.server.functional.model.response.auction.And import org.prebid.server.functional.model.response.auction.GeoCode import org.prebid.server.functional.model.response.auction.RuleConfiguration import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 import static org.prebid.server.functional.model.request.auction.ActivityType.FETCH_BIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_TID @@ -193,14 +193,14 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec { ext.prebid.trace = VERBOSE device = new Device(geo: new Geo(country: USA, region: ALABAMA.abbreviation)) regs.ext.gpc = PBSUtils.randomString - regs.gppSid = [USP_CA_V1.intValue] + regs.gppSid = [US_CA_V1.intValue] setAccountId(accountId) } and: "Set up activities" def gpc = PBSUtils.randomString def condition = Condition.baseCondition.tap { - it.gppSid = [USP_CO_V1.intValue] + it.gppSid = [US_CO_V1.intValue] it.gpc = gpc it.geo = [CAN.withState(ARIZONA)] } @@ -299,8 +299,8 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec { ext.prebid.trace = VERBOSE device = new Device(geo: new Geo(country: USA, region: ALABAMA.abbreviation)) regs.ext.gpc = PBSUtils.randomString - regs.gppSid = [USP_CA_V1.intValue] - regs.gpp = new UspNatV1Consent.Builder().setGpc(true).build() + regs.gppSid = [US_CA_V1.intValue] + regs.gpp = new UsNatV1Consent.Builder().setGpc(true).build() setAccountId(accountId) } @@ -404,4 +404,3 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec { activityInfrastructures[new IntRange(true, firstIndex, lastIndex)] } } - diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAmpSpec.groovy index 9d7657f452c..3b69b139bc3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAmpSpec.groovy @@ -7,7 +7,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Regs import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent -import org.prebid.server.functional.util.privacy.gpp.UspV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsV1Consent import static org.prebid.server.functional.model.request.GppSectionId.TCF_EU_V2 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 @@ -125,7 +125,7 @@ class GppAmpSpec extends PrivacyBaseSpec { where: gppConsent << [new TcfEuV2Consent.Builder().build(), - new UspV1Consent.Builder().build()] + new UsV1Consent.Builder().build()] } def "PBS should copy consent_string to user.consent and set gdpr=1 when consent_string is valid and gppSid contains 2"() { @@ -157,7 +157,7 @@ class GppAmpSpec extends PrivacyBaseSpec { def "PBS should copy consent_string to user.us_privacy when consent_string contains us_privacy and gppSid contains 6"() { given: "Default amp request with valid consent_string and gpp consent_type" - def gppConsent = new UspV1Consent.Builder().build() + def gppConsent = new UsV1Consent.Builder().build() def gppSidIds = USP_V1.value def ampRequest = getGppAmpRequest(gppConsent.consentString, gppSidIds) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy index 0283bc1887f..cef812e4cf5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy @@ -8,7 +8,7 @@ import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.CcpaConsent import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent -import org.prebid.server.functional.util.privacy.gpp.UspV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsV1Consent import static org.prebid.server.functional.model.request.GppSectionId.TCF_EU_V2 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 @@ -173,7 +173,7 @@ class GppAuctionSpec extends PrivacyBaseSpec { def "PBS should copy regs.gpp to regs.usPrivacy when gppSid contains 6, gpp is USP_V1 and regs.us_privacy isn't specified"() { given: "Default bid request with gpp and gppSid, without us_privacy" - def gppConsent = new UspV1Consent.Builder().build() + def gppConsent = new UsV1Consent.Builder().build() def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gpp: gppConsent, gppSid: [USP_V1.intValue], usPrivacy: null) } @@ -190,7 +190,7 @@ class GppAuctionSpec extends PrivacyBaseSpec { def "PBS shouldn't copy regs.gpp to regs.usPrivacy when gppSid doesn't contain 6, gpp is USP_V1 and regs.us_privacy isn't specified"() { given: "Default bid request with gpp and gppSid, without us_privacy" def gppSidIds = [PBSUtils.getRandomNumberWithExclusion(USP_V1.intValue)] - def gpp = new UspV1Consent.Builder().build() + def gpp = new UsV1Consent.Builder().build() def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gppSid: gppSidIds, gpp: gpp, usPrivacy: null) } @@ -211,7 +211,7 @@ class GppAuctionSpec extends PrivacyBaseSpec { def "PBS should emit warning when gppSid contains 6, gpp is USP_V1 and regs.gpp and regs.usPrivacy are different"() { given: "Default bid request with gpp, gppSid and usPrivacy" def gppSidIds = [USP_V1.intValue] - def gpp = new UspV1Consent.Builder().build() + def gpp = new UsV1Consent.Builder().build() def ccpaConsent = new CcpaConsent(explicitNotice: ENFORCED, optOutSale: NOT_ENFORCED) def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gppSid: gppSidIds, gpp: gpp, usPrivacy: ccpaConsent) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy index 9f44c987360..c200c154bab 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy @@ -11,7 +11,7 @@ import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.CcpaConsent import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent -import org.prebid.server.functional.util.privacy.gpp.UspV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsV1Consent import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.request.GppSectionId.TCF_EU_V2 @@ -186,7 +186,7 @@ class GppCookieSyncSpec extends BaseSpec { given: "Cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { it.gppSid = USP_V1.value - it.gpp = new UspV1Consent.Builder().build() + it.gpp = new UsV1Consent.Builder().build() it.gdpr = null it.usPrivacy = new CcpaConsent(explicitNotice: ENFORCED, optOutSale: ENFORCED) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy index a2683a8b7ff..0d090758e08 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy @@ -3,27 +3,27 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.db.StoredRequest +import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity import org.prebid.server.functional.model.request.auction.ActivityRule import org.prebid.server.functional.model.request.auction.AllowActivities import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Condition -import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -31,6 +31,7 @@ import java.time.Instant import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.config.DataActivity.CONSENT import static org.prebid.server.functional.model.config.DataActivity.NOTICE_NOT_PROVIDED import static org.prebid.server.functional.model.config.DataActivity.NOTICE_PROVIDED @@ -41,6 +42,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -53,16 +55,15 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_RELIGIOUS_BELIEFS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.pricefloors.Country.USA import static org.prebid.server.functional.model.pricefloors.Country.CAN -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 +import static org.prebid.server.functional.model.pricefloors.Country.USA import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.auction.ActivityType.FETCH_BIDS import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL @@ -71,8 +72,8 @@ import static org.prebid.server.functional.model.request.auction.PrivacyModule.I import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_CUSTOM_LOGIC import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE -import static org.prebid.server.functional.util.privacy.model.State.ONTARIO import static org.prebid.server.functional.util.privacy.model.State.ALABAMA +import static org.prebid.server.functional.util.privacy.model.State.ONTARIO class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { @@ -584,8 +585,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = BidRequest.defaultBidRequest.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] - regs.gpp = new UspNatV1Consent.Builder().build() + regs.gppSid = [US_NAT_V1.intValue] + regs.gpp = new UsNatV1Consent.Builder().build() } and: "Activities set for fetchBid with rejecting privacy regulation" @@ -642,13 +643,13 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert bidder.getBidderRequest(bidRequest.id) where: - gppConsent | gppSid - new UspNatV1Consent.Builder().build() | USP_NAT_V1 - new UspCaV1Consent.Builder().build() | USP_CA_V1 - new UspVaV1Consent.Builder().build() | USP_VA_V1 - new UspCoV1Consent.Builder().build() | USP_CO_V1 - new UspUtV1Consent.Builder().build() | USP_UT_V1 - new UspCtV1Consent.Builder().build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().build() | US_NAT_V1 + new UsCaV1Consent.Builder().build() | US_CA_V1 + new UsVaV1Consent.Builder().build() | US_VA_V1 + new UsCoV1Consent.Builder().build() | US_CO_V1 + new UsUtV1Consent.Builder().build() | US_UT_V1 + new UsCtV1Consent.Builder().build() | US_CT_V1 } def "PBS auction call when privacy regulation have duplicate should process request and update alerts metrics"() { @@ -657,7 +658,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def genericBidRequest = BidRequest.defaultBidRequest.tap { it.setAccountId(accountId) ext.prebid.trace = VERBOSE - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] } and: "Activities set for fetchBid with privacy regulation" @@ -671,7 +672,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -692,8 +693,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = BidRequest.defaultBidRequest.tap { - regs.gppSid = [USP_NAT_V1.intValue] - regs.gpp = new UspNatV1Consent.Builder().build() + regs.gppSid = [US_NAT_V1.intValue] + regs.gpp = new UsNatV1Consent.Builder().build() it.setAccountId(accountId) } @@ -721,10 +722,10 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation don't match custom requirement should call to bidder"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def generalBidRequest = BidRequest.defaultBidRequest.tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -739,7 +740,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], accountLogic), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], accountLogic), [US_NAT_V1], false) } and: "Existed account with privacy regulation setup" @@ -764,7 +765,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def generalBidRequest = BidRequest.defaultBidRequest.tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -780,7 +781,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], accountLogic), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], accountLogic), [US_NAT_V1], false) } and: "Existed account with privacy regulation setup" @@ -794,23 +795,23 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert bidder.getBidderRequests(generalBidRequest.id).size() == 0 where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def generalBidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.trace = VERBOSE - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -826,7 +827,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -885,74 +886,74 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert !bidder.getBidderRequests(generalBidRequest.id) where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1281,8 +1282,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value - it.consentString = new UspNatV1Consent.Builder().build() + it.gppSid = US_NAT_V1.value + it.consentString = new UsNatV1Consent.Builder().build() it.consentType = GPP } @@ -1354,13 +1355,13 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert bidder.getBidderRequest(ampStoredRequest.id) where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS amp call when privacy regulation have duplicate should process request and update alerts metrics"() { @@ -1373,7 +1374,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value } and: "Activities set for fetchBid with privacy regulation" @@ -1387,7 +1388,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -1416,8 +1417,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value - it.consentString = new UspNatV1Consent.Builder().build() + it.gppSid = US_NAT_V1.value + it.consentString = new UsNatV1Consent.Builder().build() it.consentType = GPP } @@ -1455,10 +1456,10 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { } and: "amp request with link to account and gppSid" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -1508,7 +1509,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -1542,22 +1543,22 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert !bidder.getBidderRequests(ampStoredRequest.id).size() where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Store bid request with gpp string and link for account" def accountId = PBSUtils.randomNumber as String - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def ampStoredRequest = BidRequest.defaultBidRequest.tap { - regs.gppSid = [USP_CT_V1.intValue] + regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -1565,7 +1566,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue } and: "Activities set with privacy regulation" @@ -1579,7 +1580,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -1656,74 +1657,74 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert !bidder.getBidderRequests(ampStoredRequest.id) where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSetUidSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSetUidSpec.groovy index 877676332fa..47a04509805 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSetUidSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSetUidSpec.groovy @@ -6,10 +6,10 @@ import org.prebid.server.functional.model.request.setuid.SetuidRequest import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent -import org.prebid.server.functional.util.privacy.gpp.UspV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsV1Consent import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID class GppSetUidSpec extends PrivacyBaseSpec { @@ -18,7 +18,7 @@ class GppSetUidSpec extends PrivacyBaseSpec { given: "Set uid request with invalid GPP" def setUidRequest = SetuidRequest.defaultSetuidRequest.tap { it.gpp = "Invalid_GPP_Consent_String" - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.uid = UUID.randomUUID().toString() it.gdpr = null it.gdprConsent = null @@ -68,7 +68,7 @@ class GppSetUidSpec extends PrivacyBaseSpec { assert response.uidsCookie.tempUIDs[GENERIC] where: - gpp << [new UspV1Consent.Builder().build().encodeSection(), + gpp << [new UsV1Consent.Builder().build().encodeSection(), new TcfEuV2Consent.Builder().build().encodeSection()] } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy index 42a096d2c55..fefb27cfd1b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy @@ -8,9 +8,9 @@ import org.prebid.server.functional.model.config.AccountPrivacyConfig import org.prebid.server.functional.model.config.AccountSetting import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.Activity import org.prebid.server.functional.model.request.auction.ActivityRule @@ -20,12 +20,12 @@ import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest import org.prebid.server.functional.model.request.setuid.SetuidRequest import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -43,6 +43,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -57,23 +58,23 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.auction.ActivityType.SYNC_USER import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_ALL +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_TFC_EU import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_CUSTOM_LOGIC +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL import static org.prebid.server.functional.model.request.auction.PublicCountryIp.USA_IP -import static org.prebid.server.functional.util.privacy.model.State.MANITOBA import static org.prebid.server.functional.util.privacy.model.State.ALABAMA import static org.prebid.server.functional.util.privacy.model.State.ALASKA -import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_TFC_EU -import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL +import static org.prebid.server.functional.util.privacy.model.State.MANITOBA class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { @@ -340,7 +341,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -373,7 +374,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId it.gpp = disallowGppLogic } @@ -401,22 +402,81 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build() + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build(), + new UsNatV1Consent.Builder().setSaleOptOut(1).setSaleOptOutNotice(1).setMspaServiceProviderMode(2).setMspaOptOutOptionMode(1).build(), + new UsNatV1Consent.Builder().setSaleOptOutNotice(2).setSaleOptOut(1).setMspaServiceProviderMode(2).setMspaOptOutOptionMode(1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build() + ] + } + + def "PBS cookie sync call when privacy module contain some part of disallow logic which violates GPP validation should exclude bidders URLs"() { + given: "Cookie sync request with link to account" + def accountId = PBSUtils.randomString + def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { + it.gppSid = US_NAT_V1.value + it.account = accountId + it.gpp = disallowGppLogic + } + + and: "Activities set for cookie sync with allowing privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with cookie sync and privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + when: "PBS processes cookie sync request" + def response = activityPbsService.sendCookieSyncRequest(cookieSyncRequest) + + then: "Response should not contain any URLs for bidders" + assert !response.bidderStatus.userSync.url + + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAACAAAAAAA.QA' ] } @@ -450,20 +510,20 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert !response.bidderStatus.userSync.url where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS cookie sync call when privacy modules contain allowing settings should include proper responded with bidders URLs"() { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -489,7 +549,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -497,7 +557,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId it.gpp = regsGpp } @@ -524,14 +584,14 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert response.getBidderUserSync(GENERIC).userSync.url where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS cookie sync call when privacy regulation have duplicate should include proper responded with bidders URLs"() { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId } @@ -543,7 +603,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def activities = AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([ruleUsGeneric])) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) and: "Flush metrics" @@ -568,7 +628,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = SIMPLE_GPC_DISALLOW_LOGIC it.account = accountId } @@ -596,10 +656,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def "PBS cookie sync call when privacy regulation don't match custom requirement should include proper responded with bidders URLs"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.account = accountId it.gpp = gppConsent } @@ -639,7 +699,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.account = accountId it.gpp = gppConsent } @@ -669,22 +729,22 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert !response.bidderStatus.userSync.url where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS cookie sync call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.gpp = gppConsent setAccount(accountId) } @@ -700,7 +760,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([SYNC_USER], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([SYNC_USER], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -760,74 +820,74 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert !response.bidderStatus.userSync.url where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1112,7 +1172,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1150,7 +1210,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = disallowGppLogic } @@ -1182,22 +1242,86 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build() + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build(), + new UsNatV1Consent.Builder().setSaleOptOut(1).setSaleOptOutNotice(1).setMspaServiceProviderMode(2).setMspaOptOutOptionMode(1).build(), + new UsNatV1Consent.Builder().setSaleOptOutNotice(2).setSaleOptOut(1).setMspaServiceProviderMode(2).setMspaOptOutOptionMode(1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build() + ] + } + + def "PBS setuid request when privacy module contain some part of disallow logic which violates GPP validation should reject bidders with status code invalidStatusCode"() { + given: "Cookie sync SetuidRequest with accountId" + def accountId = PBSUtils.randomString + def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { + it.account = accountId + it.gppSid = US_NAT_V1.value + it.gpp = disallowGppLogic + } + + and: "UIDS Cookie" + def uidsCookie = UidsCookie.defaultUidsCookie + + and: "Activities set for cookie sync with allowing privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with cookie sync and allow activities setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + when: "PBS processes cookie sync request" + activityPbsService.sendSetUidRequest(setuidRequest, uidsCookie) + + then: "Request should fail with error" + def exception = thrown(PrebidServerException) + assert exception.statusCode == INVALID_STATUS_CODE + assert exception.responseBody == INVALID_STATUS_MESSAGE + + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAACAAAAAAA.QA' ] } @@ -1236,13 +1360,13 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert exception.responseBody == INVALID_STATUS_MESSAGE where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS setuid request when privacy modules contain allowing settings should respond with valid bidders UIDs cookies"() { @@ -1250,7 +1374,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1278,7 +1402,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true), + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true), ] } @@ -1288,7 +1412,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = regsGpp } @@ -1317,7 +1441,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert response.responseBody where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS setuid request when privacy regulation have duplicate should respond with valid bidders UIDs cookies"() { @@ -1325,7 +1449,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value } and: "UIDS Cookie" @@ -1339,7 +1463,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def activities = AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([ruleUsGeneric])) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) and: "Flush metrics" @@ -1365,7 +1489,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1396,10 +1520,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def "PBS setuid call when privacy regulation don't match custom requirement should respond with required UIDs cookies"() { given: "Cookie sync SetuidRequest with accountId" def accountId = PBSUtils.randomNumber as String - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.account = accountId it.gpp = gppConsent } @@ -1442,7 +1566,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync SetuidRequest with accountId" def accountId = PBSUtils.randomNumber as String def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.account = accountId it.gpp = gppConsent } @@ -1477,24 +1601,24 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert exception.responseBody == INVALID_STATUS_MESSAGE where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS setuid call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Cookie sync SetuidRequest with accountId" def accountId = PBSUtils.randomString - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId it.gpp = gppConsent - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value } and: "UIDS Cookie" @@ -1511,7 +1635,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([SYNC_USER], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([SYNC_USER], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -1576,74 +1700,74 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert exception.responseBody == INVALID_STATUS_MESSAGE where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy index a05f0e64b39..464197e7985 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy @@ -3,9 +3,9 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity @@ -20,12 +20,12 @@ import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsNationalSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -45,6 +45,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -59,13 +60,13 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL @@ -613,7 +614,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default Generic BidRequests with EIDS fields and account id" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -650,7 +651,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default Generic BidRequests with EIDS fields and account id" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -681,25 +682,73 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder() + .setMspaServiceProviderMode(1) + .setMspaOptOutOptionMode(2) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOutNotice(2) + .setSaleOptOut(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataProcessingOptOutNotice(2) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 2) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(1, 0) + .build(), + new UsNatV1Consent.Builder() + .setPersonalDataConsents(2) + .build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 1, religiousBeliefs: 1, healthInfo: 1, @@ -707,7 +756,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { citizenshipStatus: 1, unionMembership: 1, )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -722,7 +771,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -737,14 +786,14 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 1, biometricId: 1, idNumbers: 1, accountInfo: 1, communicationContents: 1 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 2, biometricId: 2, idNumbers: 2, @@ -754,6 +803,47 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { ] } + def "PBS auction call when privacy module contain some part of disallow logic which violates GPP validation should remove EIDS fields in request"() { + given: "Default Generic BidRequests with EIDS fields and account id" + def accountId = PBSUtils.randomNumber as String + def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { + regs.gppSid = [US_NAT_V1.intValue] + regs.gpp = disallowGppLogic + } + + and: "Activities set for transmitEIDS with rejecting privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_EIDS, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + when: "PBS processes auction requests" + activityPbsService.sendAuctionRequest(genericBidRequest) + + then: "Generic bidder request should have empty EIDS fields" + def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + verifyAll { + !genericBidderRequest.user.eids + !genericBidderRequest.user?.ext?.eids + } + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BCAAAAAAAAA.QA', + 'DBABLA~BAAEAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA' + ] + } + def "PBS auction call when request have different gpp consent but match and rejecting should remove EIDS fields in request"() { given: "Default Generic BidRequests with EIDS fields and account id" def accountId = PBSUtils.randomNumber as String @@ -787,20 +877,20 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS auction call when privacy modules contain allowing settings should leave EIDS fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -825,7 +915,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -833,7 +923,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = regsGpp } @@ -859,14 +949,14 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { assert genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS auction call when privacy regulation have duplicate should leave EIDS fields in request and update alerts metrics"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] } and: "Activities set for transmitEIDS with privacy regulation" @@ -880,7 +970,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -902,7 +992,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -930,10 +1020,10 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation don't match custom requirement should leave EIDS fields in request"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -973,7 +1063,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def generalBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1006,23 +1096,23 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { ext.prebid.trace = VERBOSE - regs.gppSid = [USP_CT_V1.intValue] + regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent } @@ -1037,7 +1127,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_EIDS], restrictedRule), [USP_CT_V1], false) + config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_EIDS], restrictedRule), [US_CT_V1], false) } and: "Flush metrics" @@ -1100,74 +1190,74 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1492,7 +1582,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1537,7 +1627,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = disallowGppLogic it.consentType = GPP } @@ -1573,25 +1663,73 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder() + .setMspaServiceProviderMode(1) + .setMspaOptOutOptionMode(2) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOutNotice(2) + .setSaleOptOut(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataProcessingOptOutNotice(2) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 2) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(1, 0) + .build(), + new UsNatV1Consent.Builder() + .setPersonalDataConsents(2) + .build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 1, religiousBeliefs: 1, healthInfo: 1, @@ -1599,7 +1737,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { citizenshipStatus: 1, unionMembership: 1, )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -1614,7 +1752,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -1629,14 +1767,14 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 1, biometricId: 1, idNumbers: 1, accountInfo: 1, communicationContents: 1 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 2, biometricId: 2, idNumbers: 2, @@ -1646,6 +1784,56 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { ] } + def "PBS amp call when privacy module contain some part of disallow logic which violates GPP validation should remove EIDS fields in request"() { + given: "Default Generic BidRequest with EIDS fields field and account id" + def accountId = PBSUtils.randomNumber as String + def ampStoredRequest = givenBidRequestWithAccountAndEidsData(accountId) + + and: "amp request with link to account" + def ampRequest = AmpRequest.defaultAmpRequest.tap { + it.account = accountId + it.gppSid = US_NAT_V1.value + it.consentString = disallowGppLogic + it.consentType = GPP + } + + and: "Activities set for transmitEIDS with allowing privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_EIDS, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + and: "Stored request in DB" + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes amp request" + activityPbsService.sendAmpRequest(ampRequest) + + then: "Generic bidder request should have empty EIDS fields" + def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + verifyAll { + !genericBidderRequest.user.eids + !genericBidderRequest.user?.ext?.eids + } + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BCAAAAAAAAA.QA', + 'DBABLA~BAAEAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA' + ] + } + def "PBS amp call when request have different gpp consent but match and rejecting should remove EIDS fields in request"() { given: "Default Generic BidRequest with EIDS fields field and account id" def accountId = PBSUtils.randomNumber as String @@ -1688,13 +1876,13 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS amp call when privacy modules contain allowing settings should leave EIDS fields in request"() { @@ -1705,7 +1893,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1735,7 +1923,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -1747,7 +1935,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = regsGpp it.consentType = GPP } @@ -1778,7 +1966,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { assert genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS amp call when privacy regulation have duplicate should leave EIDS fields in request and update alerts metrics"() { @@ -1789,7 +1977,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = "" it.consentType = GPP } @@ -1805,7 +1993,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -1835,7 +2023,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1872,10 +2060,10 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = givenBidRequestWithAccountAndEidsData(accountId) and: "amp request with link to account and gpp" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -1924,7 +2112,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -1962,14 +2150,14 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { @@ -1978,10 +2166,10 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = givenBidRequestWithAccountAndEidsData(accountId) and: "amp request with link to account and gpp string" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.consentString = gppConsent it.consentType = GPP } @@ -1997,7 +2185,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_EIDS], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_EIDS], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -2076,74 +2264,74 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy index 3372d8d0c15..7115f3fc561 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy @@ -3,9 +3,9 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity @@ -15,12 +15,12 @@ import org.prebid.server.functional.model.request.auction.Condition import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsNationalSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -40,6 +40,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -54,16 +55,20 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO -import static org.prebid.server.functional.model.request.auction.PrivacyModule.* +import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_ALL +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_TFC_EU +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_CUSTOM_LOGIC +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE import static org.prebid.server.functional.util.privacy.model.State.ALABAMA import static org.prebid.server.functional.util.privacy.model.State.ONTARIO @@ -767,7 +772,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -809,7 +814,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -845,24 +850,28 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 1 @@ -909,13 +918,13 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS auction call when privacy modules contain allowing settings should not round lat/lon data"() { @@ -923,7 +932,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -956,7 +965,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -965,7 +974,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = regsGpp } @@ -999,7 +1008,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS auction call when privacy regulation have duplicate should process request and update alerts metrics"() { @@ -1007,7 +1016,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] } and: "Activities set for transmitPreciseGeo with privacy regulation" @@ -1021,7 +1030,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -1052,7 +1061,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1080,10 +1089,10 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation don't match custom requirement should not round lat/lon data"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = bidRequestWithGeo.tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -1133,7 +1142,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def generalBidRequest = bidRequestWithGeo.tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -1173,23 +1182,23 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def generalBidRequest = bidRequestWithGeo.tap { ext.prebid.trace = VERBOSE - regs.gppSid = [USP_CT_V1.intValue] + regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -1207,7 +1216,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_PRECISE_GEO], restrictedRule), [USP_CT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_PRECISE_GEO], restrictedRule), [US_CT_V1], false) } and: "Flush metrics" @@ -1279,74 +1288,74 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1730,7 +1739,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1780,7 +1789,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = disallowGppLogic it.consentType = GPP } @@ -1821,24 +1830,28 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 1 @@ -1893,13 +1906,13 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS amp call when privacy modules contain allowing settings should not round lat/lon data"() { @@ -1910,7 +1923,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1948,7 +1961,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -1960,7 +1973,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = regsGpp it.consentType = GPP } @@ -1999,7 +2012,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS amp call when privacy regulation have duplicate should process request and update alerts metrics"() { @@ -2010,7 +2023,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value } and: "Activities set for transmitPreciseGeo with privacy regulation" @@ -2024,7 +2037,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -2062,7 +2075,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -2097,7 +2110,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def "PBS amp call when privacy regulation don't match custom requirement should not round lat/lon data in request"() { given: "Store bid request with gpp string and link for account" def accountId = PBSUtils.randomNumber as String - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def ampStoredRequest = bidRequestWithGeo.tap { setAccountId(accountId) } @@ -2105,7 +2118,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -2165,7 +2178,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -2209,20 +2222,20 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Store bid request with gpp string and link for account" def accountId = PBSUtils.randomNumber as String - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def ampStoredRequest = bidRequestWithGeo.tap { setAccountId(accountId) } @@ -2230,7 +2243,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.consentString = gppConsent it.consentType = GPP } @@ -2246,7 +2259,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_PRECISE_GEO], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_PRECISE_GEO], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -2332,74 +2345,74 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index d056412e225..a1d8a1d6104 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -4,13 +4,14 @@ import org.prebid.server.functional.model.config.AccountGdprConfig import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.Purpose import org.prebid.server.functional.model.config.PurposeConfig import org.prebid.server.functional.model.config.PurposeEid import org.prebid.server.functional.model.db.StoredRequest +import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity import org.prebid.server.functional.model.request.auction.ActivityRule import org.prebid.server.functional.model.request.auction.AllowActivities @@ -23,15 +24,14 @@ import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.model.request.auction.UserExtData -import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsNationalSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -40,6 +40,7 @@ import java.time.Instant import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.config.DataActivity.CONSENT import static org.prebid.server.functional.model.config.DataActivity.NOTICE_NOT_PROVIDED import static org.prebid.server.functional.model.config.DataActivity.NOTICE_PROVIDED @@ -50,6 +51,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -62,16 +64,15 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_RELIGIOUS_BELIEFS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_UFPD import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL @@ -793,7 +794,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -841,7 +842,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -884,25 +885,73 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder() + .setMspaServiceProviderMode(1) + .setMspaOptOutOptionMode(2) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOutNotice(2) + .setSaleOptOut(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataProcessingOptOutNotice(2) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 2) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(1, 0) + .build(), + new UsNatV1Consent.Builder() + .setPersonalDataConsents(2) + .build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 1, religiousBeliefs: 1, healthInfo: 1, @@ -910,7 +959,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { citizenshipStatus: 1, unionMembership: 1, )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -925,7 +974,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -940,14 +989,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 1, biometricId: 1, idNumbers: 1, accountInfo: 1, communicationContents: 1 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 2, biometricId: 2, idNumbers: 2, @@ -957,6 +1006,60 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { ] } + def "PBS auction call when privacy module contain some part of disallow logic which violates GPP validation should remove UFPD fields in request"() { + given: "Default Generic BidRequests with UFPD fields and account id" + def accountId = PBSUtils.randomNumber as String + def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + regs.gppSid = [US_NAT_V1.intValue] + regs.gpp = disallowGppLogic + } + + and: "Activities set for transmitUfpd with rejecting privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + when: "PBS processes auction requests" + activityPbsService.sendAuctionRequest(genericBidRequest) + + then: "Generic bidder request should have empty UFPD fields" + def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + verifyAll { + !genericBidderRequest.device.didsha1 + !genericBidderRequest.device.didmd5 + !genericBidderRequest.device.dpidsha1 + !genericBidderRequest.device.ifa + !genericBidderRequest.device.macsha1 + !genericBidderRequest.device.macmd5 + !genericBidderRequest.device.dpidmd5 + !genericBidderRequest.user.id + !genericBidderRequest.user.buyeruid + !genericBidderRequest.user.yob + !genericBidderRequest.user.gender + !genericBidderRequest.user.eids + !genericBidderRequest.user.data + !genericBidderRequest.user.ext + } + + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BCAAAAAAAAA.QA', + 'DBABLA~BAAEAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA' + ] + } + def "PBS auction call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String @@ -1002,20 +1105,20 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS auction call when privacy modules contain allowing settings should leave UFPD fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1057,7 +1160,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -1065,7 +1168,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = regsGpp } @@ -1108,14 +1211,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS auction call when privacy regulation have duplicate should leave UFPD fields in request and update alerts metrics"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] } and: "Activities set for transmitUfpd with privacy regulation" @@ -1129,7 +1232,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -1168,7 +1271,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1196,10 +1299,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation don't match custom requirement should leave UFPD fields in request"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1254,7 +1357,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def generalBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1299,23 +1402,23 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { ext.prebid.trace = VERBOSE - regs.gppSid = [USP_CT_V1.intValue] + regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent } @@ -1330,7 +1433,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_UFPD], restrictedRule), [USP_CT_V1], false) + config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_UFPD], restrictedRule), [US_CT_V1], false) } and: "Flush metrics" @@ -1405,74 +1508,74 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1893,7 +1996,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1950,7 +2053,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = disallowGppLogic it.consentType = GPP } @@ -1998,25 +2101,73 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder() + .setMspaServiceProviderMode(1) + .setMspaOptOutOptionMode(2) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOutNotice(2) + .setSaleOptOut(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataProcessingOptOutNotice(2) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 2) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(1, 0) + .build(), + new UsNatV1Consent.Builder() + .setPersonalDataConsents(2) + .build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 1, religiousBeliefs: 1, healthInfo: 1, @@ -2024,7 +2175,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { citizenshipStatus: 1, unionMembership: 1, )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -2039,7 +2190,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -2054,14 +2205,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 1, biometricId: 1, idNumbers: 1, accountInfo: 1, communicationContents: 1 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 2, biometricId: 2, idNumbers: 2, @@ -2071,6 +2222,69 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { ] } + def "PBS amp call when privacy module contain some part of disallow logic which violates GPP validation should remove UFPD fields in request"() { + given: "Default Generic BidRequest with UFPD fields field and account id" + def accountId = PBSUtils.randomNumber as String + def ampStoredRequest = givenBidRequestWithAccountAndUfpdData(accountId) + + and: "amp request with link to account" + def ampRequest = AmpRequest.defaultAmpRequest.tap { + it.account = accountId + it.gppSid = US_NAT_V1.value + it.consentString = disallowGppLogic + it.consentType = GPP + } + + and: "Activities set for transmitUfpd with allowing privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + and: "Stored request in DB" + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes amp request" + activityPbsService.sendAmpRequest(ampRequest) + + then: "Generic bidder request should have empty UFPD fields" + def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + verifyAll { + !genericBidderRequest.device.didsha1 + !genericBidderRequest.device.didmd5 + !genericBidderRequest.device.dpidsha1 + !genericBidderRequest.device.ifa + !genericBidderRequest.device.macsha1 + !genericBidderRequest.device.macmd5 + !genericBidderRequest.device.dpidmd5 + !genericBidderRequest.user.id + !genericBidderRequest.user.buyeruid + !genericBidderRequest.user.yob + !genericBidderRequest.user.gender + !genericBidderRequest.user.eids + !genericBidderRequest.user.data + !genericBidderRequest.user.ext + } + + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BCAAAAAAAAA.QA', + 'DBABLA~BAAEAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA' + ] + } + def "PBS amp call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { given: "Default Generic BidRequest with UFPD fields field and account id" def accountId = PBSUtils.randomNumber as String @@ -2125,13 +2339,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS amp call when privacy modules contain allowing settings should leave UFPD fields in request"() { @@ -2142,7 +2356,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -2188,7 +2402,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -2200,7 +2414,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = regsGpp it.consentType = GPP } @@ -2247,7 +2461,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS amp call when privacy regulation have duplicate should leave UFPD fields in request and update alerts metrics"() { @@ -2258,7 +2472,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = "" it.consentType = GPP } @@ -2274,7 +2488,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -2320,7 +2534,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -2357,10 +2571,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "amp request with link to account and gpp" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -2424,7 +2638,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -2474,14 +2688,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { @@ -2490,10 +2704,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "amp request with link to account and gpp string" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.consentString = gppConsent it.consentType = GPP } @@ -2509,7 +2723,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_UFPD], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_UFPD], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -2600,74 +2814,74 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy index 4a8a1d5e68e..c2115d06f4a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy @@ -29,7 +29,7 @@ import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.ConsentString import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.functional.util.privacy.gpp.GppConsent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent import spock.lang.Shared import static org.prebid.server.functional.model.bidder.BidderName.GENERIC @@ -89,7 +89,7 @@ abstract class PrivacyBaseSpec extends BaseSpec { protected static final String VENDOR_LIST_PATH = "/app/prebid-server/data/vendorlist-v{VendorVersion}/{VendorVersion}.json" protected static final String VALID_VALUE_FOR_GPC_HEADER = "1" - protected static final GppConsent SIMPLE_GPC_DISALLOW_LOGIC = new UspNatV1Consent.Builder().setGpc(true).build() + protected static final GppConsent SIMPLE_GPC_DISALLOW_LOGIC = new UsNatV1Consent.Builder().setGpc(true).build() protected static final VendorList vendorListResponse = new VendorList(networkServiceContainer) @Shared diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/GppConsent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/GppConsent.groovy index 09ce5fdb277..dd30e8c20ba 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/GppConsent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/GppConsent.groovy @@ -2,13 +2,13 @@ package org.prebid.server.functional.util.privacy.gpp import com.iab.gpp.encoder.GppModel import com.iab.gpp.encoder.section.TcfEuV2 -import com.iab.gpp.encoder.section.UspCaV1 -import com.iab.gpp.encoder.section.UspCoV1 -import com.iab.gpp.encoder.section.UspCtV1 -import com.iab.gpp.encoder.section.UspNatV1 -import com.iab.gpp.encoder.section.UspUtV1 +import com.iab.gpp.encoder.section.UsCaV1 +import com.iab.gpp.encoder.section.UsCoV1 +import com.iab.gpp.encoder.section.UsCtV1 +import com.iab.gpp.encoder.section.UsNatV1 +import com.iab.gpp.encoder.section.UsUtV1 +import com.iab.gpp.encoder.section.UsVaV1 import com.iab.gpp.encoder.section.UspV1 -import com.iab.gpp.encoder.section.UspVaV1 import org.prebid.server.functional.util.privacy.ConsentString abstract class GppConsent implements ConsentString { @@ -62,14 +62,14 @@ abstract class GppConsent implements ConsentString { enum Section { - TCF_EU_V2(TcfEuV2.NAME, TcfEuV2.VERSION), //2 - USP_V1(UspV1.NAME, UspV1.VERSION), //6 - USP_NAT_V1(UspNatV1.NAME, UspNatV1.VERSION), //7 - USP_CA_V1(UspCaV1.NAME, UspCaV1.VERSION), //8 - USP_VA_V1(UspVaV1.NAME, UspVaV1.VERSION), //9 - USP_CO_V1(UspCoV1.NAME, UspCoV1.VERSION), //10 - USP_UT_V1(UspUtV1.NAME, UspUtV1.VERSION), //11 - USP_CT_V1(UspCtV1.NAME, UspCtV1.VERSION), // 12 + TCF_EU_V2(TcfEuV2.NAME, TcfEuV2.VERSION), //2 + USP_V1(UspV1.NAME, UspV1.VERSION), //6 + US_NAT_V1(UsNatV1.NAME, UsNatV1.VERSION), //7 + US_CA_V1(UsCaV1.NAME, UsCaV1.VERSION), //8 + US_VA_V1(UsVaV1.NAME, UsVaV1.VERSION), //9 + US_CO_V1(UsCoV1.NAME, UsCoV1.VERSION), //10 + US_UT_V1(UsUtV1.NAME, UsUtV1.VERSION), //11 + US_CT_V1(UsCtV1.NAME, UsCtV1.VERSION), //12 final String name final int version diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCaV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCaV1Consent.groovy similarity index 56% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCaV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCaV1Consent.groovy index d5ab56be602..dec740c4395 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCaV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCaV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspCaV1Field +import com.iab.gpp.encoder.field.UsCaV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData -class UspCaV1Consent extends GppConsent { +class UsCaV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_CA_V1 + private static final Section SECTION = Section.US_CA_V1 - protected UspCaV1Consent(Section section, Map fieldValues) { + protected UsCaV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -23,83 +23,83 @@ class UspCaV1Consent extends GppConsent { } Builder setVersion(Integer version) { - fieldValue(UspCaV1Field.VERSION, version) + fieldValue(UsCaV1Field.VERSION, version) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspCaV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsCaV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setSharingOptOutNotice(Integer sharingOptOutNotice) { - fieldValue(UspCaV1Field.SHARING_OPT_OUT_NOTICE, sharingOptOutNotice) + fieldValue(UsCaV1Field.SHARING_OPT_OUT_NOTICE, sharingOptOutNotice) this } Builder setSensitiveDataLimitUseNotice(Integer sensitiveDataLimitUseNotice) { - fieldValue(UspCaV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE, sensitiveDataLimitUseNotice) + fieldValue(UsCaV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE, sensitiveDataLimitUseNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspCaV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsCaV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setSharingOptOut(Integer sharingOptOut) { - fieldValue(UspCaV1Field.SHARING_OPT_OUT, sharingOptOut) + fieldValue(UsCaV1Field.SHARING_OPT_OUT, sharingOptOut) this } Builder setSensitiveDataProcessing(UsCaliforniaSensitiveData sensitiveDataProcessing) { - fieldValue(UspCaV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsCaV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer childFrom13to16, Integer childBlow13) { - fieldValue(UspCaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13]) + fieldValue(UsCaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13]) this } Builder setPersonalDataConsents(Integer personalDataConsents) { - fieldValue(UspCaV1Field.PERSONAL_DATA_CONSENTS, personalDataConsents) + fieldValue(UsCaV1Field.PERSONAL_DATA_CONSENTS, personalDataConsents) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspCaV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsCaV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspCaV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsCaV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspCaV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsCaV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } Builder setGpcSegmentType(Integer gpcSegmentType) { - fieldValue(UspCaV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) + fieldValue(UsCaV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) this } Builder setGpcSegmentIncluded(Boolean gpcSegmentIncluded) { - fieldValue(UspCaV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) + fieldValue(UsCaV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) this } Builder setGpc(Boolean gpc) { - fieldValue(UspCaV1Field.GPC, gpc) + fieldValue(UsCaV1Field.GPC, gpc) this } @Override GppConsent build() { - return new UspCaV1Consent(section, fieldValues) + return new UsCaV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCoV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCoV1Consent.groovy similarity index 55% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCoV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCoV1Consent.groovy index 4469eac024c..25bbc9dfb81 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCoV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCoV1Consent.groovy @@ -1,19 +1,19 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspCoV1Field +import com.iab.gpp.encoder.field.UsCoV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsColoradoSensitiveData -class UspCoV1Consent extends GppConsent { +class UsCoV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_CO_V1 + private static final Section SECTION = Section.US_CO_V1 - protected UspCoV1Consent(Section section, Map fieldValues) { + protected UsCoV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @Override protected String encodeSection() { - gppModel.encodeSection(Section.USP_CO_V1.name) + gppModel.encodeSection(SECTION.name) } static class Builder extends GppConsent.Builder { @@ -23,78 +23,78 @@ class UspCoV1Consent extends GppConsent { } Builder setVersion(Integer version) { - fieldValue(UspCoV1Field.VERSION, version) + fieldValue(UsCoV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspCoV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsCoV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspCoV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsCoV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspCoV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsCoV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspCoV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsCoV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspCoV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsCoV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsColoradoSensitiveData sensitiveDataProcessing) { - fieldValue(UspCoV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsCoV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer knownChildSensitiveDataConsents) { - fieldValue(UspCoV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, knownChildSensitiveDataConsents) + fieldValue(UsCoV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, knownChildSensitiveDataConsents) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspCoV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsCoV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspCoV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsCoV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspCoV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsCoV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } Builder setGpcSegmentType(Integer gpcSegmentType) { - fieldValue(UspCoV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) + fieldValue(UsCoV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) this } Builder setGpcSegmentIncluded(Integer gpcSegmentIncluded) { - fieldValue(UspCoV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) + fieldValue(UsCoV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) this } Builder setGpc(Boolean gpc) { - fieldValue(UspCoV1Field.GPC, gpc) + fieldValue(UsCoV1Field.GPC, gpc) this } @Override GppConsent build() { - new UspCoV1Consent(section, fieldValues) + new UsCoV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCtV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCtV1Consent.groovy similarity index 56% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCtV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCtV1Consent.groovy index a7fe10c4443..9c95345939a 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCtV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCtV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspCtV1Field +import com.iab.gpp.encoder.field.UsCtV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsConnecticutSensitiveData -class UspCtV1Consent extends GppConsent { +class UsCtV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_CT_V1 + private static final Section SECTION = Section.US_CT_V1 - protected UspCtV1Consent(Section section, Map fieldValues) { + protected UsCtV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -23,78 +23,78 @@ class UspCtV1Consent extends GppConsent { } Builder setVersion(Integer version) { - fieldValue(UspCtV1Field.VERSION, version) + fieldValue(UsCtV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspCtV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsCtV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspCtV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsCtV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspCtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsCtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspCtV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsCtV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspCtV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsCtV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsConnecticutSensitiveData sensitiveDataProcessing) { - fieldValue(UspCtV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsCtV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer childFrom13to16, Integer childBlow13, Integer childFrom16to18) { - fieldValue(UspCtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13, childFrom16to18]) + fieldValue(UsCtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13, childFrom16to18]) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspCtV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsCtV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspCtV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsCtV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspCtV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsCtV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } Builder setGpcSegmentType(Integer gpcSegmentType) { - fieldValue(UspCtV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) + fieldValue(UsCtV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) this } Builder setGpcSegmentIncluded(Integer gpcSegmentIncluded) { - fieldValue(UspCtV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) + fieldValue(UsCtV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) this } Builder setGpc(Boolean gpc) { - fieldValue(UspCtV1Field.GPC, gpc) + fieldValue(UsCtV1Field.GPC, gpc) this } @Override GppConsent build() { - return new UspCtV1Consent(section, fieldValues) + return new UsCtV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspNatV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsNatV1Consent.groovy similarity index 54% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspNatV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsNatV1Consent.groovy index a5c38e9de72..1805cdcf9bd 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspNatV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsNatV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspNatV1Field +import com.iab.gpp.encoder.field.UsNatV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsNationalSensitiveData -class UspNatV1Consent extends GppConsent { +class UsNatV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_NAT_V1 + private static final Section SECTION = Section.US_NAT_V1 - protected UspNatV1Consent(Section section, Map fieldValues) { + protected UsNatV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -19,107 +19,107 @@ class UspNatV1Consent extends GppConsent { static class Builder extends GppConsent.Builder { Builder() { - super(GppConsent.Section.USP_NAT_V1) + super(SECTION) } Builder setVersion(Integer version) { - fieldValue(UspNatV1Field.VERSION, version) + fieldValue(UsNatV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspNatV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsNatV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspNatV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsNatV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setSharingOptOutNotice(Integer sharingOptOutNotice) { - fieldValue(UspNatV1Field.SHARING_OPT_OUT_NOTICE, sharingOptOutNotice) + fieldValue(UsNatV1Field.SHARING_OPT_OUT_NOTICE, sharingOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspNatV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsNatV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSensitiveDataProcessingOptOutNotice(Integer sensitiveDataProcessingOptOutNotice) { - fieldValue(UspNatV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE, sensitiveDataProcessingOptOutNotice) + fieldValue(UsNatV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE, sensitiveDataProcessingOptOutNotice) this } Builder setSensitiveDataLimitUseNotice(Integer sensitiveDataLimitUseNotice) { - fieldValue(UspNatV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE, sensitiveDataLimitUseNotice) + fieldValue(UsNatV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE, sensitiveDataLimitUseNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspNatV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsNatV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setSharingOptOut(Integer sharingOptOut) { - fieldValue(UspNatV1Field.SHARING_OPT_OUT, sharingOptOut) + fieldValue(UsNatV1Field.SHARING_OPT_OUT, sharingOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspNatV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsNatV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsNationalSensitiveData sensitiveDataProcessing) { - fieldValue(UspNatV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsNatV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setPersonalDataConsents(Integer personalDataConsents) { - fieldValue(UspNatV1Field.PERSONAL_DATA_CONSENTS, personalDataConsents) + fieldValue(UsNatV1Field.PERSONAL_DATA_CONSENTS, personalDataConsents) this } Builder setKnownChildSensitiveDataConsents(Integer childFrom13to16, Integer childBlow13) { - fieldValue(UspNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13]) + fieldValue(UsNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13]) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspNatV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsNatV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspNatV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsNatV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspNatV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsNatV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } Builder setGpcSegmentType(Integer gpcSegmentType) { - fieldValue(UspNatV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) + fieldValue(UsNatV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) this } Builder setGpcSegmentIncluded(Boolean gpcSegmentIncluded) { - fieldValue(UspNatV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) + fieldValue(UsNatV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) this } Builder setGpc(Boolean gpc) { - fieldValue(UspNatV1Field.GPC, gpc) + fieldValue(UsNatV1Field.GPC, gpc) this } @Override GppConsent build() { - new UspNatV1Consent(section, fieldValues) + new UsNatV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspUtV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsUtV1Consent.groovy similarity index 54% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspUtV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsUtV1Consent.groovy index cb9101db214..fd37a095026 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspUtV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsUtV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspUtV1Field +import com.iab.gpp.encoder.field.UsUtV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData -class UspUtV1Consent extends GppConsent { +class UsUtV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_UT_V1 + private static final Section SECTION = Section.US_UT_V1 - protected UspUtV1Consent(Section section, Map fieldValues) { + protected UsUtV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -19,72 +19,72 @@ class UspUtV1Consent extends GppConsent { static class Builder extends GppConsent.Builder { Builder() { - super(GppConsent.Section.USP_UT_V1) + super(SECTION) } Builder setVersion(Integer version) { - fieldValue(UspUtV1Field.VERSION, version) + fieldValue(UsUtV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspUtV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsUtV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspUtV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsUtV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspUtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsUtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSensitiveDataProcessingOptOutNotice(Integer sensitiveDataProcessingOptOutNotice) { - fieldValue(UspUtV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE, sensitiveDataProcessingOptOutNotice) + fieldValue(UsUtV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE, sensitiveDataProcessingOptOutNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspUtV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsUtV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspUtV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsUtV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsUtahSensitiveData sensitiveDataProcessing) { - fieldValue(UspUtV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsUtV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer knownChildSensitiveDataConsents) { - fieldValue(UspUtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, knownChildSensitiveDataConsents) + fieldValue(UsUtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, knownChildSensitiveDataConsents) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspUtV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsUtV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspUtV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsUtV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspUtV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsUtV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } @Override GppConsent build() { - return new UspUtV1Consent(section, fieldValues) + return new UsUtV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsV1Consent.groovy similarity index 80% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsV1Consent.groovy index 371611e0851..e3a0682ca73 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsV1Consent.groovy @@ -2,9 +2,9 @@ package org.prebid.server.functional.util.privacy.gpp import com.iab.gpp.encoder.field.UspV1Field -class UspV1Consent extends GppConsent { +class UsV1Consent extends GppConsent { - protected UspV1Consent(Section section, Map fieldValues) { + protected UsV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -35,8 +35,8 @@ class UspV1Consent extends GppConsent { } @Override - UspV1Consent build() { - new UspV1Consent(section, fieldValues) + UsV1Consent build() { + new UsV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspVaV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsVaV1Consent.groovy similarity index 56% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspVaV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsVaV1Consent.groovy index b33cf2d9603..97463c079fc 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspVaV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsVaV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspVaV1Field +import com.iab.gpp.encoder.field.UsVaV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsVirginiaSensitiveData -class UspVaV1Consent extends GppConsent { +class UsVaV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_VA_V1 + private static final Section SECTION = Section.US_VA_V1 - protected UspVaV1Consent(Section section, Map fieldValues) { + protected UsVaV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -23,63 +23,63 @@ class UspVaV1Consent extends GppConsent { } Builder setVersion(Integer version) { - fieldValue(UspVaV1Field.VERSION, version) + fieldValue(UsVaV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspVaV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsVaV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspVaV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsVaV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspVaV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsVaV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspVaV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsVaV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspVaV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsVaV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsVirginiaSensitiveData sensitiveDataProcessing) { - fieldValue(UspVaV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsVaV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer childSensitiveDataConsents) { - fieldValue(UspVaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, childSensitiveDataConsents) + fieldValue(UsVaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, childSensitiveDataConsents) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspVaV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsVaV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspVaV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsVaV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspVaV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsVaV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } @Override GppConsent build() { - return new UspVaV1Consent(section, fieldValues) + return new UsVaV1Consent(section, fieldValues) } } } diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReaderTest.java index 2a2bde3824d..1582b453ce9 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCaV1; +import com.iab.gpp.encoder.section.UsCaV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USCaliforniaGppReaderTest { private GppModel gppModel; @Mock - private UspCaV1 uspCaV1; + private UsCaV1 usCaV1; private USCaliforniaGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCaV1Section()).willReturn(uspCaV1); + given(gppModel.getUsCaV1Section()).willReturn(usCaV1); gppReader = new USCaliforniaGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCaV1.getVersion()).willReturn(1); + given(usCaV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCaV1.getGpc()).willReturn(true); + given(usCaV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCaV1.getGpcSegmentIncluded()).willReturn(true); + given(usCaV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCaV1.getSaleOptOut()).willReturn(1); + given(usCaV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSaleOptOutNotice()).willReturn(1); + given(usCaV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -92,13 +92,13 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { public void getSharingNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getSharingOptOutShouldReturnExpectedResult() { // given - given(uspCaV1.getSharingOptOut()).willReturn(1); + given(usCaV1.getSharingOptOut()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOut()).isEqualTo(1); @@ -107,7 +107,7 @@ public void getSharingOptOutShouldReturnExpectedResult() { @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSharingOptOutNotice()).willReturn(1); + given(usCaV1.getSharingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOutNotice()).isEqualTo(1); @@ -117,20 +117,20 @@ public void getSharingOptOutNoticeShouldReturnExpectedResult() { public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSensitiveDataLimitUseNotice()).willReturn(1); + given(usCaV1.getSensitiveDataLimitUseNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isEqualTo(1); @@ -140,7 +140,7 @@ public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCaV1.getSensitiveDataProcessing()).willReturn(data); + given(usCaV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -150,14 +150,14 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCaV1.getKnownChildSensitiveDataConsents()).willReturn(data); + given(usCaV1.getKnownChildSensitiveDataConsents()).willReturn(data); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isSameAs(data); @@ -166,7 +166,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { @Test public void getPersonalDataConsentsShouldReturnExpectedResult() { // given - given(uspCaV1.getPersonalDataConsents()).willReturn(1); + given(usCaV1.getPersonalDataConsents()).willReturn(1); // when and then assertThat(gppReader.getPersonalDataConsents()).isEqualTo(1); @@ -175,7 +175,7 @@ public void getPersonalDataConsentsShouldReturnExpectedResult() { @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaCoveredTransaction()).willReturn(1); + given(usCaV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -184,7 +184,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaServiceProviderMode()).willReturn(1); + given(usCaV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -193,7 +193,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCaV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReaderTest.java index bbe77552039..c0304049075 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCoV1; +import com.iab.gpp.encoder.section.UsCoV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USColoradoGppReaderTest { private GppModel gppModel; @Mock - private UspCoV1 uspCoV1; + private UsCoV1 usCoV1; private USColoradoGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCoV1Section()).willReturn(uspCoV1); + given(gppModel.getUsCoV1Section()).willReturn(usCoV1); gppReader = new USColoradoGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCoV1.getVersion()).willReturn(1); + given(usCoV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCoV1.getGpc()).willReturn(true); + given(usCoV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCoV1.getGpcSegmentIncluded()).willReturn(true); + given(usCoV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCoV1.getSaleOptOut()).willReturn(1); + given(usCoV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getSaleOptOutNotice()).willReturn(1); + given(usCoV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -91,7 +91,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getSharingNotice()).willReturn(1); + given(usCoV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -101,20 +101,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspCoV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usCoV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -123,7 +123,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usCoV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -133,14 +133,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCoV1.getSensitiveDataProcessing()).willReturn(data); + given(usCoV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -150,13 +150,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given - given(uspCoV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usCoV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isEqualTo(1); @@ -166,13 +166,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaCoveredTransaction()).willReturn(1); + given(usCoV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -181,7 +181,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaServiceProviderMode()).willReturn(1); + given(usCoV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -190,7 +190,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCoV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReaderTest.java index 0ee56cfcd1a..a3ffa92c763 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCtV1; +import com.iab.gpp.encoder.section.UsCtV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USConnecticutGppReaderTest { private GppModel gppModel; @Mock - private UspCtV1 uspCtV1; + private UsCtV1 usCtV1; private USConnecticutGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCtV1Section()).willReturn(uspCtV1); + given(gppModel.getUsCtV1Section()).willReturn(usCtV1); gppReader = new USConnecticutGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCtV1.getVersion()).willReturn(1); + given(usCtV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCtV1.getGpc()).willReturn(true); + given(usCtV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCtV1.getGpcSegmentIncluded()).willReturn(true); + given(usCtV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCtV1.getSaleOptOut()).willReturn(1); + given(usCtV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getSaleOptOutNotice()).willReturn(1); + given(usCtV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -91,7 +91,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getSharingNotice()).willReturn(1); + given(usCtV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -101,20 +101,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspCtV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usCtV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -123,7 +123,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usCtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -133,14 +133,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCtV1.getSensitiveDataProcessing()).willReturn(data); + given(usCtV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -150,14 +150,14 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCtV1.getKnownChildSensitiveDataConsents()).willReturn(data); + given(usCtV1.getKnownChildSensitiveDataConsents()).willReturn(data); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isSameAs(data); @@ -167,13 +167,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaCoveredTransaction()).willReturn(1); + given(usCtV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -182,7 +182,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaServiceProviderMode()).willReturn(1); + given(usCtV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -191,7 +191,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCtV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReaderTest.java index ace4324c7b3..70ba21416da 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspUtV1; +import com.iab.gpp.encoder.section.UsUtV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USUtahGppReaderTest { private GppModel gppModel; @Mock - private UspUtV1 uspUtV1; + private UsUtV1 usUtV1; private USUtahGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspUtV1Section()).willReturn(uspUtV1); + given(gppModel.getUsUtV1Section()).willReturn(usUtV1); gppReader = new USUtahGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspUtV1.getVersion()).willReturn(1); + given(usUtV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,27 +49,27 @@ public void getVersionShouldReturnExpectedResult() { public void getGpcShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpc()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentIncluded()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspUtV1.getSaleOptOut()).willReturn(1); + given(usUtV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -78,7 +78,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSaleOptOutNotice()).willReturn(1); + given(usUtV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -87,7 +87,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSharingNotice()).willReturn(1); + given(usUtV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -97,20 +97,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspUtV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usUtV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -119,7 +119,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usUtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -129,14 +129,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspUtV1.getSensitiveDataProcessing()).willReturn(data); + given(usUtV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -145,7 +145,7 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { @Test public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); + given(usUtV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isEqualTo(1); @@ -154,7 +154,7 @@ public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given - given(uspUtV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usUtV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isEqualTo(1); @@ -164,13 +164,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaCoveredTransaction()).willReturn(1); + given(usUtV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -179,7 +179,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaServiceProviderMode()).willReturn(1); + given(usUtV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -188,7 +188,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaOptOutOptionMode()).willReturn(1); + given(usUtV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReaderTest.java index 7d326e4b0ae..04a685037e2 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsVaV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USVirginiaGppReaderTest { private GppModel gppModel; @Mock - private UspVaV1 uspVaV1; + private UsVaV1 usVaV1; private USVirginiaGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspVaV1Section()).willReturn(uspVaV1); + given(gppModel.getUsVaV1Section()).willReturn(usVaV1); gppReader = new USVirginiaGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspVaV1.getVersion()).willReturn(1); + given(usVaV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,27 +49,27 @@ public void getVersionShouldReturnExpectedResult() { public void getGpcShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpc()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentIncluded()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspVaV1.getSaleOptOut()).willReturn(1); + given(usVaV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -78,7 +78,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getSaleOptOutNotice()).willReturn(1); + given(usVaV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -87,7 +87,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getSharingNotice()).willReturn(1); + given(usVaV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -97,20 +97,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspVaV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usVaV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -119,7 +119,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usVaV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -129,14 +129,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspVaV1.getSensitiveDataProcessing()).willReturn(data); + given(usVaV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -146,13 +146,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given - given(uspVaV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usVaV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isEqualTo(1); @@ -162,13 +162,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaCoveredTransaction()).willReturn(1); + given(usVaV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -177,7 +177,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaServiceProviderMode()).willReturn(1); + given(usVaV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -186,7 +186,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaOptOutOptionMode()).willReturn(1); + given(usVaV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReaderTest.java index 6b4133f2ba9..9e5ab6ba540 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCaV1; +import com.iab.gpp.encoder.section.UsCaV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USMappedCaliforniaGppReaderTest { private GppModel gppModel; @Mock - private UspCaV1 uspCaV1; + private UsCaV1 usCaV1; private USMappedCaliforniaGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCaV1Section()).willReturn(uspCaV1); + given(gppModel.getUsCaV1Section()).willReturn(usCaV1); gppReader = new USMappedCaliforniaGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCaV1.getVersion()).willReturn(1); + given(usCaV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCaV1.getGpc()).willReturn(true); + given(usCaV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCaV1.getGpcSegmentIncluded()).willReturn(true); + given(usCaV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCaV1.getSaleOptOut()).willReturn(1); + given(usCaV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSaleOptOutNotice()).willReturn(1); + given(usCaV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -92,13 +92,13 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { public void getSharingNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getSharingOptOutShouldReturnExpectedResult() { // given - given(uspCaV1.getSharingOptOut()).willReturn(1); + given(usCaV1.getSharingOptOut()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOut()).isEqualTo(1); @@ -107,7 +107,7 @@ public void getSharingOptOutShouldReturnExpectedResult() { @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSharingOptOutNotice()).willReturn(1); + given(usCaV1.getSharingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOutNotice()).isEqualTo(1); @@ -117,20 +117,20 @@ public void getSharingOptOutNoticeShouldReturnExpectedResult() { public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSensitiveDataLimitUseNotice()).willReturn(1); + given(usCaV1.getSensitiveDataLimitUseNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isEqualTo(1); @@ -139,7 +139,7 @@ public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given - given(uspCaV1.getSensitiveDataProcessing()).willReturn(asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); + given(usCaV1.getSensitiveDataProcessing()).willReturn(asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); // when and then assertThat(gppReader.getSensitiveDataProcessing()) @@ -150,13 +150,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResult() { // given - given(uspCaV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 0)); + given(usCaV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 0)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -165,7 +165,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResult() { // given - given(uspCaV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 2)); + given(usCaV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 2)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -174,7 +174,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResult() { @Test public void getPersonalDataConsentsShouldReturnExpectedResult() { // given - given(uspCaV1.getPersonalDataConsents()).willReturn(1); + given(usCaV1.getPersonalDataConsents()).willReturn(1); // when and then assertThat(gppReader.getPersonalDataConsents()).isEqualTo(1); @@ -183,7 +183,7 @@ public void getPersonalDataConsentsShouldReturnExpectedResult() { @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaCoveredTransaction()).willReturn(1); + given(usCaV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -192,7 +192,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaServiceProviderMode()).willReturn(1); + given(usCaV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -201,7 +201,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCaV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReaderTest.java index 4f7d83f0be8..0e45614e6da 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCoV1; +import com.iab.gpp.encoder.section.UsCoV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USMappedColoradoGppReaderTest { private GppModel gppModel; @Mock - private UspCoV1 uspCoV1; + private UsCoV1 usCoV1; private USMappedColoradoGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCoV1Section()).willReturn(uspCoV1); + given(gppModel.getUsCoV1Section()).willReturn(usCoV1); gppReader = new USMappedColoradoGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCoV1.getVersion()).willReturn(1); + given(usCoV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCoV1.getGpc()).willReturn(true); + given(usCoV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCoV1.getGpcSegmentIncluded()).willReturn(true); + given(usCoV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCoV1.getSaleOptOut()).willReturn(1); + given(usCoV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getSaleOptOutNotice()).willReturn(1); + given(usCoV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -91,7 +91,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getSharingNotice()).willReturn(1); + given(usCoV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -101,20 +101,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspCoV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usCoV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -123,7 +123,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usCoV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -133,14 +133,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCoV1.getSensitiveDataProcessing()).willReturn(data); + given(usCoV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -150,13 +150,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { // given - given(uspCoV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usCoV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -165,7 +165,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { // given - given(uspCoV1.getKnownChildSensitiveDataConsents()).willReturn(2); + given(usCoV1.getKnownChildSensitiveDataConsents()).willReturn(2); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -174,7 +174,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { // given - given(uspCoV1.getKnownChildSensitiveDataConsents()).willReturn(0); + given(usCoV1.getKnownChildSensitiveDataConsents()).willReturn(0); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -184,13 +184,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaCoveredTransaction()).willReturn(1); + given(usCoV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -199,7 +199,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaServiceProviderMode()).willReturn(1); + given(usCoV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -208,7 +208,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCoV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReaderTest.java index 75e4caf48e9..ed15d382944 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCtV1; +import com.iab.gpp.encoder.section.UsCtV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -26,13 +26,13 @@ public class USMappedConnecticutGppReaderTest { private GppModel gppModel; @Mock - private UspCtV1 uspCtV1; + private UsCtV1 usCtV1; private USMappedConnecticutGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCtV1Section()).willReturn(uspCtV1); + given(gppModel.getUsCtV1Section()).willReturn(usCtV1); gppReader = new USMappedConnecticutGppReader(gppModel); } @@ -40,7 +40,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCtV1.getVersion()).willReturn(1); + given(usCtV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,7 +49,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCtV1.getGpc()).willReturn(true); + given(usCtV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -59,13 +59,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCtV1.getGpcSegmentIncluded()).willReturn(true); + given(usCtV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -74,7 +74,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCtV1.getSaleOptOut()).willReturn(1); + given(usCtV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -83,7 +83,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getSaleOptOutNotice()).willReturn(1); + given(usCtV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -92,7 +92,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getSharingNotice()).willReturn(1); + given(usCtV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -102,20 +102,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspCtV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usCtV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -124,7 +124,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usCtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -134,14 +134,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCtV1.getSensitiveDataProcessing()).willReturn(data); + given(usCtV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -151,13 +151,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResult() { // given - given(uspCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 0, 0)); + given(usCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 0, 0)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -166,7 +166,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnMixedChildResult() { // given - given(uspCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(null, 2, 2)); + given(usCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(null, 2, 2)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(2, 1); @@ -175,7 +175,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnMixedChildResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResult() { // given - given(uspCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(null, null, null)); + given(usCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(null, null, null)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -185,13 +185,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaCoveredTransaction()).willReturn(1); + given(usCtV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -200,7 +200,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaServiceProviderMode()).willReturn(1); + given(usCtV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -209,7 +209,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCtV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReaderTest.java index 92b87cdd8e9..799a2cd914b 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspUtV1; +import com.iab.gpp.encoder.section.UsUtV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USMappedUtahGppReaderTest { private GppModel gppModel; @Mock - private UspUtV1 uspUtV1; + private UsUtV1 usUtV1; private USMappedUtahGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspUtV1Section()).willReturn(uspUtV1); + given(gppModel.getUsUtV1Section()).willReturn(usUtV1); gppReader = new USMappedUtahGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspUtV1.getVersion()).willReturn(1); + given(usUtV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,27 +49,27 @@ public void getVersionShouldReturnExpectedResult() { public void getGpcShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpc()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentIncluded()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspUtV1.getSaleOptOut()).willReturn(1); + given(usUtV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -78,7 +78,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSaleOptOutNotice()).willReturn(1); + given(usUtV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -87,7 +87,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSharingNotice()).willReturn(1); + given(usUtV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -97,20 +97,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspUtV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usUtV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -119,7 +119,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usUtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -129,13 +129,13 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given - given(uspUtV1.getSensitiveDataProcessing()).willReturn(asList(0, 1, 2, 3, 4, 5, 6, 7)); + given(usUtV1.getSensitiveDataProcessing()).willReturn(asList(0, 1, 2, 3, 4, 5, 6, 7)); // when and then assertThat(gppReader.getSensitiveDataProcessing()) @@ -145,7 +145,7 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { @Test public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); + given(usUtV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isEqualTo(1); @@ -154,7 +154,7 @@ public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { // given - given(uspUtV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usUtV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -163,7 +163,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { // given - given(uspUtV1.getKnownChildSensitiveDataConsents()).willReturn(2); + given(usUtV1.getKnownChildSensitiveDataConsents()).willReturn(2); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -172,7 +172,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { // given - given(uspUtV1.getKnownChildSensitiveDataConsents()).willReturn(0); + given(usUtV1.getKnownChildSensitiveDataConsents()).willReturn(0); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -182,13 +182,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaCoveredTransaction()).willReturn(1); + given(usUtV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -197,7 +197,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaServiceProviderMode()).willReturn(1); + given(usUtV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -206,7 +206,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaOptOutOptionMode()).willReturn(1); + given(usUtV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReaderTest.java index 0d420793460..1aaae9a9592 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsVaV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USMappedVirginiaGppReaderTest { private GppModel gppModel; @Mock - private UspVaV1 uspVaV1; + private UsVaV1 usVaV1; private USMappedVirginiaGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspVaV1Section()).willReturn(uspVaV1); + given(gppModel.getUsVaV1Section()).willReturn(usVaV1); gppReader = new USMappedVirginiaGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspVaV1.getVersion()).willReturn(1); + given(usVaV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,27 +49,27 @@ public void getVersionShouldReturnExpectedResult() { public void getGpcShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpc()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentIncluded()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspVaV1.getSaleOptOut()).willReturn(1); + given(usVaV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -78,7 +78,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getSaleOptOutNotice()).willReturn(1); + given(usVaV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -87,7 +87,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getSharingNotice()).willReturn(1); + given(usVaV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -97,20 +97,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspVaV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usVaV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -119,7 +119,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usVaV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -129,14 +129,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspVaV1.getSensitiveDataProcessing()).willReturn(data); + given(usVaV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -146,13 +146,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { // given - given(uspVaV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usVaV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -161,7 +161,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { // given - given(uspVaV1.getKnownChildSensitiveDataConsents()).willReturn(2); + given(usVaV1.getKnownChildSensitiveDataConsents()).willReturn(2); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -170,7 +170,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { // given - given(uspVaV1.getKnownChildSensitiveDataConsents()).willReturn(0); + given(usVaV1.getKnownChildSensitiveDataConsents()).willReturn(0); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -180,13 +180,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaCoveredTransaction()).willReturn(1); + given(usVaV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -195,7 +195,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaServiceProviderMode()).willReturn(1); + given(usVaV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -204,7 +204,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaOptOutOptionMode()).willReturn(1); + given(usVaV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReaderTest.java index 80beebf8770..79279c280bf 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspNatV1; +import com.iab.gpp.encoder.section.UsNatV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USNationalGppReaderTest { private GppModel gppModel; @Mock - private UspNatV1 uspNatV1; + private UsNatV1 usNatV1; private USNationalGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspNatV1Section()).willReturn(uspNatV1); + given(gppModel.getUsNatV1Section()).willReturn(usNatV1); gppReader = new USNationalGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspNatV1.getVersion()).willReturn(1); + given(usNatV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspNatV1.getGpc()).willReturn(true); + given(usNatV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspNatV1); + verifyNoInteractions(usNatV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspNatV1.getGpcSegmentIncluded()).willReturn(true); + given(usNatV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspNatV1.getSaleOptOut()).willReturn(1); + given(usNatV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSaleOptOutNotice()).willReturn(1); + given(usNatV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -91,7 +91,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSharingNotice()).willReturn(1); + given(usNatV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -100,7 +100,7 @@ public void getSharingNoticeShouldReturnExpectedResult() { @Test public void getSharingOptOutShouldReturnExpectedResult() { // given - given(uspNatV1.getSharingOptOut()).willReturn(1); + given(usNatV1.getSharingOptOut()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOut()).isEqualTo(1); @@ -109,7 +109,7 @@ public void getSharingOptOutShouldReturnExpectedResult() { @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSharingOptOutNotice()).willReturn(1); + given(usNatV1.getSharingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOutNotice()).isEqualTo(1); @@ -118,7 +118,7 @@ public void getSharingOptOutNoticeShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspNatV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usNatV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -127,7 +127,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usNatV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -136,7 +136,7 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { @Test public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSensitiveDataLimitUseNotice()).willReturn(1); + given(usNatV1.getSensitiveDataLimitUseNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isEqualTo(1); @@ -146,7 +146,7 @@ public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspNatV1.getSensitiveDataProcessing()).willReturn(data); + given(usNatV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -155,7 +155,7 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { @Test public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); + given(usNatV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isEqualTo(1); @@ -165,7 +165,7 @@ public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspNatV1.getKnownChildSensitiveDataConsents()).willReturn(data); + given(usNatV1.getKnownChildSensitiveDataConsents()).willReturn(data); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isSameAs(data); @@ -174,7 +174,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { @Test public void getPersonalDataConsentsShouldReturnExpectedResult() { // given - given(uspNatV1.getPersonalDataConsents()).willReturn(1); + given(usNatV1.getPersonalDataConsents()).willReturn(1); // when and then assertThat(gppReader.getPersonalDataConsents()).isEqualTo(1); @@ -183,7 +183,7 @@ public void getPersonalDataConsentsShouldReturnExpectedResult() { @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspNatV1.getMspaCoveredTransaction()).willReturn(1); + given(usNatV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -192,7 +192,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspNatV1.getMspaServiceProviderMode()).willReturn(1); + given(usNatV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -201,7 +201,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspNatV1.getMspaOptOutOptionMode()).willReturn(1); + given(usNatV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java b/src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java index 2a998ec0421..3ffd0b1a40a 100644 --- a/src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java @@ -37,7 +37,7 @@ public void fromShouldReturnGppContextWrapperWithErrorOnInvalidGpp() { assertThat(gppContext.regions()).isEqualTo(GppContext.Regions.builder().build()); }); assertThat(gppContextWrapper.getErrors()) - .containsExactly("GPP string invalid: Undecodable FibonacciIntegerRange '101111011'"); + .containsExactly("GPP string invalid: Unable to decode 'invalid'"); } @Test From 970f38426f0dd0599be3c01a19d61a367dd2d397 Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Wed, 8 May 2024 16:13:44 +0300 Subject: [PATCH 32/62] Core: Change default value for `p4.eid.activity_transition` (#3159) --- .../ActivityInfrastructureCreator.java | 2 +- .../GppTransmitUfpdActivitiesSpec.groovy | 131 +++++++++++------- .../ActivityInfrastructureCreatorTest.java | 10 +- 3 files changed, 84 insertions(+), 59 deletions(-) diff --git a/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java b/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java index f3a0b515a3c..49e24a06183 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java @@ -124,7 +124,7 @@ private Function fallbackActivity( .or(() -> Optional.ofNullable(defaultPurpose4)) .map(Purpose::getEid) .map(PurposeEid::getActivityTransition) - .orElse(true); + .orElse(false); return originalActivity -> originalActivity == Activity.TRANSMIT_EIDS && imitateTransmitEids ? activityControllerCreator.apply(Activity.TRANSMIT_UFPD) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index a1d8a1d6104..c6c68f81714 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -126,15 +126,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 } def "PBS auction call when transmit UFPD activities is rejecting requests should remove UFPD fields in request and update disallowed metrics"() { @@ -171,10 +170,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -213,10 +214,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids } def "PBS auction call when bidder allowed activities have empty condition type should skip this rule and emit an error"() { @@ -286,7 +289,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -326,10 +328,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids } def "PBS auction shouldn't allow rule when gppSid not intersect"() { @@ -375,15 +379,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 where: regsGppSid | conditionGppSid @@ -434,10 +437,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -490,15 +495,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.buyeruid == bidRequest.user.buyeruid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender - bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source bidderRequest.user.data == bidRequest.user.data bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 where: deviceGeo | conditionGeo @@ -553,10 +557,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -613,15 +619,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.buyeruid == bidRequest.user.buyeruid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender - bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source bidderRequest.user.data == bidRequest.user.data bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 } def "PBS auction should disallowed rule when regs.ext.gpc intersection with condition.gpc"() { @@ -669,10 +674,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -724,15 +731,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.buyeruid == bidRequest.user.buyeruid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender - bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source bidderRequest.user.data == bidRequest.user.data bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 } def "PBS auction should disallowed rule when header gpc intersection with condition.gpc"() { @@ -779,10 +785,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -829,11 +837,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + where: privacyAllowRegulations << [IAB_US_GENERAL, IAB_ALL, ALL] } @@ -877,11 +887,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, @@ -1099,11 +1111,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + where: gppConsent | gppSid new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 @@ -1152,7 +1166,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1205,7 +1218,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1257,7 +1269,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1340,7 +1351,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1396,11 +1406,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == generalBidRequest.user.eids + where: gppConsent | valueRules new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] @@ -1459,7 +1471,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when custom privacy regulation with normalizing that match custom config should have empty UFPD fields"() { given: "Generic BidRequest with gpp and account setup" def accountId = PBSUtils.randomNumber as String - def generalBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { ext.prebid.trace = VERBOSE regs.gppSid = [gppSid.intValue] regs.gpp = gppStateConsent.build() @@ -1486,10 +1498,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(generalBidRequest) + activityPbsService.sendAuctionRequest(genericBidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(generalBidRequest.id) + def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) verifyAll { !genericBidderRequest.device.didsha1 !genericBidderRequest.device.didmd5 @@ -1502,11 +1514,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + where: gppSid | equalityValueRules | gppStateConsent US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() @@ -1621,14 +1635,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 } def "PBS amp call when transmit UFPD activities is rejecting request should remove UFPD fields field in active request and update disallowed metrics"() { @@ -1673,11 +1686,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -1724,10 +1739,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp call when bidder allowed activities have empty condition type should skip this rule and emit an error"() { @@ -1815,7 +1832,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -1864,10 +1880,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp should disallowed rule when header.gpc intersection with condition.gpc"() { @@ -1919,11 +1937,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -1978,14 +1998,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 } def "PBS amp call when privacy regulation match and rejecting should remove UFPD fields in request"() { @@ -2036,11 +2055,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: privacyAllowRegulations << [IAB_US_GENERAL, IAB_ALL, ALL] } @@ -2093,11 +2114,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, @@ -2333,11 +2356,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: gppConsent | gppSid new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 @@ -2394,7 +2419,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2455,7 +2479,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2516,7 +2539,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2617,7 +2639,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2682,11 +2703,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: gppConsent | valueRules new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] @@ -2808,11 +2831,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: gppSid | equalityValueRules | gppStateConsent US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() diff --git a/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java b/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java index 0927f596a41..d938ec69aa0 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java @@ -141,7 +141,7 @@ public void parseShouldReturnExpectedResult() { } @Test - public void parseShouldReturnImitatedTransmitEidsActivity() { + public void parseShouldReturnOriginalTransmitEidsActivity() { // given final Account account = Account.builder() .privacy(AccountPrivacyConfig.builder() @@ -158,17 +158,17 @@ public void parseShouldReturnImitatedTransmitEidsActivity() { assertThat(controllers.get(Activity.CALL_BIDDER).isAllowed(null)).isEqualTo(true); assertThat(controllers.get(Activity.TRANSMIT_UFPD).isAllowed(null)).isEqualTo(false); - assertThat(controllers.get(Activity.TRANSMIT_EIDS).isAllowed(null)).isEqualTo(false); + assertThat(controllers.get(Activity.TRANSMIT_EIDS).isAllowed(null)).isEqualTo(true); } @Test - public void parseShouldReturnOriginalTransmitEidsActivity() { + public void parseShouldReturnImitatedTransmitEidsActivity() { // given final Account account = Account.builder() .privacy(AccountPrivacyConfig.builder() .gdpr(AccountGdprConfig.builder() .purposes(Purposes.builder() - .p4(Purpose.of(null, null, null, PurposeEid.of(false, false, null))) + .p4(Purpose.of(null, null, null, PurposeEid.of(true, false, null))) .build()) .build()) .activities(Map.of(Activity.TRANSMIT_UFPD, AccountActivityConfiguration.of(false, null))) @@ -184,6 +184,6 @@ public void parseShouldReturnOriginalTransmitEidsActivity() { assertThat(controllers.get(Activity.CALL_BIDDER).isAllowed(null)).isEqualTo(true); assertThat(controllers.get(Activity.TRANSMIT_UFPD).isAllowed(null)).isEqualTo(false); - assertThat(controllers.get(Activity.TRANSMIT_EIDS).isAllowed(null)).isEqualTo(true); + assertThat(controllers.get(Activity.TRANSMIT_EIDS).isAllowed(null)).isEqualTo(false); } } From 8652ffffb533dd956d3b69d92dd1805821b8566a Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Thu, 9 May 2024 13:22:13 +0300 Subject: [PATCH 33/62] Core: Update transmitPreciseGeo and transmitUfpd activities (#3128) --- ...ConfiantAdQualityBidResponsesScanHook.java | 2 +- ...iantAdQualityBidResponsesScanHookTest.java | 6 +- .../reporter/AnalyticsReporterDelegator.java | 2 +- .../enforcement/ActivityEnforcement.java | 11 +- .../privacy/enforcement/TcfEnforcement.java | 2 +- .../enforcement/mask/UserFpdActivityMask.java | 7 +- .../enforcement/mask/UserFpdCcpaMask.java | 35 +- .../enforcement/mask/UserFpdCoppaMask.java | 27 +- .../enforcement/mask/UserFpdPrivacyMask.java | 39 +- .../enforcement/mask/UserFpdTcfMask.java | 23 +- .../config/PrivacyServiceConfiguration.java | 8 +- .../request/auction/GeoExtGeoProvider.groovy | 5 + .../functional/tests/privacy/CoppaSpec.groovy | 242 ++++ ...GppTransmitPreciseGeoActivitiesSpec.groovy | 1022 +++++++++++++---- .../GppTransmitUfpdActivitiesSpec.groovy | 50 + .../tests/privacy/PrivacyBaseSpec.groovy | 32 +- .../AnalyticsReporterDelegatorTest.java | 2 +- .../enforcement/ActivityEnforcementTest.java | 2 +- .../enforcement/TcfEnforcementTest.java | 6 +- .../mask/UserFpdActivityMaskTest.java | 20 +- .../enforcement/mask/UserFpdCcpaMaskTest.java | 75 +- .../mask/UserFpdCoppaMaskTest.java | 71 +- .../enforcement/mask/UserFpdTcfMaskTest.java | 76 +- 23 files changed, 1261 insertions(+), 504 deletions(-) diff --git a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHook.java b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHook.java index 4cf66880bef..7db1446bcce 100644 --- a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHook.java +++ b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHook.java @@ -81,7 +81,7 @@ private BidRequest getBidRequest(AuctionInvocationContext auctionInvocationConte final boolean disallowTransmitGeo = !auctionContext.getActivityInfrastructure() .isAllowed(Activity.TRANSMIT_GEO, activityInvocationPayload); - final User maskedUser = userFpdActivityMask.maskUser(bidRequest.getUser(), true, true, disallowTransmitGeo); + final User maskedUser = userFpdActivityMask.maskUser(bidRequest.getUser(), true, true); final Device maskedDevice = userFpdActivityMask.maskDevice(bidRequest.getDevice(), true, disallowTransmitGeo); return bidRequest.toBuilder() diff --git a/extra/modules/confiant-ad-quality/src/test/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHookTest.java b/extra/modules/confiant-ad-quality/src/test/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHookTest.java index 8746a3e10b2..4d2e61ee1cb 100644 --- a/extra/modules/confiant-ad-quality/src/test/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHookTest.java +++ b/extra/modules/confiant-ad-quality/src/test/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHookTest.java @@ -277,8 +277,7 @@ public void callShouldSubmitBidsWithoutMaskedGeoInfoWhenTransmitGeoIsAllowed() { final Boolean transmitGeoIsAllowed = true; final BidsScanResult bidsScanResult = redisParser.parseBidsScanResult( "[[[{\"tag_key\": \"tag\", \"issues\":[{\"spec_name\":\"malicious_domain\",\"value\":\"ads.deceivenetworks.net\",\"first_adinstance\":\"e91e8da982bb8b7f80100426\"}]}]]]"); - final User user = userFpdActivityMask.maskUser( - getUser(), true, true, !transmitGeoIsAllowed); + final User user = userFpdActivityMask.maskUser(getUser(), true, true); final Device device = userFpdActivityMask.maskDevice( getDevice(), true, !transmitGeoIsAllowed); @@ -306,8 +305,7 @@ public void callShouldSubmitBidsWithMaskedGeoInfoWhenTransmitGeoIsNotAllowed() { final Boolean transmitGeoIsAllowed = false; final BidsScanResult bidsScanResult = redisParser.parseBidsScanResult( "[[[{\"tag_key\": \"tag\", \"issues\":[{\"spec_name\":\"malicious_domain\",\"value\":\"ads.deceivenetworks.net\",\"first_adinstance\":\"e91e8da982bb8b7f80100426\"}]}]]]"); - final User user = userFpdActivityMask.maskUser( - getUser(), true, true, !transmitGeoIsAllowed); + final User user = userFpdActivityMask.maskUser(getUser(), true, true); final Device device = userFpdActivityMask.maskDevice( getDevice(), true, !transmitGeoIsAllowed); diff --git a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java index a65b2293a8d..adaf4aaf888 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java +++ b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java @@ -238,7 +238,7 @@ private BidRequest updateBidRequest(BidRequest bidRequest, final boolean disallowTransmitGeo = !isAllowedActivity(infrastructure, Activity.TRANSMIT_GEO, payload); final User user = bidRequest != null ? bidRequest.getUser() : null; - final User resolvedUser = mask.maskUser(user, disallowTransmitUfpd, disallowTransmitEids, disallowTransmitGeo); + final User resolvedUser = mask.maskUser(user, disallowTransmitUfpd, disallowTransmitEids); final Device device = bidRequest != null ? bidRequest.getDevice() : null; final Device resolvedDevice = mask.maskDevice(device, disallowTransmitUfpd, disallowTransmitGeo); diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcement.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcement.java index 29e07658eb6..df7603048ee 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcement.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcement.java @@ -57,15 +57,8 @@ private BidderPrivacyResult applyActivityRestrictions(BidderPrivacyResult bidder final boolean disallowTransmitEids = !infrastructure.isAllowed(Activity.TRANSMIT_EIDS, payload); final boolean disallowTransmitGeo = !infrastructure.isAllowed(Activity.TRANSMIT_GEO, payload); - final User resolvedUser = userFpdActivityMask.maskUser( - user, - disallowTransmitUfpd, - disallowTransmitEids, - disallowTransmitGeo); - final Device resolvedDevice = userFpdActivityMask.maskDevice( - device, - disallowTransmitUfpd, - disallowTransmitGeo); + final User resolvedUser = userFpdActivityMask.maskUser(user, disallowTransmitUfpd, disallowTransmitEids); + final Device resolvedDevice = userFpdActivityMask.maskDevice(device, disallowTransmitUfpd, disallowTransmitGeo); return bidderPrivacyResult.toBuilder() .user(resolvedUser) diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java index 042e130132b..fc5e2dab1fb 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java @@ -194,7 +194,7 @@ private BidderPrivacyResult createBidderPrivacyResult(String bidder, final boolean maskUserIds = privacyEnforcementAction.isRemoveUserIds() || isLmtEnabled; final boolean maskGeo = privacyEnforcementAction.isMaskGeo() || isLmtEnabled; final Set eidExceptions = privacyEnforcementAction.getEidExceptions(); - final User maskedUser = userFpdTcfMask.maskUser(user, maskUserFpd, maskUserIds, maskGeo, eidExceptions); + final User maskedUser = userFpdTcfMask.maskUser(user, maskUserFpd, maskUserIds, eidExceptions); final boolean maskIp = privacyEnforcementAction.isMaskDeviceIp() || isLmtEnabled; final boolean maskDeviceInfo = privacyEnforcementAction.isMaskDeviceInfo() || isLmtEnabled; diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMask.java index 559d35b02fc..6e8a5558ba2 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMask.java @@ -14,16 +14,11 @@ public UserFpdActivityMask(UserFpdTcfMask userFpdTcfMask) { this.userFpdTcfMask = Objects.requireNonNull(userFpdTcfMask); } - public User maskUser(User user, - boolean disallowTransmitUfpd, - boolean disallowTransmitEids, - boolean disallowTransmitGeo) { - + public User maskUser(User user, boolean disallowTransmitUfpd, boolean disallowTransmitEids) { return userFpdTcfMask.maskUser( user, disallowTransmitUfpd, disallowTransmitEids, - disallowTransmitGeo, Collections.emptySet()); } diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMask.java index 4ed50a5cb58..fbb20d55a9b 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMask.java @@ -1,42 +1,23 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; -import org.prebid.server.auction.IpAddressHelper; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Collections; +import java.util.Objects; -public class UserFpdCcpaMask extends UserFpdPrivacyMask { +public class UserFpdCcpaMask { - public UserFpdCcpaMask(IpAddressHelper ipAddressHelper) { - super(ipAddressHelper); + private final UserFpdActivityMask userFpdActivityMask; + + public UserFpdCcpaMask(UserFpdActivityMask userFpdActivityMask) { + this.userFpdActivityMask = Objects.requireNonNull(userFpdActivityMask); } public User maskUser(User user) { - return maskUser(user, true, true, true, Collections.emptySet()); + return userFpdActivityMask.maskUser(user, true, true); } public Device maskDevice(Device device) { - return maskDevice(device, true, true, true); - } - - @Override - protected Geo maskGeo(Geo geo) { - return geo.toBuilder() - .lat(maskGeoCoordinate(geo.getLat())) - .lon(maskGeoCoordinate(geo.getLon())) - .metro(null) - .city(null) - .zip(null) - .build(); - } - - private static Float maskGeoCoordinate(Float coordinate) { - return coordinate != null - ? BigDecimal.valueOf(coordinate).setScale(2, RoundingMode.HALF_UP).floatValue() - : null; + return userFpdActivityMask.maskDevice(device, true, true); } } diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMask.java index 0fc8a6ad6fc..ded930bff83 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMask.java @@ -1,34 +1,23 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; -import org.prebid.server.auction.IpAddressHelper; -import java.util.Collections; +import java.util.Objects; -public class UserFpdCoppaMask extends UserFpdPrivacyMask { +public class UserFpdCoppaMask { - public UserFpdCoppaMask(IpAddressHelper ipAddressHelper) { - super(ipAddressHelper); + private final UserFpdActivityMask userFpdActivityMask; + + public UserFpdCoppaMask(UserFpdActivityMask userFpdActivityMask) { + this.userFpdActivityMask = Objects.requireNonNull(userFpdActivityMask); } public User maskUser(User user) { - return maskUser(user, true, true, true, Collections.emptySet()); + return userFpdActivityMask.maskUser(user, true, true); } public Device maskDevice(Device device) { - return maskDevice(device, true, true, true); - } - - @Override - protected Geo maskGeo(Geo geo) { - return geo.toBuilder() - .lat(null) - .lon(null) - .metro(null) - .city(null) - .zip(null) - .build(); + return userFpdActivityMask.maskDevice(device, true, true); } } diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdPrivacyMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdPrivacyMask.java index 4d2a04ee203..6ce4e99c44f 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdPrivacyMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdPrivacyMask.java @@ -8,6 +8,8 @@ import org.prebid.server.auction.IpAddressHelper; import org.prebid.server.proto.openrtb.ext.request.ExtUser; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.List; import java.util.Objects; import java.util.Set; @@ -23,10 +25,9 @@ protected UserFpdPrivacyMask(IpAddressHelper ipAddressHelper) { protected User maskUser(User user, boolean maskUserFpd, boolean maskEids, - boolean maskGeo, Set eidExceptions) { - if (user == null || !(maskUserFpd || maskEids || maskGeo)) { + if (user == null || !(maskUserFpd || maskEids)) { return user; } @@ -40,6 +41,7 @@ protected User maskUser(User user, .keywords(null) .kwarray(null) .data(null) + .geo(null) .ext(maskExtUser(user.getExt())); } @@ -47,10 +49,6 @@ protected User maskUser(User user, userBuilder.eids(removeEids(user.getEids(), eidExceptions)); } - if (maskGeo) { - userBuilder.geo(maskNullableGeo(user.getGeo())); - } - return nullIfEmpty(userBuilder.build()); } @@ -73,12 +71,6 @@ private static List removeEids(List eids, Set exceptions) { return clearedEids.isEmpty() ? null : clearedEids; } - private Geo maskNullableGeo(Geo geo) { - return geo != null ? nullIfEmpty(maskGeo(geo)) : null; - } - - protected abstract Geo maskGeo(Geo geo); - protected Device maskDevice(Device device, boolean maskIp, boolean maskGeo, boolean maskDeviceInfo) { if (device == null || !(maskIp || maskGeo || maskDeviceInfo)) { return device; @@ -105,6 +97,29 @@ protected Device maskDevice(Device device, boolean maskIp, boolean maskGeo, bool return deviceBuilder.build(); } + private static Geo maskNullableGeo(Geo geo) { + return geo != null ? nullIfEmpty(maskGeo(geo)) : null; + } + + private static Geo maskGeo(Geo geo) { + return geo.toBuilder() + .lat(maskGeoCoordinate(geo.getLat())) + .lon(maskGeoCoordinate(geo.getLon())) + .metro(null) + .city(null) + .zip(null) + .accuracy(null) + .ipservice(null) + .ext(null) + .build(); + } + + private static Float maskGeoCoordinate(Float coordinate) { + return coordinate != null + ? BigDecimal.valueOf(coordinate).setScale(2, RoundingMode.HALF_UP).floatValue() + : null; + } + private static User nullIfEmpty(User user) { return user.equals(User.EMPTY) ? null : user; } diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMask.java index 744b492807d..c0dfed0c175 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMask.java @@ -1,12 +1,9 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; import org.prebid.server.auction.IpAddressHelper; -import java.math.BigDecimal; -import java.math.RoundingMode; import java.util.Set; public class UserFpdTcfMask extends UserFpdPrivacyMask { @@ -15,27 +12,11 @@ public UserFpdTcfMask(IpAddressHelper ipAddressHelper) { super(ipAddressHelper); } - public User maskUser(User user, boolean maskUserFpd, boolean maskEids, boolean maskGeo, Set eidExceptions) { - return super.maskUser(user, maskUserFpd, maskEids, maskGeo, eidExceptions); + public User maskUser(User user, boolean maskUserFpd, boolean maskEids, Set eidExceptions) { + return super.maskUser(user, maskUserFpd, maskEids, eidExceptions); } public Device maskDevice(Device device, boolean maskIp, boolean maskGeo, boolean maskDeviceInfo) { return super.maskDevice(device, maskIp, maskGeo, maskDeviceInfo); } - - @Override - protected Geo maskGeo(Geo geo) { - return geo != null - ? geo.toBuilder() - .lat(maskGeoCoordinate(geo.getLat())) - .lon(maskGeoCoordinate(geo.getLon())) - .build() - : null; - } - - private static Float maskGeoCoordinate(Float coordinate) { - return coordinate != null - ? BigDecimal.valueOf(coordinate).setScale(2, RoundingMode.HALF_UP).floatValue() - : null; - } } diff --git a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java index 2fa66398e28..d9ac686d861 100644 --- a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java @@ -355,13 +355,13 @@ UserFpdActivityMask userFpdActivityMask(UserFpdTcfMask userFpdTcfMask) { } @Bean - UserFpdCcpaMask userFpdCcpaMask(IpAddressHelper ipAddressHelper) { - return new UserFpdCcpaMask(ipAddressHelper); + UserFpdCcpaMask userFpdCcpaMask(UserFpdActivityMask userFpdActivityMask) { + return new UserFpdCcpaMask(userFpdActivityMask); } @Bean - UserFpdCoppaMask userFpdCoppaMask(IpAddressHelper ipAddressHelper) { - return new UserFpdCoppaMask(ipAddressHelper); + UserFpdCoppaMask userFpdCoppaMask(UserFpdActivityMask userFpdActivityMask) { + return new UserFpdCoppaMask(userFpdActivityMask); } @Bean diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/GeoExtGeoProvider.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/GeoExtGeoProvider.groovy index c2c15f595da..1aa51084f20 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/GeoExtGeoProvider.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/GeoExtGeoProvider.groovy @@ -1,5 +1,10 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode +import groovy.transform.ToString + +@EqualsAndHashCode +@ToString(includeNames = true, ignoreNulls = true) class GeoExtGeoProvider { String country diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy index dac9fafca18..6ad61e46cd3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy @@ -2,9 +2,17 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest +import org.prebid.server.functional.model.request.auction.BidRequest +import org.prebid.server.functional.model.request.auction.Data +import org.prebid.server.functional.model.request.auction.Eid +import org.prebid.server.functional.model.request.auction.Geo +import org.prebid.server.functional.model.request.auction.UserExt +import org.prebid.server.functional.model.request.auction.UserExtData +import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature import static org.prebid.server.functional.model.bidder.BidderName.GENERIC +import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE class CoppaSpec extends PrivacyBaseSpec { @@ -139,4 +147,238 @@ class CoppaSpec extends PrivacyBaseSpec { privacy.errors?.isEmpty() } } + + def "PBS shouldn't mask device and user fields for auction request when coppa = 0 was passed"() { + given: "BidRequest with personal data" + def bidRequest = bidRequestWithPersonalData.tap { + regs.coppa = 0 + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request shouldn't mask device and user personal data" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + verifyAll (bidderRequest) { + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.device.ip == bidRequest.device.ip + bidderRequest.device.ipv6 == "af47:892b:3e98:b49a::" + bidderRequest.device.geo.lat == bidRequest.device.geo.lat + bidderRequest.device.geo.lon == bidRequest.device.geo.lon + bidderRequest.device.geo.country == bidRequest.device.geo.country + bidderRequest.device.geo.region == bidRequest.device.geo.region + bidderRequest.device.geo.utcoffset == bidRequest.device.geo.utcoffset + bidderRequest.device.geo.metro == bidRequest.device.geo.metro + bidderRequest.device.geo.city == bidRequest.device.geo.city + bidderRequest.device.geo.zip == bidRequest.device.geo.zip + bidderRequest.device.geo.accuracy == bidRequest.device.geo.accuracy + bidderRequest.device.geo.ipservice == bidRequest.device.geo.ipservice + bidderRequest.device.geo.ext == bidRequest.device.geo.ext + + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo.lat == bidRequest.user.geo.lat + bidderRequest.user.geo.lon == bidRequest.user.geo.lon + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + } + } + + def "PBS should mask device and user fields for auction request when coppa = 1 was passed"() { + given: "BidRequest with personal data" + def bidRequest = bidRequestWithPersonalData.tap { + regs.coppa = 1 + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request should mask device and user personal data" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + verifyAll (bidderRequest) { + bidderRequest.device.ip == "43.77.114.0" + bidderRequest.device.ipv6 == "af47:892b:3e98:b400::" + bidderRequest.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequest.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequest.device.geo.country == bidRequest.device.geo.country + bidderRequest.device.geo.region == bidRequest.device.geo.region + bidderRequest.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask device personal data" + verifyAll (bidderRequest.device) { + !didsha1 + !didmd5 + !dpidsha1 + !ifa + !macsha1 + !macmd5 + !dpidmd5 + !geo.metro + !geo.city + !geo.zip + !geo.accuracy + !geo.ipservice + !geo.ext + } + + and: "Bidder request should mask user personal data" + verifyAll (bidderRequest.user) { + !id + !buyeruid + !yob + !gender + !eids + !data + !geo + !ext + !eids + !ext?.eids + } + } + + def "PBS shouldn't mask device and user fields for amp request when coppa = 0 was passed"() { + given: "Default AmpRequest" + def ampRequest = AmpRequest.defaultAmpRequest + + and: "Save storedRequest into DB" + def ampStoredRequest = bidRequestWithPersonalData.tap { + regs.coppa = 0 + } + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes auction request" + defaultPbsService.sendAmpRequest(ampRequest) + + then: "Bidder request shouldn't mask device and user personal data" + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + verifyAll (bidderRequest) { + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.device.ip == ampStoredRequest.device.ip + bidderRequest.device.ipv6 == "af47:892b:3e98:b49a::" + bidderRequest.device.geo.lat == ampStoredRequest.device.geo.lat + bidderRequest.device.geo.lon == ampStoredRequest.device.geo.lon + bidderRequest.device.geo.country == ampStoredRequest.device.geo.country + bidderRequest.device.geo.region == ampStoredRequest.device.geo.region + bidderRequest.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + bidderRequest.device.geo.metro == ampStoredRequest.device.geo.metro + bidderRequest.device.geo.city == ampStoredRequest.device.geo.city + bidderRequest.device.geo.zip == ampStoredRequest.device.geo.zip + bidderRequest.device.geo.accuracy == ampStoredRequest.device.geo.accuracy + bidderRequest.device.geo.ipservice == ampStoredRequest.device.geo.ipservice + bidderRequest.device.geo.ext == ampStoredRequest.device.geo.ext + + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequest.user.geo.lon == ampStoredRequest.user.geo.lon + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + } + } + + def "PBS should mask device and user fields for amp request when coppa = 1 was passed"() { + given: "Default AmpRequest" + def ampRequest = AmpRequest.defaultAmpRequest + + and: "Save storedRequest into DB" + def ampStoredRequest = bidRequestWithPersonalData.tap { + regs.coppa = 1 + } + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes auction request" + defaultPbsService.sendAmpRequest(ampRequest) + + then: "Bidder request should mask device and user personal data" + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + verifyAll (bidderRequest) { + bidderRequest.device.ip == "43.77.114.0" + bidderRequest.device.ipv6 == "af47:892b:3e98:b400::" + bidderRequest.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequest.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequest.device.geo.country == ampStoredRequest.device.geo.country + bidderRequest.device.geo.region == ampStoredRequest.device.geo.region + bidderRequest.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask device personal data" + verifyAll (bidderRequest.device) { + !didsha1 + !didmd5 + !dpidsha1 + !ifa + !macsha1 + !macmd5 + !dpidmd5 + !geo.metro + !geo.city + !geo.zip + !geo.accuracy + !geo.ipservice + !geo.ext + } + + and: "Bidder request should mask user personal data" + verifyAll (bidderRequest.user) { + !id + !buyeruid + !yob + !gender + !eids + !data + !geo + !ext + !eids + !ext?.eids + } + } + + private static BidRequest getBidRequestWithPersonalData() { + getBidRequestWithGeo().tap { + setAccountId(accountId) + ext.prebid.trace = VERBOSE + device.tap { + didsha1 = PBSUtils.randomString + didmd5 = PBSUtils.randomString + dpidsha1 = PBSUtils.randomString + ifa = PBSUtils.randomString + macsha1 = PBSUtils.randomString + macmd5 = PBSUtils.randomString + dpidmd5 = PBSUtils.randomString + } + user.tap { + customdata = PBSUtils.randomString + eids = [Eid.defaultEid] + data = [new Data(name: PBSUtils.randomString)] + buyeruid = PBSUtils.randomString + yob = PBSUtils.randomNumber + gender = PBSUtils.randomString + geo = Geo.FPDGeo + ext = new UserExt(data: new UserExtData(buyeruid: PBSUtils.randomString)) + } + } + } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy index 7115f3fc561..c1e90d78a06 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy @@ -105,12 +105,26 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -145,14 +159,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -189,10 +220,24 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } } @@ -254,12 +299,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -289,14 +347,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } } @@ -332,12 +407,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -385,14 +473,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -439,12 +544,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -468,7 +586,10 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { it.setAccountId(accountId) it.regs.gppSid = [USP_V1.intValue] it.ext.prebid.trace = VERBOSE - it.device.geo = null + it.device.geo.tap { + country = null + region = null + } } and: "Setup condition" @@ -476,7 +597,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { it.componentType = null it.componentName = [PBSUtils.randomString] it.gppSid = [USP_V1.intValue] - it.geo = ["$USA.ISOAlpha3".toString()] + it.geo = [USA.ISOAlpha3] } and: "Set activity" @@ -495,14 +616,27 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon - !bidderRequests.device.geo - !bidderRequests.device.geo } and: "Metrics processed across activities should be updated" @@ -518,9 +652,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { it.setAccountId(accountId) it.regs.gppSid = null it.ext.prebid.trace = VERBOSE - it.device.geo = deviceGeo.tap { - lat = PBSUtils.getRandomDecimal(0, 90) - lon = PBSUtils.getRandomDecimal(0, 90) + it.device.geo.tap { + country = geoCountry + region = geoRegion } } @@ -548,14 +682,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -565,10 +716,10 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { assert metrics[DISALLOWED_COUNT_FOR_GENERIC_ADAPTER] == 1 where: - deviceGeo | conditionGeo - new Geo(country: USA) | [USA.ISOAlpha3] - new Geo(country: USA, region: ALABAMA.abbreviation) | [USA.withState(ALABAMA)] - new Geo(country: USA, region: ALABAMA.abbreviation) | [CAN.withState(ONTARIO), USA.withState(ALABAMA)] + geoCountry | geoRegion | conditionGeo + USA | null | [USA.ISOAlpha3] + USA | ALABAMA.abbreviation | [USA.withState(ALABAMA)] + USA | ALABAMA.abbreviation | [CAN.withState(ONTARIO), USA.withState(ALABAMA)] } def "PBS auction should process rule when regs.ext.gpc doesn't intersection with condition.gpc"() { @@ -603,12 +754,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -657,10 +821,28 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -702,12 +884,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -750,14 +945,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -795,14 +1007,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -837,14 +1066,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -907,14 +1153,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -952,12 +1215,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -997,12 +1273,26 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -1041,12 +1331,26 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -1091,7 +1395,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String - def genericBidRequest = bidRequestWithGeo.tap { + def bidRequest = bidRequestWithGeo.tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) @@ -1116,18 +1420,32 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain not rounded geo data for device and user" - def bidderRequests = bidder.getBidderRequest(genericBidRequest.id) - + def bidderRequests = bidder.getBidderRequest(bidRequest.id) + def deviceBidderRequest = bidderRequests.device verifyAll { - bidderRequests.device.ip == genericBidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == genericBidRequest.device.geo.lat - bidderRequests.device.geo.lon == genericBidRequest.device.geo.lon - bidderRequests.user.geo.lat == genericBidRequest.user.geo.lat - bidderRequests.user.geo.lon == genericBidRequest.user.geo.lon + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -1141,7 +1459,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation match custom requirement should round lat/lon data to 2 digits"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def generalBidRequest = bidRequestWithGeo.tap { + def bidRequest = bidRequestWithGeo.tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) @@ -1167,18 +1485,35 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(generalBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain rounded geo data for device and user to 2 digits" - def bidderRequests = bidder.getBidderRequest(generalBidRequest.id) - + def bidderRequests = bidder.getBidderRequest(bidRequest.id) verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - generalBidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - generalBidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - generalBidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - generalBidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -1242,7 +1577,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when custom privacy regulation with normalizing should change request consent and call to bidder"() { given: "Generic BidRequest with gpp and account setup" def accountId = PBSUtils.randomNumber as String - def generalBidRequest = bidRequestWithGeo.tap { + def bidRequest = bidRequestWithGeo.tap { ext.prebid.trace = VERBOSE regs.gppSid = [gppSid.intValue] regs.gpp = gppStateConsent.build() @@ -1273,18 +1608,35 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(generalBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain rounded geo data for device and user to 2 digits" - def bidderRequests = bidder.getBidderRequest(generalBidRequest.id) - + def bidderRequests = bidder.getBidderRequest(bidRequest.id) verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - generalBidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - generalBidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - generalBidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - generalBidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -1391,12 +1743,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -1438,14 +1803,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -1483,14 +1865,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } } @@ -1570,12 +1969,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -1614,14 +2026,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } } @@ -1662,12 +2091,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -1715,14 +2157,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -1767,14 +2226,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: @@ -1817,14 +2293,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: @@ -1895,14 +2388,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: @@ -1948,12 +2458,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -2001,12 +2524,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -2052,12 +2588,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -2150,12 +2699,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -2211,14 +2773,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: @@ -2334,14 +2913,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index c6c68f81714..e842521e853 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -127,6 +127,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -171,6 +172,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo + !genericBidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -215,6 +218,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -290,6 +294,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } } @@ -329,6 +334,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -380,6 +386,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -437,7 +444,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender + !genericBidderRequest.user.eids + !genericBidderRequest.user.geo !genericBidderRequest.user.data + !genericBidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -496,6 +506,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } @@ -557,7 +568,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender + !bidderRequest.user.eids + !bidderRequest.user.geo !bidderRequest.user.data + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -620,6 +634,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } @@ -674,7 +689,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender + !bidderRequest.user.eids + !bidderRequest.user.geo !bidderRequest.user.data + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -732,6 +750,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo.zip == bidRequest.user.geo.zip bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } @@ -785,7 +804,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender + !bidderRequest.user.eids + !bidderRequest.user.geo !bidderRequest.user.data + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -838,6 +860,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -888,6 +911,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1112,6 +1136,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1167,6 +1192,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1219,6 +1245,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1270,6 +1297,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1352,6 +1380,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1407,6 +1436,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1515,6 +1545,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1636,6 +1667,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -1687,6 +1719,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1740,6 +1773,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1833,6 +1867,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } } @@ -1881,6 +1916,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1938,6 +1974,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1999,6 +2036,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2056,6 +2094,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2115,6 +2154,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2357,6 +2397,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2420,6 +2461,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2480,6 +2522,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2540,6 +2583,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2640,6 +2684,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2704,6 +2749,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2832,6 +2878,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2947,6 +2994,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo + !genericBidderRequest.user.ext } and: "Eids fields should have original data" @@ -2979,6 +3028,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { it.user.buyeruid = PBSUtils.randomString it.user.yob = PBSUtils.randomNumber it.user.gender = PBSUtils.randomString + it.user.geo = Geo.FPDGeo it.user.ext = new UserExt(data: new UserExtData(buyeruid: PBSUtils.randomString)) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy index c2115d06f4a..d709c5ba5b4 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy @@ -19,6 +19,8 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.DistributionChannel import org.prebid.server.functional.model.request.auction.Geo +import org.prebid.server.functional.model.request.auction.GeoExt +import org.prebid.server.functional.model.request.auction.GeoExtGeoProvider import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt @@ -38,6 +40,7 @@ import static org.prebid.server.functional.model.config.PurposeEnforcement.BASIC import static org.prebid.server.functional.model.config.PurposeEnforcement.FULL import static org.prebid.server.functional.model.config.PurposeEnforcement.NO import static org.prebid.server.functional.model.mock.services.vendorlist.VendorListResponse.getDefaultVendorListResponse +import static org.prebid.server.functional.model.pricefloors.Country.USA import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.amp.ConsentType.TCF_2 import static org.prebid.server.functional.model.request.amp.ConsentType.US_PRIVACY @@ -50,6 +53,7 @@ import static org.prebid.server.functional.util.privacy.TcfConsent.RestrictionTy import static org.prebid.server.functional.util.privacy.TcfConsent.RestrictionType.REQUIRE_LEGITIMATE_INTEREST import static org.prebid.server.functional.util.privacy.TcfConsent.RestrictionType.UNDEFINED import static org.prebid.server.functional.util.privacy.TcfConsent.TcfPolicyVersion.TCF_POLICY_V2 +import static org.prebid.server.functional.util.privacy.model.State.ALABAMA abstract class PrivacyBaseSpec extends BaseSpec { @@ -112,10 +116,26 @@ abstract class PrivacyBaseSpec extends BaseSpec { protected static BidRequest getBidRequestWithGeo(DistributionChannel channel = SITE) { BidRequest.getDefaultBidRequest(channel).tap { - device = new Device(ip: "43.77.114.227", ipv6: "af47:892b:3e98:b49a:a747:bda4:a6c8:aee2", - geo: new Geo(lat: PBSUtils.getRandomDecimal(0, 90), lon: PBSUtils.getRandomDecimal(0, 90))) + device = new Device( + ip: "43.77.114.227", + ipv6: "af47:892b:3e98:b49a:a747:bda4:a6c8:aee2", + geo: new Geo( + lat: PBSUtils.getRandomDecimal(0, 90), + lon: PBSUtils.getRandomDecimal(0, 90), + country: USA, + region: ALABAMA, + utcoffset: PBSUtils.randomNumber, + metro: PBSUtils.randomString, + city: PBSUtils.randomString, + zip: PBSUtils.randomString, + accuracy: PBSUtils.randomNumber, + ipservice: PBSUtils.randomNumber, + ext: new GeoExt(geoProvider: new GeoExtGeoProvider()), + )) user = User.defaultUser.tap { - geo = new Geo(lat: PBSUtils.getRandomDecimal(0, 90), lon: PBSUtils.getRandomDecimal(0, 90)) + geo = new Geo( + lat: PBSUtils.getRandomDecimal(0, 90), + lon: PBSUtils.getRandomDecimal(0, 90)) } } } @@ -169,6 +189,12 @@ abstract class PrivacyBaseSpec extends BaseSpec { def geo = bidRequest.device.geo.clone() geo.lat = PBSUtils.roundDecimal(bidRequest.device.geo.lat as BigDecimal, precision) geo.lon = PBSUtils.roundDecimal(bidRequest.device.geo.lon as BigDecimal, precision) + geo.accuracy = null + geo.zip = null + geo.metro = null + geo.city = null + geo.ext = null + geo.ipservice = null geo } diff --git a/src/test/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegatorTest.java b/src/test/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegatorTest.java index 10c53f7ba06..d76d0d68dbd 100644 --- a/src/test/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegatorTest.java +++ b/src/test/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegatorTest.java @@ -355,7 +355,7 @@ public void shouldUpdateAuctionEventToConsideringActivitiesRestrictions() { given(activityInfrastructure.isAllowed(eq(Activity.TRANSMIT_EIDS), any())).willReturn(false); given(activityInfrastructure.isAllowed(eq(Activity.TRANSMIT_GEO), any())).willReturn(false); - given(userFpdActivityMask.maskUser(any(), eq(true), eq(true), eq(true))) + given(userFpdActivityMask.maskUser(any(), eq(true), eq(true))) .willReturn(User.builder().id("masked").build()); given(userFpdActivityMask.maskDevice(any(), eq(true), eq(true))) .willReturn(Device.builder().model("masked").build()); diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcementTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcementTest.java index 78512a06f41..a46d068f221 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcementTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcementTest.java @@ -47,7 +47,7 @@ public void enforceShouldReturnExpectedResult() { final Device maskedDevice = Device.builder().ip("maskedDevice").build(); given(activityInfrastructure.isAllowed(any(), any())).willReturn(false); - given(userFpdActivityMask.maskUser(any(), anyBoolean(), anyBoolean(), anyBoolean())) + given(userFpdActivityMask.maskUser(any(), anyBoolean(), anyBoolean())) .willReturn(maskedUser); given(userFpdActivityMask.maskDevice(any(), anyBoolean(), anyBoolean())) .willReturn(maskedDevice); diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcementTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcementTest.java index e0b2c288673..6d138486f72 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcementTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcementTest.java @@ -67,7 +67,7 @@ public class TcfEnforcementTest { @Before public void setUp() { - given(userFpdTcfMask.maskUser(any(), anyBoolean(), anyBoolean(), anyBoolean(), anySet())) + given(userFpdTcfMask.maskUser(any(), anyBoolean(), anyBoolean(), anySet())) .willAnswer(invocation -> invocation.getArgument(0)); given(userFpdTcfMask.maskDevice(any(), anyBoolean(), anyBoolean(), anyBoolean())) .willAnswer(invocation -> invocation.getArgument(0)); @@ -276,7 +276,7 @@ public void enforceShouldMaskUserAndDeviceWhenRestrictionsEnforcedAndLmtNotEnabl final User maskedUser = User.builder().id("maskedUser").build(); final Device maskedDevice = Device.builder().ip("maskedDevice").build(); - given(userFpdTcfMask.maskUser(any(), eq(true), eq(true), eq(true), eq(singleton("eidException")))) + given(userFpdTcfMask.maskUser(any(), eq(true), eq(true), eq(singleton("eidException")))) .willReturn(maskedUser); given(userFpdTcfMask.maskDevice(any(), eq(true), eq(true), eq(true))) .willReturn(maskedDevice); @@ -333,7 +333,7 @@ public void enforceShouldMaskUserAndDeviceWhenRestrictionsNotEnforcedAndLmtEnabl final User maskedUser = User.builder().id("maskedUser").build(); final Device maskedDevice = Device.builder().ip("maskedDevice").build(); - given(userFpdTcfMask.maskUser(any(), eq(true), eq(true), eq(true), eq(singleton("eidException")))) + given(userFpdTcfMask.maskUser(any(), eq(true), eq(true), eq(singleton("eidException")))) .willReturn(maskedUser); given(userFpdTcfMask.maskDevice(any(), eq(true), eq(true), eq(true))) .willReturn(maskedDevice); diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMaskTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMaskTest.java index bcf2ee5f7d7..811c1b30a0e 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMaskTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMaskTest.java @@ -35,10 +35,10 @@ public void maskUserShouldProperlyDelegateUfpdParameter() { final User user = User.builder().build(); // when - target.maskUser(user, true, false, false); + target.maskUser(user, true, false); // then - verify(userFpdTcfMask).maskUser(same(user), eq(true), eq(false), eq(false), eq(emptySet())); + verify(userFpdTcfMask).maskUser(same(user), eq(true), eq(false), eq(emptySet())); } @Test @@ -47,22 +47,10 @@ public void maskUserShouldProperlyDelegateEidsParameter() { final User user = User.builder().build(); // when - target.maskUser(user, false, true, false); + target.maskUser(user, false, true); // then - verify(userFpdTcfMask).maskUser(same(user), eq(false), eq(true), eq(false), eq(emptySet())); - } - - @Test - public void maskUserShouldProperlyDelegateGeoParameter() { - // given - final User user = User.builder().build(); - - // when - target.maskUser(user, false, false, true); - - // then - verify(userFpdTcfMask).maskUser(same(user), eq(false), eq(false), eq(true), eq(emptySet())); + verify(userFpdTcfMask).maskUser(same(user), eq(false), eq(true), eq(emptySet())); } @Test diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMaskTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMaskTest.java index 53d4a1571df..7247e8e0118 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMaskTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMaskTest.java @@ -1,7 +1,6 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; import org.junit.Before; import org.junit.Rule; @@ -10,13 +9,10 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; -import org.prebid.server.auction.IpAddressHelper; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.same; +import static org.mockito.Mockito.verify; public class UserFpdCcpaMaskTest extends VertxTest { @@ -24,81 +20,36 @@ public class UserFpdCcpaMaskTest extends VertxTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private IpAddressHelper ipAddressHelper; + private UserFpdActivityMask userFpdActivityMask; private UserFpdCcpaMask target; @Before public void setUp() { - target = new UserFpdCcpaMask(ipAddressHelper); + target = new UserFpdCcpaMask(userFpdActivityMask); } @Test - public void maskUserShouldReturnExpectedResult() { + public void maskUserShouldProperlyDelegateUser() { // given - final User user = User.builder() - .id("id") - .buyeruid("buyeruid") - .yob(1) - .gender("gender") - .keywords("keywords") - .kwarray(emptyList()) - .data(emptyList()) - .eids(emptyList()) - .geo(Geo.builder() - .lon(-85.34321F) - .lat(189.342323F) - .metro("metro") - .city("city") - .zip("zip") - .build()) - .ext(ExtUser.builder().data(mapper.createObjectNode()).build()) - .build(); + final User user = User.builder().build(); // when - final User result = target.maskUser(user); + target.maskUser(user); // then - assertThat(result).isEqualTo( - User.builder() - .geo(Geo.builder().lon(-85.34F).lat(189.34F).build()) - .build()); + verify(userFpdActivityMask).maskUser(same(user), eq(true), eq(true)); } @Test - public void maskDeviceShouldReturnExpectedResult() { + public void maskDeviceShouldProperlyDelegateDevice() { // given - given(ipAddressHelper.maskIpv4(any())).willReturn("ip4"); - given(ipAddressHelper.anonymizeIpv6(any())).willReturn("ip6"); - - final Device device = Device.builder() - .ip("192.168.0.10") - .ipv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334") - .geo(Geo.builder() - .lon(-85.34321F) - .lat(189.342323F) - .metro("metro") - .city("city") - .zip("zip") - .build()) - .ifa("ifa") - .macsha1("macsha1") - .macmd5("macmd5") - .didsha1("didsha1") - .didmd5("didmd5") - .dpidsha1("dpidsha1") - .dpidmd5("dpidmd5") - .build(); + final Device device = Device.builder().build(); // when - final Device result = target.maskDevice(device); + target.maskDevice(device); // then - assertThat(result).isEqualTo( - Device.builder() - .ip("ip4") - .ipv6("ip6") - .geo(Geo.builder().lon(-85.34F).lat(189.34F).build()) - .build()); + verify(userFpdActivityMask).maskDevice(same(device), eq(true), eq(true)); } } diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMaskTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMaskTest.java index 056b36f3a84..46bbd3cb1ea 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMaskTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMaskTest.java @@ -1,7 +1,6 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; import org.junit.Before; import org.junit.Rule; @@ -10,13 +9,10 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; -import org.prebid.server.auction.IpAddressHelper; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.same; +import static org.mockito.Mockito.verify; public class UserFpdCoppaMaskTest extends VertxTest { @@ -24,77 +20,36 @@ public class UserFpdCoppaMaskTest extends VertxTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private IpAddressHelper ipAddressHelper; + private UserFpdActivityMask userFpdActivityMask; private UserFpdCoppaMask target; @Before public void setUp() { - target = new UserFpdCoppaMask(ipAddressHelper); + target = new UserFpdCoppaMask(userFpdActivityMask); } @Test - public void maskUserShouldReturnExpectedResult() { + public void maskUserShouldProperlyDelegateUser() { // given - final User user = User.builder() - .id("id") - .buyeruid("buyeruid") - .yob(1) - .gender("gender") - .keywords("keywords") - .kwarray(emptyList()) - .data(emptyList()) - .eids(emptyList()) - .geo(Geo.builder() - .lon(-85.34321F) - .lat(189.342323F) - .metro("metro") - .city("city") - .zip("zip") - .build()) - .ext(ExtUser.builder().data(mapper.createObjectNode()).build()) - .build(); + final User user = User.builder().build(); // when - final User result = target.maskUser(user); + target.maskUser(user); // then - assertThat(result).isNull(); + verify(userFpdActivityMask).maskUser(same(user), eq(true), eq(true)); } @Test - public void maskDeviceShouldReturnExpectedResult() { + public void maskDeviceShouldProperlyDelegateDevice() { // given - given(ipAddressHelper.maskIpv4(any())).willReturn("ip4"); - given(ipAddressHelper.anonymizeIpv6(any())).willReturn("ip6"); - - final Device device = Device.builder() - .ip("192.168.0.10") - .ipv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334") - .geo(Geo.builder() - .lon(-85.34321F) - .lat(189.342323F) - .metro("metro") - .city("city") - .zip("zip") - .build()) - .ifa("ifa") - .macsha1("macsha1") - .macmd5("macmd5") - .didsha1("didsha1") - .didmd5("didmd5") - .dpidsha1("dpidsha1") - .dpidmd5("dpidmd5") - .build(); + final Device device = Device.builder().build(); // when - final Device result = target.maskDevice(device); + target.maskDevice(device); // then - assertThat(result).isEqualTo( - Device.builder() - .ip("ip4") - .ipv6("ip6") - .build()); + verify(userFpdActivityMask).maskDevice(same(device), eq(true), eq(true)); } } diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMaskTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMaskTest.java index 444fd839aa7..33ccbf94803 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMaskTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMaskTest.java @@ -12,6 +12,7 @@ import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; import org.prebid.server.auction.IpAddressHelper; +import org.prebid.server.proto.openrtb.ext.request.ExtGeo; import org.prebid.server.proto.openrtb.ext.request.ExtUser; import static java.util.Arrays.asList; @@ -55,14 +56,10 @@ public void maskUserShouldReturnExpectedResultWhenFpdMasked() { .build(); // when - final User result = target.maskUser(user, true, false, false, emptySet()); + final User result = target.maskUser(user, true, false, emptySet()); // then - assertThat(result).isEqualTo( - User.builder() - .eids(emptyList()) - .geo(Geo.builder().lon(-85.34321F).lat(189.342323F).build()) - .build()); + assertThat(result).isEqualTo(User.builder().eids(emptyList()).build()); } @Test @@ -85,7 +82,7 @@ public void maskUserShouldReturnExpectedResultWhenEidsMasked() { .build(); // when - final User result = target.maskUser(user, false, true, false, singleton("2")); + final User result = target.maskUser(user, false, true, singleton("2")); // then assertThat(result).isEqualTo( @@ -103,41 +100,6 @@ public void maskUserShouldReturnExpectedResultWhenEidsMasked() { .build()); } - @Test - public void maskUserShouldReturnExpectedResultWhenGeoMasked() { - // given - final User user = User.builder() - .id("id") - .buyeruid("buyeruid") - .yob(1) - .gender("gender") - .keywords("keywords") - .kwarray(emptyList()) - .data(emptyList()) - .eids(emptyList()) - .geo(Geo.builder().lon(-85.34321F).lat(189.342323F).build()) - .ext(ExtUser.builder().data(mapper.createObjectNode()).build()) - .build(); - - // when - final User result = target.maskUser(user, false, false, true, emptySet()); - - // then - assertThat(result).isEqualTo( - User.builder() - .id("id") - .buyeruid("buyeruid") - .yob(1) - .gender("gender") - .keywords("keywords") - .kwarray(emptyList()) - .data(emptyList()) - .eids(emptyList()) - .geo(Geo.builder().lon(-85.34F).lat(189.34F).build()) - .ext(ExtUser.builder().data(mapper.createObjectNode()).build()) - .build()); - } - @Test public void maskDeviceShouldReturnExpectedResultWhenIpMasked() { // given @@ -150,6 +112,12 @@ public void maskDeviceShouldReturnExpectedResultWhenIpMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .ifa("ifa") .macsha1("macsha1") @@ -171,6 +139,12 @@ public void maskDeviceShouldReturnExpectedResultWhenIpMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .ifa("ifa") .macsha1("macsha1") @@ -194,6 +168,12 @@ public void maskDeviceShouldReturnExpectedResultWhenGeoMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .ifa("ifa") .macsha1("macsha1") @@ -238,6 +218,12 @@ public void maskDeviceShouldReturnExpectedResultWhenDeviceInfoMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .ifa("ifa") .macsha1("macsha1") @@ -259,6 +245,12 @@ public void maskDeviceShouldReturnExpectedResultWhenDeviceInfoMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .build()); } From 43cba2892ebf580324f2e9b4a994b021106e6788 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Thu, 9 May 2024 09:29:04 -0400 Subject: [PATCH 34/62] Core: Reorganize Maven dependencies (#3180) --- extra/bundle/pom.xml | 8 - extra/modules/confiant-ad-quality/pom.xml | 1 - extra/modules/pom.xml | 51 +- extra/pom.xml | 219 ++- pom.xml | 205 +-- .../container/NetworkServiceContainer.groovy | 1 - .../GppTransmitUfpdActivitiesSpec.groovy | 1237 +++++++++-------- .../tests/prometheus/PrometheusSpec.groovy | 2 +- .../adtelligent/AdtelligentBidderTest.java | 6 +- 9 files changed, 888 insertions(+), 842 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 7f1adad0d6c..454a9b0de5b 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -14,14 +14,6 @@ prebid-server-bundle Creates bundle (fat jar) with PBS-Core and other submodules listed as dependency - - UTF-8 - UTF-8 - ${java.version} - ${java.version} - 2.5.6 - - org.prebid diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 51a81049e5e..7e1bfc91bd9 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -17,7 +17,6 @@ io.vertx vertx-redis-client - ${vertx.version} diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 865b928cb79..36014ede43a 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -22,51 +22,12 @@ pb-richmedia-filter - - UTF-8 - UTF-8 - ${java.version} - ${java.version} - - 5.9.0 - 3.23.1 - 4.13.2 - 4.7.0 - - org.prebid prebid-server - 3.0.0-SNAPSHOT - - - org.projectlombok - lombok - ${lombok.version} - - - org.junit - junit-bom - ${junit-bom.version} - pom - import - - - org.assertj - assertj-core - ${assertj.version} - - - junit - junit - ${junit.version} - - - org.mockito - mockito-core - ${mockito.version} + ${project.version} @@ -76,6 +37,11 @@ org.prebid prebid-server + + org.junit.jupiter + junit-jupiter-engine + test + org.junit.vintage junit-vintage-engine @@ -86,11 +52,6 @@ assertj-core test - - junit - junit - test - org.mockito mockito-core diff --git a/extra/pom.xml b/extra/pom.xml index d6b22c6383f..dc0d1be2c02 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.prebid @@ -15,17 +16,48 @@ + 21 UTF-8 - UTF-8 + UTF-8 ${java.version} ${java.version} - 4.5.5 - 1.18.30 + + 3.0.0-M6 3.11.0 2.22.2 - false + ${maven-surefire-plugin.version} + 0.40.2 + + + 3.2.3 + 4.5.5 + 2.0.1.Final + 4.4 + 1.26.0 + 3.6.1 + 2.1 + 4.5.14 + 5.3.1 + 6.4.5 + 1.0.76 + 1.13 + 2.2.0 + 1.2.2 + 0.16.0 + 2.0.10 + 3.2.0 + 2.12.0 + 3.21.7 + 3.17.3 + 1.0.7 + + + 2.35.1 + 2.4-M4-groovy-4.0 + + 5.15.0 @@ -34,11 +66,186 @@ bundle + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + io.vertx + vertx-dependencies + ${vertx.version} + pom + import + + + org.spockframework + spock-bom + ${spock.version} + pom + import + + + com.github.tomakehurst + wiremock-jre8 + ${wiremock.version} + + + javax.validation + validation-api + ${validation-api.version} + + + com.ongres.scram + client + ${scram.version} + + + org.apache.commons + commons-collections4 + ${commons.collections.version} + + + org.apache.commons + commons-compress + ${commons.compress.version} + + + org.apache.commons + commons-math3 + ${commons-math3.version} + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + com.github.seancfoley + ipaddress + ${ipaddress.version} + + + com.github.oshi + oshi-core + ${oshi.version} + + + com.networknt + json-schema-validator + ${json-schema-validator.version} + + + com.github.java-json-tools + json-patch + ${jsonpatch.version} + + + com.google.code.findbugs + jsr305 + + + + + de.malkusch.whois-server-list + public-suffix-list + ${psl.version} + + + com.google.code.findbugs + jsr305 + + + + + com.izettle + dropwizard-metrics-influxdb + ${metrics-influxdb.version} + + + io.dropwizard + dropwizard-metrics + + + org.apache.kafka + kafka-clients + + + + + io.prometheus + simpleclient_vertx4 + ${vertx.prometheus.version} + + + io.prometheus + simpleclient_dropwizard + ${vertx.prometheus.version} + + + com.iabtcf + iabtcf-decoder + ${iabtcf.version} + + + com.iabtcf + iabtcf-encoder + ${iabtcf.version} + + + com.iabgpp + iabgpp-encoder + ${gpp-encoder.version} + + + com.maxmind.geoip2 + geoip2 + ${maxmind-client.version} + + + com.google.protobuf + protobuf-java + ${protobuf.version} + + + com.google.protobuf + protobuf-java-util + ${protobuf.version} + + + com.google.code.findbugs + jsr305 + + + + + io.github.jamsesso + json-logic-java + ${json-logic.version} + + + org.mock-server + mockserver-client-java + ${mockserver.version} + + + com.google.code.findbugs + jsr305 + + + + + + org.projectlombok lombok - ${lombok.version} provided diff --git a/pom.xml b/pom.xml index aee1ffd7d5e..d01e20873bd 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -19,53 +20,10 @@ - UTF-8 - UTF-8 - ${java.version} - ${java.version} Dockerfile - - 3.2.3 - 2.0.1.Final - 3.14.0 - 4.4 - 1.26.0 - 3.6.1 - 4.5.14 - 5.3.1 - 6.4.5 - 2.16.2 - 1.0.76 - 1.13 - 8.0.28 - 42.7.2 - 2.2.0 - 1.2.2 - 0.16.0 - 2.0.2 - 2.0.10 - 2.12.0 - 3.2.0 - 3.21.7 - 3.17.3 - 1.0.7 - 2.1 - - - 4.13.2 - 5.10.2 - 4.11.0 - 3.24.2 - 2.35.1 + 9.4.53.v20231009 - 5.4.0 - 2.2.220 - 2.4-M2-groovy-4.0 - 4.0.15 - 1.17.4 - 5.14.0 - 1.12.14 3.1.2 @@ -73,8 +31,7 @@ 1.2.0 0.8.11 2.2.4 - ${maven-surefire-plugin.version} - 0.40.2 + 3.0.2 false true @@ -83,40 +40,6 @@ 0.6.1 - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - com.google.code.gson - gson - - - commons-codec - commons-codec - compile - - - org.apache.httpcomponents - httpcore - compile - - - com.rabbitmq - amqp-client - - - org.jboss.logging - jboss-logging - - - - org.springframework.boot @@ -129,7 +52,6 @@ javax.validation validation-api - ${validation-api.version} org.hibernate.validator @@ -138,47 +60,38 @@ io.vertx vertx-core - ${vertx.version} io.vertx vertx-web - ${vertx.version} io.vertx vertx-config - ${vertx.version} io.vertx vertx-mysql-client - ${vertx.version} io.vertx vertx-pg-client - ${vertx.version} io.vertx vertx-circuit-breaker - ${vertx.version} io.vertx vertx-dropwizard-metrics - ${vertx.version} io.vertx vertx-auth-common - ${vertx.version} com.ongres.scram client - ${scram.version} io.netty @@ -193,94 +106,76 @@ org.apache.commons commons-lang3 - ${commons.version} org.apache.commons commons-collections4 - ${commons.collections.version} org.apache.commons commons-compress - ${commons.compress.version} org.apache.commons commons-math3 - ${commons-math3.version} org.apache.httpcomponents httpclient - ${httpclient.version} com.github.seancfoley ipaddress - ${ipaddress.version} com.github.oshi oshi-core - ${oshi.version} com.fasterxml.jackson.core jackson-core - ${jackson.version} com.fasterxml.jackson.core jackson-databind - ${jackson.version} com.fasterxml.jackson.core jackson-annotations - ${jackson.version} com.fasterxml.jackson.dataformat jackson-dataformat-yaml - ${jackson.version} com.fasterxml.jackson.module jackson-module-blackbird - ${jackson.version} com.fasterxml.jackson.datatype jackson-datatype-jsr310 - ${jackson.version} test com.fasterxml.jackson.dataformat jackson-dataformat-xml - ${jackson.version} test com.networknt json-schema-validator - ${json-schema-validator.version} com.github.java-json-tools json-patch - ${jsonpatch.version} - mysql - mysql-connector-java - ${mysql.version} + com.mysql + mysql-connector-j org.postgresql postgresql - ${postgresql.version} com.github.ben-manes.caffeine @@ -289,13 +184,6 @@ de.malkusch.whois-server-list public-suffix-list - ${psl.version} - - - com.google.code.findbugs - jsr305 - - io.dropwizard.metrics @@ -312,92 +200,63 @@ com.izettle dropwizard-metrics-influxdb - ${metrics-influxdb.version} - - - io.dropwizard - dropwizard-metrics - - - org.apache.kafka - kafka-clients - - - - - com.conversantmedia.gdpr - consent-string-sdk-java - ${consent-string-sdk.version} com.iabtcf iabtcf-decoder - ${iabtcf.version} io.prometheus simpleclient_vertx4 - ${vertx.prometheus.version} io.prometheus simpleclient_dropwizard - ${vertx.prometheus.version} com.maxmind.geoip2 geoip2 - ${maxmind-client.version} com.iabgpp iabgpp-encoder - ${gpp-encoder.version} com.google.protobuf protobuf-java-util - ${protobuf.version} com.google.protobuf protobuf-java - ${protobuf.version} io.github.jamsesso json-logic-java - ${json-logic.version} - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter-engine test org.junit.vintage junit-vintage-engine - ${junit-jupiter.version} test org.mockito mockito-core - ${mockito.version} test org.mockito mockito-junit-jupiter - ${mockito.version} test org.assertj assertj-core - ${assertj.version} test @@ -408,19 +267,16 @@ io.vertx vertx-unit - ${vertx.version} test com.github.tomakehurst wiremock-jre8 - ${wiremock.version} test com.iabtcf iabtcf-encoder - ${iabtcf.version} test @@ -486,49 +342,31 @@ io.rest-assured rest-assured - ${restassured.version} test io.rest-assured json-path - ${restassured.version} test io.rest-assured xml-path - ${restassured.version} - test - - - net.bytebuddy - byte-buddy - ${bytebuddy.version} test org.spockframework spock-core - ${spock.version} test - - - org.apache.groovy - groovy - - org.apache.groovy groovy - ${groovy.version} test org.apache.groovy groovy-yaml - ${groovy.version} test @@ -540,43 +378,36 @@ io.vertx vertx-codegen - ${vertx.version} test com.h2database h2 - ${h2.version} test org.testcontainers testcontainers - ${testcontainers.version} test org.testcontainers mockserver - ${testcontainers.version} test org.testcontainers mysql - ${testcontainers.version} test - org.mock-server - mockserver-client-java - ${mockserver.version} + org.testcontainers + postgresql test - org.testcontainers - postgresql - ${testcontainers.version} + org.mock-server + mockserver-client-java test @@ -719,7 +550,9 @@ ${project.basedir}/src/main/proto ${project.basedir}/src/test/proto - com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + + com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + @@ -734,7 +567,9 @@ wget - https://raw.githubusercontent.com/IABTechLab/openrtb-proto-v2/master/openrtb-core/src/main/protobuf/openrtb.proto + + https://raw.githubusercontent.com/IABTechLab/openrtb-proto-v2/master/openrtb-core/src/main/protobuf/openrtb.proto + ${project.basedir}/src/main/proto openrtb.proto @@ -746,7 +581,9 @@ wget - https://raw.githubusercontent.com/MagniteEngineering/xapi-proto/main/src/proto/com/magnite/openrtb/v2/openrtb-xapi.proto + + https://raw.githubusercontent.com/MagniteEngineering/xapi-proto/main/src/proto/com/magnite/openrtb/v2/openrtb-xapi.proto + ${project.basedir}/src/main/proto openrtb-xapi.proto diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/container/NetworkServiceContainer.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/container/NetworkServiceContainer.groovy index 2d3cbe8abf0..53faa7165fa 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/container/NetworkServiceContainer.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/container/NetworkServiceContainer.groovy @@ -8,7 +8,6 @@ class NetworkServiceContainer extends MockServerContainer { NetworkServiceContainer(String version) { super(DockerImageName.parse("mockserver/mockserver:mockserver-$version")) - withCommand("-serverPort $PORT -logLevel WARN") } String getHostAndPort() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index e842521e853..935903e8581 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -96,7 +96,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when transmit UFPD activities is allowing requests should leave UFPD fields in request and update proper metrics"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Activities set with generic bidder allowed" def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.defaultActivity) @@ -109,28 +109,31 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -140,7 +143,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when transmit UFPD activities is rejecting requests should remove UFPD fields in request and update disallowed metrics"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Allow activities setup" def activity = Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)]) @@ -154,30 +157,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext - } + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext - and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + } and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() @@ -189,7 +192,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when default activity setting set to false should remove UFPD fields from request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Allow activities setup" def activity = new Activity(defaultAction: false) @@ -200,30 +203,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids } def "PBS auction call when bidder allowed activities have empty condition type should skip this rule and emit an error"() { @@ -232,7 +235,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Activities set for transmit ufpd with bidder allowed without type" def activity = Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(conditions, isAllowed)]) @@ -243,7 +246,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Response should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -261,7 +264,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when first rule allowing in activities should leave UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields field and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Activity rules with same priority" def allowActivity = new ActivityRule(condition: Condition.baseCondition, allow: true) @@ -276,33 +279,36 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids } def "PBS auction call when first rule disallowing in activities should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Activities set for actions with Generic bidder rejected by hierarchy setup" def disallowActivity = new ActivityRule(condition: Condition.baseCondition, allow: false) @@ -317,35 +323,35 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids } def "PBS auction shouldn't allow rule when gppSid not intersect"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = regsGppSid } @@ -368,28 +374,31 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -404,7 +413,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction should allow rule when gppSid intersect"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [USP_V1.intValue] } @@ -427,31 +436,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.eids - !genericBidderRequest.user.geo - !genericBidderRequest.user.data - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.geo + !bidderRequest.user.data + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() @@ -510,6 +518,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -568,7 +579,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.geo !bidderRequest.user.data !bidderRequest.user.ext @@ -638,6 +648,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -689,7 +702,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.geo !bidderRequest.user.data !bidderRequest.user.ext @@ -754,6 +766,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -804,7 +819,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.geo !bidderRequest.user.data !bidderRequest.user.ext @@ -823,7 +837,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation match and rejecting should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -843,29 +857,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: privacyAllowRegulations << [IAB_US_GENERAL, IAB_ALL, ALL] @@ -874,7 +888,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain some part of disallow logic should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -894,29 +908,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: disallowGppLogic << [ @@ -1045,7 +1059,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain some part of disallow logic which violates GPP validation should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -1065,27 +1079,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.eids - !genericBidderRequest.user.data - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + where: disallowGppLogic << [ 'DBABLA~BAAgAAAAAAA.QA', @@ -1099,7 +1115,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [gppSid.intValue] regs.gpp = gppConsent } @@ -1119,29 +1135,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: gppConsent | gppSid @@ -1156,7 +1172,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy modules contain allowing settings should leave UFPD fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1173,29 +1189,32 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) and: "Generic bidder should be called due to positive allow in activities" verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), @@ -1206,7 +1225,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when regs.gpp in request is allowing should leave UFPD fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = regsGpp } @@ -1226,29 +1245,32 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) and: "Generic bidder should be called due to positive allow in activities" verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + where: regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } @@ -1256,7 +1278,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation have duplicate should leave UFPD fields in request and update alerts metrics"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] } @@ -1278,29 +1300,32 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) and: "Generic bidder should be called due to positive allow in activities" verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ALERT_GENERAL] == 1 @@ -1309,7 +1334,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain invalid property should respond with an error"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1328,7 +1353,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Response should contain error" def error = thrown(PrebidServerException) @@ -1340,7 +1365,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1363,27 +1388,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + where: gpcValue | accountLogic false | LogicalRestrictedRule.generateSingleRestrictedRule(OR, [new EqualityValueRule(GPC, NOTICE_PROVIDED)]) @@ -1395,7 +1423,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation match custom requirement should remove UFPD fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def generalBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1419,29 +1447,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(generalBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(generalBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == generalBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: gppConsent | valueRules @@ -1458,7 +1486,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Generic BidRequest with gpp and account setup" def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { ext.prebid.trace = VERBOSE regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent @@ -1486,7 +1514,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Response should contain error" def error = thrown(PrebidServerException) @@ -1501,7 +1529,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when custom privacy regulation with normalizing that match custom config should have empty UFPD fields"() { given: "Generic BidRequest with gpp and account setup" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { ext.prebid.trace = VERBOSE regs.gppSid = [gppSid.intValue] regs.gpp = gppStateConsent.build() @@ -1528,29 +1556,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: gppSid | equalityValueRules | gppStateConsent @@ -1652,25 +1680,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -1705,26 +1736,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() @@ -1758,27 +1789,27 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp call when bidder allowed activities have empty condition type should skip this rule and emit an error"() { @@ -1852,24 +1883,27 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp call when first rule disallowing in activities should remove UFPD fields in request"() { @@ -1902,26 +1936,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp should disallowed rule when header.gpc intersection with condition.gpc"() { @@ -1960,26 +1994,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest, ["Sec-GPC": VALID_VALUE_FOR_GPC_HEADER]) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() @@ -2021,25 +2055,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest, ["Sec-GPC": VALID_VALUE_FOR_GPC_HEADER]) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -2080,26 +2117,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: privacyAllowRegulations << [IAB_US_GENERAL, IAB_ALL, ALL] @@ -2140,26 +2177,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: disallowGppLogic << [ @@ -2320,24 +2357,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.eids - !genericBidderRequest.user.data - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + where: disallowGppLogic << [ 'DBABLA~BAAgAAAAAAA.QA', @@ -2345,7 +2384,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { 'DBABLA~BAAEAAAAAAA.QA', 'DBABLA~BAAIAAAAAAA.QA', 'DBABLA~BAAIAAAAAAA.QA' - ] + ] } def "PBS amp call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { @@ -2383,26 +2422,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: gppConsent | gppSid @@ -2446,25 +2485,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), @@ -2507,25 +2549,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + where: regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } @@ -2568,25 +2613,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ALERT_GENERAL] == 1 @@ -2670,24 +2718,27 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + where: gpcValue | accountLogic false | LogicalRestrictedRule.generateSingleRestrictedRule(OR, [new EqualityValueRule(GPC, NOTICE_PROVIDED)]) @@ -2735,26 +2786,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: gppConsent | valueRules @@ -2864,26 +2915,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: gppSid | equalityValueRules | gppStateConsent @@ -2960,7 +3011,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when transmit UFPD activities is rejecting requests with activityTransition false should remove only UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Allow activities setup" def activity = Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)]) @@ -2976,30 +3027,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Eids fields should have original data" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() diff --git a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy index 826e110299a..538705e3b68 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy @@ -111,7 +111,7 @@ class PrometheusSpec extends BaseSpec { and: "PBS container is prepared" def pbsContainer = new PrebidServerContainer(config) - pbsContainer.setWaitStrategy(Wait.defaultWaitStrategy()) + pbsContainer.waitingFor(Wait.defaultWaitStrategy()) when: "PBS is started" pbsContainer.start() diff --git a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java index 73622242460..c279492e5ed 100644 --- a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java @@ -401,9 +401,9 @@ public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCantBeParsed() { // then assertThat(result.getErrors()).hasSize(1) .containsExactly(BidderError.badServerResponse( - "Failed to decode: Unexpected end-of-input: expected close marker" - + " for Object (start marker at [Source: (String)\"{\"; line: 1, column: 1])\n" - + " at [Source: (String)\"{\"; line: 1, column: 2]")); + "Failed to decode: Unexpected end-of-input: expected close marker for Object (start marker at" + + " [Source: (String)\"{\"; line: 1, column: 1])\n at [Source: (String)\"{\"; line: 1, " + + "column: 2]")); } private static BidderCall givenHttpCall(String body) { From 36bd261b6d19db702e50785dbbb8302748220542 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Fri, 10 May 2024 14:33:07 +0200 Subject: [PATCH 35/62] ZetaGlobalSsp: Revert renaming (#3187) --- src/main/resources/bidder-config/generic.yaml | 4 ++-- .../{zeta-global-ssp.json => zeta_global_ssp.json} | 0 .../java/org/prebid/server/it/ZetaGlobalSspTest.java | 12 ++++++------ .../test-auction-zeta_global_ssp-request.json} | 2 +- .../test-auction-zeta_global_ssp-response.json} | 4 ++-- .../test-zeta_global_ssp-bid-request.json} | 0 .../test-zeta_global_ssp-bid-response.json} | 0 .../org/prebid/server/it/test-application.properties | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) rename src/main/resources/static/bidder-params/{zeta-global-ssp.json => zeta_global_ssp.json} (100%) rename src/test/resources/org/prebid/server/it/openrtb2/{zetaglobalssp/test-auction-zeta-global-ssp-request.json => zeta_global_ssp/test-auction-zeta_global_ssp-request.json} (94%) rename src/test/resources/org/prebid/server/it/openrtb2/{zetaglobalssp/test-auction-zeta-global-ssp-response.json => zeta_global_ssp/test-auction-zeta_global_ssp-response.json} (86%) rename src/test/resources/org/prebid/server/it/openrtb2/{zetaglobalssp/test-zeta-global-ssp-bid-request.json => zeta_global_ssp/test-zeta_global_ssp-bid-request.json} (100%) rename src/test/resources/org/prebid/server/it/openrtb2/{zetaglobalssp/test-zeta-global-ssp-bid-response.json => zeta_global_ssp/test-zeta_global_ssp-bid-response.json} (100%) diff --git a/src/main/resources/bidder-config/generic.yaml b/src/main/resources/bidder-config/generic.yaml index 5c4ab6dd510..172069d1a2e 100644 --- a/src/main/resources/bidder-config/generic.yaml +++ b/src/main/resources/bidder-config/generic.yaml @@ -56,7 +56,7 @@ adapters: - native supported-vendors: vendor-id: 109 - zeta-global-ssp: + zeta_global_ssp: enabled: false endpoint: https://ssp.disqus.com/bid/prebid-server?sid=GET_SID_FROM_ZETA endpoint-compression: gzip @@ -72,7 +72,7 @@ adapters: vendor-id: 833 usersync: enabled: true - cookie-family-name: zeta-global-ssp + cookie-family-name: zeta_global_ssp redirect: url: https://ssp.disqus.com/redirectuser?sid=GET_SID_FROM_ZETA&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&r={{redirect_url}} uid-macro: 'BUYERUID' diff --git a/src/main/resources/static/bidder-params/zeta-global-ssp.json b/src/main/resources/static/bidder-params/zeta_global_ssp.json similarity index 100% rename from src/main/resources/static/bidder-params/zeta-global-ssp.json rename to src/main/resources/static/bidder-params/zeta_global_ssp.json diff --git a/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java b/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java index 074e503b50e..7556d13e67f 100644 --- a/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java +++ b/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java @@ -21,18 +21,18 @@ public class ZetaGlobalSspTest extends IntegrationTest { @Test public void openrtb2AuctionShouldRespondWithBidsFromZetaGlobalSsp() throws IOException, JSONException { // given - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/zeta-global-ssp-exchange")) + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/zeta_global_ssp-exchange")) .withRequestBody(equalToJson( - jsonFrom("openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json"))) + jsonFrom("openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json"))) .willReturn(aResponse().withBody( - jsonFrom("openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json")))); + jsonFrom("openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json")))); // when - final Response response = responseFor("openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json", + final Response response = responseFor("openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json", Endpoint.openrtb2_auction); // then - assertJsonEquals("openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json", response, - singletonList("zeta-global-ssp")); + assertJsonEquals("openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json", response, + singletonList("zeta_global_ssp")); } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json similarity index 94% rename from src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json rename to src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json index 3ed84b4e1ee..0a3824d6e31 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json @@ -12,7 +12,7 @@ ] }, "ext": { - "zeta-global-ssp": {} + "zeta_global_ssp": {} } } ], diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json similarity index 86% rename from src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json rename to src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json index afb9594d84b..802e057bc7a 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json @@ -21,14 +21,14 @@ } } ], - "seat": "zeta-global-ssp", + "seat": "zeta_global_ssp", "group": 0 } ], "cur": "USD", "ext": { "responsetimemillis": { - "zeta-global-ssp": "{{ zeta-global-ssp.response_time_ms }}" + "zeta_global_ssp": "{{ zeta_global_ssp.response_time_ms }}" }, "prebid": { "auctiontimestamp": 1000 diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json similarity index 100% rename from src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json rename to src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json similarity index 100% rename from src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json rename to src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 8112a071772..e4f8a793e55 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -12,8 +12,8 @@ adapters.generic.aliases.infytv.enabled=true adapters.generic.aliases.infytv.endpoint=http://localhost:8090/infytv-exchange adapters.generic.aliases.loopme.enabled=true adapters.generic.aliases.loopme.endpoint=http://localhost:8090/loopme-exchange -adapters.generic.aliases.zeta-global-ssp.enabled=true -adapters.generic.aliases.zeta-global-ssp.endpoint=http://localhost:8090/zeta-global-ssp-exchange +adapters.generic.aliases.zeta_global_ssp.enabled=true +adapters.generic.aliases.zeta_global_ssp.endpoint=http://localhost:8090/zeta_global_ssp-exchange adapters.aceex.enabled=true adapters.aceex.endpoint=http://localhost:8090/aceex-exchange adapters.acuityads.enabled=true From afe72e3d31c8d19af5356e89573a12b763a3ebd1 Mon Sep 17 00:00:00 2001 From: bretg Date: Fri, 10 May 2024 08:34:05 -0400 Subject: [PATCH 36/62] Core: Add switzerland to the default eea-countries (#3186) --- src/main/resources/application.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index e85b4a9de5c..2e7f328a81e 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -194,7 +194,7 @@ host-cookie: max-cookie-size-bytes: 4096 gdpr: enabled: true - eea-countries: at,bg,be,cy,cz,dk,ee,fi,fr,de,gr,hu,ie,it,lv,lt,lu,mt,nl,pl,pt,ro,sk,si,es,se,gb,is,no,li,ai,aw,pt,bm,aq,io,vg,ic,ky,fk,re,mw,gp,gf,yt,pf,tf,gl,pt,ms,an,bq,cw,sx,nc,pn,sh,pm,gs,tc,uk,wf + eea-countries: at,bg,be,cy,cz,dk,ee,fi,fr,de,gr,hu,ie,it,lv,lt,lu,mt,nl,pl,pt,ro,sk,si,es,se,gb,is,no,li,ai,aw,pt,bm,aq,io,vg,ic,ky,fk,re,mw,gp,gf,yt,pf,tf,gl,pt,ms,an,bq,cw,sx,nc,pn,sh,pm,gs,tc,uk,wf,ch vendorlist: default-timeout-ms: 2000 v2: From 00b749ab3dbee8aaed4c13131ab8939af6077a88 Mon Sep 17 00:00:00 2001 From: SerhiiNahornyi Date: Mon, 13 May 2024 12:37:11 +0200 Subject: [PATCH 37/62] Revert "Core: Finish transition period for alias resolving (#2644)" (#3188) --- .../prebid/server/auction/BidResponseCreator.java | 12 +++++++++++- .../settings/model/AccountAuctionEventConfig.java | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/prebid/server/auction/BidResponseCreator.java b/src/main/java/org/prebid/server/auction/BidResponseCreator.java index 273f9f7cbfc..c1ccc7922f9 100644 --- a/src/main/java/org/prebid/server/auction/BidResponseCreator.java +++ b/src/main/java/org/prebid/server/auction/BidResponseCreator.java @@ -35,6 +35,7 @@ import org.prebid.server.auction.model.MultiBidConfig; import org.prebid.server.auction.model.TargetingInfo; import org.prebid.server.auction.model.debug.DebugContext; +import org.prebid.server.auction.requestfactory.Ortb2ImplicitParametersResolver; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderError; @@ -1443,7 +1444,16 @@ private static String channelFromRequest(BidRequest bidRequest) { final ExtRequestPrebid prebid = ext != null ? ext.getPrebid() : null; final ExtRequestPrebidChannel channel = prebid != null ? prebid.getChannel() : null; - return channel != null ? channel.getName() : null; + return channel != null ? recogniseChannelName(channel.getName()) : null; + } + + // TODO: remove alias resolving after transition period + private static String recogniseChannelName(String channelName) { + if (StringUtils.equalsIgnoreCase("pbjs", channelName)) { + return Ortb2ImplicitParametersResolver.WEB_CHANNEL; + } + + return channelName; } private static boolean eventsAllowedByRequest(AuctionContext auctionContext) { diff --git a/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java b/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java index 9f9c7b18e54..3df397c63f8 100644 --- a/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java +++ b/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import lombok.Builder; import lombok.Value; +import org.apache.commons.lang3.StringUtils; import java.util.Collections; import java.util.HashMap; @@ -22,6 +23,14 @@ public Map getEvents() { @JsonAnySetter public void addEvent(String key, Boolean value) { - events.put(key, value); + events.put(resolveKey(key), value); + } + + private static String resolveKey(String key) { + if (StringUtils.equalsIgnoreCase("pbjs", key)) { + return "web"; + } + + return key; } } From 3d42462332f33d00fd61e89ff356995c185d7aca Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 16 May 2024 15:34:46 +0200 Subject: [PATCH 38/62] Adkernel: Unsecured endpoint url (#3109) --- src/main/resources/bidder-config/adkernel.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/adkernel.yaml b/src/main/resources/bidder-config/adkernel.yaml index 210900b4466..8fe685f93e2 100644 --- a/src/main/resources/bidder-config/adkernel.yaml +++ b/src/main/resources/bidder-config/adkernel.yaml @@ -1,6 +1,6 @@ adapters: adkernel: - endpoint: https://pbs.adksrv.com/hb?zone=%s + endpoint: http://pbs.adksrv.com/hb?zone=%s endpoint-compression: gzip meta-info: maintainer-email: prebid-dev@adkernel.com From 51f3f82403e45dc0968836362a50c9d3c3ff0c12 Mon Sep 17 00:00:00 2001 From: CPMStar Date: Thu, 16 May 2024 06:41:30 -0700 Subject: [PATCH 39/62] CPMStar: updated to use iframe based usersync (#3175) --- src/main/resources/bidder-config/cpmstar.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/bidder-config/cpmstar.yaml b/src/main/resources/bidder-config/cpmstar.yaml index d85bf27a51c..a61a8503a81 100644 --- a/src/main/resources/bidder-config/cpmstar.yaml +++ b/src/main/resources/bidder-config/cpmstar.yaml @@ -13,6 +13,10 @@ adapters: vendor-id: 0 usersync: cookie-family-name: cpmstar + iframe: + url: https://server.cpmstar.com/usersync.aspx?ifr=1&gdpr={{gdpr}}&consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} + support-cors: false + uid-macro: '$UID' redirect: url: https://server.cpmstar.com/usersync.aspx?gdpr={{gdpr}}&consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} support-cors: false From 7ce1ecbb46d1489664617e8fe41b8989cb3bdb33 Mon Sep 17 00:00:00 2001 From: SerhiiNahornyi Date: Mon, 20 May 2024 13:08:26 +0200 Subject: [PATCH 40/62] Core: Ortb26 downgrader update (#3196) --- .../down/BidRequestOrtb26To25Converter.java | 276 +------ .../model/request/auction/Audio.groovy | 2 + .../model/request/auction/Content.groovy | 2 + .../model/request/auction/Dooh.groovy | 4 +- .../model/request/auction/DoohExt.groovy | 2 + .../model/request/auction/Publisher.groovy | 2 + .../model/request/auction/Qty.groovy | 2 + .../model/request/auction/RefSettings.groovy | 2 + .../model/request/auction/Refresh.groovy | 2 + .../model/request/auction/Video.groovy | 2 + .../model/response/auction/Bid.groovy | 2 + .../functional/tests/OrtbConverterSpec.groovy | 778 +++++++++--------- .../BidRequestOrtb26To25ConverterTest.java | 151 +--- .../algorix/test-algorix-bid-request.json | 1 + .../test-bidmachine-bid-request.json | 1 + .../test-generic-bid-request.json | 1 + 16 files changed, 443 insertions(+), 787 deletions(-) diff --git a/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java b/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java index 3a968fc8192..43de9dff9a0 100644 --- a/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java +++ b/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java @@ -2,23 +2,16 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.iab.openrtb.request.App; -import com.iab.openrtb.request.Audio; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Content; -import com.iab.openrtb.request.Device; import com.iab.openrtb.request.Eid; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Producer; -import com.iab.openrtb.request.Publisher; import com.iab.openrtb.request.Regs; -import com.iab.openrtb.request.Site; import com.iab.openrtb.request.Source; import com.iab.openrtb.request.SupplyChain; import com.iab.openrtb.request.User; -import com.iab.openrtb.request.Video; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.prebid.server.auction.versionconverter.BidRequestOrtbVersionConverter; import org.prebid.server.json.JacksonMapper; import org.prebid.server.proto.openrtb.ext.FlexibleExtension; @@ -37,9 +30,6 @@ public class BidRequestOrtb26To25Converter implements BidRequestOrtbVersionConve private static final String PREBID_FIELD = "prebid"; private static final String IS_REWARDED_INVENTORY_FIELD = "is_rewarded_inventory"; - private static final Producer EMPTY_PRODUCER = Producer.builder().build(); - private static final Publisher EMPTY_PUBLISHER = Publisher.builder().build(); - private final JacksonMapper mapper; public BidRequestOrtb26To25Converter(JacksonMapper mapper) { @@ -51,15 +41,6 @@ public BidRequest convert(BidRequest bidRequest) { final List imps = bidRequest.getImp(); final List modifiedImps = modifyImps(imps); - final Site site = bidRequest.getSite(); - final Site modifiedSite = modifySite(site); - - final App app = bidRequest.getApp(); - final App modifiedApp = modifyApp(app); - - final Device device = bidRequest.getDevice(); - final Device modifiedDevice = modifyDevice(device); - final User user = bidRequest.getUser(); final User modifiedUser = modifyUser(user); @@ -71,25 +52,13 @@ public BidRequest convert(BidRequest bidRequest) { return ObjectUtils.anyNotNull( modifiedImps, - modifiedSite, - modifiedApp, - modifiedDevice, modifiedUser, - bidRequest.getWlangb(), - bidRequest.getCattax(), - bidRequest.getDooh(), modifiedSource, modifiedRegs) ? bidRequest.toBuilder() .imp(modifiedImps != null ? modifiedImps : imps) - .site(modifiedSite != null ? modifiedSite : site) - .app(modifiedApp != null ? modifiedApp : app) - .device(modifiedDevice != null ? modifiedDevice : device) .user(modifiedUser != null ? modifiedUser : user) - .wlangb(null) - .cattax(null) - .dooh(null) .source(modifiedSource != null ? modifiedSource : source) .regs(modifiedRegs != null ? modifiedRegs : regs) .build() @@ -112,88 +81,10 @@ private List modifyImps(List imps) { } private Imp modifyImp(Imp imp) { - final Video video = imp.getVideo(); - final Video modifiedVideo = modifyVideo(video); - - final Audio audio = imp.getAudio(); - final Audio modifiedAudio = modifyAudio(audio); - - final ObjectNode impExt = imp.getExt(); - final ObjectNode modifiedImpExt = modifyImpExt(impExt, imp.getRwdd()); - - return ObjectUtils.anyNotNull(modifiedVideo, - modifiedAudio, - imp.getSsai(), - imp.getQty(), - imp.getDt(), - imp.getRefresh(), - modifiedImpExt) - - ? imp.toBuilder() - .video(modifiedVideo != null ? modifiedVideo : video) - .audio(modifiedAudio != null ? modifiedAudio : audio) - .rwdd(null) - .ssai(null) - .qty(null) - .dt(null) - .refresh(null) - .ext(modifiedImpExt != null ? modifiedImpExt : impExt) - .build() - - : null; - } - - private static Video modifyVideo(Video video) { - if (video == null) { - return null; - } - - return ObjectUtils.anyNotNull( - video.getMaxseq(), - video.getPoddur(), - video.getPodid(), - video.getPodseq(), - video.getRqddurs(), - video.getSlotinpod(), - video.getMincpmpersec()) - - ? video.toBuilder() - .maxseq(null) - .poddur(null) - .podid(null) - .podseq(null) - .rqddurs(null) - .slotinpod(null) - .mincpmpersec(null) - .build() - - : null; - } - - private static Audio modifyAudio(Audio audio) { - if (audio == null) { - return null; - } - - return ObjectUtils.anyNotNull( - audio.getPoddur(), - audio.getRqddurs(), - audio.getPodid(), - audio.getPodseq(), - audio.getSlotinpod(), - audio.getMincpmpersec(), - audio.getMaxseq()) - - ? audio.toBuilder() - .poddur(null) - .rqddurs(null) - .podid(null) - .podseq(null) - .slotinpod(null) - .mincpmpersec(null) - .maxseq(null) - .build() + final ObjectNode modifiedImpExt = modifyImpExt(imp.getExt(), imp.getRwdd()); + return modifiedImpExt != null + ? imp.toBuilder().ext(modifiedImpExt).build() : null; } @@ -216,160 +107,25 @@ private ObjectNode modifyImpExt(ObjectNode impExt, Integer rewarded) { return copy; } - private static Site modifySite(Site site) { - if (site == null) { - return null; - } - - final Publisher publisher = site.getPublisher(); - final Publisher modifiedPublisher = modifyPublisher(publisher); - - final Content content = site.getContent(); - final Content modifiedContent = modifyContent(content); - - return ObjectUtils.anyNotNull( - site.getCattax(), - site.getInventorypartnerdomain(), - modifiedPublisher, - modifiedContent, - site.getKwarray()) - - ? site.toBuilder() - .cattax(null) - .inventorypartnerdomain(null) - .publisher(modifiedPublisher != null ? nullIfEmpty(modifiedPublisher) : publisher) - .content(modifiedContent != null ? nullIfEmpty(modifiedContent) : content) - .kwarray(null) - .build() - - : null; - } - - private static Publisher modifyPublisher(Publisher publisher) { - return publisher != null && publisher.getCattax() != null - ? publisher.toBuilder() - .cattax(null) - .build() - : null; - } - - private static Content modifyContent(Content content) { - if (content == null) { - return null; - } - - final Producer producer = content.getProducer(); - final Producer modifiedProducer = modifyProducer(producer); - - return ObjectUtils.anyNotNull( - modifiedProducer, - content.getCattax(), - content.getKwarray(), - content.getLangb(), - content.getNetwork(), - content.getChannel()) - - ? content.toBuilder() - .producer(modifiedProducer != null ? nullIfEmpty(modifiedProducer) : producer) - .cattax(null) - .kwarray(null) - .langb(null) - .network(null) - .channel(null) - .build() - - : null; - } - - private static Producer modifyProducer(Producer producer) { - return producer != null && producer.getCattax() != null - ? producer.toBuilder() - .cattax(null) - .build() - : null; - } - - private static Producer nullIfEmpty(Producer producer) { - return nullIfEmpty(producer, EMPTY_PRODUCER.equals(producer)); - } - - private static Publisher nullIfEmpty(Publisher publisher) { - return nullIfEmpty(publisher, EMPTY_PUBLISHER.equals(publisher)); - } - - private static Content nullIfEmpty(Content content) { - return nullIfEmpty(content, content.isEmpty()); - } - - private static T nullIfEmpty(T object, boolean isEmpty) { - return isEmpty ? null : object; - } - - private static App modifyApp(App app) { - if (app == null) { - return null; - } - - final Publisher publisher = app.getPublisher(); - final Publisher modifiedPublisher = modifyPublisher(publisher); - - final Content content = app.getContent(); - final Content modifiedContent = modifyContent(content); - - return ObjectUtils.anyNotNull( - app.getCattax(), - app.getInventorypartnerdomain(), - modifiedPublisher, - modifiedContent, - app.getKwarray()) - - ? app.toBuilder() - .cattax(null) - .inventorypartnerdomain(null) - .publisher(modifiedPublisher != null ? nullIfEmpty(modifiedPublisher) : publisher) - .content(modifiedContent != null ? nullIfEmpty(modifiedContent) : content) - .kwarray(null) - .build() - - : null; - } - - private static Device modifyDevice(Device device) { - if (device == null) { - return null; - } - - return ObjectUtils.anyNotNull(device.getSua(), device.getLangb()) - ? device.toBuilder() - .sua(null) - .langb(null) - .build() - : null; - } - private static User modifyUser(User user) { if (user == null) { return null; } - final ExtUser extUser = user.getExt(); - final ExtUser modifiedExtUser = modifyUserExt(extUser, user.getConsent(), user.getEids()); + final List eids = user.getEids(); + final String consent = user.getConsent(); + if (StringUtils.isEmpty(consent) && CollectionUtils.isEmpty(eids)) { + return null; + } - return ObjectUtils.anyNotNull(user.getKwarray(), modifiedExtUser) - ? user.toBuilder() - .kwarray(null) - .consent(null) + return user.toBuilder() .eids(null) - .ext(modifiedExtUser != null ? modifiedExtUser : extUser) - .build() - : null; + .consent(null) + .ext(modifyUserExt(user.getExt(), consent, eids)) + .build(); } private static ExtUser modifyUserExt(ExtUser extUser, String consent, List eids) { - if (consent == null && CollectionUtils.isEmpty(eids)) { - return null; - } - final ExtUser modifiedExtUser = Optional.ofNullable(extUser) .map(ExtUser::toBuilder) .orElseGet(ExtUser::builder) @@ -413,9 +169,7 @@ private static Regs modifyRegs(Regs regs) { final Integer gdpr = regs.getGdpr(); final String usPrivacy = regs.getUsPrivacy(); - final String gpp = regs.getGpp(); - final List gppSid = regs.getGppSid(); - if (gdpr == null && usPrivacy == null && gpp == null && gppSid == null) { + if (gdpr == null && usPrivacy == null) { return null; } @@ -428,8 +182,6 @@ private static Regs modifyRegs(Regs regs) { return regs.toBuilder() .gdpr(null) .usPrivacy(null) - .gpp(null) - .gppSid(null) .ext(extRegs) .build(); } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Audio.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Audio.groovy index 9fd950aaf21..57d9bbd40ee 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Audio.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Audio.groovy @@ -1,8 +1,10 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Audio { List mimes diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Content.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Content.groovy index 9634910fb02..7b49458a5fc 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Content.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Content.groovy @@ -1,9 +1,11 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Content { String id diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Dooh.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Dooh.groovy index b5cefe73339..321d7e53585 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Dooh.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Dooh.groovy @@ -2,13 +2,15 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) +@EqualsAndHashCode class Dooh { - + String id String name List venueType diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/DoohExt.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/DoohExt.groovy index d7a2bcee7b8..1654b806d5c 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/DoohExt.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/DoohExt.groovy @@ -1,8 +1,10 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class DoohExt { DoohExtData data diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Publisher.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Publisher.groovy index b0778a10cd5..ef0c64fe881 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Publisher.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Publisher.groovy @@ -1,9 +1,11 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Publisher { String id diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Qty.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Qty.groovy index 938b044fd7a..590e232cfb5 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Qty.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Qty.groovy @@ -2,10 +2,12 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) +@EqualsAndHashCode class Qty { BigDecimal multiplier diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/RefSettings.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/RefSettings.groovy index e00ee5ecdf5..c90adf142ae 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/RefSettings.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/RefSettings.groovy @@ -2,10 +2,12 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) +@EqualsAndHashCode class RefSettings { RefType refType diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Refresh.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Refresh.groovy index aee58a890d0..397c9053eaa 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Refresh.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Refresh.groovy @@ -2,10 +2,12 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) +@EqualsAndHashCode class Refresh { List refSettings diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy index 064a5e01b9d..40b32028217 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy @@ -1,8 +1,10 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Video { List mimes diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy index ff4a1933d0d..9346c228932 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.model.response.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.model.request.auction.Asset import org.prebid.server.functional.model.request.auction.Imp @@ -7,6 +8,7 @@ import org.prebid.server.functional.util.ObjectMapperWrapper import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Bid implements ObjectMapperWrapper { String id diff --git a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy index b22ef5438c6..856315e17d2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests +import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.auction.Audio import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Content @@ -8,6 +9,7 @@ import org.prebid.server.functional.model.request.auction.Dooh import org.prebid.server.functional.model.request.auction.DoohExt import org.prebid.server.functional.model.request.auction.Eid import org.prebid.server.functional.model.request.auction.Network +import org.prebid.server.functional.model.request.auction.PrebidStoredRequest import org.prebid.server.functional.model.request.auction.Producer import org.prebid.server.functional.model.request.auction.Publisher import org.prebid.server.functional.model.request.auction.Qty @@ -39,22 +41,24 @@ class OrtbConverterSpec extends BaseSpec { @Shared PrebidServerService prebidServerServiceWithElderOrtb = pbsServiceFactory.getService([(ORTB_PROPERTY_VERSION): "2.5"]) - def "PBS shouldn't move regs to past location when adapter support ortb 2.6"() { + def "PBS shouldn't move regs.{gdpr,usPrivacy} to regs.ext.{gdpr,usPrivacy} when adapter support ortb 2.6"() { given: "Default bid request with regs object" def usPrivacyRandomString = PBSUtils.randomString + def gdpr = 0 def bidRequest = BidRequest.defaultBidRequest.tap { regs = Regs.defaultRegs.tap { - usPrivacy = usPrivacyRandomString + it.usPrivacy = usPrivacyRandomString + it.gdpr = gdpr } } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same regs as on request" + then: "Bidder request should contain the same regs.{gdpr,usPrivacy} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { regs.usPrivacy == usPrivacyRandomString - regs.gdpr == 0 + regs.gdpr == gdpr !regs.ext } } @@ -71,14 +75,14 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same imp.rwdd as on request" + then: "Bidder request should contain the same imp.rwdd as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { imp.first().rwdd == rwdRandomNumber !imp.first().ext.prebid } } - def "PBS shouldn't move eids to past location when adapter support ortb 2.6"() { + def "PBS shouldn't move user.eids to user.ext.eids when adapter support ortb 2.6"() { given: "Default bid request with user.eids" def defaultEids = [Eid.defaultEid] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -90,16 +94,14 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same user.eids as on request" + then: "Bidder request should contain user.eids as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - user.eids.first().source == defaultEids.first().source - user.eids.first().uids.first().id == defaultEids.first().uids.first().id - user.eids.first().uids.first().atype == defaultEids.first().uids.first().atype + user.eids == defaultEids !user.ext } } - def "PBS shouldn't move consent to past location when adapter support ortb 2.6"() { + def "PBS shouldn't move consent to user.ext.consent when adapter support ortb 2.6"() { given: "Default bid request with user.consent" def consentRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -111,14 +113,14 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same user.consent as on request" + then: "Bidder request should contain the same user.consent as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { user.consent == consentRandomString !user.ext } } - def "PBS shouldn't move schain to past location when adapter support ortb 2.6"() { + def "PBS shouldn't move source.schain to source.ext.schain when adapter support ortb 2.6"() { given: "Default bid request with source.schain" def defaultSource = Source.defaultSource def defaultSupplyChain = defaultSource.schain @@ -129,16 +131,9 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same source.schain as on request" + then: "Bidder request should contain the same source.schain as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - source.schain.ver == defaultSupplyChain.ver - source.schain.complete == defaultSupplyChain.complete - source.schain.nodes.first().asi == defaultSupplyChain.nodes.first().asi - source.schain.nodes.first().sid == defaultSupplyChain.nodes.first().sid - source.schain.nodes.first().rid == defaultSupplyChain.nodes.first().rid - source.schain.nodes.first().name == defaultSupplyChain.nodes.first().name - source.schain.nodes.first().domain == defaultSupplyChain.nodes.first().domain - source.schain.nodes.first().hp == defaultSupplyChain.nodes.first().hp + source.schain == defaultSupplyChain !source.ext } } @@ -154,7 +149,7 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same source.schain as on request but should be in source.ext.schain" + then: "Bidder request should contain the same source.schain as on request but should be in source.ext.schain" verifyAll(bidder.getBidderRequest(bidRequest.id)) { source.ext.schain.ver == defaultSupplyChain.ver source.ext.schain.complete == defaultSupplyChain.complete @@ -168,7 +163,7 @@ class OrtbConverterSpec extends BaseSpec { } } - def "PBS should move consent to past location when adapter doesn't support ortb 2.6"() { + def "PBS should move consent to user.ext.consent when adapter doesn't support ortb 2.6"() { given: "Default bid request with user.consent" def consentRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -180,14 +175,14 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same user.consent as on request but should be in user.ext" + then: "Bidder request should contain the same user.consent as on request but should be in user.ext" verifyAll(bidder.getBidderRequest(bidRequest.id)) { user.ext.consent == consentRandomString !user.consent } } - def "PBS should move eids to past location when adapter doesn't support ortb 2.6"() { + def "PBS should move eids to o user.ext.eids when adapter doesn't support ortb 2.6"() { given: "Default bid request with user.eids" def defaultEids = [Eid.defaultEid] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -199,7 +194,7 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same user.eids as on request but should be in user.ext.eids" + then: "Bidder request should contain the same user.eids as on request but should be in user.ext.eids" verifyAll(bidder.getBidderRequest(bidRequest.id)) { user.ext.eids.first().source == defaultEids.first().source user.ext.eids.first().uids.first().id == defaultEids.first().uids.first().id @@ -208,7 +203,7 @@ class OrtbConverterSpec extends BaseSpec { } } - def "PBS should move regs to past location when adapter doesn't support ortb 2.6"() { + def "PBS should move regs to regs.ext.{gdpr,upPrivacy} when adapter doesn't support ortb 2.6"() { given: "Default bid request with regs object" def usPrivacyRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -220,7 +215,7 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same regs object as on request but should be in regs.ext" + then: "Bidder request should contain the same regs object as on request but should be in regs.ext" verifyAll(bidder.getBidderRequest(bidRequest.id)) { regs.ext.usPrivacy == usPrivacyRandomString regs.ext.gdpr == 0 @@ -229,26 +224,24 @@ class OrtbConverterSpec extends BaseSpec { } } - def "PBS should move rewarded video to past location when adapter doesn't support ortb 2.6"() { + def "PBS should copy rewarded video to imp.ext.prebid.isRewardedInventory when adapter support ortb 2.6"() { given: "Default bid request with rwdd" def rwdRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].tap { - rwdd = rwdRandomNumber - } + imp[0].rwdd = rwdRandomNumber } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same imp.rwdd as on request but should be in ext.prebid" + then: "Bidder request should contain the same imp.rwdd as on request but should be also in ext.prebid" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp.first().ext.prebid.isRewardedInventory == rwdRandomNumber - !imp.first().rwdd + imp[0].ext.prebid.isRewardedInventory == rwdRandomNumber + imp[0].rwdd == rwdRandomNumber } } - def "PBS shouldn't remove wlangb when we we support ortb 2.6"() { + def "PBS shouldn't remove wlangb when bidder supports ortb 2.6"() { given: "Default bid request with wlangb" def wlangbRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -258,45 +251,43 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn contain the wlangb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - wlangb == wlangbRandomStrings - } + then: "Bidder request shouldn contain the wlangb as on request" + assert bidder.getBidderRequest(bidRequest.id).wlangb == wlangbRandomStrings } - def "PBS should remove wlangb when we don't support ortb 2.6"() { + def "PBS shouldn't remove wlangb when bidder doesn't support ortb 2.6"() { given: "Default bid request with wlangb" + def wlangbRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { - wlangb = [PBSUtils.randomString] + wlangb = wlangbRandomStrings } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the wlangb as on request" + then: "Bidder request should contain the wlangb as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !wlangb + wlangb == wlangbRandomStrings } } - def "PBS should remove device.langb when we don't support ortb 2.6"() { + def "PBS shouldn't remove device.langb when bidder doesn't support ortb 2.6"() { given: "Default bid request with device.langb" + def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { device = new Device().tap { - langb = PBSUtils.randomString + langb = langbRandomString } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the device.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !device.langb - } + then: "Bidder request should contain the device.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).device.langb == langbRandomString } - def "PBS shouldn't remove device.langb when we support ortb 2.6"() { + def "PBS shouldn't remove device.langb when bidder supports ortb 2.6"() { given: "Default bid request with device.langb" def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -308,30 +299,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the device.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - device.langb == langbRandomString - } + then: "Bidder request should contain the device.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).device.langb == langbRandomString } - def "PBS should remove site.content.langb when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.langb when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.langb" + def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { - langb = PBSUtils.randomString + langb = langbRandomString } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.langb - } + then: "Bidder request should contain the site.content.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.langb == langbRandomString } - def "PBS shouldn't remove site.content.langb when we support ortb 2.6"() { + def "PBS shouldn't remove site.content.langb when bidder supports ortb 2.6"() { given: "Default bid request with site.content.langb" def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -343,30 +331,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.content.langb == langbRandomString - } + then: "Bidder request should contain the site.content.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.langb == langbRandomString } - def "PBS should remove app.content.langb when we don't support ortb 2.6"() { + def "PBS shouldn't remove app.content.langb when bidder doesn't support ortb 2.6"() { given: "Default bid request with app.content.langb" + def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { app.content = Content.defaultContent.tap { - langb = PBSUtils.randomString + langb = langbRandomString } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the app.content.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.content.langb - } + then: "Bidder request should contain the app.content.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).app.content.langb == langbRandomString } - def "PBS shouldn't remove app.content.langb when we support ortb 2.6"() { + def "PBS shouldn't remove app.content.langb when bidder supports ortb 2.6"() { given: "Default bid request with app.content.langb" def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { @@ -378,30 +363,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the app.content.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - app.content.langb == langbRandomString - } + then: "Bidder request should contain the app.content.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).app.content.langb == langbRandomString } - def "PBS should remove site.publisher.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.publisher.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.publisher.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { site.publisher = Publisher.defaultPublisher.tap { - cattax = PBSUtils.randomNumber + cattax = cattaxRandomNumber } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.publisher.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.publisher.cattax - } + then: "Bidder request should contain the site.publisher.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.publisher.cattax == cattaxRandomNumber } - def "PBS shouldn't remove site.publisher.cattax when we support ortb 2.6"() { + def "PBS shouldn't remove site.publisher.cattax when bidder supports ortb 2.6"() { given: "Default bid request with site.publisher.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -413,18 +395,17 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.publisher.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.publisher.cattax == cattaxRandomNumber - } + then: "Bidder request should contain the site.publisher.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.publisher.cattax == cattaxRandomNumber } - def "PBS should remove site.content.producer.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.producer.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.producer.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { producer = Producer.defaultProducer.tap { - cattax = PBSUtils.randomNumber + cattax = cattaxRandomNumber } } } @@ -432,13 +413,11 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.producer.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.producer.cattax - } + then: "Bidder request should contain the site.content.producer.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.producer.cattax == cattaxRandomNumber } - def "PBS shouldn't remove site.content.producer.cattax when we support ortb 2.6"() { + def "PBS shouldn't remove site.content.producer.cattax when bidder supports ortb 2.6"() { given: "Default bid request with site.content.producer.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -452,28 +431,25 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.producer.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.content.producer.cattax == cattaxRandomNumber - } + then: "Bidder request should contain the site.content.producer.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.producer.cattax == cattaxRandomNumber } - def "PBS should remove app.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove app.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with app.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.catTax = PBSUtils.randomNumber + app.catTax = cattaxRandomNumber } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the app.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.catTax - } + then: "Bidder request should contain the app.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).app.catTax == cattaxRandomNumber } - def "PBS shouldn't remove app.cattax when we support ortb 2.6"() { + def "PBS shouldn't remove app.cattax when bidder supports ortb 2.6"() { given: "Default bid request with app.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { @@ -483,28 +459,25 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the app.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - app.catTax == cattaxRandomNumber - } + then: "Bidder request should contain the app.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).app.catTax == cattaxRandomNumber } - def "PBS should remove cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { - cattax = PBSUtils.randomNumber + cattax = cattaxRandomNumber } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !cattax - } + then: "Bidder request should contain the cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).cattax == cattaxRandomNumber } - def "PBS shouldn't remove cattax when we support ortb 2.6"() { + def "PBS shouldn't remove cattax when bidder supports ortb 2.6"() { given: "Default bid request with cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -514,28 +487,25 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - cattax == cattaxRandomNumber - } + then: "Bidder request should contain the cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).cattax == cattaxRandomNumber } - def "PBS should remove site.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { - site.catTax = PBSUtils.randomNumber + site.catTax = cattaxRandomNumber } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.catTax - } + then: "Bidder request should contain the site.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.catTax == cattaxRandomNumber } - def "PBS shouldn't remove site.cattax when we support ortb 2.6"() { + def "PBS shouldn't remove site.cattax when bidder supports ortb 2.6"() { given: "Default bid request with site.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -545,30 +515,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.catTax == cattaxRandomNumber - } + then: "Bidder request should contain the site.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.catTax == cattaxRandomNumber } - def "PBS should remove site.content.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { - cattax = PBSUtils.randomNumber + cattax = cattaxRandomNumber } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.cattax - } + then: "Bidder request should contain the site.content.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.cattax == cattaxRandomNumber } - def "PBS shouldn't remove site.content.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.cattax when bidder supports ortb 2.5"() { given: "Default bid request with site.content.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -580,15 +547,12 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.content.cattax == cattaxRandomNumber - } + then: "Bidder request should contain the site.content.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.cattax == cattaxRandomNumber } - def "PBS should remove imp[0].video.* and keep imp[0].video.plcmt when we don't support ortb 2.6"() { + def "PBS shouldn't remove imp[0].video.* and keep imp[0].video.plcmt when bidder doesn't support ortb 2.6"() { given: "Default bid request with imp[0].video.*" - def placement = PBSUtils.getRandomEnum(VideoPlcmtSubtype) def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].video = Video.defaultVideo.tap { rqddurs = [PBSUtils.randomNumber] @@ -598,69 +562,42 @@ class OrtbConverterSpec extends BaseSpec { podseq = PBSUtils.randomNumber mincpmpersec = PBSUtils.randomDecimal slotinpod = PBSUtils.randomNumber - plcmt = placement + plcmt = PBSUtils.getRandomEnum(VideoPlcmtSubtype) } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "Bidder request shouldn't contain the imp[0].video.* as on request" + then: "Bidder request should contain the imp[0].video.* as on request" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - verifyAll(bidderRequest) { - !imp[0].video.rqddurs - !imp[0].video.maxseq - !imp[0].video.poddur - !imp[0].video.podid - !imp[0].video.podseq - !imp[0].video.mincpmpersec - !imp[0].video.slotinpod - } - - and: "Bidder request should contain the imp[0].video.* as on request" - bidderRequest.imp[0].video.plcmt == placement + assert bidderRequest.imp[0].video == bidRequest.imp[0].video } - def "PBS shouldn't remove imp[0].video.* when we support ortb 2.6"() { + def "PBS shouldn't remove imp[0].video.* when bidder supports ortb 2.6"() { given: "Default bid request with imp[0].video.*" - def rqddursListOfRandomNumber = [PBSUtils.randomNumber] - def maxseqRandomNumber = PBSUtils.randomNumber - def poddurRandomNumber = PBSUtils.randomNumber - def podidRandomNumber = PBSUtils.randomNumber - def podseqRandomNumber = PBSUtils.randomNumber - def mincpmpersecRandomNumber = PBSUtils.randomDecimal - def slotinpodRandomNumber = PBSUtils.randomNumber - def plcmtRandomEnum = PBSUtils.getRandomEnum(VideoPlcmtSubtype) def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].video = Video.defaultVideo.tap { - rqddurs = rqddursListOfRandomNumber - maxseq = maxseqRandomNumber - poddur = poddurRandomNumber - podid = podidRandomNumber - podseq = podseqRandomNumber - mincpmpersec = mincpmpersecRandomNumber - slotinpod = slotinpodRandomNumber - plcmt = plcmtRandomEnum + rqddurs = [PBSUtils.randomNumber] + maxseq = PBSUtils.randomNumber + poddur = PBSUtils.randomNumber + podid = PBSUtils.randomNumber + podseq = PBSUtils.randomNumber + mincpmpersec = PBSUtils.randomDecimal + slotinpod = PBSUtils.randomNumber + plcmt = PBSUtils.getRandomEnum(VideoPlcmtSubtype) } } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the imp[0].video.* as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp[0].video.rqddurs == rqddursListOfRandomNumber - imp[0].video.maxseq == maxseqRandomNumber - imp[0].video.poddur == poddurRandomNumber - imp[0].video.podid == podidRandomNumber - imp[0].video.podseq == podseqRandomNumber - imp[0].video.mincpmpersec == mincpmpersecRandomNumber - imp[0].video.slotinpod == slotinpodRandomNumber - imp[0].video.plcmt == plcmtRandomEnum - } + then: "Bidder request should contain the imp[0].video.* as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].video == bidRequest.imp[0].video } - def "PBS should remove imp[0].audio.* when we don't support ortb 2.6"() { + def "PBS shouldn't remove imp[0].audio.* when bidder doesn't support ortb 2.6"() { given: "Default bid request with imp[0].audio.*" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].audio = Audio.defaultAudio.tap { @@ -677,70 +614,49 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the imp[0].audio.* as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !imp[0].audio.rqddurs - !imp[0].audio.maxseq - !imp[0].audio.poddur - !imp[0].audio.podid - !imp[0].audio.podseq - !imp[0].audio.mincpmpersec - !imp[0].audio.slotinpod - } + then: "Bidder request should contain the imp[0].audio.* as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].audio == bidRequest.imp[0].audio } - def "PBS shouldn't remove imp[0].audio.* when we support ortb 2.6"() { + def "PBS shouldn't remove imp[0].audio.* when bidder supports ortb 2.6"() { given: "Default bid request with imp[0].audio.*" - def rqddursListOfRandomNumber = [PBSUtils.randomNumber] - def maxseqRandomNumber = PBSUtils.randomNumber - def poddurRandomNumber = PBSUtils.randomNumber - def podidRandomNumber = PBSUtils.randomNumber - def podseqRandomNumber = PBSUtils.randomNumber - def mincpmpersecRandomNumber = PBSUtils.randomDecimal - def slotinpodRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].audio = Audio.defaultAudio.tap { - rqddurs = rqddursListOfRandomNumber - maxseq = maxseqRandomNumber - poddur = poddurRandomNumber - podid = podidRandomNumber - podseq = podseqRandomNumber - mincpmpersec = mincpmpersecRandomNumber - slotinpod = slotinpodRandomNumber + rqddurs = [PBSUtils.randomNumber] + maxseq = PBSUtils.randomNumber + poddur = PBSUtils.randomNumber + podid = PBSUtils.randomNumber + podseq = PBSUtils.randomNumber + mincpmpersec = BigDecimal.valueOf(1) + slotinpod = PBSUtils.randomNumber } } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the imp[0].audio.* as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp[0].audio.rqddurs == rqddursListOfRandomNumber - imp[0].audio.maxseq == maxseqRandomNumber - imp[0].audio.poddur == poddurRandomNumber - imp[0].audio.podid == podidRandomNumber - imp[0].audio.podseq == podseqRandomNumber - imp[0].audio.mincpmpersec == mincpmpersecRandomNumber - imp[0].audio.slotinpod == slotinpodRandomNumber - } + then: "Bidder request should contain the imp[0].audio.* as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].audio == bidRequest.imp[0].audio } - def "PBS should remove imp[0].ssai when we don't support ortb 2.6"() { + def "PBS shouldn't remove imp[0].ssai when bidder doesn't support ortb 2.6"() { given: "Default bid request with imp[0].ssai" + def randomSsai = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].ssai = PBSUtils.randomNumber + imp[0].ssai = randomSsai } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the imp[0].ssai as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !imp[0].ssai - } + then: "Bidder request should contain the imp[0].ssai as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].ssai == randomSsai } - def "PBS shouldn't remove imp[0].ssai when we support ortb 2.6"() { + def "PBS shouldn't remove imp[0].ssai when bidder supports ortb 2.6"() { given: "Default bid request with imp[0].ssai" def ssaiRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -750,32 +666,33 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the imp[0].ssai as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp[0].ssai == ssaiRandomNumber - } + then: "Bidder request should contain the imp[0].ssai as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].ssai == ssaiRandomNumber } - def "PBS should remove site.content.{channel, network} when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.{channel, network} when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.{network, channel}" + def defaultChannel = Channel.defaultChannel + def defaultNetwork = Network.defaultNetwork def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { - channel = Channel.defaultChannel - network = Network.defaultNetwork + it.channel = defaultChannel + it.network = defaultNetwork } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.{network, channel} as on request" + then: "Bidder request should contain the site.content.{network, channel} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.channel - !site.content.network + site.content.channel.id == defaultChannel.id + site.content.network.id == defaultNetwork.id } } - def "PBS shouldn't remove site.content.{channel, network} when we support ortb 2.6"() { + def "PBS shouldn't remove site.content.{channel, network} when bidder supports ortb 2.6"() { given: "Default bid request with site.content.{network, channel}" def defaultChannel = Channel.defaultChannel def defaultNetwork = Network.defaultNetwork @@ -789,33 +706,35 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.{channel, network} as on request" + then: "Bidder request should contain the site.content.{channel, network} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { site.content.channel.id == defaultChannel.id site.content.network.id == defaultNetwork.id } } - def "PBS should remove app.content.{channel, network} when we don't support ortb 2.6"() { + def "PBS shouldn't remove app.content.{channel, network} when bidder doesn't support ortb 2.6"() { given: "Default bid request with app.content.{network, channel}" + def defaultChannel = Channel.defaultChannel + def defaultNetwork = Network.defaultNetwork def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { app.content = Content.defaultContent.tap { - channel = Channel.defaultChannel - network = Network.defaultNetwork + channel = defaultChannel + network = defaultNetwork } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the app.content.{network, channel} as on request" + then: "Bidder request should contain the app.content.{network, channel} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.content.channel - !app.content.network + app.content.channel.id == defaultChannel.id + app.content.network.id == defaultNetwork.id } } - def "PBS shouldn't remove app.content.{channel, network} when we support ortb 2.6"() { + def "PBS shouldn't remove app.content.{channel, network} when bidder supports ortb 2.6"() { given: "Default bid request with content.{network, channel}" def defaultChannel = Channel.defaultChannel def defaultNetwork = Network.defaultNetwork @@ -829,29 +748,28 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the app.content.{channel, network} as on request" + then: "Bidder response should contain the app.content.{channel, network} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { app.content.channel.id == defaultChannel.id app.content.network.id == defaultNetwork.id } } - def "PBS should remove site.kwarray when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.kwarray when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.kwarray" + def randomKwArray = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { - site.kwArray = [PBSUtils.randomString] + site.kwArray = randomKwArray } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.kwArray - } + then: "Bidder request should contain the site.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).site.kwArray == randomKwArray } - def "PBS shouldn't remove site.kwarray when we support ortb 2.6"() { + def "PBS shouldn't remove site.kwarray when bidder supports ortb 2.6"() { given: "Default bid request with site.kwarray" def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -861,30 +779,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.kwArray == kwarrayRandomStrings - } + then: "Bidder request should contain the site.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).site.kwArray == kwarrayRandomStrings } - def "PBS should remove site.content.kwarray when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.kwarray when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.kwarray" + def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { - kwarray = [PBSUtils.randomString] + kwarray = kwarrayRandomStrings } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.kwarray - } + then: "Bidder request should contain the site.content.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.kwarray == kwarrayRandomStrings } - def "PBS shouldn't remove site.content.kwarray when we support ortb 2.6"() { + def "PBS shouldn't remove site.content.kwarray when bidder supports ortb 2.6"() { given: "Default bid request with site.content.kwarray" def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -896,28 +811,25 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.content.kwarray == kwarrayRandomStrings - } + then: "Bidder request should contain the site.content.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.kwarray == kwarrayRandomStrings } - def "PBS should remove app.kwarray when we don't support ortb 2.6"() { + def "PBS shouldn't remove app.kwarray when bidder doesn't support ortb 2.6"() { given: "Default bid request with app.kwarray" + def randomKwArray = [PBSUtils.randomString] def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.kwArray = [PBSUtils.randomString] + app.kwArray = randomKwArray } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the app.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.kwArray - } + then: "Bidder request should contain the app.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).app.kwArray == randomKwArray } - def "PBS shouldn't remove app.kwarray when we support ortb 2.6"() { + def "PBS shouldn't remove app.kwarray when bidder supports ortb 2.6"() { given: "Default bid request with app.kwarray" def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { @@ -927,30 +839,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the app.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - app.kwArray == kwarrayRandomStrings - } + then: "Bidder request should contain the app.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).app.kwArray == kwarrayRandomStrings } - def "PBS should remove user.kwarray when we don't support ortb 2.6"() { + def "PBS shouldn't remove user.kwarray when bidder doesn't support ortb 2.6"() { given: "Default bid request with user.kwarray" + def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { user = User.defaultUser.tap { - kwarray = [PBSUtils.randomString] + kwarray = kwarrayRandomStrings } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the user.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !user.kwarray - } + then: "Bidder request shouldn't contain the user.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).user.kwarray == kwarrayRandomStrings } - def "PBS shouldn't remove user.kwarray when we support ortb 2.6"() { + def "PBS shouldn't remove user.kwarray when bidder supports ortb 2.6"() { given: "Default bid request with user.kwarray" def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -962,18 +871,17 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the user.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - user.kwarray == kwarrayRandomStrings - } + then: "Bidder request should contain the user.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).user.kwarray == kwarrayRandomStrings } - def "PBS should remove device.sua when we don't support ortb 2.6"() { + def "PBS shouldn't remove device.sua when bidder doesn't support ortb 2.6"() { given: "Default bid request with device.sua" + def model = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { device = new Device().tap { sua = new UserAgent().tap { - model = PBSUtils.randomString + it.model = model } } } @@ -981,19 +889,17 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the device.sua as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !device.sua - } + then: "Bidder request should contain the device.sua as on request" + assert bidder.getBidderRequest(bidRequest.id).device.sua.model == model } - def "PBS shouldn't remove device.sua when we support ortb 2.6"() { + def "PBS shouldn't remove device.sua when bidder supports ortb 2.6"() { given: "Default bid request with device.sua" - def modelRandomString = PBSUtils.randomString + def model = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { device = new Device().tap { sua = new UserAgent().tap { - model = modelRandomString + it.model = model } } } @@ -1001,10 +907,8 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the device.sua as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - device.sua.model == modelRandomString - } + then: "Bidder request should contain the device.sua as on request" + assert bidder.getBidderRequest(bidRequest.id).device.sua.model == model } def "PBS should pass bid[].{langb, dur, slotinpor, apis, cattax} through to response"() { @@ -1017,12 +921,14 @@ class OrtbConverterSpec extends BaseSpec { def apisRandomNumbers = [PBSUtils.randomNumber] def slotinpodRandomNumber = PBSUtils.randomNumber def cattaxRandomNumber = PBSUtils.randomNumber + def catRandomNumber = [PBSUtils.randomString] def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { seatbid.first().bid.first().langb = langbRandomString seatbid.first().bid.first().dur = durRandomNumber seatbid.first().bid.first().apis = apisRandomNumbers seatbid.first().bid.first().slotinpod = slotinpodRandomNumber seatbid.first().bid.first().cattax = cattaxRandomNumber + seatbid.first().bid.first().cat = catRandomNumber } and: "Set bidder response" @@ -1031,30 +937,32 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" def response = prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the lang, dur, apis, slotinpod, cattax as on request" + then: "Bidder request should contain the lang, dur, apis, slotinpod, cattax,cat as on request" verifyAll(response) { seatbid.first().bid.first().langb == langbRandomString seatbid.first().bid.first().dur == durRandomNumber seatbid.first().bid.first().apis == apisRandomNumbers seatbid.first().bid.first().slotinpod == slotinpodRandomNumber seatbid.first().bid.first().cattax == cattaxRandomNumber + seatbid.first().bid.first().cat == catRandomNumber } } - def "PBS should remove gpp and gppSid when PBS don't support ortb 2.6"() { + def "PBS shouldn't remove gpp and gppSid when PBS don't support ortb 2.6"() { given: "Default bid request with device.sua" + def randomGpp = PBSUtils.randomString + def randomGppSid = [PBSUtils.getRandomNumber(), PBSUtils.getRandomNumber()] def bidRequest = BidRequest.defaultBidRequest.tap { - regs = new Regs(gpp: PBSUtils.randomString, gppSid: [PBSUtils.getRandomNumber(), - PBSUtils.getRandomNumber()]) + regs = new Regs(gpp: randomGpp, gppSid: randomGppSid) } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest shouldn't contain the regs.gpp and regs.gppSid as on request" + then: "BidderRequest should contain the regs.gpp and regs.gppSid as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !regs.gpp - !regs.gppSid + regs.gpp == bidRequest.regs.gpp + regs.gppSid.eachWithIndex { value, i -> bidRequest.regs.gppSid[i] == value } } } @@ -1071,122 +979,114 @@ class OrtbConverterSpec extends BaseSpec { then: "BidderRequest should contain the regs.gpp and regs.gppSid as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { regs.gpp == bidRequest.regs.gpp - regs.gppSid.eachWithIndex { Integer value, int i -> bidRequest.regs.gppSid[i] == value } + regs.gppSid.eachWithIndex { value, i -> bidRequest.regs.gppSid[i] == value } } } - def "PBS should remove imp[0].{refresh/qty/dt} when we don't support ortb 2.6"() { + def "PBS shouldn't remove imp[0].{refresh/qty/dt} when bidder doesn't support ortb 2.6"() { given: "Default bid request with imp[0].{refresh/qty/dt}" + def refresh = new Refresh(count: PBSUtils.randomNumber, refSettings: + [new RefSettings(refType: PBSUtils.getRandomEnum(RefType), minInt: PBSUtils.randomNumber)]) + def qty = new Qty(multiplier: PBSUtils.randomDecimal, sourceType: PBSUtils.getRandomEnum(SourceType), + vendor: PBSUtils.randomString) + def dt = PBSUtils.randomDecimal def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].tap { - refresh = new Refresh(count: PBSUtils.randomNumber, refSettings: [new RefSettings( - refType: PBSUtils.getRandomEnum(RefType), - minInt: PBSUtils.randomNumber)]) - qty = new Qty(multiplier: PBSUtils.randomDecimal, - sourceType: PBSUtils.getRandomEnum(SourceType), - vendor: PBSUtils.randomString) - dt = PBSUtils.randomDecimal + it.refresh = refresh + it.qty = qty + it.dt = dt } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the imp[0].{refresh/qty/dt} as on request" + then: "Bidder request should contain the imp[0].{refresh/qty/dt} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !imp[0].refresh - !imp[0].qty - !imp[0].dt + imp[0].refresh == refresh + imp[0].qty == qty + imp[0].dt == dt } } - def "PBS shouldn't remove imp[0].{refresh/qty/dt} when we support ortb 2.6"() { + def "PBS shouldn't remove imp[0].{refresh/qty/dt} when bidder supports ortb 2.6"() { given: "Default bid request with imp[0].{refresh/qty/dt}" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].tap { - refresh = new Refresh(count: PBSUtils.randomNumber, refSettings: [new RefSettings( - refType: PBSUtils.getRandomEnum(RefType), - minInt: PBSUtils.randomNumber)]) - qty = new Qty(multiplier: PBSUtils.randomDecimal, + it.refresh = new Refresh(count: PBSUtils.randomNumber, refSettings: + [new RefSettings(refType: PBSUtils.getRandomEnum(RefType), minInt: PBSUtils.randomNumber)]) + it.qty = new Qty(multiplier: PBSUtils.randomDecimal, sourceType: PBSUtils.getRandomEnum(SourceType), vendor: PBSUtils.randomString) - dt = PBSUtils.randomDecimal + it.dt = PBSUtils.randomDecimal } } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the imp[0].{refresh/qty/dt} as on request" + then: "Bidder request should contain the imp[0].{refresh/qty/dt} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp[0].refresh.count == bidRequest.imp[0].refresh.count - imp[0].refresh.refSettings[0].refType == bidRequest.imp[0].refresh.refSettings[0].refType - imp[0].refresh.refSettings[0].minInt == bidRequest.imp[0].refresh.refSettings[0].minInt - imp[0].qty.multiplier == bidRequest.imp[0].qty.multiplier - imp[0].qty.sourceType == bidRequest.imp[0].qty.sourceType - imp[0].qty.vendor == bidRequest.imp[0].qty.vendor + imp[0].refresh == bidRequest.imp[0].refresh + imp[0].qty == bidRequest.imp[0].qty imp[0].dt == bidRequest.imp[0].dt } } - def "PBS should remove site.inventoryPartnerDomain when PBS don't support ortb 2.6"() { + def "PBS shouldn't remove site.inventoryPartnerDomain when PBS don't support ortb 2.6"() { given: "Default bid request with site.inventoryPartnerDomain" + def inventoryPartnerDomain = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { - site.inventoryPartnerDomain = PBSUtils.randomString + site.inventoryPartnerDomain = inventoryPartnerDomain } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest shouldn't contain the app.inventoryPartnerDomain as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.inventoryPartnerDomain - } + then: "BidderRequest should contain the app.inventoryPartnerDomain as on request" + assert bidder.getBidderRequest(bidRequest.id).site.inventoryPartnerDomain == inventoryPartnerDomain } def "PBS shouldn't remove site.inventoryPartnerDomain when PBS support ortb 2.6"() { given: "Default bid request with site.inventoryPartnerDomain" + def inventoryPartnerDomain = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { - site.inventoryPartnerDomain = PBSUtils.randomString + site.inventoryPartnerDomain = inventoryPartnerDomain } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) then: "BidderRequest should contain the site.inventoryPartnerDomain as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.inventoryPartnerDomain == bidRequest.site.inventoryPartnerDomain - } + assert bidder.getBidderRequest(bidRequest.id).site.inventoryPartnerDomain == inventoryPartnerDomain } - def "PBS should remove app.inventoryPartnerDomain when PBS don't support ortb 2.6"() { + def "PBS shouldn't remove app.inventoryPartnerDomain when PBS don't support ortb 2.6"() { given: "Default bid request with app.inventoryPartnerDomain" + def inventoryPartnerDomain = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.inventoryPartnerDomain = PBSUtils.randomString + app.inventoryPartnerDomain = inventoryPartnerDomain } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest shouldn't contain the app.inventoryPartnerDomain as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.inventoryPartnerDomain - } + then: "Bidder request should contain the app.inventoryPartnerDomain as on request" + assert bidder.getBidderRequest(bidRequest.id).app.inventoryPartnerDomain == inventoryPartnerDomain } def "PBS shouldn't remove app.inventoryPartnerDomain when PBS support ortb 2.6"() { given: "Default bid request with app.inventoryPartnerDomain" + def inventoryPartnerDomain = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.inventoryPartnerDomain = PBSUtils.randomString + app.inventoryPartnerDomain = inventoryPartnerDomain } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest should contain the app.inventoryPartnerDomain as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - app.inventoryPartnerDomain == bidRequest.app.inventoryPartnerDomain - } + then: "Bidder request should contain the app.inventoryPartnerDomain as on request" + assert bidder.getBidderRequest(bidRequest.id).app.inventoryPartnerDomain == inventoryPartnerDomain } def "PBS should remove bidRequest.dooh when PBS don't support ortb 2.6"() { @@ -1208,10 +1108,8 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest shouldn't contain the bidRequest.dooh as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !dooh - } + then: "Bidder request should contain the bidRequest.dooh as on request" + assert bidder.getBidderRequest(bidRequest.id).dooh == bidRequest.dooh } def "PBS shouldn't remove bidRequest.dooh when PBS support ortb 2.6"() { @@ -1233,18 +1131,8 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest should contain the bidRequest.dooh as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - dooh.id == bidRequest.dooh.id - dooh.name == bidRequest.dooh.name - dooh.venueType == bidRequest.dooh.venueType - dooh.venueTypeTax == bidRequest.dooh.venueTypeTax - dooh.publisher.id == bidRequest.dooh.publisher.id - dooh.domain == bidRequest.dooh.domain - dooh.keywords == bidRequest.dooh.keywords - dooh.content.id == bidRequest.dooh.content.id - dooh.ext.data == bidRequest.dooh.ext.data - } + then: "Bidder request should contain the bidRequest.dooh as on request" + assert bidder.getBidderRequest(bidRequest.id).dooh == bidRequest.dooh } def "PBS shouldn't remove regs.ext.gpc when ortb request support ortb 2.6"() { @@ -1259,10 +1147,8 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same regs as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - regs.ext.gpc == randomGpc - } + then: "Bidder request should contain the same regs as on request" + assert bidder.getBidderRequest(bidRequest.id).regs.ext.gpc == randomGpc } def "PBS shouldn't remove regs.ext.gpc when ortb request doesn't support ortb 2.6"() { @@ -1277,9 +1163,131 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same regs as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - regs.ext.gpc == randomGpc + then: "Bidder request should contain the same regs as on request" + assert bidder.getBidderRequest(bidRequest.id).regs.ext.gpc == randomGpc + } + + def "PBS shouldn't remove video.protocols when ortb request support 2.6"() { + given: "Default bid request with Banner object" + def protocols = [PBSUtils.randomNumber] + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].video = Video.getDefaultVideo().tap { + it.protocols = protocols + } + } + + when: "Requesting PBS auction with ortb 2.6" + prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain video.protocols on request" + assert bidder.getBidderRequest(bidRequest.id).imp[0].video.protocols == protocols + } + + def "PBS shouldn't remove video.protocols when ortb request support 2.5"() { + given: "Default bid request with Banner object" + def protocols = [PBSUtils.randomNumber] + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].video = Video.getDefaultVideo().tap { + it.protocols = protocols + } + } + + when: "Requesting PBS auction with ortb 2.5" + prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain video.protocols on request" + assert bidder.getBidderRequest(bidRequest.id).imp[0].video.protocols == protocols + } + + def "PBS shouldn't remove saetbid[0].bid[].{lang,dur.slotinpod,apis,cat,cattax} when ortb request support 2.5"() { + given: "Default bid request with stored request object" + def storedRequestId = PBSUtils.randomString + def bidRequest = BidRequest.defaultBidRequest.tap { + ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) + } + + and: "Save storedRequest into DB" + def storedRequest = StoredRequest.getStoredRequest(bidRequest) + storedRequestDao.save(storedRequest) + + and: "Default bidder response" + def langb = PBSUtils.randomString + def dur = PBSUtils.randomNumber + def slotinpod = PBSUtils.randomNumber + def apis = [PBSUtils.randomNumber] + def cat = [PBSUtils.randomString] + def cattax = PBSUtils.randomNumber + def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + seatbid[0].bid[0].tap { + it.langb = langb + it.dur = dur + it.slotinpod = slotinpod + it.apis = apis + it.cat = cat + it.cattax = cattax + } + } + + and: "Set bidder response" + bidder.setResponse(bidRequest.id, bidResponse) + + when: "Requesting PBS auction with ortb 2.5" + def response = prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain seat[0].bid[0].{langb,dur,slotinpod,apis,cattax,cat} on request" + verifyAll(response.seatbid[0].bid[0]) { + it.langb == langb + it.dur == dur + it.slotinpod == slotinpod + it.apis == apis + it.cattax == cattax + it.cat == cat + } + } + + def "PBS shouldn't remove saetbid[0].bid[].{lang,dur.slotinpod,apis,cat,cattax} when ortb request support 2.6"() { + given: "Default bid request with stored request object" + def storedRequestId = PBSUtils.randomString + def bidRequest = BidRequest.defaultBidRequest.tap { + ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) + } + + and: "Save storedRequest into DB" + def storedRequest = StoredRequest.getStoredRequest(bidRequest) + storedRequestDao.save(storedRequest) + + and: "Default bidder response " + def langb = PBSUtils.randomString + def dur = PBSUtils.randomNumber + def slotinpod = PBSUtils.randomNumber + def apis = [PBSUtils.randomNumber] + def cat = [PBSUtils.randomString] + def cattax = PBSUtils.randomNumber + def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + seatbid[0].bid[0].tap { + it.langb = langb + it.dur = dur + it.slotinpod = slotinpod + it.apis = apis + it.cattax = cattax + it.cat = cat + } + } + + and: "Set bidder response" + bidder.setResponse(bidRequest.id, bidResponse) + + when: "Requesting PBS auction with ortb 2.6" + def response = prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain seat[0].bid[0].{langb,dur,slotinpod,apis,cattax,cat} on request" + verifyAll(response.seatbid[0].bid[0]) { + it.langb == langb + it.dur == dur + it.slotinpod == slotinpod + it.apis == apis + it.cattax == cattax + it.cat == cat } } } diff --git a/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java b/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java index 5dd9ef12906..f485fad913d 100644 --- a/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java +++ b/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java @@ -1,28 +1,13 @@ package org.prebid.server.auction.versionconverter.down; import com.fasterxml.jackson.databind.node.TextNode; -import com.iab.openrtb.request.App; -import com.iab.openrtb.request.Audio; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Channel; -import com.iab.openrtb.request.Content; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Dooh; import com.iab.openrtb.request.Eid; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Network; -import com.iab.openrtb.request.Producer; -import com.iab.openrtb.request.Publisher; -import com.iab.openrtb.request.Qty; -import com.iab.openrtb.request.RefSettings; -import com.iab.openrtb.request.Refresh; import com.iab.openrtb.request.Regs; -import com.iab.openrtb.request.Site; import com.iab.openrtb.request.Source; import com.iab.openrtb.request.SupplyChain; import com.iab.openrtb.request.User; -import com.iab.openrtb.request.UserAgent; -import com.iab.openrtb.request.Video; import org.junit.Test; import org.prebid.server.VertxTest; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; @@ -30,16 +15,14 @@ import org.prebid.server.proto.openrtb.ext.request.ExtSource; import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import java.math.BigDecimal; -import java.util.List; import java.util.Map; import java.util.function.UnaryOperator; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; +import static java.util.function.UnaryOperator.identity; import static org.assertj.core.api.Assertions.assertThat; -import static org.prebid.server.hooks.v1.PayloadUpdate.identity; public class BidRequestOrtb26To25ConverterTest extends VertxTest { @@ -60,20 +43,17 @@ public void convertShouldMoveImpsRwdd() { // then assertThat(result) .extracting(BidRequest::getImp) - .satisfies(imps -> { - assertThat(imps) - .extracting(Imp::getRwdd) - .containsOnlyNulls(); - assertThat(imps) - .extracting(Imp::getExt) - .containsExactly( - null, - mapper.valueToTree(Map.of("prebid", Map.of("is_rewarded_inventory", 1))), - mapper.valueToTree(Map.of( - "prebid", Map.of( - "is_rewarded_inventory", 0, - "someField", "someValue")))); - }); + .satisfies(imps -> + assertThat(imps) + .extracting(Imp::getExt) + .containsExactly( + null, + mapper.valueToTree(Map.of("prebid", Map.of("is_rewarded_inventory", 1))), + mapper.valueToTree(Map.of( + "prebid", Map.of( + "is_rewarded_inventory", 0, + "someField", "someValue")))) + ); } @Test @@ -145,25 +125,6 @@ public void convertShouldMoveRegsData() { }); } - @Test - public void convertShouldRemoveRegsGppData() { - // given - final BidRequest bidRequest = givenBidRequest(request -> request.regs( - Regs.builder() - .gpp("gppValue") - .gppSid(List.of(1, 2, 3)) - .build())); - - // when - final BidRequest result = target.convert(bidRequest); - - // then - assertThat(result) - .extracting(BidRequest::getRegs) - .extracting(Regs::getGpp, Regs::getGppSid) - .containsOnlyNulls(); - } - @Test public void convertShouldMoveUserData() { // given @@ -196,94 +157,6 @@ public void convertShouldMoveUserData() { }); } - @Test - public void convertShouldRemoveFieldsThatAreNotInOrtb25() { - // given - final BidRequest bidRequest = givenBidRequest(request -> request - .imp(singletonList(givenImp(imp -> imp - .video(Video.builder() - .maxseq(1) - .poddur(1) - .podid(1) - .podseq(1) - .rqddurs(singletonList(1)) - .slotinpod(1) - .mincpmpersec(BigDecimal.ONE) - .build()) - .audio(Audio.builder() - .poddur(1) - .rqddurs(singletonList(1)) - .podid(1) - .podseq(1) - .slotinpod(1) - .mincpmpersec(BigDecimal.ONE) - .maxseq(1) - .build()) - .refresh(Refresh.builder().count(1) - .refsettings(singletonList(RefSettings.builder().minint(1).build())) - .build()) - .qty(Qty.builder().multiplier(BigDecimal.ONE).build()) - .dt(0.1) - .ssai(1)))) - .site(Site.builder() - .cattax(1) - .inventorypartnerdomain("inventorypartnerdomain") - .publisher(Publisher.builder().cattax(1).build()) - .content(Content.builder() - .producer(Producer.builder().cattax(1).build()) - .cattax(1) - .kwarray(singletonList("kwarray")) - .langb("langb") - .network(Network.builder().build()) - .channel(Channel.builder().build()) - .build()) - .kwarray(singletonList("kwarray")) - .build()) - .app(App.builder() - .cattax(1) - .inventorypartnerdomain("inventorypartnerdomain") - .publisher(Publisher.builder().cattax(1).build()) - .content(Content.builder() - .producer(Producer.builder().cattax(1).build()) - .cattax(1) - .kwarray(singletonList("kwarray")) - .langb("langb") - .network(Network.builder().build()) - .channel(Channel.builder().build()) - .build()) - .kwarray(singletonList("kwarray")) - .build()) - .dooh(Dooh.builder().build()) - .device(Device.builder().sua(UserAgent.builder().build()).langb("langb").build()) - .user(User.builder().kwarray(singletonList("kwarray")).build()) - .wlangb(singletonList("wlangb")) - .cattax(1)); - - // when - final BidRequest result = target.convert(bidRequest); - - // then - assertThat(result).satisfies(request -> { - assertThat(result.getImp()) - .hasSize(1) - .allSatisfy(imp -> { - assertThat(imp.getVideo()).isEqualTo(Video.builder().build()); - assertThat(imp.getAudio()).isEqualTo(Audio.builder().build()); - assertThat(imp.getSsai()).isNull(); - assertThat(imp.getRefresh()).isNull(); - assertThat(imp.getQty()).isNull(); - assertThat(imp.getDt()).isNull(); - }); - - assertThat(request.getSite()).isEqualTo(Site.builder().build()); - assertThat(request.getApp()).isEqualTo(App.builder().build()); - assertThat(request.getDevice()).isEqualTo(Device.builder().build()); - assertThat(request.getUser()).isEqualTo(User.builder().build()); - assertThat(request.getWlangb()).isNull(); - assertThat(request.getCattax()).isNull(); - }); - } - private static BidRequest givenBidRequest(UnaryOperator bidRequestCustomizer) { return bidRequestCustomizer.apply(BidRequest.builder().imp(emptyList())).build(); } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/algorix/test-algorix-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/algorix/test-algorix-bid-request.json index 348d06b2871..db4e61dfe97 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/algorix/test-algorix-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/algorix/test-algorix-bid-request.json @@ -4,6 +4,7 @@ { "id": "imp_id", "secure": 1, + "rwdd": 1, "banner": { "w": 300, "h": 250 diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bidmachine/test-bidmachine-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/bidmachine/test-bidmachine-bid-request.json index 755609f67df..850609a42f2 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/bidmachine/test-bidmachine-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/bidmachine/test-bidmachine-bid-request.json @@ -4,6 +4,7 @@ { "id": "imp_id", "secure": 1, + "rwdd": 1, "banner": { "w": 320, "h": 480, diff --git a/src/test/resources/org/prebid/server/it/openrtb2/generic_core_functionality/test-generic-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/generic_core_functionality/test-generic-bid-request.json index b4895753bb0..697daed2ae1 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/generic_core_functionality/test-generic-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/generic_core_functionality/test-generic-bid-request.json @@ -38,6 +38,7 @@ "tid" : "${json-unit.any-string}" }, "regs" : { + "gpp_sid" : [ 1, 3, 7 ], "ext" : { "gdpr" : 0, "dsa": { From b318b1afd8c424c23e8d3d8ee2cb76313acfab34 Mon Sep 17 00:00:00 2001 From: serhiinahornyi Date: Tue, 21 May 2024 11:16:16 +0200 Subject: [PATCH 41/62] Prebid Server prepare release 3.0.0 --- extra/bundle/pom.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- extra/modules/ortb2-blocking/pom.xml | 2 +- extra/modules/pb-richmedia-filter/pom.xml | 2 +- extra/modules/pom.xml | 2 +- extra/pom.xml | 7 +++---- pom.xml | 5 ++--- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 454a9b0de5b..1b80b4bad74 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0-SNAPSHOT + 3.0.0 ../../extra/pom.xml diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 7e1bfc91bd9..d8ad554621e 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0-SNAPSHOT + 3.0.0 confiant-ad-quality diff --git a/extra/modules/ortb2-blocking/pom.xml b/extra/modules/ortb2-blocking/pom.xml index 2fe803c1ba6..c047c8b56a7 100644 --- a/extra/modules/ortb2-blocking/pom.xml +++ b/extra/modules/ortb2-blocking/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0-SNAPSHOT + 3.0.0 ortb2-blocking diff --git a/extra/modules/pb-richmedia-filter/pom.xml b/extra/modules/pb-richmedia-filter/pom.xml index 436fd2a33d3..c63873559f9 100644 --- a/extra/modules/pb-richmedia-filter/pom.xml +++ b/extra/modules/pb-richmedia-filter/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0-SNAPSHOT + 3.0.0 pb-richmedia-filter diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 36014ede43a..5b909a6ae42 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0-SNAPSHOT + 3.0.0 ../../extra/pom.xml diff --git a/extra/pom.xml b/extra/pom.xml index dc0d1be2c02..2115ae9ea20 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -1,18 +1,17 @@ - + 4.0.0 org.prebid prebid-server-aggregator - 3.0.0-SNAPSHOT + 3.0.0 pom https://github.com/prebid/prebid-server-java scm:git:git@github.com:prebid/prebid-server-java.git scm:git:git@github.com:prebid/prebid-server-java.git - HEAD + 3.0.0 diff --git a/pom.xml b/pom.xml index d01e20873bd..f20b2fba6df 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 org.prebid prebid-server-aggregator - 3.0.0-SNAPSHOT + 3.0.0 extra/pom.xml From 337c6a0e26ff02fed86c1a7262a253b7652ca098 Mon Sep 17 00:00:00 2001 From: serhiinahornyi Date: Tue, 21 May 2024 11:18:58 +0200 Subject: [PATCH 42/62] Prebid Server prepare for next development iteration --- extra/bundle/pom.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- extra/modules/ortb2-blocking/pom.xml | 2 +- extra/modules/pb-richmedia-filter/pom.xml | 2 +- extra/modules/pom.xml | 2 +- extra/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 1b80b4bad74..7c515927304 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0 + 3.1.0-SNAPSHOT ../../extra/pom.xml diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index d8ad554621e..924ce91e085 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0 + 3.1.0-SNAPSHOT confiant-ad-quality diff --git a/extra/modules/ortb2-blocking/pom.xml b/extra/modules/ortb2-blocking/pom.xml index c047c8b56a7..df0a826e5c9 100644 --- a/extra/modules/ortb2-blocking/pom.xml +++ b/extra/modules/ortb2-blocking/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0 + 3.1.0-SNAPSHOT ortb2-blocking diff --git a/extra/modules/pb-richmedia-filter/pom.xml b/extra/modules/pb-richmedia-filter/pom.xml index c63873559f9..b402096e626 100644 --- a/extra/modules/pb-richmedia-filter/pom.xml +++ b/extra/modules/pb-richmedia-filter/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0 + 3.1.0-SNAPSHOT pb-richmedia-filter diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 5b909a6ae42..0ec5be33e7e 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0 + 3.1.0-SNAPSHOT ../../extra/pom.xml diff --git a/extra/pom.xml b/extra/pom.xml index 2115ae9ea20..98b9787d161 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -4,14 +4,14 @@ org.prebid prebid-server-aggregator - 3.0.0 + 3.1.0-SNAPSHOT pom https://github.com/prebid/prebid-server-java scm:git:git@github.com:prebid/prebid-server-java.git scm:git:git@github.com:prebid/prebid-server-java.git - 3.0.0 + HEAD diff --git a/pom.xml b/pom.xml index f20b2fba6df..dfe9152361b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0 + 3.1.0-SNAPSHOT extra/pom.xml From 66fde3ecf99aaf9c0f2270911b5273a97d47a0fc Mon Sep 17 00:00:00 2001 From: onetag-dev <38786435+onetag-dev@users.noreply.github.com> Date: Tue, 21 May 2024 14:41:20 +0200 Subject: [PATCH 43/62] Onetag: Add redirect userSync support (#3100) --- src/main/resources/bidder-config/onetag.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/bidder-config/onetag.yaml b/src/main/resources/bidder-config/onetag.yaml index d761209a15d..34f2d844158 100644 --- a/src/main/resources/bidder-config/onetag.yaml +++ b/src/main/resources/bidder-config/onetag.yaml @@ -21,3 +21,7 @@ adapters: url: https://onetag-sys.com/usync/?redir={{redirect_url}}&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}} support-cors: false uid-macro: '${USER_TOKEN}' + redirect: + url: https://onetag-sys.com/usync/?tag=img&redir={{redirect_url}}&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}} + support-cors: false + uid-macro: '${USER_TOKEN}' From 5991bcf33de3c90552b56078a10c68ebf2c37d67 Mon Sep 17 00:00:00 2001 From: osulzhenko <125548596+osulzhenko@users.noreply.github.com> Date: Tue, 21 May 2024 15:42:50 +0300 Subject: [PATCH 44/62] Roulax: Add Adapter (#3094) --- .../server/bidder/roulax/RoulaxBidder.java | 122 +++++++++ .../ext/request/roulax/ExtImpRoulax.java | 14 + .../config/bidder/RoulaxConfiguration.java | 41 +++ src/main/resources/bidder-config/roulax.yaml | 15 ++ .../static/bidder-params/roulax.json | 22 ++ .../bidder/roulax/RoulaxBidderTest.java | 253 ++++++++++++++++++ .../java/org/prebid/server/it/RoulaxTest.java | 40 +++ .../roulax/test-auction-roulax-request.json | 24 ++ .../roulax/test-auction-roulax-response.json | 34 +++ .../roulax/test-roulax-bid-request.json | 57 ++++ .../roulax/test-roulax-bid-response.json | 16 ++ .../server/it/test-application.properties | 2 + 12 files changed, 640 insertions(+) create mode 100644 src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/request/roulax/ExtImpRoulax.java create mode 100644 src/main/java/org/prebid/server/spring/config/bidder/RoulaxConfiguration.java create mode 100644 src/main/resources/bidder-config/roulax.yaml create mode 100644 src/main/resources/static/bidder-params/roulax.json create mode 100644 src/test/java/org/prebid/server/bidder/roulax/RoulaxBidderTest.java create mode 100644 src/test/java/org/prebid/server/it/RoulaxTest.java create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-response.json diff --git a/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java b/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java new file mode 100644 index 00000000000..fc887c21f97 --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java @@ -0,0 +1,122 @@ +package org.prebid.server.bidder.roulax; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.prebid.server.bidder.Bidder; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.exception.PreBidException; +import org.prebid.server.json.DecodeException; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.roulax.ExtImpRoulax; +import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.util.BidderUtil; +import org.prebid.server.util.HttpUtil; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +public class RoulaxBidder implements Bidder { + + private final String endpointUrl; + private final JacksonMapper mapper; + + private static final String PUBLISHER_PATH_MACRO = "{{PublisherID}}"; + private static final String ACCOUNT_ID_MACRO = "{{AccountID}}"; + + private static final TypeReference> ROULAX_EXT_TYPE_REFERENCE = + new TypeReference<>() { + }; + + public RoulaxBidder(String endpointUrl, JacksonMapper mapper) { + this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); + this.mapper = Objects.requireNonNull(mapper); + } + + @Override + public Result>> makeHttpRequests(BidRequest bidRequest) { + try { + final ExtImpRoulax extImpRoulax = parseImpExt(bidRequest.getImp().get(0)); + return Result.withValue(BidderUtil.defaultRequest(bidRequest, resolveEndpoint(extImpRoulax), mapper)); + } catch (PreBidException e) { + return Result.withError(BidderError.badInput(e.getMessage())); + } + } + + private ExtImpRoulax parseImpExt(Imp imp) { + try { + return mapper.mapper().convertValue(imp.getExt(), ROULAX_EXT_TYPE_REFERENCE).getBidder(); + } catch (IllegalArgumentException e) { + throw new PreBidException("Failed to deserialize Roulax extension: " + e.getMessage()); + } + } + + private String resolveEndpoint(ExtImpRoulax extImpRoulax) { + return endpointUrl + .replace(PUBLISHER_PATH_MACRO, StringUtils.defaultString(extImpRoulax.getPublisherPath()).trim()) + .replace(ACCOUNT_ID_MACRO, StringUtils.defaultString(extImpRoulax.getPid()).trim()); + } + + @Override + public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + try { + final List errors = new ArrayList<>(); + final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); + return Result.of(extractBids(bidResponse, errors), errors); + } catch (DecodeException | PreBidException e) { + return Result.withError(BidderError.badServerResponse(e.getMessage())); + } + } + + private static List extractBids(BidResponse bidResponse, List errors) { + if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { + return Collections.emptyList(); + } + + return bidResponse.getSeatbid().stream() + .filter(Objects::nonNull) + .map(SeatBid::getBid) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .map(bid -> makeBid(bid, bidResponse.getCur(), errors)) + .filter(Objects::nonNull) + .toList(); + } + + private static BidderBid makeBid(Bid bid, String currency, List errors) { + try { + return BidderBid.of(bid, getBidType(bid), currency); + } catch (PreBidException e) { + errors.add(BidderError.badServerResponse(e.getMessage())); + return null; + } + } + + private static BidType getBidType(Bid bid) { + final Integer markupType = bid.getMtype(); + if (markupType == null) { + throw new PreBidException("Missing MType for bid: " + bid.getId()); + } + return switch (markupType) { + case 1 -> BidType.banner; + case 2 -> BidType.video; + case 4 -> BidType.xNative; + default -> throw new PreBidException( + "Unable to fetch mediaType in impID: %s, mType: %d".formatted(bid.getImpid(), bid.getMtype())); + }; + } +} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/roulax/ExtImpRoulax.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/roulax/ExtImpRoulax.java new file mode 100644 index 00000000000..11d69e39674 --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/roulax/ExtImpRoulax.java @@ -0,0 +1,14 @@ +package org.prebid.server.proto.openrtb.ext.request.roulax; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Value; + +@Value(staticConstructor = "of") +public class ExtImpRoulax { + + @JsonProperty("PublisherPath") + String publisherPath; + + @JsonProperty("Pid") + String pid; +} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RoulaxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RoulaxConfiguration.java new file mode 100644 index 00000000000..01ba4e70e3d --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/bidder/RoulaxConfiguration.java @@ -0,0 +1,41 @@ +package org.prebid.server.spring.config.bidder; + +import org.prebid.server.bidder.BidderDeps; +import org.prebid.server.bidder.roulax.RoulaxBidder; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; +import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; +import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; +import org.prebid.server.spring.env.YamlPropertySourceFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import javax.validation.constraints.NotBlank; + +@Configuration +@PropertySource(value = "classpath:/bidder-config/roulax.yaml", factory = YamlPropertySourceFactory.class) +public class RoulaxConfiguration { + + private static final String BIDDER_NAME = "roulax"; + + @Bean("roulaxConfigurationProperties") + @ConfigurationProperties("adapters.roulax") + BidderConfigurationProperties configurationProperties() { + return new BidderConfigurationProperties(); + } + + @Bean + BidderDeps roulaxBidderDeps(BidderConfigurationProperties roulaxConfigurationProperties, + @NotBlank @Value("${external-url}") String externalUrl, + JacksonMapper mapper) { + + return BidderDepsAssembler.forBidder(BIDDER_NAME) + .withConfig(roulaxConfigurationProperties) + .usersyncerCreator(UsersyncerCreator.create(externalUrl)) + .bidderCreator(config -> new RoulaxBidder(config.getEndpoint(), mapper)) + .assemble(); + } +} diff --git a/src/main/resources/bidder-config/roulax.yaml b/src/main/resources/bidder-config/roulax.yaml new file mode 100644 index 00000000000..b9055e5df4a --- /dev/null +++ b/src/main/resources/bidder-config/roulax.yaml @@ -0,0 +1,15 @@ +adapters: + roulax: + endpoint: http://dsp.rcoreads.com/api/{{PublisherID}}?pid={{AccountID}} + meta-info: + maintainer-email: bussiness@roulax.io + app-media-types: + - banner + - video + - native + site-media-types: + - banner + - video + - native + supported-vendors: + vendor-id: 0 diff --git a/src/main/resources/static/bidder-params/roulax.json b/src/main/resources/static/bidder-params/roulax.json new file mode 100644 index 00000000000..ce7af170136 --- /dev/null +++ b/src/main/resources/static/bidder-params/roulax.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Roulax Adapter Params", + "description": "A schema which validates params accepted by the Roulax adapter", + "type": "object", + "properties": { + "Pid": { + "type": "string", + "minLength": 1, + "description": "PID" + }, + "PublisherPath": { + "type": "string", + "minLength": 1, + "description": "PublisherPath" + } + }, + "required": [ + "Pid", + "PublisherPath" + ] +} diff --git a/src/test/java/org/prebid/server/bidder/roulax/RoulaxBidderTest.java b/src/test/java/org/prebid/server/bidder/roulax/RoulaxBidderTest.java new file mode 100644 index 00000000000..a0bea1326a2 --- /dev/null +++ b/src/test/java/org/prebid/server/bidder/roulax/RoulaxBidderTest.java @@ -0,0 +1,253 @@ +package org.prebid.server.bidder.roulax; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import org.junit.Test; +import org.prebid.server.VertxTest; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.HttpResponse; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.roulax.ExtImpRoulax; + +import java.util.List; +import java.util.function.UnaryOperator; + +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.groups.Tuple.tuple; +import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; +import static org.prebid.server.proto.openrtb.ext.response.BidType.video; +import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative; + +public class RoulaxBidderTest extends VertxTest { + + private static final String ENDPOINT_URL = "https://test-url.com/{{PublisherID}}?pid={{AccountID}}"; + + private final RoulaxBidder target = new RoulaxBidder(ENDPOINT_URL, jacksonMapper); + + @Test + public void creationShouldFailOnInvalidEndpointUrl() { + // when and then + assertThatIllegalArgumentException().isThrownBy(() -> new RoulaxBidder("incorrect_url", jacksonMapper)); + } + + @Test + public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { + // given + final BidRequest bidRequest = givenBidRequest(givenInvalidImp()); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).allSatisfy(error -> { + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); + assertThat(error.getMessage()).startsWith("Failed to deserialize Roulax extension:"); + }); + } + + @Test + public void makeHttpRequestsShouldResolveEndpointUrl() { + // given + final Imp imp = givenImp(" testPublisherId ", " testPid "); + final BidRequest bidRequest = givenBidRequest(imp); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()) + .extracting(HttpRequest::getUri) + .containsExactly("https://test-url.com/testPublisherId?pid=testPid"); + assertThat(result.getErrors()).isEmpty(); + } + + @Test + public void makeHttpRequestsShouldResolveEndpointWithPidAndPublisherPathBasedOnFirstImp() { + // given + final BidRequest bidRequest = givenBidRequest( + givenImp("testPublisherPath0", "testPid0"), + givenInvalidImp(), + givenImp("testPublisherPath2", "testPid2"), + givenImp(null, null)); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri, httpRequest -> httpRequest.getPayload().getImp().size()) + .containsExactly( + tuple("https://test-url.com/testPublisherPath0?pid=testPid0", 4)); + assertThat(result.getErrors()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { + // given + final BidderCall httpCall = givenHttpCall("invalid"); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).allSatisfy(error -> { + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(error.getMessage()).startsWith("Failed to decode: Unrecognized token"); + }); + } + + @Test + public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(mapper.writeValueAsString(null)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnBannerBidIfBannerIsPresentInRequestImp() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(1)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(givenBid(1), banner, "USD")); + } + + @Test + public void makeBidsShouldReturnVideoBidIfVideoIsPresentInRequestImp() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(2)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(givenBid(2), video, "USD")); + } + + @Test + public void makeBidsShouldReturnNativeBidIfNativeIsPresentInRequestImp() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(4)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(givenBid(4), xNative, "USD")); + } + + @Test + public void makeBidsShouldThrowErrorUnableToFetchMediaTypeWhenMTypeUnknownNumber() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(0)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).hasSize(1) + .allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Unable to fetch mediaType in impID: impId, mType: 0"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + }); + } + + @Test + public void makeBidsShouldThrowErrorUnableToFetchMediaTypeWhenMTypeNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(null)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).hasSize(1) + .allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing MType for bid: id"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + }); + } + + private static BidRequest givenBidRequest(Imp... imps) { + return BidRequest.builder().imp(List.of(imps)).build(); + } + + private static Imp givenImp(UnaryOperator impCustomizer) { + return impCustomizer.apply(Imp.builder()).build(); + } + + private static Imp givenImp(String publisherPath, String pid) { + return givenImp(imp -> imp.ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRoulax.of(publisherPath, pid))))); + } + + private static Imp givenInvalidImp() { + return givenImp(imp -> imp.ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))); + } + + private static String givenBidResponse(Bid... bids) throws JsonProcessingException { + return mapper.writeValueAsString(BidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder().bid(List.of(bids)).build())) + .build()); + } + + private static BidderCall givenHttpCall(Bid... bids) throws JsonProcessingException { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, givenBidResponse(bids)), + null); + } + + private static BidderCall givenHttpCall(String body) { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, body), + null); + } + + private static Bid givenBid(Integer mtype) { + return Bid.builder().mtype(mtype).id("id").impid("impId").build(); + } +} diff --git a/src/test/java/org/prebid/server/it/RoulaxTest.java b/src/test/java/org/prebid/server/it/RoulaxTest.java new file mode 100644 index 00000000000..e44ce3c0cb3 --- /dev/null +++ b/src/test/java/org/prebid/server/it/RoulaxTest.java @@ -0,0 +1,40 @@ +package org.prebid.server.it; + +import io.restassured.response.Response; +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.prebid.server.model.Endpoint; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static java.util.Collections.singletonList; + +@RunWith(SpringRunner.class) +public class RoulaxTest extends IntegrationTest { + + @Test + public void openrtb2AuctionShouldRespondWithBidsFromTheRoulaxBidder() throws IOException, JSONException { + // given + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/roulax-exchange/testPublisherPath")) + .withQueryParam("pid", equalTo("testPid")) + .withRequestBody(equalToJson( + jsonFrom("openrtb2/roulax/test-roulax-bid-request.json"))) + .willReturn(aResponse().withBody( + jsonFrom("openrtb2/roulax/test-roulax-bid-response.json")))); + + // when + final Response response = responseFor("openrtb2/roulax/test-auction-roulax-request.json", + Endpoint.openrtb2_auction); + + // then + assertJsonEquals("openrtb2/roulax/test-auction-roulax-response.json", response, + singletonList("roulax")); + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-request.json b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-request.json new file mode 100644 index 00000000000..45800c3e20d --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-request.json @@ -0,0 +1,24 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "roulax": { + "Pid": "testPid", + "PublisherPath": "testPublisherPath" + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-response.json b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-response.json new file mode 100644 index 00000000000..298f141429f --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-response.json @@ -0,0 +1,34 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 3.33, + "crid": "creativeId", + "mtype": 1, + "ext": { + "origbidcpm": 3.33, + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "roulax", + "group": 0 + } + ], + "cur": "USD", + "ext": { + "responsetimemillis": { + "roulax": "{{ roulax.response_time_ms }}" + }, + "prebid": { + "auctiontimestamp": 0 + }, + "tmaxrequest": 5000 + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-request.json new file mode 100644 index 00000000000..548a8950eb7 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-request.json @@ -0,0 +1,57 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "secure": 1, + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "tid": "${json-unit.any-string}", + "bidder": { + "Pid": "testPid", + "PublisherPath": "testPublisherPath" + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "ext": { + "gdpr": 0 + } + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-response.json new file mode 100644 index 00000000000..6922c116b46 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-response.json @@ -0,0 +1,16 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 3.33, + "crid": "creativeId", + "mtype": 1 + } + ] + } + ] +} diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index e4f8a793e55..405f016babc 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -318,6 +318,8 @@ adapters.richaudience.enabled=true adapters.richaudience.endpoint=http://localhost:8090/richaudience-exchange adapters.rise.enabled=true adapters.rise.endpoint=http://localhost:8090/rise-exchange +adapters.roulax.enabled=true +adapters.roulax.endpoint=http://localhost:8090/roulax-exchange/{{PublisherID}}?pid={{AccountID}} adapters.rtbhouse.enabled=true adapters.rtbhouse.endpoint=http://localhost:8090/rtbhouse-exchange adapters.rubicon.enabled=true From cb4cae2af26864f9cc2dfee1b05b810e0236fc53 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Tue, 21 May 2024 14:46:45 +0200 Subject: [PATCH 45/62] Sonobi: Add Consent Macros to UserSync URL (#3098) --- src/main/resources/bidder-config/sonobi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/sonobi.yaml b/src/main/resources/bidder-config/sonobi.yaml index a093b8dcd45..1c00983ec39 100644 --- a/src/main/resources/bidder-config/sonobi.yaml +++ b/src/main/resources/bidder-config/sonobi.yaml @@ -14,6 +14,6 @@ adapters: usersync: cookie-family-name: sonobi redirect: - url: https://sync.go.sonobi.com/us.gif?loc={{redirect_url}} + url: https://sync.go.sonobi.com/us.gif?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&loc={{redirect_url}} support-cors: false uid-macro: '[UID]' From dd39b7274f2310f5a8b981754a797b1114a6b9c4 Mon Sep 17 00:00:00 2001 From: Laurentiu Badea Date: Tue, 21 May 2024 05:47:55 -0700 Subject: [PATCH 46/62] OpenX: accept incoming string fields to support Prebid.js 9 (#3178) --- .../ext/request/openx/ExtImpOpenx.java | 2 ++ src/main/resources/bidder-config/openx.yaml | 1 + .../resources/static/bidder-params/openx.json | 7 +++-- .../functional/model/bidder/Openx.groovy | 2 +- .../server/bidder/openx/OpenxBidderTest.java | 29 ++++++++++--------- .../openx/test-auction-openx-request.json | 2 +- .../openx/test-openx-bid-request.json | 2 +- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/openx/ExtImpOpenx.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/openx/ExtImpOpenx.java index 862eb4289ca..0bf40d18264 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/openx/ExtImpOpenx.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/openx/ExtImpOpenx.java @@ -1,5 +1,6 @@ package org.prebid.server.proto.openrtb.ext.request.openx; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import lombok.Builder; @@ -22,6 +23,7 @@ public class ExtImpOpenx { String platform; + @JsonFormat(shape = JsonFormat.Shape.STRING) @JsonProperty("customFloor") BigDecimal customFloor; diff --git a/src/main/resources/bidder-config/openx.yaml b/src/main/resources/bidder-config/openx.yaml index c6fa7e65410..78aa8020d30 100644 --- a/src/main/resources/bidder-config/openx.yaml +++ b/src/main/resources/bidder-config/openx.yaml @@ -1,6 +1,7 @@ adapters: openx: endpoint: http://rtb.openx.net/prebid + endpoint-compression: gzip meta-info: maintainer-email: prebid@openx.com app-media-types: diff --git a/src/main/resources/static/bidder-params/openx.json b/src/main/resources/static/bidder-params/openx.json index 6dbd10178e4..89c0663e0a0 100644 --- a/src/main/resources/static/bidder-params/openx.json +++ b/src/main/resources/static/bidder-params/openx.json @@ -6,7 +6,7 @@ "type": "object", "properties": { "unit": { - "type": "string", + "type": ["number", "string"], "description": "The ad unit id.", "pattern": "^[0-9]+$" }, @@ -22,9 +22,10 @@ "format": "uuid" }, "customFloor": { - "type": "number", + "type": ["number", "string"], "description": "The minimum CPM price in USD.", - "minimum": 0 + "minimum": 0, + "pattern": "^[0-9]+(\\.[0-9]+)?$" }, "customParams": { "type": "object", diff --git a/src/test/groovy/org/prebid/server/functional/model/bidder/Openx.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/Openx.groovy index e6b08baa4c2..932d3cf80a6 100644 --- a/src/test/groovy/org/prebid/server/functional/model/bidder/Openx.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/Openx.groovy @@ -7,7 +7,7 @@ class Openx implements BidderAdapter { String unit String delDomain String platform - Integer customFloor + String customFloor Map customParams static Openx getDefaultOpenx() { diff --git a/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java b/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java index 812cc11769e..6816f352b2e 100644 --- a/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java @@ -207,18 +207,19 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { ExtImpOpenx.builder() .customParams(givenCustomParams("foo1", singletonList("bar1"))) .delDomain("se-demo-d.openx.net") - .unit("unitId").build()))).build(), + .unit("555555").build()))).build(), Imp.builder() .id("impId2") .bidfloor(BigDecimal.valueOf(0.5)) .banner(Banner.builder().build()) .ext(mapper.valueToTree( - ExtPrebid.of(null, - ExtImpOpenx.builder() - .customFloor(BigDecimal.valueOf(0.1)) - .customParams(givenCustomParams("foo2", "bar2")) - .delDomain("se-demo-d.openx.net") - .unit("unitId").build()))).build(), + Map.of( + "bidder", Map.of( + "customFloor", "0.1", + "customParams", givenCustomParams("foo2", "bar2"), + "delDomain", "se-demo-d.openx.net", + "unit", 123456 + )))).build(), Imp.builder() .id("impId3") .video(Video.builder().build()) @@ -230,7 +231,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { .customFloor(BigDecimal.valueOf(0.1)) .customParams(givenCustomParams("foo3", "bar3")) .delDomain("se-demo-d.openx.net") - .unit("unitId").build()))).build(), + .unit("555555").build()))).build(), Imp.builder() .id("impId4") .video(Video.builder().build()) @@ -239,7 +240,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { ExtImpOpenx.builder() .customParams(givenCustomParams("foo4", "bar4")) .platform("PLATFORM") - .unit("unitId").build()))).build(), + .unit("555555").build()))).build(), Imp.builder().id("impId1").audio(Audio.builder().build()).build())) .user(User.builder().ext(ExtUser.builder().consent("consent").build()).build()) @@ -264,7 +265,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { Imp.builder() .id("impId1") .banner(Banner.builder().build()) - .tagid("unitId") + .tagid("555555") .bidfloor(BigDecimal.valueOf(0.5)) .ext(mapper.valueToTree( ExtImpOpenx.builder() @@ -276,7 +277,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { Imp.builder() .id("impId2") .banner(Banner.builder().build()) - .tagid("unitId") + .tagid("123456") .bidfloor(BigDecimal.valueOf(0.5)) .ext(mapper.valueToTree( ExtImpOpenx.builder() @@ -301,7 +302,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { .video(Video.builder() .ext(mapper.valueToTree(OpenxVideoExt.of(1))) .build()) - .tagid("unitId") + .tagid("555555") // check if each of video imps is a part of separate bidRequest .bidfloor(BigDecimal.valueOf(0.1)) .ext(mapper.valueToTree( @@ -326,7 +327,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { Imp.builder() .id("impId4") .video(Video.builder().build()) - .tagid("unitId") + .tagid("555555") .ext(mapper.valueToTree( ExtImpOpenx.builder() .customParams( @@ -418,7 +419,7 @@ public void makeHttpRequestShouldReturnResultWithAuctionEnvironment() { Imp.builder() .id("impId2") .banner(Banner.builder().build()) - .tagid("unitId") + .tagid("555555") .ext(mapper.valueToTree(Map.of("ae", 1, "bidder", Map.of()))) .build())) .build(); diff --git a/src/test/resources/org/prebid/server/it/openrtb2/openx/test-auction-openx-request.json b/src/test/resources/org/prebid/server/it/openrtb2/openx/test-auction-openx-request.json index c09abbda691..afa1eff56d5 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/openx/test-auction-openx-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/openx/test-auction-openx-request.json @@ -11,7 +11,7 @@ "openx": { "unit": "539439964", "delDomain": "se-demo-d.openx.net", - "customFloor": 0.1, + "customFloor": "0.5", "customParams": { "foo": "bar", "multifoo": [ diff --git a/src/test/resources/org/prebid/server/it/openrtb2/openx/test-openx-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/openx/test-openx-bid-request.json index 8ef63ebe83d..fac8f6e765c 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/openx/test-openx-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/openx/test-openx-bid-request.json @@ -9,7 +9,7 @@ "h": 250 }, "tagid": "539439964", - "bidfloor": 0.1, + "bidfloor": 0.5, "ext": { "customParams": { "foo": "bar", From 3208ea2d321c9c40c1a40d7ea91fd6ae6c2db808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zdravko=20Kosanovi=C4=87?= <41286499+zkosanovic@users.noreply.github.com> Date: Tue, 21 May 2024 14:48:51 +0200 Subject: [PATCH 47/62] Rise: Add placementId parameter to bidder ext (#3119) --- .../server/proto/openrtb/ext/request/rise/ExtImpRise.java | 2 ++ src/main/resources/static/bidder-params/rise.json | 4 ++++ .../org/prebid/server/bidder/rise/RiseBidderTest.java | 8 ++++---- src/test/java/org/prebid/server/it/RiseTest.java | 2 +- .../it/openrtb2/rise/test-auction-rise-request.json | 3 ++- .../server/it/openrtb2/rise/test-rise-bid-request.json | 3 ++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/rise/ExtImpRise.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/rise/ExtImpRise.java index 3a3bf301a56..251eb0bc9e9 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/rise/ExtImpRise.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/rise/ExtImpRise.java @@ -8,4 +8,6 @@ public class ExtImpRise { String publisherId; String org; + + String placementId; } diff --git a/src/main/resources/static/bidder-params/rise.json b/src/main/resources/static/bidder-params/rise.json index 30dff44d29f..ee8a469cbbc 100644 --- a/src/main/resources/static/bidder-params/rise.json +++ b/src/main/resources/static/bidder-params/rise.json @@ -11,6 +11,10 @@ "publisher_id": { "type": "string", "description": "Deprecated, use org instead." + }, + "placementId": { + "type": "string", + "description": "Placement ID." } }, "oneOf": [ diff --git a/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java b/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java index 66132621bd8..c26bf6839f8 100644 --- a/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java @@ -80,7 +80,7 @@ public void makeHttpRequestsShouldThrowErrorWhenExtImpOrgAndPublisherAbsent() { .imp(singletonList(Imp.builder().id("123") .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(null, null)))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(null, null, null)))) .build())) .build(); @@ -104,7 +104,7 @@ public void makeHttpRequestsShouldPasteValueFromExtImpOrgToURLEndpointWhenPublis .id("123") .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(" testPublisherId ", null)))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(" testPublisherId ", null, null)))) .build())) .build(); @@ -127,7 +127,7 @@ public void makeHttpRequestsShouldPasteValueFromExtImpOrgToURLEndpointWhenOrgPre .id("123") .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(null, " testOrg ")))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(null, " testOrg ", null)))) .build())) .build(); @@ -265,7 +265,7 @@ private static Imp givenImp(Function impCustomiz return impCustomizer.apply(Imp.builder().id("123")) .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of("testPublisherId", null)))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of("testPublisherId", null, null)))) .build(); } diff --git a/src/test/java/org/prebid/server/it/RiseTest.java b/src/test/java/org/prebid/server/it/RiseTest.java index adfe66868a4..a36afb22544 100644 --- a/src/test/java/org/prebid/server/it/RiseTest.java +++ b/src/test/java/org/prebid/server/it/RiseTest.java @@ -23,7 +23,7 @@ public class RiseTest extends IntegrationTest { public void openrtb2AuctionShouldRespondWithBidsFromRise() throws IOException, JSONException { // given WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/rise-exchange")) - .withQueryParam("publisher_id", equalTo("testPlacementId")) + .withQueryParam("publisher_id", equalTo("testOrgId")) .withRequestBody(equalToJson(jsonFrom("openrtb2/rise/test-rise-bid-request.json"))) .willReturn(aResponse().withBody(jsonFrom("openrtb2/rise/test-rise-bid-response.json")))); diff --git a/src/test/resources/org/prebid/server/it/openrtb2/rise/test-auction-rise-request.json b/src/test/resources/org/prebid/server/it/openrtb2/rise/test-auction-rise-request.json index a6323ecce86..02cdde6a0bc 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/rise/test-auction-rise-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/rise/test-auction-rise-request.json @@ -9,7 +9,8 @@ }, "ext": { "rise": { - "publisher_id": "testPlacementId" + "org": "testOrgId", + "placementId": "testPlacementId" } } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/rise/test-rise-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/rise/test-rise-bid-request.json index bce8ccb4132..252d03c4565 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/rise/test-rise-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/rise/test-rise-bid-request.json @@ -11,7 +11,8 @@ "ext": { "tid": "${json-unit.any-string}", "bidder": { - "publisher_id": "testPlacementId" + "org": "testOrgId", + "placementId": "testPlacementId" } } } From 79c3065d56046c7ea49674821900c57202b492a6 Mon Sep 17 00:00:00 2001 From: aishwaryapatil Date: Tue, 21 May 2024 08:50:13 -0400 Subject: [PATCH 48/62] YahooAdapter: Remove warning message (#3181) --- .../server/bidder/yahooads/YahooAdsBidder.java | 4 ---- .../bidder/yahooads/YahooAdsBidderTest.java | 15 --------------- 2 files changed, 19 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java b/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java index 9d35a90c69d..997938e371e 100644 --- a/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java +++ b/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java @@ -251,10 +251,6 @@ private static List extractBids(BidResponse bidResponse, BidRequest b if (seatBids == null) { return Collections.emptyList(); } - - if (seatBids.isEmpty()) { - throw new PreBidException("Invalid SeatBids count: 0"); - } return bidsFromResponse(bidResponse, bidRequest.getImp()); } diff --git a/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java b/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java index e2041372583..e38efb41ca8 100644 --- a/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java @@ -332,21 +332,6 @@ public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws Jso assertThat(result.getValue()).isEmpty(); } - @Test - public void makeBidsShouldReturnErrorIfBidResponseSeatBidIsEmpty() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().seatbid(emptyList()).build())); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).hasSize(1) - .containsOnly(BidderError.badServerResponse("Invalid SeatBids count: 0")); - assertThat(result.getValue()).isEmpty(); - } - @Test public void makeBidsShouldReturnErrorWhenBidImpIdIsNotPresent() throws JsonProcessingException { // given From ac4a0179fcfb20d13474fe78b54498ccfe2fe769 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Tue, 21 May 2024 14:51:07 +0200 Subject: [PATCH 49/62] Evolution: Add IFrame (#3099) --- src/main/resources/bidder-config/evolution.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/bidder-config/evolution.yaml b/src/main/resources/bidder-config/evolution.yaml index 2101ba5089b..3101dadcfdb 100644 --- a/src/main/resources/bidder-config/evolution.yaml +++ b/src/main/resources/bidder-config/evolution.yaml @@ -19,3 +19,7 @@ adapters: url: https://sync.e-volution.ai/pbserver?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&ccpa={{us_privacy}}&redirect={{redirect_url}} support-cors: false uid-macro: '[UID]' + iframe: + url: https://sync.e-volution.ai/pbserver?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&ccpa={{us_privacy}}&redirect={{redirect_url}} + support-cors: false + uid-macro: '[UID]' From 460081efbc78d26ce78eed2d4e31950d002eb4cc Mon Sep 17 00:00:00 2001 From: Piotr Jaworski <109736938+piotrj-rtbh@users.noreply.github.com> Date: Tue, 21 May 2024 14:53:19 +0200 Subject: [PATCH 50/62] RTB House: Video support (#3130) --- .../bidder/rtbhouse/RtbhouseBidder.java | 2 ++ .../resources/bidder-config/rtbhouse.yaml | 2 ++ .../bidder/rtbhouse/RtbhouseBidderTest.java | 26 +++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java index 296071b0765..a363c29a0a3 100644 --- a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java +++ b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java @@ -157,6 +157,8 @@ private static BidType getBidType(String impId, List imps) { return BidType.banner; } else if (imp.getXNative() != null) { return BidType.xNative; + } else if (imp.getVideo() != null) { + return BidType.video; } } } diff --git a/src/main/resources/bidder-config/rtbhouse.yaml b/src/main/resources/bidder-config/rtbhouse.yaml index 774ed55715c..a428897379c 100644 --- a/src/main/resources/bidder-config/rtbhouse.yaml +++ b/src/main/resources/bidder-config/rtbhouse.yaml @@ -18,9 +18,11 @@ adapters: app-media-types: - banner - native + - video site-media-types: - banner - native + - video supported-vendors: vendor-id: 16 usersync: diff --git a/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java b/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java index 6fc275dcd9d..d0e5dd2beba 100644 --- a/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java @@ -6,6 +6,7 @@ import com.iab.openrtb.request.Imp; import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.Native; +import com.iab.openrtb.request.Video; import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; @@ -40,6 +41,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; +import static org.prebid.server.proto.openrtb.ext.response.BidType.video; public class RtbhouseBidderTest extends VertxTest { @@ -132,6 +134,30 @@ public void makeBidsShouldReturnBannerBidIfBannerIsPresent() throws JsonProcessi .containsOnly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); } + @Test + public void makeBidsShouldReturnVideoBidIfVideoIsPresent() throws JsonProcessingException { + // given + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder() + .id("123") + .video(Video.builder().build()) + .build())) + .build(); + + final BidderCall httpCall = givenHttpCall( + bidRequest, + mapper.writeValueAsString( + givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + + // when + final Result> result = target.makeBids(httpCall, bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); + } + @Test public void makeHttpRequestsShouldConvertCurrencyIfRequestCurrencyDoesNotMatchBidderCurrency() { // given From 88ba248d50da2bd226f9047c87ad8addd576c279 Mon Sep 17 00:00:00 2001 From: SerhiiNahornyi Date: Wed, 22 May 2024 11:41:56 +0200 Subject: [PATCH 51/62] Rubicon: Remove imp.ext.context references (#3195) --- .../server/bidder/rubicon/RubiconBidder.java | 69 ++----- .../bidder/rubicon/RubiconBidderTest.java | 188 +++--------------- 2 files changed, 42 insertions(+), 215 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java index 27d6dc59ff9..5c45d9583ec 100644 --- a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java +++ b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java @@ -86,7 +86,6 @@ import org.prebid.server.proto.openrtb.ext.request.ExtDeal; import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; import org.prebid.server.proto.openrtb.ext.request.ExtDevice; -import org.prebid.server.proto.openrtb.ext.request.ExtImpContext; import org.prebid.server.proto.openrtb.ext.request.ExtImpContextDataAdserver; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebidFloors; @@ -664,7 +663,6 @@ private RubiconImpExt makeImpExt(Imp imp, String ipfResolvedCurrency, PriceFloorResult priceFloorResult) { - final ExtImpContext context = extImpContext(imp); final RubiconImpExtPrebid rubiconImpExtPrebid = priceFloorResult != null ? makeRubiconExtPrebid(priceFloorResult, ipfResolvedCurrency, imp, bidRequest) : null; @@ -675,7 +673,7 @@ private RubiconImpExt makeImpExt(Imp imp, final RubiconImpExtRp rubiconImpExtRp = RubiconImpExtRp.of( rubiconImpExt.getZoneId(), - makeTarget(imp, rubiconImpExt, site, app, context), + makeTarget(imp, rubiconImpExt, site, app), RubiconImpExtRpTrack.of("", ""), rubiconImpExtRpRtb); @@ -689,26 +687,14 @@ private RubiconImpExt makeImpExt(Imp imp, .build(); } - private ExtImpContext extImpContext(Imp imp) { - final JsonNode context = imp.getExt().get(FPD_CONTEXT_FIELD); - if (context == null || context.isNull()) { - return null; - } - try { - return mapper.mapper().convertValue(context, ExtImpContext.class); - } catch (IllegalArgumentException e) { - throw new PreBidException(e.getMessage(), e); - } - } - - private JsonNode makeTarget(Imp imp, ExtImpRubicon rubiconImpExt, Site site, App app, ExtImpContext context) { + private JsonNode makeTarget(Imp imp, ExtImpRubicon rubiconImpExt, Site site, App app) { final ObjectNode result = mapper.mapper().createObjectNode(); populateFirstPartyDataAttributes(rubiconImpExt.getInventory(), result); mergeFirstPartyDataFromSite(site, result); mergeFirstPartyDataFromApp(app, result); - mergeFirstPartyDataFromImp(imp, rubiconImpExt, context, result); + mergeFirstPartyDataFromImp(imp, rubiconImpExt, result); return result.size() > 0 ? result : null; } @@ -771,19 +757,12 @@ private void mergeFirstPartyDataFromApp(App app, ObjectNode result) { private void mergeFirstPartyDataFromImp(Imp imp, ExtImpRubicon rubiconImpExt, - ExtImpContext context, ObjectNode result) { - mergeFirstPartyDataFromData(imp, context, result); - mergeFirstPartyDataKeywords(imp, context, result); + mergeFirstPartyDataFromData(imp, result); + mergeFirstPartyDataKeywords(imp, result); // merge OPENRTB.imp[].ext.rubicon.keywords to XAPI.imp[].ext.rp.target.keywords mergeCollectionAttributeIntoArray(result, rubiconImpExt, ExtImpRubicon::getKeywords, FPD_KEYWORDS_FIELD); - // merge OPENRTB.imp[].ext.context.search to XAPI.imp[].ext.rp.target.search - mergeStringAttributeIntoArray( - result, - context, - extContext -> getTextValueFromNode(extContext.getProperty(FPD_SEARCH_FIELD)), - FPD_SEARCH_FIELD); // merge OPENRTB.imp[].ext.data.search to XAPI.imp[].ext.rp.target.search mergeStringAttributeIntoArray( result, @@ -792,42 +771,31 @@ private void mergeFirstPartyDataFromImp(Imp imp, FPD_SEARCH_FIELD); } - private void mergeFirstPartyDataFromData(Imp imp, ExtImpContext context, ObjectNode result) { - final ObjectNode contextDataNode = toObjectNode( - ObjectUtil.getIfNotNull(context, ExtImpContext::getData)); - // merge OPENRTB.imp[].ext.context.data.* to XAPI.imp[].ext.rp.target.* - populateFirstPartyDataAttributes(contextDataNode, result); - + private void mergeFirstPartyDataFromData(Imp imp, ObjectNode result) { final ObjectNode dataNode = toObjectNode(imp.getExt().get(FPD_DATA_FIELD)); // merge OPENRTB.imp[].ext.data.* to XAPI.imp[].ext.rp.target.* populateFirstPartyDataAttributes(dataNode, result); // override XAPI.imp[].ext.rp.target.* with OPENRTB.imp[].ext.data.* - overrideFirstPartyDataAttributes(contextDataNode, dataNode, result); + overrideFirstPartyDataAttributes(dataNode, result); } - private void overrideFirstPartyDataAttributes(ObjectNode contextDataNode, ObjectNode dataNode, ObjectNode result) { + private void overrideFirstPartyDataAttributes(ObjectNode dataNode, ObjectNode result) { final JsonNode pbadslotNode = dataNode.get(FPD_DATA_PBADSLOT_FIELD); if (pbadslotNode != null && pbadslotNode.isTextual()) { // copy imp[].ext.data.pbadslot to XAPI.imp[].ext.rp.target.pbadslot result.set(FPD_DATA_PBADSLOT_FIELD, pbadslotNode); } else { // copy adserver.adslot value to XAPI field imp[].ext.rp.target.dfp_ad_unit_code - final String resolvedDfpAdUnitCode = getAdSlot(contextDataNode, dataNode); + final String resolvedDfpAdUnitCode = getAdSlotFromAdServer(dataNode); if (resolvedDfpAdUnitCode != null) { result.set(DFP_ADUNIT_CODE_FIELD, TextNode.valueOf(resolvedDfpAdUnitCode)); } } - } - private void mergeFirstPartyDataKeywords(Imp imp, ExtImpContext context, ObjectNode result) { - // merge OPENRTB.imp[].ext.context.keywords to XAPI.imp[].ext.rp.target.keywords - final JsonNode keywordsNode = context != null ? context.getProperty("keywords") : null; - final String keywords = getTextValueFromNode(keywordsNode); - if (StringUtils.isNotBlank(keywords)) { - mergeIntoArray(result, FPD_KEYWORDS_FIELD, keywords.split(",")); - } + } + private void mergeFirstPartyDataKeywords(Imp imp, ObjectNode result) { // merge OPENRTB.imp[].ext.data.keywords to XAPI.imp[].ext.rp.target.keywords final String dataKeywords = getTextValueFromNodeByPath(imp.getExt().get(FPD_DATA_FIELD), FPD_KEYWORDS_FIELD); if (StringUtils.isNotBlank(dataKeywords)) { @@ -977,19 +945,10 @@ private ObjectNode getSkadn(ObjectNode impExt) { return skadnNode != null && skadnNode.isObject() ? (ObjectNode) skadnNode : null; } - private String getAdSlot(Imp imp, ExtImpContext context) { - final ObjectNode contextDataNode = context != null ? context.getData() : null; + private String getAdSlot(Imp imp) { final ObjectNode dataNode = toObjectNode(imp.getExt().get(FPD_DATA_FIELD)); - return getAdSlot(contextDataNode, dataNode); - } - - private String getAdSlot(ObjectNode contextDataNode, ObjectNode dataNode) { - return ObjectUtils.firstNonNull( - // or imp[].ext.context.data.adserver.adslot - getAdSlotFromAdServer(contextDataNode), - // or imp[].ext.data.adserver.adslot - getAdSlotFromAdServer(dataNode)); + return getAdSlotFromAdServer(dataNode); } private String getAdSlotFromAdServer(JsonNode dataNode) { @@ -1558,7 +1517,7 @@ private BidRequest createLineItemBidRequest(ExtDealLine lineItem, BidRequest bid final Imp dealsImp = imp.toBuilder() .banner(modifyBanner(imp.getBanner(), lineItem.getSizes())) .ext(modifyRubiconImpExt(imp.getExt(), bidRequest.getExt(), lineItem.getExtLineItemId(), - getAdSlot(imp, extImpContext(imp)))) + getAdSlot(imp))) .build(); return bidRequest.toBuilder() diff --git a/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java b/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java index 9ee7f0a07c0..536c4e9d18d 100644 --- a/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java @@ -2373,7 +2373,7 @@ public void makeHttpRequestsShouldCreateRequestPerImp() { } @Test - public void makeHttpRequestsShouldCopyAndModifyImpExtContextDataAndDataFieldsToRubiconImpExtRpTarget() { + public void makeHttpRequestsShouldCopyAndModifyDataFieldsToRubiconImpExtRpTarget() { // given final BidRequest bidRequest = givenBidRequest( identity(), @@ -2381,9 +2381,6 @@ public void makeHttpRequestsShouldCopyAndModifyImpExtContextDataAndDataFieldsToR identity()); bidRequest.getImp().get(0).getExt() - .set("context", mapper.createObjectNode() - .set("data", mapper.createObjectNode() - .set("property1", mapper.createArrayNode().add("value1")))) .set("data", mapper.createObjectNode() .set("property2", mapper.createArrayNode().add("value2"))); @@ -2400,7 +2397,6 @@ public void makeHttpRequestsShouldCopyAndModifyImpExtContextDataAndDataFieldsToR .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) .containsOnly(mapper.createObjectNode() - .set("property1", mapper.createArrayNode().add("value1")) .set("property2", mapper.createArrayNode().add("value2"))); } @@ -2425,66 +2421,6 @@ public void makeHttpRequestsShouldPassThroughImpExtGpid() { .containsExactly(TextNode.valueOf("gpidvalue")); } - @Test - public void makeHttpRequestsShouldNotCopyAdSlotFromAdServerWhenAdServerNameIsNotGam() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - impBuilder -> impBuilder.video(Video.builder().build()), - identity()); - - bidRequest.getImp().get(0).getExt() - .set("context", mapper.createObjectNode() - .set("data", mapper.createObjectNode() - .put("property", "value") - .set("adserver", mapper.createObjectNode() - .put("name", "not-gam") - .put("adslot", "/test-adserver")))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getExt) - .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) - .extracting(RubiconImpExt::getRp) - .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.createObjectNode() - .set("property", mapper.createArrayNode().add("value"))); - } - - @Test - public void makeHttpRequestsShouldNotCopyAndModifyImpExtContextDataAdslotToRubiconImpExtRpTargetDfpAdUnitCode() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - impBuilder -> impBuilder.video(Video.builder().build()), - identity()); - - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - final ObjectNode impExtContextDataNode = mapper.createObjectNode() - .set("adslot", mapper.createArrayNode().add("123")); - impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextDataNode))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getExt) - .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) - .extracting(RubiconImpExt::getRp) - .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.createObjectNode().set("adslot", mapper.createArrayNode().add("123"))); - } - @Test public void makeHttpRequestsShouldCopySiteExtDataFieldsToRubiconImpExtRpTarget() { // given @@ -2538,7 +2474,7 @@ public void makeHttpRequestsShouldCopyAppExtDataFieldsToRubiconImpExtRpTarget() } @Test - public void makeHttpRequestsShouldCopySiteExtDataAndImpExtContextDataFieldsToRubiconImpExtRpTarget() + public void makeHttpRequestsShouldCopySiteExtDataFieldToRubiconImpExtRpTarget() throws IOException { // given final ObjectNode siteExtDataNode = mapper.createObjectNode() @@ -2559,6 +2495,8 @@ public void makeHttpRequestsShouldCopySiteExtDataAndImpExtContextDataFieldsToRub final Result>> result = target.makeHttpRequests(bidRequest); // then + final ArrayNode siteNode = mapper.createArrayNode(); + siteNode.add("value1"); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()) .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) @@ -2567,17 +2505,16 @@ public void makeHttpRequestsShouldCopySiteExtDataAndImpExtContextDataFieldsToRub .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"imp_ext\":[\"value2\"],\"site\":[\"value1\"]}")); + .extracting(target -> target.get("site")) + .containsExactly(siteNode); } @Test - public void makeHttpRequestsShouldCopyAppExtDataAndImpExtContextDataFieldsToRubiconImpExtRpTarget() + public void makeHttpRequestsShouldCopyAppExtDataFieldToRubiconImpExtRpTarget() throws IOException { // given final ObjectNode appExtDataNode = mapper.createObjectNode() .set("app", mapper.createArrayNode().add("value1")); - final ObjectNode impExtContextDataNode = mapper.createObjectNode() - .set("imp_ext", mapper.createArrayNode().add("value2")); final BidRequest bidRequest = givenBidRequest( requestBuilder -> requestBuilder @@ -2585,13 +2522,12 @@ public void makeHttpRequestsShouldCopyAppExtDataAndImpExtContextDataFieldsToRubi impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextDataNode))); - // when final Result>> result = target.makeHttpRequests(bidRequest); // then + final ArrayNode appNode = mapper.createArrayNode(); + appNode.add("value1"); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()) .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) @@ -2600,11 +2536,12 @@ public void makeHttpRequestsShouldCopyAppExtDataAndImpExtContextDataFieldsToRubi .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"imp_ext\":[\"value2\"],\"app\":[\"value1\"]}")); + .extracting(target -> target.get("app")) + .containsExactly(appNode); } @Test - public void makeHttpRequestsShouldMergeImpExtRubiconAndContextAndDataKeywordsToRubiconImpExtRpTargetKeywords() + public void makeHttpRequestsShouldMergeImpExtRubiconAndDataKeywordsToRubiconImpExtRpTargetKeywords() throws IOException { // given @@ -2614,9 +2551,6 @@ public void makeHttpRequestsShouldMergeImpExtRubiconAndContextAndDataKeywordsToR identity()); final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - final ExtImpContext extImpContext = ExtImpContext.of(null); - extImpContext.addProperty("keywords", new TextNode("imp,ext,context,keywords")); - impExt.set("context", mapper.valueToTree(extImpContext)); impExt.set("data", mapper.createObjectNode() .put("keywords", "imp,ext,data,keywords")); impExt.set( @@ -2637,19 +2571,13 @@ public void makeHttpRequestsShouldMergeImpExtRubiconAndContextAndDataKeywordsToR .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"keywords\":[" - + "\"imp,ext,data,keywords\"," - + " \"imp\"," - + " \"ext\"," - + " \"context\"," - + " \"keywords\"," - + " \"data\"," - + " \"rubicon\"" - + "]}")); + .extracting(target -> target.get("keywords")) + .containsOnly(mapper.readTree("[\"imp,ext,data,keywords\"," + + "\"imp\",\"ext\",\"data\",\"keywords\",\"rubicon\"]")); } @Test - public void makeHttpRequestsShouldCopyImpExtContextAndDataSearchToRubiconImpExtRpTargetSearch() throws IOException { + public void makeHttpRequestsShouldCopyDataSearchToRubiconImpExtRpTargetSearch() throws IOException { // given final BidRequest bidRequest = givenBidRequest( identity(), @@ -2657,9 +2585,6 @@ public void makeHttpRequestsShouldCopyImpExtContextAndDataSearchToRubiconImpExtR identity()); final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - final ExtImpContext extImpContext = ExtImpContext.of(null); - extImpContext.addProperty("search", new TextNode("imp ext context search")); - impExt.set("context", mapper.valueToTree(extImpContext)); impExt.set("data", mapper.createObjectNode().put("search", "imp ext data search")); // when @@ -2674,7 +2599,7 @@ public void makeHttpRequestsShouldCopyImpExtContextAndDataSearchToRubiconImpExtR .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"search\":[\"imp ext data search\", \"imp ext context search\"]}")); + .containsOnly(mapper.readTree("{\"search\":[\"imp ext data search\"]}")); } @Test @@ -2698,7 +2623,7 @@ public void makeHttpRequestsShouldCopyImpExtVideoLanguageToSiteContentLanguage() } @Test - public void makeHttpRequestsShouldMergeImpExtContextSearchAndSiteSearchAndCopyToRubiconImpExtRpTarget() + public void makeHttpRequestsShouldMergeSiteSearchAndCopyToRubiconImpExtRpTarget() throws JsonProcessingException { // given final BidRequest bidRequest = givenBidRequest( @@ -2706,11 +2631,6 @@ public void makeHttpRequestsShouldMergeImpExtContextSearchAndSiteSearchAndCopyTo impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - final ExtImpContext extImpContext = ExtImpContext.of(null); - extImpContext.addProperty("search", new TextNode("imp ext search")); - impExt.set("context", mapper.valueToTree(extImpContext)); - // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2723,11 +2643,11 @@ public void makeHttpRequestsShouldMergeImpExtContextSearchAndSiteSearchAndCopyTo .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"search\":[\"site search\", \"imp ext search\"]}")); + .containsOnly(mapper.readTree("{\"search\":[\"site search\"]}")); } @Test - public void makeHttpRequestsShouldMergeImpExtContextDataAndSiteAttributesAndCopyToRubiconImpExtRpTarget() { + public void makeHttpRequestsShouldMergeSiteAttributesAndCopyToRubiconImpExtRpTarget() { // given final BidRequest bidRequest = givenBidRequest( requestBuilder -> requestBuilder.site(Site.builder() @@ -2740,16 +2660,6 @@ public void makeHttpRequestsShouldMergeImpExtContextDataAndSiteAttributesAndCopy impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExtContextData = mapper.createObjectNode() - .set("sectioncat", mapper.createArrayNode().add("imp ext sectioncat")) - .set("pagecat", mapper.createArrayNode().add("imp ext pagecat")) - .put("page", "imp ext page") - .put("ref", "imp ext ref") - .put("search", "imp ext search"); - - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextData))); - // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2764,20 +2674,15 @@ public void makeHttpRequestsShouldMergeImpExtContextDataAndSiteAttributesAndCopy .extracting(RubiconImpExtRp::getTarget) .containsOnly(mapper.createObjectNode() .set("sectioncat", mapper.createArrayNode() - .add("site sectioncat") - .add("imp ext sectioncat")) + .add("site sectioncat")) .set("pagecat", mapper.createArrayNode() - .add("site pagecat") - .add("imp ext pagecat")) + .add("site pagecat")) .set("page", mapper.createArrayNode() - .add("site page") - .add("imp ext page")) + .add("site page")) .set("ref", mapper.createArrayNode() - .add("site ref") - .add("imp ext ref")) + .add("site ref")) .set("search", mapper.createArrayNode() - .add("site search") - .add("imp ext search"))); + .add("site search"))); } @Test @@ -2832,35 +2737,7 @@ public void makeHttpRequestsShouldOverrideDfpAdunitCodeIfAdslotPresentInImpExtDa } @Test - public void makeHttpRequestsShouldOverrideDfpAdunitCodeIfAdslotPresentInImpExtContextDataAndAndAdserverNameIsGam() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), impBuilder -> impBuilder.video(Video.builder().build()), identity()); - - final ObjectNode dataNode = - mapper.createObjectNode() - .set("adserver", mapper.createObjectNode() - .put("adslot", "adslotvalue") - .put("name", "gam")); - - bidRequest.getImp().get(0).getExt() - .set("context", mapper.createObjectNode().set("data", dataNode)); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getExt) - .extracting(ext -> ext.at("/rp/target/dfp_ad_unit_code")) - .containsExactly(TextNode.valueOf("adslotvalue")); - } - - @Test - public void makeHttpRequestsShouldMergeImpExtContextDataAndAppAttributesAndCopyToRubiconImpExtRpTarget() { + public void makeHttpRequestsShouldMergeAppAttributesAndCopyToRubiconImpExtRpTarget() { // given final BidRequest bidRequest = givenBidRequest( requestBuilder -> requestBuilder.app(App.builder() @@ -2870,13 +2747,6 @@ public void makeHttpRequestsShouldMergeImpExtContextDataAndAppAttributesAndCopyT impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExtContextData = mapper.createObjectNode() - .set("sectioncat", mapper.createArrayNode().add("imp ext sectioncat")) - .set("pagecat", mapper.createArrayNode().add("imp ext pagecat")); - - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextData))); - // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2891,11 +2761,9 @@ public void makeHttpRequestsShouldMergeImpExtContextDataAndAppAttributesAndCopyT .extracting(RubiconImpExtRp::getTarget) .containsOnly(mapper.createObjectNode() .set("sectioncat", mapper.createArrayNode() - .add("app sectioncat") - .add("imp ext sectioncat")) + .add("app sectioncat")) .set("pagecat", mapper.createArrayNode() - .add("app pagecat") - .add("imp ext pagecat"))); + .add("app pagecat"))); } @Test From 37cd7aafa40799b7e291b4b86bef984bd77e4046 Mon Sep 17 00:00:00 2001 From: Anand Venkatraman Date: Wed, 22 May 2024 16:58:58 +0530 Subject: [PATCH 52/62] PulsePoint Adapter: ensuring ct/cp params can be either int or string (#3184) --- .../static/bidder-params/pulsepoint.json | 10 +++- .../org/prebid/server/it/PulsepointTest.java | 18 +++++- ...n-pulsepoint-request-params-as-string.json | 24 ++++++++ ...lsepoint-bid-request-params-as-string.json | 59 +++++++++++++++++++ 4 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/pulsepoint/test-auction-pulsepoint-request-params-as-string.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/pulsepoint/test-pulsepoint-bid-request-params-as-string.json diff --git a/src/main/resources/static/bidder-params/pulsepoint.json b/src/main/resources/static/bidder-params/pulsepoint.json index 7758a67084d..8650a96a2f7 100644 --- a/src/main/resources/static/bidder-params/pulsepoint.json +++ b/src/main/resources/static/bidder-params/pulsepoint.json @@ -5,11 +5,17 @@ "type": "object", "properties": { "cp": { - "type": "integer", + "type": [ + "integer", + "string" + ], "description": "An ID which identifies the publisher selling the impression" }, "ct": { - "type": "integer", + "type": [ + "integer", + "string" + ], "description": "An ID which identifies the ad slot being sold" } }, diff --git a/src/test/java/org/prebid/server/it/PulsepointTest.java b/src/test/java/org/prebid/server/it/PulsepointTest.java index 5e813f50744..db61b4a3cf9 100644 --- a/src/test/java/org/prebid/server/it/PulsepointTest.java +++ b/src/test/java/org/prebid/server/it/PulsepointTest.java @@ -20,13 +20,27 @@ public class PulsepointTest extends IntegrationTest { @Test public void openrtb2AuctionShouldRespondWithBidsFromPulsepoint() throws IOException, JSONException { + // pulsepoint params as integers + openrtb2AuctionShouldRespondWithBidsFromPulsepoint( + "openrtb2/pulsepoint/test-auction-pulsepoint-request.json", + "openrtb2/pulsepoint/test-pulsepoint-bid-request.json"); + + // pulsepoint params as string + openrtb2AuctionShouldRespondWithBidsFromPulsepoint( + "openrtb2/pulsepoint/test-auction-pulsepoint-request-params-as-string.json", + "openrtb2/pulsepoint/test-pulsepoint-bid-request-params-as-string.json"); + } + + private void openrtb2AuctionShouldRespondWithBidsFromPulsepoint(String auctionFilePath, + String pulsepointRequestPath) + throws IOException, JSONException { // given WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/pulsepoint-exchange")) - .withRequestBody(equalToJson(jsonFrom("openrtb2/pulsepoint/test-pulsepoint-bid-request.json"))) + .withRequestBody(equalToJson(jsonFrom(pulsepointRequestPath))) .willReturn(aResponse().withBody(jsonFrom("openrtb2/pulsepoint/test-pulsepoint-bid-response.json")))); // when - final Response response = responseFor("openrtb2/pulsepoint/test-auction-pulsepoint-request.json", + final Response response = responseFor(auctionFilePath, Endpoint.openrtb2_auction); // then diff --git a/src/test/resources/org/prebid/server/it/openrtb2/pulsepoint/test-auction-pulsepoint-request-params-as-string.json b/src/test/resources/org/prebid/server/it/openrtb2/pulsepoint/test-auction-pulsepoint-request-params-as-string.json new file mode 100644 index 00000000000..ca908d76e96 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/pulsepoint/test-auction-pulsepoint-request-params-as-string.json @@ -0,0 +1,24 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 300, + "h": 600 + }, + "ext": { + "pulsepoint": { + "cp": "321", + "ct": "456" + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/pulsepoint/test-pulsepoint-bid-request-params-as-string.json b/src/test/resources/org/prebid/server/it/openrtb2/pulsepoint/test-pulsepoint-bid-request-params-as-string.json new file mode 100644 index 00000000000..4bec8bff353 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/pulsepoint/test-pulsepoint-bid-request-params-as-string.json @@ -0,0 +1,59 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "secure": 1, + "banner": { + "w": 300, + "h": 600 + }, + "tagid" : "456", + "ext": { + "tid": "${json-unit.any-string}", + "bidder": { + "cp": "321", + "ct": "456" + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "id": "321", + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "ext": { + "gdpr": 0 + } + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} From f10fbe4b3c0b2836dcaa3462c3bf7b6db3c4585d Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Wed, 22 May 2024 16:34:55 +0300 Subject: [PATCH 53/62] Core: Update `NextMillennium` bidder (#3103) --- .../nextmillennium/NextMillenniumBidder.java | 102 ++++++++++++------ .../bidder-config/nextmillennium.yaml | 2 + .../NextMillenniumBidderTest.java | 85 +++++++++++++-- .../test-auction-nextmillennium-response.json | 3 +- .../test-nextmillennium-bid-request.json | 6 ++ .../test-nextmillennium-bid-response.json | 1 + 6 files changed, 160 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidder.java b/src/main/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidder.java index 955ae3bb9d6..c8cb6418de9 100644 --- a/src/main/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidder.java +++ b/src/main/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidder.java @@ -8,6 +8,7 @@ import com.iab.openrtb.request.Format; import com.iab.openrtb.request.Imp; import com.iab.openrtb.request.Site; +import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; import io.vertx.core.MultiMap; @@ -21,6 +22,7 @@ import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; +import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.proto.openrtb.ext.ExtPrebid; @@ -36,6 +38,7 @@ import java.util.Collection; import java.util.List; import java.util.Objects; +import java.util.Optional; public class NextMillenniumBidder implements Bidder { @@ -57,47 +60,53 @@ public NextMillenniumBidder(String endpointUrl, JacksonMapper mapper, List>> makeHttpRequests(BidRequest bidRequest) { final List errors = new ArrayList<>(); - final List impExts = getImpExts(bidRequest, errors); - - return errors.isEmpty() - ? Result.withValues(makeRequests(bidRequest, impExts)) - : Result.withErrors(errors); - } - - private List getImpExts(BidRequest bidRequest, List errors) { - return bidRequest.getImp().stream() - .map(imp -> convertExt(imp, errors)) - .toList(); - } + final List> httpRequests = new ArrayList<>(); + + for (Imp imp : bidRequest.getImp()) { + final ExtImpNextMillennium extImpNextMillennium; + try { + extImpNextMillennium = convertExt(imp.getExt()); + } catch (PreBidException e) { + errors.add(BidderError.badInput(e.getMessage())); + continue; + } + httpRequests.add(makeHttpRequest(updateBidRequest(bidRequest, extImpNextMillennium))); + } - private List> makeRequests(BidRequest bidRequest, List extImps) { - return extImps.stream() - .map(extImp -> makeHttpRequest(updateBidRequest(bidRequest, extImp))) - .toList(); + return errors.isEmpty() ? Result.withValues(httpRequests) : Result.withErrors(errors); } - private ExtImpNextMillennium convertExt(Imp imp, List errors) { + private ExtImpNextMillennium convertExt(ObjectNode impExt) { try { - return mapper.mapper() - .convertValue(imp.getExt(), NEXTMILLENNIUM_EXT_TYPE_REFERENCE) - .getBidder(); + return mapper.mapper().convertValue(impExt, NEXTMILLENNIUM_EXT_TYPE_REFERENCE).getBidder(); } catch (IllegalArgumentException e) { - errors.add(BidderError.badInput(e.getMessage())); + throw new PreBidException(e.getMessage()); } - return null; } private BidRequest updateBidRequest(BidRequest bidRequest, ExtImpNextMillennium ext) { - final ExtRequestPrebid prebid = ExtRequestPrebid.builder() - .storedrequest(ExtStoredRequest.of(resolveStoredRequestId(bidRequest, ext))) + final ExtStoredRequest storedRequest = ExtStoredRequest.of(resolveStoredRequestId(bidRequest, ext)); + + final ExtRequestPrebid createdExtRequestPrebid = ExtRequestPrebid.builder() + .storedrequest(storedRequest) .build(); - final ExtRequest extRequest = ExtRequest.of(prebid); - final List imps = bidRequest.getImp().stream() - .map(imp -> imp.toBuilder().ext(createImpExt(prebid)).build()) - .toList(); + final ExtRequestPrebid extRequestPrebid = Optional.ofNullable(bidRequest) + .map(BidRequest::getExt) + .map(ExtRequest::getPrebid) + .map(prebid -> prebid.toBuilder().storedrequest(storedRequest).build()) + .orElse(createdExtRequestPrebid); + + return bidRequest.toBuilder() + .imp(updateImps(bidRequest, createdExtRequestPrebid)) + .ext(ExtRequest.of(extRequestPrebid)) + .build(); + } - return bidRequest.toBuilder().imp(imps).ext(extRequest).build(); + private List updateImps(BidRequest bidRequest, ExtRequestPrebid extRequestPrebid) { + return bidRequest.getImp().stream() + .map(imp -> imp.toBuilder().ext(createImpExt(extRequestPrebid)).build()) + .toList(); } private static String resolveStoredRequestId(BidRequest bidRequest, ExtImpNextMillennium extImpNextMillennium) { @@ -164,24 +173,53 @@ private static MultiMap headers() { @Override public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + final List bidderErrors = new ArrayList<>(); try { final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); if (CollectionUtils.isEmpty(bidResponse.getSeatbid())) { return Result.empty(); } - return Result.withValues(bidsFromResponse(bidResponse)); + return Result.of(bidsFromResponse(bidResponse, bidderErrors), bidderErrors); } catch (DecodeException e) { return Result.withError(BidderError.badServerResponse(e.getMessage())); } } - private static List bidsFromResponse(BidResponse bidResponse) { + private static List bidsFromResponse(BidResponse bidResponse, List bidderErrors) { return bidResponse.getSeatbid().stream() .filter(Objects::nonNull) .map(SeatBid::getBid) .filter(Objects::nonNull) .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, BidType.banner, bidResponse.getCur())) + .map(bid -> resolveBidderBid(bidResponse, bidderErrors, bid)) + .filter(Objects::nonNull) .toList(); } + + private static BidderBid resolveBidderBid(BidResponse bidResponse, List bidderErrors, Bid bid) { + final BidType bidType = getBidType(bid, bidderErrors); + if (bidType == null) { + return null; + } + + return BidderBid.of(bid, bidType, bidResponse.getCur()); + } + + private static BidType getBidType(Bid bid, List bidderErrors) { + final Integer markupType = bid.getMtype(); + if (markupType == null) { + bidderErrors.add(BidderError.badServerResponse("Missing MType for bid: " + bid.getId())); + return null; + } + + return switch (markupType) { + case 1 -> BidType.banner; + case 2 -> BidType.video; + default -> { + bidderErrors.add(BidderError.badServerResponse( + "Unable to fetch mediaType " + bid.getMtype() + " in multi-format: " + bid.getImpid())); + yield null; + } + }; + } } diff --git a/src/main/resources/bidder-config/nextmillennium.yaml b/src/main/resources/bidder-config/nextmillennium.yaml index 51524341a45..f1039b8e45b 100644 --- a/src/main/resources/bidder-config/nextmillennium.yaml +++ b/src/main/resources/bidder-config/nextmillennium.yaml @@ -5,8 +5,10 @@ adapters: maintainer-email: accountmanagers@nextmillennium.io app-media-types: - banner + - video site-media-types: - banner + - video supported-vendors: vendor-id: 1060 usersync: diff --git a/src/test/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidderTest.java b/src/test/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidderTest.java index 62ac9ae78a5..375ac6e4c73 100644 --- a/src/test/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidderTest.java @@ -28,6 +28,7 @@ import org.prebid.server.proto.openrtb.ext.request.nextmillennium.ExtImpNextMillennium; import org.prebid.server.proto.openrtb.ext.response.BidType; +import java.util.Arrays; import java.util.List; import java.util.function.UnaryOperator; @@ -275,11 +276,11 @@ public void makeHttpRequestsShouldReturnImpExtNextMillenniumWhenNmmFlagsConfigur } @Test - public void makeBidsShouldReturnBannerBidByDefault() throws JsonProcessingException { + public void makeBidsShouldReturnBannerBidWhenMTypeIsOne() throws JsonProcessingException { // given final BidRequest bidRequest = givenBidRequest(identity()); final BidderCall httpCall = givenHttpCall(bidRequest, - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.mtype(1).impid("123")))); // when final Result> result = target.makeBids(httpCall, bidRequest); @@ -287,7 +288,76 @@ public void makeBidsShouldReturnBannerBidByDefault() throws JsonProcessingExcept // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), BidType.banner, "USD")); + .containsExactly(BidderBid.of(Bid.builder().mtype(1).impid("123").build(), + BidType.banner, "USD")); + } + + @Test + public void makeBidsShouldReturnVideoBidWhenMTypeIsTwo() throws JsonProcessingException { + // given + final BidRequest bidRequest = givenBidRequest(identity()); + final BidderCall httpCall = givenHttpCall(bidRequest, + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.mtype(2).impid("123")))); + + // when + final Result> result = target.makeBids(httpCall, bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().mtype(2).impid("123").build(), + BidType.video, "USD")); + } + + @Test + public void makeBidsShouldReturnErrorWhenMTypeIsUnknown() throws JsonProcessingException { + // given + final BidRequest bidRequest = givenBidRequest(identity()); + final BidderCall httpCall = givenHttpCall(bidRequest, + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.mtype(999).impid("123")))); + + // when + final Result> result = target.makeBids(httpCall, bidRequest); + + // then + assertThat(result.getErrors()) + .contains(BidderError.badServerResponse("Unable to fetch mediaType 999 in multi-format: 123")); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnErrorWhenMTypeIsMissing() throws JsonProcessingException { + // given + final BidRequest bidRequest = givenBidRequest(identity()); + final BidderCall httpCall = givenHttpCall(bidRequest, + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.id("bidId").impid("123")))); + + // when + final Result> result = target.makeBids(httpCall, bidRequest); + + // then + assertThat(result.getErrors()).contains(BidderError.badServerResponse("Missing MType for bid: bidId")); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnBothValidAndInvalidBidderBidAtTheSameTime() throws JsonProcessingException { + // given + final BidRequest bidRequest = givenBidRequest(identity()); + final BidderCall httpCall = givenHttpCall(givenBidRequest(identity()), + mapper.writeValueAsString(givenBidResponse( + bidBuilder -> bidBuilder.mtype(999).impid("123"), + bidBuilder -> bidBuilder.mtype(1).impid("312")))); + + // when + final Result> result = target.makeBids(httpCall, bidRequest); + + // then + assertThat(result.getErrors()) + .contains(BidderError.badServerResponse("Unable to fetch mediaType 999 in multi-format: 123")); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().mtype(1).impid("312").build(), + BidType.banner, "USD")); } @Test @@ -476,12 +546,15 @@ private static Imp givenImp(UnaryOperator impCustomizer) { return impCustomizer.apply(Imp.builder()).build(); } - private static BidResponse givenBidResponse(UnaryOperator bidCustomizer) { + @SafeVarargs + private static BidResponse givenBidResponse(UnaryOperator... bidCustomizers) { return BidResponse.builder() + .cur("USD") .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bidCustomizer.apply(Bid.builder()).build())) + .bid(Arrays.stream(bidCustomizers) + .map(bidCustomizer -> bidCustomizer.apply(Bid.builder()).build()) + .toList()) .build())) - .cur("USD") .build(); } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-auction-nextmillennium-response.json b/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-auction-nextmillennium-response.json index 5429ae0e438..71068f2cb94 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-auction-nextmillennium-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-auction-nextmillennium-response.json @@ -7,6 +7,7 @@ "id": "bid_id", "impid": "imp_id", "price": 0.01, + "mtype": 1, "adid": "adid001", "cid": "cid001", "crid": "crid001", @@ -25,7 +26,7 @@ "cur": "USD", "ext": { "responsetimemillis": { - "nextmillennium" : "{{ nextmillennium.response_time_ms }}" + "nextmillennium": "{{ nextmillennium.response_time_ms }}" }, "prebid": { "auctiontimestamp": 0 diff --git a/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-nextmillennium-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-nextmillennium-bid-request.json index 92191632e7c..24a61053439 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-nextmillennium-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-nextmillennium-bid-request.json @@ -53,6 +53,12 @@ "prebid": { "storedrequest": { "id": "placement_id" + }, + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" } } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-nextmillennium-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-nextmillennium-bid-response.json index dede1455066..27756dd8f0a 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-nextmillennium-bid-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/nextmillennium/test-nextmillennium-bid-response.json @@ -6,6 +6,7 @@ { "crid": "crid001", "adid": "adid001", + "mtype": 1, "price": 0.01, "id": "bid_id", "impid": "imp_id", From 8a6ca71e4bd49df03fb15914ac281e770f480084 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Wed, 22 May 2024 15:37:08 +0200 Subject: [PATCH 54/62] Aso: Add adapter (#3087) --- .../prebid/server/bidder/aso/AsoBidder.java | 162 ++++++++++ .../openrtb/ext/request/aso/ExtImpAso.java | 10 + .../config/bidder/AsoConfiguration.java | 41 +++ src/main/resources/bidder-config/aso.yaml | 25 ++ .../resources/static/bidder-params/aso.json | 13 + .../server/bidder/aso/AsoBidderTest.java | 296 ++++++++++++++++++ .../java/org/prebid/server/it/AsoTest.java | 41 +++ .../java/org/prebid/server/it/BcmintTest.java | 41 +++ .../org/prebid/server/it/BidAgencyTest.java | 41 +++ .../it/openrtb2/aso/test-aso-bid-request.json | 56 ++++ .../openrtb2/aso/test-aso-bid-response.json | 22 ++ .../aso/test-auction-aso-request.json | 23 ++ .../aso/test-auction-aso-response.json | 35 +++ .../bcmint/test-auction-bcmint-request.json | 23 ++ .../bcmint/test-auction-bcmint-response.json | 35 +++ .../bcmint/test-bcmint-bid-request.json | 56 ++++ .../bcmint/test-bcmint-bid-response.json | 22 ++ .../test-auction-bidagency-request.json | 23 ++ .../test-auction-bidagency-response.json | 35 +++ .../bidagency/test-bidagency-bid-request.json | 56 ++++ .../test-bidagency-bid-response.json | 22 ++ .../server/it/test-application.properties | 10 + 22 files changed, 1088 insertions(+) create mode 100644 src/main/java/org/prebid/server/bidder/aso/AsoBidder.java create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/request/aso/ExtImpAso.java create mode 100644 src/main/java/org/prebid/server/spring/config/bidder/AsoConfiguration.java create mode 100644 src/main/resources/bidder-config/aso.yaml create mode 100644 src/main/resources/static/bidder-params/aso.json create mode 100644 src/test/java/org/prebid/server/bidder/aso/AsoBidderTest.java create mode 100644 src/test/java/org/prebid/server/it/AsoTest.java create mode 100644 src/test/java/org/prebid/server/it/BcmintTest.java create mode 100644 src/test/java/org/prebid/server/it/BidAgencyTest.java create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/aso/test-aso-bid-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/aso/test-aso-bid-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/aso/test-auction-aso-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/aso/test-auction-aso-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-auction-bcmint-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-auction-bcmint-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-bcmint-bid-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-bcmint-bid-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-auction-bidagency-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-auction-bidagency-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-bidagency-bid-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-bidagency-bid-response.json diff --git a/src/main/java/org/prebid/server/bidder/aso/AsoBidder.java b/src/main/java/org/prebid/server/bidder/aso/AsoBidder.java new file mode 100644 index 00000000000..62307fb7bf8 --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/aso/AsoBidder.java @@ -0,0 +1,162 @@ +package org.prebid.server.bidder.aso; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import io.vertx.core.http.HttpMethod; +import org.apache.commons.lang3.StringUtils; +import org.prebid.server.bidder.Bidder; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.exception.PreBidException; +import org.prebid.server.json.DecodeException; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.aso.ExtImpAso; +import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.proto.openrtb.ext.response.ExtBidPrebid; +import org.prebid.server.util.BidderUtil; +import org.prebid.server.util.HttpUtil; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +public class AsoBidder implements Bidder { + + private static final TypeReference> EXT_TYPE_REFERENCE = new TypeReference<>() { + }; + + private static final TypeReference> EXT_PREBID_TYPE_REFERENCE = + new TypeReference<>() { + }; + + private static final String ZONE_MACRO = "{{ZoneID}}"; + private static final String PRICE_MACRO = "${AUCTION_PRICE}"; + + private final String endpointUrl; + private final JacksonMapper mapper; + + public AsoBidder(String endpointUrl, JacksonMapper mapper) { + this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); + this.mapper = Objects.requireNonNull(mapper); + } + + @Override + public Result>> makeHttpRequests(BidRequest request) { + final List errors = new ArrayList<>(); + final List> httpRequests = new ArrayList<>(); + + for (Imp imp : request.getImp()) { + try { + final ExtImpAso extImp = parseImpExt(imp); + final BidRequest modifiedRequest = modifyBidRequest(request, imp); + httpRequests.add(makeHttpRequest(modifiedRequest, extImp)); + } catch (PreBidException e) { + errors.add(BidderError.badInput(e.getMessage())); + } + } + + return Result.of(httpRequests, errors); + } + + private ExtImpAso parseImpExt(Imp imp) { + try { + return mapper.mapper().convertValue(imp.getExt(), EXT_TYPE_REFERENCE).getBidder(); + } catch (IllegalArgumentException e) { + throw new PreBidException("Missing bidder ext in impression with id: " + imp.getId()); + } + } + + private BidRequest modifyBidRequest(BidRequest request, Imp imp) { + return request.toBuilder() + .imp(Collections.singletonList(imp)) + .build(); + } + + private HttpRequest makeHttpRequest(BidRequest request, ExtImpAso extImp) { + return HttpRequest.builder() + .method(HttpMethod.POST) + .uri(makeUrl(extImp.getZone())) + .impIds(BidderUtil.impIds(request)) + .headers(HttpUtil.headers()) + .payload(request) + .body(mapper.encodeToBytes(request)) + .build(); + } + + private String makeUrl(Integer zone) { + return endpointUrl.replace(ZONE_MACRO, zone.toString()); + } + + @Override + public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + try { + final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); + final List errors = new ArrayList<>(); + return Result.of(extractBids(bidResponse, errors), errors); + } catch (DecodeException | PreBidException e) { + return Result.withError(BidderError.badServerResponse(e.getMessage())); + } + } + + private List extractBids(BidResponse bidResponse, List errors) { + if (bidResponse == null || bidResponse.getSeatbid() == null) { + return Collections.emptyList(); + } + return bidsFromResponse(bidResponse, errors); + } + + private List bidsFromResponse(BidResponse bidResponse, List errors) { + return bidResponse.getSeatbid().stream() + .filter(Objects::nonNull) + .map(SeatBid::getBid) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .map(bid -> makeBid(bid, bidResponse.getCur(), errors)) + .filter(Objects::nonNull) + .toList(); + } + + private BidderBid makeBid(Bid bid, String currency, List errors) { + final BidType mediaType = getMediaType(bid, errors); + + if (mediaType == null) { + return null; + } + + final BigDecimal price = bid.getPrice(); + final String priceAsString = price != null ? price.toPlainString() : "0"; + + final Bid modifiedBid = bid.toBuilder() + .nurl(StringUtils.replace(bid.getNurl(), PRICE_MACRO, priceAsString)) + .adm(StringUtils.replace(bid.getAdm(), PRICE_MACRO, priceAsString)) + .build(); + + return BidderBid.of(modifiedBid, mediaType, currency); + } + + private BidType getMediaType(Bid bid, List errors) { + try { + return Optional.ofNullable(bid.getExt()) + .map(ext -> mapper.mapper().convertValue(ext, EXT_PREBID_TYPE_REFERENCE)) + .map(ExtPrebid::getPrebid) + .map(ExtBidPrebid::getType) + .orElseThrow(IllegalArgumentException::new); + } catch (IllegalArgumentException e) { + errors.add(BidderError.badServerResponse("Failed to get type of bid \"%s\"".formatted(bid.getImpid()))); + return null; + } + } +} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/aso/ExtImpAso.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/aso/ExtImpAso.java new file mode 100644 index 00000000000..94eacc87567 --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/aso/ExtImpAso.java @@ -0,0 +1,10 @@ +package org.prebid.server.proto.openrtb.ext.request.aso; + +import lombok.Value; + +@Value(staticConstructor = "of") +public class ExtImpAso { + + Integer zone; + +} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AsoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AsoConfiguration.java new file mode 100644 index 00000000000..840b578ea28 --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/bidder/AsoConfiguration.java @@ -0,0 +1,41 @@ +package org.prebid.server.spring.config.bidder; + +import org.prebid.server.bidder.BidderDeps; +import org.prebid.server.bidder.aso.AsoBidder; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; +import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; +import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; +import org.prebid.server.spring.env.YamlPropertySourceFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import javax.validation.constraints.NotBlank; + +@Configuration +@PropertySource(value = "classpath:/bidder-config/aso.yaml", factory = YamlPropertySourceFactory.class) +public class AsoConfiguration { + + private static final String BIDDER_NAME = "aso"; + + @Bean("asoConfigurationProperties") + @ConfigurationProperties("adapters.aso") + BidderConfigurationProperties configurationProperties() { + return new BidderConfigurationProperties(); + } + + @Bean + BidderDeps asoBidderDeps(BidderConfigurationProperties asoConfigurationProperties, + @NotBlank @Value("${external-url}") String externalUrl, + JacksonMapper mapper) { + + return BidderDepsAssembler.forBidder(BIDDER_NAME) + .withConfig(asoConfigurationProperties) + .usersyncerCreator(UsersyncerCreator.create(externalUrl)) + .bidderCreator(config -> new AsoBidder(config.getEndpoint(), mapper)) + .assemble(); + } +} diff --git a/src/main/resources/bidder-config/aso.yaml b/src/main/resources/bidder-config/aso.yaml new file mode 100644 index 00000000000..ddae491f357 --- /dev/null +++ b/src/main/resources/bidder-config/aso.yaml @@ -0,0 +1,25 @@ +adapters: + aso: + endpoint: https://srv.aso1.net/pbs/bidder?zid={{ZoneID}} + aliases: + bcmint: + enabled: false + endpoint: https://srv.datacygnal.io/pbs/bidder?zid={{ZoneID}} + meta-info: + maintainer-email: contact@bcm.ltd + bidagency: + enabled: false + endpoint: https://srv.bidgx.com/pbs/bidder?zid={{ZoneID}} + meta-info: + maintainer-email: aso@bidgency.com + meta-info: + maintainer-email: support@adsrv.org + app-media-types: + - banner + - video + - native + site-media-types: + - banner + - video + - native + vendor-id: 0 diff --git a/src/main/resources/static/bidder-params/aso.json b/src/main/resources/static/bidder-params/aso.json new file mode 100644 index 00000000000..edb3c0feb9c --- /dev/null +++ b/src/main/resources/static/bidder-params/aso.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Adserver.Online Adapter Params", + "description": "A schema which validates params accepted by the aso adapter", + "type": "object", + "properties": { + "zone": { + "type": "integer", + "description": "An ID which identifies the zone selling the impression" + } + }, + "required": ["zone"] +} diff --git a/src/test/java/org/prebid/server/bidder/aso/AsoBidderTest.java b/src/test/java/org/prebid/server/bidder/aso/AsoBidderTest.java new file mode 100644 index 00000000000..46e3375e8f4 --- /dev/null +++ b/src/test/java/org/prebid/server/bidder/aso/AsoBidderTest.java @@ -0,0 +1,296 @@ +package org.prebid.server.bidder.aso; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import io.vertx.core.http.HttpMethod; +import org.junit.Test; +import org.prebid.server.VertxTest; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.HttpResponse; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.aso.ExtImpAso; +import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.proto.openrtb.ext.response.ExtBidPrebid; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.function.UnaryOperator; + +import static java.util.Collections.singletonList; +import static java.util.function.UnaryOperator.identity; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.tuple; +import static org.prebid.server.bidder.model.BidderError.Type.bad_server_response; +import static org.prebid.server.util.HttpUtil.ACCEPT_HEADER; +import static org.prebid.server.util.HttpUtil.APPLICATION_JSON_CONTENT_TYPE; +import static org.prebid.server.util.HttpUtil.CONTENT_TYPE_HEADER; +import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; + +public class AsoBidderTest extends VertxTest { + + private static final String ENDPOINT_URL = "https://test-url.com?zid={{ZoneID}}"; + + private final AsoBidder target = new AsoBidder(ENDPOINT_URL, jacksonMapper); + + @Test + public void shouldFailOnBidderCreation() { + assertThatIllegalArgumentException().isThrownBy(() -> new AsoBidder("invalid_url", jacksonMapper)); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedUrl() { + // given + final ObjectNode invalidExt = mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())); + final BidRequest bidRequest = givenBidRequest( + impBuilder -> impBuilder.id("imp1").ext(givenImpExt(1)), + impBuilder -> impBuilder.id("imp2").ext(givenImpExt(2)), + impBuilder -> impBuilder.id("invalid_imp3").ext(invalidExt)); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).hasSize(2) + .extracting(HttpRequest::getUri) + .containsExactly("https://test-url.com?zid=1", "https://test-url.com?zid=2"); + + assertThat(result.getErrors()).hasSize(1).allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing bidder ext in impression with id: invalid_imp3"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); + }); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedHeaders() { + // given + final BidRequest bidRequest = givenBidRequest(identity()); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).hasSize(1).first() + .extracting(HttpRequest::getHeaders) + .satisfies(headers -> assertThat(headers.get(CONTENT_TYPE_HEADER)) + .isEqualTo(APPLICATION_JSON_CONTENT_TYPE)) + .satisfies(headers -> assertThat(headers.get(ACCEPT_HEADER)) + .isEqualTo(APPLICATION_JSON_VALUE)); + assertThat(result.getErrors()).isEmpty(); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedBody() { + // given + final ObjectNode invalidExt = mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())); + final BidRequest bidRequest = givenBidRequest( + impBuilder -> impBuilder.id("imp1"), + impBuilder -> impBuilder.id("imp2"), + impBuilder -> impBuilder.id("invalid_imp3").ext(invalidExt)); + + // when + final Result>> results = target.makeHttpRequests(bidRequest); + + // then + final BidRequest firstExpectedRequest = givenBidRequest(impBuilder -> impBuilder.id("imp1")); + final BidRequest secondExpectedRequest = givenBidRequest(impBuilder -> impBuilder.id("imp2")); + assertThat(results.getValue()).hasSize(2) + .extracting(HttpRequest::getBody, HttpRequest::getPayload) + .containsExactly( + tuple(jacksonMapper.encodeToBytes(firstExpectedRequest), firstExpectedRequest), + tuple(jacksonMapper.encodeToBytes(secondExpectedRequest), secondExpectedRequest)); + + assertThat(results.getErrors()).hasSize(1).allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing bidder ext in impression with id: invalid_imp3"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); + }); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedRequestMethod() { + // given + final BidRequest bidRequest = givenBidRequest(identity()); + + // when + final Result>> results = target.makeHttpRequests(bidRequest); + + // then + assertThat(results.getValue()).hasSize(1).first() + .satisfies(request -> assertThat(request.getMethod()).isEqualTo(HttpMethod.POST)); + assertThat(results.getErrors()).isEmpty(); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedImpIds() { + // given + final ObjectNode invalidExt = mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())); + final BidRequest bidRequest = givenBidRequest( + impBuilder -> impBuilder.id("imp1"), + impBuilder -> impBuilder.id("imp2"), + impBuilder -> impBuilder.id("invalid_imp3").ext(invalidExt)); + + // when + final Result>> results = target.makeHttpRequests(bidRequest); + + // then + assertThat(results.getValue()).hasSize(2) + .extracting(HttpRequest::getImpIds) + .containsExactly(Set.of("imp1"), Set.of("imp2")); + assertThat(results.getErrors()).hasSize(1).allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing bidder ext in impression with id: invalid_imp3"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); + }); + } + + @Test + public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { + // given + final BidderCall httpCall = givenHttpCall("invalid"); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).hasSize(1); + assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().get(0).getType()).isEqualTo(bad_server_response); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnEmptyListWhenBidResponseSeatBidIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnErrorAndEmptyListWhenBidTypeCanBeResolved() throws JsonProcessingException { + // given + final Bid invalidBid1 = Bid.builder().impid("imp_id1").ext(mapper.createObjectNode().put("prebid", 2)).build(); + final Bid invalidBid2 = Bid.builder().impid("imp_id2").ext(mapper.createObjectNode()).build(); + final BidderCall httpCall = givenHttpCall(invalidBid1, invalidBid2); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).hasSize(2) + .extracting(BidderError::getMessage, BidderError::getType) + .containsExactly( + tuple("Failed to get type of bid \"imp_id1\"", bad_server_response), + tuple("Failed to get type of bid \"imp_id2\"", bad_server_response)); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnBidWithResolvedMacros() throws JsonProcessingException { + // given + final ObjectNode bidExt = mapper.valueToTree(ExtPrebid.of( + ExtBidPrebid.builder().type(BidType.banner).build(), null)); + final Bid givenBid = Bid.builder() + .impid("imp_id") + .price(BigDecimal.valueOf(3.32)) + .nurl("nurl_${AUCTION_PRICE}_nurl") + .adm("adm_${AUCTION_PRICE}_adm") + .ext(bidExt) + .build(); + final BidderCall httpCall = givenHttpCall(givenBid); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1).first() + .satisfies(bid -> { + assertThat(bid.getBidCurrency()).isEqualTo("USD"); + assertThat(bid.getType()).isEqualTo(BidType.banner); + assertThat(bid.getBid().getAdm()).isEqualTo("adm_3.32_adm"); + assertThat(bid.getBid().getNurl()).isEqualTo("nurl_3.32_nurl"); + assertThat(bid.getBid().getPrice()).isEqualTo(BigDecimal.valueOf(3.32)); + }); + } + + @Test + public void makeBidsShouldReturnBidWithResolvedMacrosWhenPriceIsEmpty() throws JsonProcessingException { + // given + final ObjectNode bidExt = mapper.valueToTree(ExtPrebid.of( + ExtBidPrebid.builder().type(BidType.banner).build(), null)); + final Bid givenBid = Bid.builder() + .impid("imp_id") + .price(null) + .nurl("nurl_${AUCTION_PRICE}_nurl") + .adm("adm_${AUCTION_PRICE}_adm") + .ext(bidExt) + .build(); + final BidderCall httpCall = givenHttpCall(givenBid); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1).first() + .satisfies(bid -> { + assertThat(bid.getBidCurrency()).isEqualTo("USD"); + assertThat(bid.getType()).isEqualTo(BidType.banner); + assertThat(bid.getBid().getAdm()).isEqualTo("adm_0_adm"); + assertThat(bid.getBid().getNurl()).isEqualTo("nurl_0_nurl"); + assertThat(bid.getBid().getPrice()).isNull(); + }); + } + + private static BidRequest givenBidRequest(UnaryOperator... impCustomizers) { + return BidRequest.builder() + .imp(Arrays.stream(impCustomizers).map(AsoBidderTest::givenImp).toList()) + .build(); + } + + private static Imp givenImp(UnaryOperator impCustomizer) { + return impCustomizer.apply(Imp.builder().id("imp_id").ext(givenImpExt(1))).build(); + } + + private static ObjectNode givenImpExt(int zone) { + return mapper.valueToTree(ExtPrebid.of(null, ExtImpAso.of(zone))); + } + + private static String givenBidResponse(Bid... bids) throws JsonProcessingException { + return mapper.writeValueAsString(BidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder().bid(List.of(bids)).build())) + .build()); + } + + private static BidderCall givenHttpCall(Bid... bids) throws JsonProcessingException { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, givenBidResponse(bids)), + null); + } + + private static BidderCall givenHttpCall(String body) { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, body), + null); + } + +} diff --git a/src/test/java/org/prebid/server/it/AsoTest.java b/src/test/java/org/prebid/server/it/AsoTest.java new file mode 100644 index 00000000000..2f99f5e7b6c --- /dev/null +++ b/src/test/java/org/prebid/server/it/AsoTest.java @@ -0,0 +1,41 @@ +package org.prebid.server.it; + +import io.restassured.response.Response; +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.prebid.server.model.Endpoint; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static java.util.Collections.singletonList; + +@RunWith(SpringRunner.class) +public class AsoTest extends IntegrationTest { + + @Test + public void openrtb2AuctionShouldRespondWithBidsFromAso() throws IOException, JSONException { + // given + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/aso-exchange")) + .withQueryParam("zid", equalTo("1")) + .withRequestBody(equalToJson( + jsonFrom("openrtb2/aso/test-aso-bid-request.json"))) + .willReturn(aResponse().withBody( + jsonFrom("openrtb2/aso/test-aso-bid-response.json")))); + + // when + final Response response = responseFor("openrtb2/aso/test-auction-aso-request.json", + Endpoint.openrtb2_auction); + + // then + assertJsonEquals("openrtb2/aso/test-auction-aso-response.json", response, + singletonList("aso")); + } +} + diff --git a/src/test/java/org/prebid/server/it/BcmintTest.java b/src/test/java/org/prebid/server/it/BcmintTest.java new file mode 100644 index 00000000000..efdf9d2b16d --- /dev/null +++ b/src/test/java/org/prebid/server/it/BcmintTest.java @@ -0,0 +1,41 @@ +package org.prebid.server.it; + +import io.restassured.response.Response; +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.prebid.server.model.Endpoint; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static java.util.Collections.singletonList; + +@RunWith(SpringRunner.class) +public class BcmintTest extends IntegrationTest { + + @Test + public void openrtb2AuctionShouldRespondWithBidsFromBcmint() throws IOException, JSONException { + // given + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/bcmint-exchange")) + .withQueryParam("zid", equalTo("1")) + .withRequestBody(equalToJson( + jsonFrom("openrtb2/bcmint/test-bcmint-bid-request.json"))) + .willReturn(aResponse().withBody( + jsonFrom("openrtb2/bcmint/test-bcmint-bid-response.json")))); + + // when + final Response response = responseFor("openrtb2/bcmint/test-auction-bcmint-request.json", + Endpoint.openrtb2_auction); + + // then + assertJsonEquals("openrtb2/bcmint/test-auction-bcmint-response.json", response, + singletonList("bcmint")); + } +} + diff --git a/src/test/java/org/prebid/server/it/BidAgencyTest.java b/src/test/java/org/prebid/server/it/BidAgencyTest.java new file mode 100644 index 00000000000..ba4422aac30 --- /dev/null +++ b/src/test/java/org/prebid/server/it/BidAgencyTest.java @@ -0,0 +1,41 @@ +package org.prebid.server.it; + +import io.restassured.response.Response; +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.prebid.server.model.Endpoint; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static java.util.Collections.singletonList; + +@RunWith(SpringRunner.class) +public class BidAgencyTest extends IntegrationTest { + + @Test + public void openrtb2AuctionShouldRespondWithBidsFromBidAgency() throws IOException, JSONException { + // given + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/bidagency-exchange")) + .withQueryParam("zid", equalTo("1")) + .withRequestBody(equalToJson( + jsonFrom("openrtb2/bidagency/test-bidagency-bid-request.json"))) + .willReturn(aResponse().withBody( + jsonFrom("openrtb2/bidagency/test-bidagency-bid-response.json")))); + + // when + final Response response = responseFor("openrtb2/bidagency/test-auction-bidagency-request.json", + Endpoint.openrtb2_auction); + + // then + assertJsonEquals("openrtb2/bidagency/test-auction-bidagency-response.json", response, + singletonList("bidagency")); + } +} + diff --git a/src/test/resources/org/prebid/server/it/openrtb2/aso/test-aso-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/aso/test-aso-bid-request.json new file mode 100644 index 00000000000..a50e33e55e4 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/aso/test-aso-bid-request.json @@ -0,0 +1,56 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "secure": 1, + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "tid": "${json-unit.any-string}", + "bidder" : { + "zone" : 1 + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "ext": { + "gdpr": 0 + } + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/aso/test-aso-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/aso/test-aso-bid-response.json new file mode 100644 index 00000000000..665be9472f4 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/aso/test-aso-bid-response.json @@ -0,0 +1,22 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 4.7, + "adm": "adm6_${AUCTION_PRICE}", + "nurl": "nurl_${AUCTION_PRICE}", + "crid": "crid6", + "ext": { + "prebid": { + "type": "banner" + } + } + } + ] + } + ] +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/aso/test-auction-aso-request.json b/src/test/resources/org/prebid/server/it/openrtb2/aso/test-auction-aso-request.json new file mode 100644 index 00000000000..396436aead1 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/aso/test-auction-aso-request.json @@ -0,0 +1,23 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "aso": { + "zone" : 1 + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/aso/test-auction-aso-response.json b/src/test/resources/org/prebid/server/it/openrtb2/aso/test-auction-aso-response.json new file mode 100644 index 00000000000..cef76b6cec9 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/aso/test-auction-aso-response.json @@ -0,0 +1,35 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 4.7, + "adm": "adm6_4.7", + "nurl": "nurl_4.7", + "crid": "crid6", + "ext": { + "prebid": { + "type": "banner" + }, + "origbidcpm": 4.7 + } + } + ], + "seat": "aso", + "group": 0 + } + ], + "cur": "USD", + "ext": { + "responsetimemillis": { + "aso": "{{ aso.response_time_ms }}" + }, + "prebid": { + "auctiontimestamp": 0 + }, + "tmaxrequest": 5000 + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-auction-bcmint-request.json b/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-auction-bcmint-request.json new file mode 100644 index 00000000000..9d97ef6cb6c --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-auction-bcmint-request.json @@ -0,0 +1,23 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bcmint": { + "zone" : 1 + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-auction-bcmint-response.json b/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-auction-bcmint-response.json new file mode 100644 index 00000000000..1ca1cb7607c --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-auction-bcmint-response.json @@ -0,0 +1,35 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 4.7, + "adm": "adm6_4.7", + "nurl": "nurl_4.7", + "crid": "crid6", + "ext": { + "prebid": { + "type": "banner" + }, + "origbidcpm": 4.7 + } + } + ], + "seat": "bcmint", + "group": 0 + } + ], + "cur": "USD", + "ext": { + "responsetimemillis": { + "bcmint": "{{ bcmint.response_time_ms }}" + }, + "prebid": { + "auctiontimestamp": 0 + }, + "tmaxrequest": 5000 + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-bcmint-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-bcmint-bid-request.json new file mode 100644 index 00000000000..a50e33e55e4 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-bcmint-bid-request.json @@ -0,0 +1,56 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "secure": 1, + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "tid": "${json-unit.any-string}", + "bidder" : { + "zone" : 1 + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "ext": { + "gdpr": 0 + } + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-bcmint-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-bcmint-bid-response.json new file mode 100644 index 00000000000..665be9472f4 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bcmint/test-bcmint-bid-response.json @@ -0,0 +1,22 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 4.7, + "adm": "adm6_${AUCTION_PRICE}", + "nurl": "nurl_${AUCTION_PRICE}", + "crid": "crid6", + "ext": { + "prebid": { + "type": "banner" + } + } + } + ] + } + ] +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-auction-bidagency-request.json b/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-auction-bidagency-request.json new file mode 100644 index 00000000000..5ad79b5e2fe --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-auction-bidagency-request.json @@ -0,0 +1,23 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidagency": { + "zone" : 1 + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-auction-bidagency-response.json b/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-auction-bidagency-response.json new file mode 100644 index 00000000000..80cfe99af9e --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-auction-bidagency-response.json @@ -0,0 +1,35 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 4.7, + "adm": "adm6_4.7", + "nurl": "nurl_4.7", + "crid": "crid6", + "ext": { + "prebid": { + "type": "banner" + }, + "origbidcpm": 4.7 + } + } + ], + "seat": "bidagency", + "group": 0 + } + ], + "cur": "USD", + "ext": { + "responsetimemillis": { + "bidagency": "{{ bidagency.response_time_ms }}" + }, + "prebid": { + "auctiontimestamp": 0 + }, + "tmaxrequest": 5000 + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-bidagency-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-bidagency-bid-request.json new file mode 100644 index 00000000000..a50e33e55e4 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-bidagency-bid-request.json @@ -0,0 +1,56 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "secure": 1, + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "tid": "${json-unit.any-string}", + "bidder" : { + "zone" : 1 + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "ext": { + "gdpr": 0 + } + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-bidagency-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-bidagency-bid-response.json new file mode 100644 index 00000000000..665be9472f4 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bidagency/test-bidagency-bid-response.json @@ -0,0 +1,22 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 4.7, + "adm": "adm6_${AUCTION_PRICE}", + "nurl": "nurl_${AUCTION_PRICE}", + "crid": "crid6", + "ext": { + "prebid": { + "type": "banner" + } + } + } + ] + } + ] +} diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 405f016babc..7dbefb776a6 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -99,6 +99,16 @@ adapters.appnexus.aliases.mediafuse.enabled=true adapters.appnexus.aliases.mediafuse.endpoint=http://localhost:8090/mediafuse-exchange adapters.appush.enabled=true adapters.appush.endpoint=http://localhost:8090/appush-exchange + +adapters.aso.enabled=true +adapters.aso.endpoint=http://localhost:8090/aso-exchange?zid={{ZoneID}} + +adapters.aso.aliases.bcmint.enabled=true +adapters.aso.aliases.bcmint.endpoint=http://localhost:8090/bcmint-exchange?zid={{ZoneID}} + +adapters.aso.aliases.bidagency.enabled=true +adapters.aso.aliases.bidagency.endpoint=http://localhost:8090/bidagency-exchange?zid={{ZoneID}} + adapters.automatad.enabled=true adapters.automatad.endpoint=http://localhost:8090/automatad-exchange adapters.avocet.enabled=true From 4a440de53e286adaf4797f29dcbf365883eeb8e2 Mon Sep 17 00:00:00 2001 From: "chinmay.b@media.net" <104977653+b-chinmay@users.noreply.github.com> Date: Wed, 22 May 2024 19:08:49 +0530 Subject: [PATCH 55/62] Medianet: Fledge support (#3129) --- .../bidder/medianet/MedianetBidder.java | 50 +++++-- .../response/InterestGroupAuctionBuyer.java | 23 ++++ .../response/InterestGroupAuctionIntent.java | 15 +++ .../response/InterestGroupAuctionSeller.java | 16 +++ .../model/response/MedianetBidResponse.java | 26 ++++ .../response/MedianetBidResponseExt.java | 11 ++ .../bidder/medianet/MedianetBidderTest.java | 123 ++++++++++++++---- 7 files changed, 231 insertions(+), 33 deletions(-) create mode 100644 src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionBuyer.java create mode 100644 src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionIntent.java create mode 100644 src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionSeller.java create mode 100644 src/main/java/org/prebid/server/bidder/medianet/model/response/MedianetBidResponse.java create mode 100644 src/main/java/org/prebid/server/bidder/medianet/model/response/MedianetBidResponseExt.java diff --git a/src/main/java/org/prebid/server/bidder/medianet/MedianetBidder.java b/src/main/java/org/prebid/server/bidder/medianet/MedianetBidder.java index 2e88d1becd7..d184aefc297 100644 --- a/src/main/java/org/prebid/server/bidder/medianet/MedianetBidder.java +++ b/src/main/java/org/prebid/server/bidder/medianet/MedianetBidder.java @@ -3,19 +3,23 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.bidder.Bidder; +import org.prebid.server.bidder.medianet.model.response.InterestGroupAuctionIntent; +import org.prebid.server.bidder.medianet.model.response.MedianetBidResponse; +import org.prebid.server.bidder.medianet.model.response.MedianetBidResponseExt; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderCall; import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.CompositeBidderResponse; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig; import org.prebid.server.util.BidderUtil; import org.prebid.server.util.HttpUtil; @@ -24,6 +28,7 @@ import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.Optional; public class MedianetBidder implements Bidder { @@ -40,22 +45,36 @@ public Result>> makeHttpRequests(BidRequest bidRequ return Result.withValue(BidderUtil.defaultRequest(bidRequest, endpointUrl, mapper)); } + /** + * @deprecated for this bidder in favor of @link{makeBidderResponse} which supports additional response data + */ @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - final BidResponse bidResponse; + @Deprecated(forRemoval = true) + public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + return Result.withError(BidderError.generic("Deprecated adapter method invoked")); + } + + @Override + public final CompositeBidderResponse makeBidderResponse(BidderCall httpCall, BidRequest bidRequest) { + final MedianetBidResponse bidResponse; try { - bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); + bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), MedianetBidResponse.class); } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); + return CompositeBidderResponse.withError(BidderError.badServerResponse(e.getMessage())); } final List errors = new ArrayList<>(); final List bids = extractBids(httpCall.getRequest().getPayload(), bidResponse, errors); + final List fledgeAuctionConfigs = extractFledge(bidResponse); - return Result.of(bids, errors); + return CompositeBidderResponse.builder() + .bids(bids) + .fledgeAuctionConfigs(fledgeAuctionConfigs) + .errors(errors) + .build(); } - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse, + private static List extractBids(BidRequest bidRequest, MedianetBidResponse bidResponse, List errors) { if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { return Collections.emptyList(); @@ -84,9 +103,8 @@ private static BidType resolveBidType(Bid bid, List imps) { case 2 -> BidType.video; case 3 -> BidType.audio; case 4 -> BidType.xNative; - default -> - throw new PreBidException("Unable to fetch mediaType: %s" - .formatted(bid.getImpid())); + default -> throw new PreBidException("Unable to fetch mediaType: %s" + .formatted(bid.getImpid())); }; } @@ -119,4 +137,16 @@ private static BidType resolveBidTypeFromImpId(String impId, List imps) { return BidType.banner; } + + private static List extractFledge(MedianetBidResponse bidResponse) { + return Optional.ofNullable(bidResponse) + .map(MedianetBidResponse::getExt) + .map(MedianetBidResponseExt::getIgi) + .orElse(Collections.emptyList()) + .stream() + .map(InterestGroupAuctionIntent::getIgs) + .flatMap(Collection::stream) + .map(e -> FledgeAuctionConfig.builder().impId(e.getImpId()).config(e.getConfig()).build()) + .toList(); + } } diff --git a/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionBuyer.java b/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionBuyer.java new file mode 100644 index 00000000000..04340fd8321 --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionBuyer.java @@ -0,0 +1,23 @@ +package org.prebid.server.bidder.medianet.model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.node.ObjectNode; +import lombok.Value; + +@Value +public class InterestGroupAuctionBuyer { + + String origin; + + @JsonProperty("maxbid") + Double maxBid; + + @JsonProperty("cur") + String currency; + + @JsonProperty("pbs") + String buyerSignals; + + @JsonProperty("ps") + ObjectNode prioritySignals; +} diff --git a/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionIntent.java b/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionIntent.java new file mode 100644 index 00000000000..e060c1fb5dd --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionIntent.java @@ -0,0 +1,15 @@ +package org.prebid.server.bidder.medianet.model.response; + +import lombok.Builder; +import lombok.Value; + +import java.util.List; + +@Builder +@Value +public class InterestGroupAuctionIntent { + + List igb; + + List igs; +} diff --git a/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionSeller.java b/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionSeller.java new file mode 100644 index 00000000000..15ae3ade13b --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/medianet/model/response/InterestGroupAuctionSeller.java @@ -0,0 +1,16 @@ +package org.prebid.server.bidder.medianet.model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.node.ObjectNode; +import lombok.Builder; +import lombok.Value; + +@Builder +@Value +public class InterestGroupAuctionSeller { + + @JsonProperty(value = "impid") + String impId; + + ObjectNode config; +} diff --git a/src/main/java/org/prebid/server/bidder/medianet/model/response/MedianetBidResponse.java b/src/main/java/org/prebid/server/bidder/medianet/model/response/MedianetBidResponse.java new file mode 100644 index 00000000000..4677294e6fc --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/medianet/model/response/MedianetBidResponse.java @@ -0,0 +1,26 @@ +package org.prebid.server.bidder.medianet.model.response; + +import com.iab.openrtb.response.SeatBid; +import lombok.Builder; +import lombok.Value; + +import java.util.List; + +@Value +@Builder +public class MedianetBidResponse { + + String id; + + List seatbid; + + String bidid; + + String cur; + + String customdata; + + Integer nbr; + + MedianetBidResponseExt ext; +} diff --git a/src/main/java/org/prebid/server/bidder/medianet/model/response/MedianetBidResponseExt.java b/src/main/java/org/prebid/server/bidder/medianet/model/response/MedianetBidResponseExt.java new file mode 100644 index 00000000000..2ce5775704c --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/medianet/model/response/MedianetBidResponseExt.java @@ -0,0 +1,11 @@ +package org.prebid.server.bidder.medianet.model.response; + +import lombok.Value; + +import java.util.List; + +@Value(staticConstructor = "of") +public class MedianetBidResponseExt { + + List igi; +} diff --git a/src/test/java/org/prebid/server/bidder/medianet/MedianetBidderTest.java b/src/test/java/org/prebid/server/bidder/medianet/MedianetBidderTest.java index fb541c35d5d..42390ad0f79 100644 --- a/src/test/java/org/prebid/server/bidder/medianet/MedianetBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/medianet/MedianetBidderTest.java @@ -9,18 +9,25 @@ import com.iab.openrtb.response.SeatBid; import org.junit.Test; import org.prebid.server.VertxTest; +import org.prebid.server.bidder.medianet.model.response.InterestGroupAuctionIntent; +import org.prebid.server.bidder.medianet.model.response.InterestGroupAuctionSeller; +import org.prebid.server.bidder.medianet.model.response.MedianetBidResponse; +import org.prebid.server.bidder.medianet.model.response.MedianetBidResponseExt; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderCall; import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.CompositeBidderResponse; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.HttpResponse; import org.prebid.server.bidder.model.Result; import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig; import java.util.ArrayList; import java.util.List; import java.util.function.Function; +import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -63,7 +70,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { final BidderCall httpCall = sampleHttpCall(givenBidRequest(), "invalid response"); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then assertThat(result.getErrors()).hasSize(1) @@ -78,11 +85,11 @@ public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProces httpCall = sampleHttpCall(givenBidRequest(), mapper.writeValueAsString(null)); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then + assertThat(result.getBids()).isEmpty(); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); } @Test @@ -92,11 +99,11 @@ public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws Jso httpCall = sampleHttpCall(null, mapper.writeValueAsString(BidResponse.builder().build())); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then + assertThat(result.getBids()).isEmpty(); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); } @Test @@ -107,12 +114,12 @@ public void makeBidsShouldReturnBannerBidIfBannerIsPresent() throws JsonProcessi mapper.writeValueAsString(sampleBidResponse(bidBuilder -> bidBuilder.impid("123")))); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) + assertThat(result.getBids()) .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); + assertThat(result.getErrors()).isEmpty(); } @Test @@ -133,16 +140,16 @@ public void makeBidsShouldReturnCorrespondingMtypesAndAdTypes() throws JsonProce mapper.writeValueAsString(sampleMultiFormatBidResponse(bids))); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then + assertThat(result.getBids()).hasSize(4); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(4); final BidderBid bannerBid = BidderBid.of(bid1, banner, "USD"); final BidderBid videoBid = BidderBid.of(bid2, video, "USD"); final BidderBid audioBid = BidderBid.of(bid3, audio, "USD"); final BidderBid xNativeBid = BidderBid.of(bid4, xNative, "USD"); - assertThat(result.getValue()).containsExactlyInAnyOrder(bannerBid, videoBid, audioBid, xNativeBid); + assertThat(result.getBids()).containsExactlyInAnyOrder(bannerBid, videoBid, audioBid, xNativeBid); } @Test @@ -153,13 +160,13 @@ public void makeBidsShouldReturnAdTypeAccordingToImpressionIfMtypeIsAbsent() thr mapper.writeValueAsString(sampleBidResponse(bidBuilder -> bidBuilder.impid("imp_id")))); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then + assertThat(result.getBids()).hasSize(1); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1); final BidderBid videoBid = BidderBid.of(Bid.builder().impid("imp_id").build(), video, "USD"); - assertThat(result.getValue()).containsExactly(videoBid); + assertThat(result.getBids()).containsExactly(videoBid); } @Test @@ -171,13 +178,13 @@ public void makeBidsShouldReturnBannerAdTypeIfMtypeIsAbsentAndIfNoImpressionIdMa mapper.writeValueAsString(sampleBidResponse(bidBuilder -> bidBuilder.impid("imp_id2")))); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then + assertThat(result.getBids()).hasSize(1); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1); final BidderBid bannerBid = BidderBid.of(Bid.builder().impid("imp_id2").build(), banner, "USD"); - assertThat(result.getValue()).containsExactly(bannerBid); + assertThat(result.getBids()).containsExactly(bannerBid); } @Test @@ -188,18 +195,58 @@ public void makeBidsShouldReturnErrorIfMtypeIsWrong() throws JsonProcessingExcep mapper.writeValueAsString(sampleBidResponse(bidBuilder -> bidBuilder.impid("imp_id").mtype(5)))); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then + assertThat(result.getBids()).isEmpty(); assertThat(result.getErrors()).hasSize(1); - assertThat(result.getValue()).isEmpty(); final BidderError error = BidderError.badServerResponse("Unable to fetch mediaType: imp_id"); assertThat(result.getErrors()).containsExactly(error); } - private static BidResponse sampleBidResponse(Function httpCall = sampleHttpCall( + givenBidRequest(), + mapper.writeValueAsString(sampleBidResponseWithFledgeConfig(bidBuilder -> bidBuilder.impid("imp_id")))); + + // when + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getBids()).hasSize(1); + assertThat(result.getFledgeAuctionConfigs()) + .containsOnly(FledgeAuctionConfig.builder() + .impId("imp_id") + .config(mapper.createObjectNode().put("someKey", "someValue")) + .build()); + } + + @Test + public void makeBidsShouldReturnFledgeConfigIfBidIsAbsent() throws JsonProcessingException { + // given + final BidderCall httpCall = sampleHttpCall( + givenBidRequest(), + mapper.writeValueAsString(sampleBidResponseWithoutBidAndWithFledgeConfig("imp_id"))); + + // when + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getBids()).isEmpty(); + assertThat(result.getFledgeAuctionConfigs()) + .containsOnly(FledgeAuctionConfig.builder() + .impId("imp_id") + .config(mapper.createObjectNode().put("someKey", "someValue")) + .build()); + } + + private static MedianetBidResponse sampleBidResponse(Function bidCustomizer) { - return BidResponse.builder() + return MedianetBidResponse.builder() .cur("USD") .seatbid(singletonList(SeatBid.builder() .bid(singletonList(bidCustomizer.apply(Bid.builder()).build())) @@ -207,8 +254,38 @@ private static BidResponse sampleBidResponse(Function bids) { - return BidResponse.builder() + private static MedianetBidResponse sampleBidResponseWithFledgeConfig(Function bidCustomizer) { + final Bid bid = bidCustomizer.apply(Bid.builder()).build(); + return MedianetBidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder() + .bid(singletonList(bid)) + .build())) + .ext(MedianetBidResponseExt.of(List.of(InterestGroupAuctionIntent.builder() + .igs(List.of(InterestGroupAuctionSeller.builder() + .impId(bid.getImpid()) + .config(mapper.createObjectNode().put("someKey", "someValue")) + .build())) + .build()))) + .build(); + } + + private static MedianetBidResponse sampleBidResponseWithoutBidAndWithFledgeConfig(String impId) { + return MedianetBidResponse.builder() + .cur("USD") + .seatbid(emptyList()) + .ext(MedianetBidResponseExt.of(List.of(InterestGroupAuctionIntent.builder() + .igs(List.of(InterestGroupAuctionSeller.builder() + .impId(impId) + .config(mapper.createObjectNode().put("someKey", "someValue")) + .build())) + .build()))) + .build(); + } + + private static MedianetBidResponse sampleMultiFormatBidResponse(List bids) { + return MedianetBidResponse.builder() .cur("USD") .seatbid(singletonList(SeatBid.builder() .bid(bids) From 610e724cb1883c1ee6227670df9d25007fb408ba Mon Sep 17 00:00:00 2001 From: Bryan DeLong Date: Wed, 22 May 2024 17:44:19 -0400 Subject: [PATCH 56/62] Consumable: Rewrite to support full ORTB from GO (#2927) --- .../bidder/consumable/ConsumableBidder.java | 320 ++++++----- .../consumable/model/ConsumableAdType.java | 70 --- .../consumable/model/ConsumableBidGdpr.java | 13 - .../model/ConsumableBidRequest.java | 53 -- .../model/ConsumableBidResponse.java | 13 - .../consumable/model/ConsumableContents.java | 11 - .../consumable/model/ConsumableDecision.java | 32 -- .../consumable/model/ConsumablePlacement.java | 30 - .../consumable/model/ConsumablePricing.java | 13 - .../consumable/model/ConsumableUser.java | 11 - .../request/consumable/ExtImpConsumable.java | 3 + .../resources/bidder-config/consumable.yaml | 8 +- .../consumable/ConsumableBidderTest.java | 514 ++++++++++-------- .../org/prebid/server/it/ConsumableTest.java | 19 +- .../test-auction-consumable-request.json | 31 +- .../test-auction-consumable-response.json | 24 +- .../test-consumable-bid-request-1.json | 23 - .../test-consumable-bid-request.json | 64 +++ .../test-consumable-bid-response-1.json | 18 - .../test-consumable-bid-response.json | 21 + 20 files changed, 582 insertions(+), 709 deletions(-) delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumableAdType.java delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidGdpr.java delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidRequest.java delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidResponse.java delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumableContents.java delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumableDecision.java delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumablePlacement.java delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumablePricing.java delete mode 100644 src/main/java/org/prebid/server/bidder/consumable/model/ConsumableUser.java delete mode 100644 src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-request-1.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-request.json delete mode 100644 src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-response-1.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-response.json diff --git a/src/main/java/org/prebid/server/bidder/consumable/ConsumableBidder.java b/src/main/java/org/prebid/server/bidder/consumable/ConsumableBidder.java index 507fcc97666..f636c3ff88c 100644 --- a/src/main/java/org/prebid/server/bidder/consumable/ConsumableBidder.java +++ b/src/main/java/org/prebid/server/bidder/consumable/ConsumableBidder.java @@ -1,227 +1,217 @@ package org.prebid.server.bidder.consumable; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.base.Strings; +import com.iab.openrtb.request.App; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Device; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Regs; import com.iab.openrtb.request.Site; -import com.iab.openrtb.request.User; import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; import io.vertx.core.MultiMap; -import io.vertx.core.http.HttpMethod; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.consumable.model.ConsumableAdType; -import org.prebid.server.bidder.consumable.model.ConsumableBidGdpr; -import org.prebid.server.bidder.consumable.model.ConsumableBidRequest; -import org.prebid.server.bidder.consumable.model.ConsumableBidResponse; -import org.prebid.server.bidder.consumable.model.ConsumableDecision; -import org.prebid.server.bidder.consumable.model.ConsumablePlacement; -import org.prebid.server.bidder.consumable.model.ConsumablePricing; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderCall; import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.CompositeBidderResponse; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.request.ExtRegs; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; import org.prebid.server.proto.openrtb.ext.request.consumable.ExtImpConsumable; import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.proto.openrtb.ext.response.ExtBidPrebidVideo; +import org.prebid.server.util.BidderUtil; import org.prebid.server.util.HttpUtil; -import java.math.BigDecimal; -import java.time.Instant; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.Objects; +import java.util.Optional; -public class ConsumableBidder implements Bidder { +public class ConsumableBidder implements Bidder { - private final String endpointUrl; + private static final String OPENRTB_VERSION = "2.5"; + private static final TypeReference> CONS_EXT_TYPE_REFERENCE = new TypeReference<>() { + }; + public static final String SITE_URI_PATH = "/sb/rtb"; + public static final String APP_URI_PATH = "/rtb/bid?s="; private final JacksonMapper mapper; + private final String endpointUrl; + public ConsumableBidder(String endpointUrl, JacksonMapper mapper) { this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); this.mapper = Objects.requireNonNull(mapper); } @Override - public Result>> makeHttpRequests(BidRequest request) { - final ConsumableBidRequest.ConsumableBidRequestBuilder requestBuilder = ConsumableBidRequest.builder() - .time(Instant.now().getEpochSecond()) - .includePricingData(true) - .enableBotFiltering(true) - .parallel(true); - - final Site site = request.getSite(); - if (site != null) { - requestBuilder - .referrer(site.getRef()) - .url(site.getPage()); - } - - final Regs regs = request.getRegs(); - - final String gpp = regs != null ? regs.getGpp() : null; - if (gpp != null) { - requestBuilder.gpp(gpp); - } - - final List gppSid = regs != null ? regs.getGppSid() : null; - if (CollectionUtils.isNotEmpty(gppSid)) { - requestBuilder.gppSid(gppSid); - } + public Result>> makeHttpRequests(BidRequest bidRequest) { + final List imps = new ArrayList<>(); + final List errors = new ArrayList<>(); + final List> httpRequests = new ArrayList<>(); + String placementId = null; + for (Imp imp : bidRequest.getImp()) { + try { + final ExtImpConsumable impExt = parseImpExt(imp); + if (!isImpValid(bidRequest.getSite(), bidRequest.getApp(), impExt)) { + continue; + } + if (Strings.isNullOrEmpty(placementId) && !Strings.isNullOrEmpty(impExt.getPlacementId())) { + placementId = impExt.getPlacementId(); + } - final ExtRegs extRegs = regs != null ? regs.getExt() : null; - final String usPrivacy = extRegs != null ? extRegs.getUsPrivacy() : null; - if (usPrivacy != null) { - requestBuilder.usPrivacy(usPrivacy); - } + imps.add(imp); - final Integer gdpr = extRegs != null ? extRegs.getGdpr() : null; - final User user = request.getUser(); - final ExtUser extUser = user != null ? user.getExt() : null; - final String gdprConsent = extUser != null ? extUser.getConsent() : null; - if (gdpr != null || gdprConsent != null) { - final ConsumableBidGdpr.ConsumableBidGdprBuilder bidGdprBuilder = ConsumableBidGdpr.builder(); - if (gdpr != null) { - bidGdprBuilder.applies(gdpr != 0); - } - if (gdprConsent != null) { - bidGdprBuilder.consent(gdprConsent).build(); + } catch (PreBidException e) { + errors.add(BidderError.badInput(e.getMessage())); } - requestBuilder.gdpr(bidGdprBuilder.build()); } - - try { - resolveRequestFields(requestBuilder, request.getImp()); - } catch (PreBidException e) { - return Result.withError(BidderError.badInput(e.getMessage())); + if (imps.isEmpty()) { + return Result.withErrors(errors); } - - final ConsumableBidRequest outgoingRequest = requestBuilder.build(); - - return Result.withValue(HttpRequest.builder() - .method(HttpMethod.POST) - .uri(endpointUrl) - .body(mapper.encodeToBytes(outgoingRequest)) - .headers(resolveHeaders(request)) - .payload(outgoingRequest) - .build()); - } - - private void resolveRequestFields(ConsumableBidRequest.ConsumableBidRequestBuilder requestBuilder, - List imps) { - final List placements = new ArrayList<>(); - for (int i = 0; i < imps.size(); i++) { - final Imp currentImp = imps.get(i); - final ExtImpConsumable extImpConsumable = parseImpExt(currentImp); - if (i == 0) { - requestBuilder - .networkId(extImpConsumable.getNetworkId()) - .siteId(extImpConsumable.getSiteId()) - .unitId(extImpConsumable.getUnitId()) - .unitName(extImpConsumable.getUnitName()); - } - placements.add(ConsumablePlacement.builder() - .divName(currentImp.getId()) - .networkId(extImpConsumable.getNetworkId()) - .siteId(extImpConsumable.getSiteId()) - .unitId(extImpConsumable.getUnitId()) - .unitName(extImpConsumable.getUnitName()) - .adTypes(ConsumableAdType.getSizeCodes(currentImp.getBanner().getFormat())) - .build()); - } - requestBuilder.placements(placements); + final BidRequest modRequest = modifyBidRequest(bidRequest, imps); + final String finalUrl = constructUri(placementId); + httpRequests.add(BidderUtil.defaultRequest(modRequest, resolveHeaders(), finalUrl, mapper)); + return Result.of(httpRequests, errors); } private ExtImpConsumable parseImpExt(Imp imp) { try { - return mapper.mapper().convertValue(imp.getExt().get("bidder"), ExtImpConsumable.class); + return mapper.mapper().convertValue(imp.getExt(), CONS_EXT_TYPE_REFERENCE).getBidder(); } catch (IllegalArgumentException e) { - throw new PreBidException(e.getMessage(), e); + throw new PreBidException(e.getMessage()); } } - private static MultiMap resolveHeaders(BidRequest request) { - final MultiMap headers = HttpUtil.headers(); + private boolean isImpValid(Site site, App app, ExtImpConsumable impExt) { + return (app != null && !Strings.isNullOrEmpty(impExt.getPlacementId())) + || (site != null && impExt.getSiteId() != 0 && impExt.getNetworkId() != 0 && impExt.getUnitId() != 0); - final Device device = request.getDevice(); - if (device != null) { - HttpUtil.addHeaderIfValueIsNotEmpty(headers, HttpUtil.USER_AGENT_HEADER, device.getUa()); - final String ip = device.getIp(); - if (StringUtils.isNotBlank(ip)) { - headers.add(HttpUtil.X_FORWARDED_FOR_HEADER, ip); - headers.add("Forwarded", "for=" + ip); - } - } + } - final User user = request.getUser(); - if (user != null && StringUtils.isNotBlank(user.getBuyeruid())) { - headers.add(HttpUtil.COOKIE_HEADER, "azk=" + user.getBuyeruid().trim()); - } + private BidRequest modifyBidRequest(BidRequest bidRequest, List imps) { + return bidRequest.toBuilder().imp(imps).build(); + } - final Site site = request.getSite(); - final String page = site != null ? site.getPage() : null; - if (StringUtils.isNotBlank(page)) { - headers.set(HttpUtil.REFERER_HEADER, page); - try { - headers.set(HttpUtil.ORIGIN_HEADER, HttpUtil.validateUrl(page)); - } catch (IllegalArgumentException e) { - // do nothing, just skip adding this header - } - } + private String constructUri(String placementId) { + final String uri = Strings.isNullOrEmpty(placementId) ? SITE_URI_PATH : (APP_URI_PATH + placementId); + return this.endpointUrl + uri; + } + + private static MultiMap resolveHeaders() { + return HttpUtil.headers().add(HttpUtil.X_OPENRTB_VERSION_HEADER, OPENRTB_VERSION); + } - return headers; + @Override + @Deprecated(since = "Not used, since Bidder.makeBidderResponse(...) was overridden.") + public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + return Result.withError(BidderError.generic("Invalid method call")); } @Override - public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - final ConsumableBidResponse consumableResponse; + public CompositeBidderResponse makeBidderResponse(BidderCall httpCall, BidRequest bidRequest) { try { - consumableResponse = mapper.decodeValue(httpCall.getResponse().getBody(), ConsumableBidResponse.class); + final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); + final List bidderErrors = new ArrayList<>(); + return CompositeBidderResponse.builder().bids(extractConsumableBids(bidRequest, bidResponse, bidderErrors)) + .errors(bidderErrors).build(); } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); + return CompositeBidderResponse.withError(BidderError.badServerResponse(e.getMessage())); } - final List errors = new ArrayList<>(); - final List bidderBids = extractBids(bidRequest, consumableResponse.getDecisions()); - return Result.of(bidderBids, errors); - } - - private static List extractBids(BidRequest bidRequest, - Map impIdToDecisions) { - final List bidderBids = new ArrayList<>(); - for (Map.Entry entry : impIdToDecisions.entrySet()) { - final ConsumableDecision decision = entry.getValue(); - - if (decision != null) { - final ConsumablePricing pricing = decision.getPricing(); - if (pricing != null && pricing.getClearPrice() != null) { - final String impId = entry.getKey(); - - final Bid bid = Bid.builder() - .id(bidRequest.getId()) - .impid(impId) - .price(BigDecimal.valueOf(pricing.getClearPrice())) - .adm(CollectionUtils.isNotEmpty(decision.getContents()) - ? decision.getContents().get(0).getBody() : "") - .w(decision.getWidth()) - .h(decision.getHeight()) - .crid(String.valueOf(decision.getAdId())) - .exp(30) - .build(); - // Consumable units are always HTML, never VAST. - // From Prebid's point of view, this means that Consumable units - // are always "banners". - bidderBids.add(BidderBid.of(bid, BidType.banner, null)); + } + + private List extractConsumableBids(BidRequest bidRequest, BidResponse bidResponse, + List errors) { + if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { + return Collections.emptyList(); + } + + return bidResponse.getSeatbid().stream() + .filter(Objects::nonNull) + .map(SeatBid::getBid) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .map(bid -> toBidderBid(bid, bidRequest, bidResponse, errors)) + .filter(Objects::nonNull) + .toList(); + + } + + private BidderBid toBidderBid(Bid bid, BidRequest bidRequest, BidResponse bidResponse, List errors) { + final BidType bidType; + try { + bidType = getBidType(bid, bidRequest.getImp()); + } catch (PreBidException e) { + errors.add(BidderError.badServerResponse(e.getMessage())); + return null; + } + + return BidderBid.builder() + .bid(bid) + .type(bidType) + .bidCurrency(bidResponse.getCur()) + .videoInfo(makeVideoInfo(bid)) + .build(); + } + + private static BidType getBidType(Bid bid, List imps) { + return getBidTypeFromMtype(bid.getMtype()) + .or(() -> getBidTypeFromExtPrebidType(bid.getExt())) + .orElseGet(() -> getBidTypeFromImp(imps, bid.getImpid())); + } + + private static Optional getBidTypeFromMtype(Integer mType) { + final BidType bidType = mType != null ? switch (mType) { + case 1 -> BidType.banner; + case 2 -> BidType.video; + case 3 -> BidType.audio; + case 4 -> BidType.xNative; + default -> null; + } : null; + + return Optional.ofNullable(bidType); + } + + private static Optional getBidTypeFromExtPrebidType(ObjectNode bidExt) { + return Optional.ofNullable(bidExt) + .map(ext -> ext.get("prebid")) + .map(prebid -> prebid.get("type")) + .map(JsonNode::asText).map(BidType::fromString); + } + + private static BidType getBidTypeFromImp(List imps, String impId) { + for (Imp imp : imps) { + if (imp.getId().equals(impId)) { + if (imp.getBanner() != null) { + return BidType.banner; + } else if (imp.getVideo() != null) { + return BidType.video; + } else if (imp.getXNative() != null) { + return BidType.xNative; + } else if (imp.getAudio() != null) { + return BidType.audio; } } } - return bidderBids; + throw new PreBidException("Unmatched impression id " + impId); + } + + private static ExtBidPrebidVideo makeVideoInfo(Bid bid) { + + final int duration = Optional.ofNullable(bid) + .map(Bid::getDur) + .orElse(0); + + return ExtBidPrebidVideo.of(duration, null); } } diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableAdType.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableAdType.java deleted file mode 100644 index ad9d505b2ce..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableAdType.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import com.iab.openrtb.request.Format; -import org.apache.commons.collections4.CollectionUtils; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -public class ConsumableAdType { - - private static final Map SIZE_MAP = new HashMap<>(); - - private ConsumableAdType() { - } - - public static List getSizeCodes(List formats) { - if (CollectionUtils.isEmpty(formats)) { - return Collections.emptyList(); - } - return formats.stream() - .map(format -> format.getW() + "x" + format.getH()) - .map(SIZE_MAP::get) - .filter(Objects::nonNull) - .toList(); - } - - static { - SIZE_MAP.put("120x90", 1); - SIZE_MAP.put("468x60", 3); - SIZE_MAP.put("728x90", 4); - SIZE_MAP.put("300x250", 5); - SIZE_MAP.put("160x600", 6); - SIZE_MAP.put("120x600", 7); - SIZE_MAP.put("300x100", 8); - SIZE_MAP.put("180x150", 9); - SIZE_MAP.put("336x280", 10); - SIZE_MAP.put("240x400", 11); - SIZE_MAP.put("234x60", 12); - SIZE_MAP.put("88x31", 13); - SIZE_MAP.put("120x60", 14); - SIZE_MAP.put("120x240", 15); - SIZE_MAP.put("125x125", 16); - SIZE_MAP.put("220x250", 17); - SIZE_MAP.put("250x90", 19); - SIZE_MAP.put("0x0", 20); - SIZE_MAP.put("200x90", 21); - SIZE_MAP.put("300x50", 22); - SIZE_MAP.put("320x50", 23); - SIZE_MAP.put("320x480", 24); - SIZE_MAP.put("185x185", 25); - SIZE_MAP.put("620x45", 26); - SIZE_MAP.put("300x125", 27); - SIZE_MAP.put("800x250", 28); - SIZE_MAP.put("970x90", 77); - SIZE_MAP.put("970x250", 123); - SIZE_MAP.put("300x600", 43); - SIZE_MAP.put("970x66", 286); - SIZE_MAP.put("970x280", 3230); - SIZE_MAP.put("486x60", 429); - SIZE_MAP.put("700x500", 374); - SIZE_MAP.put("300x1050", 934); - SIZE_MAP.put("320x100", 1578); - SIZE_MAP.put("320x250", 331); - SIZE_MAP.put("320x267", 3301); - SIZE_MAP.put("728x250", 2730); - } -} diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidGdpr.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidGdpr.java deleted file mode 100644 index 517c40d93d5..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidGdpr.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import lombok.Builder; -import lombok.Value; - -@Builder -@Value -public class ConsumableBidGdpr { - - Boolean applies; - - String consent; -} diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidRequest.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidRequest.java deleted file mode 100644 index 1c2706d2c6f..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidRequest.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -import java.util.List; - -@Builder -@Value -public class ConsumableBidRequest { - - List placements; - - Long time; - - @JsonProperty("networkId") - Integer networkId; - - @JsonProperty("siteId") - Integer siteId; - - @JsonProperty("unitId") - Integer unitId; - - @JsonProperty("unitName") - String unitName; - - @JsonProperty("includePricingData") - Boolean includePricingData; - - ConsumableUser user; - - String referrer; - - String ip; - - String url; - - @JsonProperty("enableBotFiltering") - Boolean enableBotFiltering; - - Boolean parallel; - - String usPrivacy; - - ConsumableBidGdpr gdpr; - - String gpp; - - @JsonProperty("gpp_sid") - List gppSid; -} diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidResponse.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidResponse.java deleted file mode 100644 index cf9e31ec3f5..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableBidResponse.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.Map; - -@AllArgsConstructor(staticName = "of") -@Value -public class ConsumableBidResponse { - - Map decisions; -} diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableContents.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableContents.java deleted file mode 100644 index e5e24034cc0..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableContents.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class ConsumableContents { - - String body; -} diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableDecision.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableDecision.java deleted file mode 100644 index 7089e017b22..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableDecision.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -import java.util.List; - -@Builder -@Value -public class ConsumableDecision { - - ConsumablePricing pricing; - - @JsonProperty("adId") - Long adId; - - @JsonProperty("bidderName") - String bidderName; - - @JsonProperty("creativeId") - String creativeId; - - List contents; - - @JsonProperty("impressionUrl") - String impressionUrl; - - Integer width; - - Integer height; -} diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumablePlacement.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumablePlacement.java deleted file mode 100644 index bc813d19793..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumablePlacement.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -import java.util.List; - -@Builder -@Value -public class ConsumablePlacement { - - @JsonProperty("divName") - String divName; - - @JsonProperty("networkId") - Integer networkId; - - @JsonProperty("siteId") - Integer siteId; - - @JsonProperty("unitId") - Integer unitId; - - @JsonProperty("unitName") - String unitName; - - @JsonProperty("adTypes") - List adTypes; -} diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumablePricing.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumablePricing.java deleted file mode 100644 index 705594902d6..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumablePricing.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class ConsumablePricing { - - @JsonProperty("clearPrice") - Double clearPrice; -} diff --git a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableUser.java b/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableUser.java deleted file mode 100644 index d40fe2c8597..00000000000 --- a/src/main/java/org/prebid/server/bidder/consumable/model/ConsumableUser.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.prebid.server.bidder.consumable.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor -@Value -public class ConsumableUser { - - String key; -} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/consumable/ExtImpConsumable.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/consumable/ExtImpConsumable.java index bc4d479f443..e9590dc2b17 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/consumable/ExtImpConsumable.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/consumable/ExtImpConsumable.java @@ -22,4 +22,7 @@ public class ExtImpConsumable { @JsonProperty("unitName") String unitName; + + @JsonProperty("placementId") + String placementId; } diff --git a/src/main/resources/bidder-config/consumable.yaml b/src/main/resources/bidder-config/consumable.yaml index 7bd28634f7d..6f3f8f1660e 100644 --- a/src/main/resources/bidder-config/consumable.yaml +++ b/src/main/resources/bidder-config/consumable.yaml @@ -1,12 +1,16 @@ adapters: consumable: - endpoint: https://e.serverbid.com/api/v2 + endpoint: https://e.serverbid.com meta-info: - maintainer-email: naffis@consumable.com + maintainer-email: prebid@consumable.com app-media-types: - banner + - audio + - video site-media-types: - banner + - audio + - video supported-vendors: vendor-id: 591 usersync: diff --git a/src/test/java/org/prebid/server/bidder/consumable/ConsumableBidderTest.java b/src/test/java/org/prebid/server/bidder/consumable/ConsumableBidderTest.java index 01e87b12640..50463bd776e 100644 --- a/src/test/java/org/prebid/server/bidder/consumable/ConsumableBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/consumable/ConsumableBidderTest.java @@ -1,411 +1,483 @@ package org.prebid.server.bidder.consumable; import com.fasterxml.jackson.core.JsonProcessingException; +import com.iab.openrtb.request.App; +import com.iab.openrtb.request.Audio; import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Format; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Regs; import com.iab.openrtb.request.Site; -import com.iab.openrtb.request.User; +import com.iab.openrtb.request.Video; import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; import io.netty.handler.codec.http.HttpHeaderValues; import io.vertx.core.MultiMap; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; -import org.prebid.server.bidder.consumable.model.ConsumableBidGdpr; -import org.prebid.server.bidder.consumable.model.ConsumableBidRequest; -import org.prebid.server.bidder.consumable.model.ConsumableBidResponse; -import org.prebid.server.bidder.consumable.model.ConsumableContents; -import org.prebid.server.bidder.consumable.model.ConsumableDecision; -import org.prebid.server.bidder.consumable.model.ConsumablePlacement; -import org.prebid.server.bidder.consumable.model.ConsumablePricing; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderCall; import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.CompositeBidderResponse; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.HttpResponse; import org.prebid.server.bidder.model.Result; import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.ExtRegs; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; import org.prebid.server.proto.openrtb.ext.request.consumable.ExtImpConsumable; import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.proto.openrtb.ext.response.ExtBidPrebid; +import org.prebid.server.proto.openrtb.ext.response.ExtBidPrebidVideo; import org.prebid.server.util.HttpUtil; +import org.prebid.server.version.PrebidVersionProvider; -import java.math.BigDecimal; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.function.UnaryOperator; import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; import static java.util.function.UnaryOperator.identity; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.tuple; public class ConsumableBidderTest extends VertxTest { - private static final String ENDPOINT_URL = "https://test.endpoint.com"; + private static final String ENDPOINT_URL = "http://exchange.org/"; - private final ConsumableBidder target = new ConsumableBidder(ENDPOINT_URL, jacksonMapper); + @Rule + public final MockitoRule mockitoRule = MockitoJUnit.rule(); - @Test - public void creationShouldFailOnInvalidEndpointUrl() { - assertThatIllegalArgumentException().isThrownBy(() -> new ConsumableBidder("invalid_url", jacksonMapper)); + @Mock + private PrebidVersionProvider prebidVersionProvider; + + private ConsumableBidder target; + + @Before + public void setUp() { + target = new ConsumableBidder(ENDPOINT_URL, jacksonMapper); } @Test - public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { + public void makeHttpRequestsShouldHaveCorrectHeaders() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequest(impBuilder -> impBuilder - .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))); + final BidRequest bidRequest = givenSiteBidRequest(identity()); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final Result>> result = target.makeHttpRequests(bidRequest); // then - assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); - assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .extracting(HttpRequest::getHeaders) + .flatExtracting(MultiMap::entries) + .extracting(Map.Entry::getKey, Map.Entry::getValue) + .containsExactlyInAnyOrder( + tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), + tuple(HttpUtil.ACCEPT_HEADER.toString(), HttpHeaderValues.APPLICATION_JSON.toString()), + tuple(HttpUtil.X_OPENRTB_VERSION_HEADER.toString(), "2.5") + ); } @Test - public void makeHttpRequestsShouldSetDefaultHeaders() { + public void makeHttpRequestsShouldHaveCorrectURIForSiteRequest() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequest(identity()); + final BidRequest bidRequest = givenSiteBidRequest(identity()); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final Result>> result = target.makeHttpRequests(bidRequest); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getHeaders) - .flatExtracting(MultiMap::entries) - .extracting(Map.Entry::getKey, Map.Entry::getValue) - .containsOnly( - tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), - tuple(HttpUtil.ACCEPT_HEADER.toString(), HttpHeaderValues.APPLICATION_JSON.toString())); + assertThat(result.getValue()) + .extracting(HttpRequest::getUri) + .containsExactly(ENDPOINT_URL + ConsumableBidder.SITE_URI_PATH); } @Test - public void makeHttpRequestsShouldSetAdditionalHeadersIfDeviceIsNotNull() { + public void makeHttpRequestsShouldHaveCorrectURIForAppRequest() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequest( - requestBuilder -> requestBuilder - .device(Device.builder() - .ip("123.123.123.321") - .ua("some_ua") - .build()), - identity()); + final BidRequest bidRequest = givenAppBidRequest(identity()); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final Result>> result = target.makeHttpRequests(bidRequest); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getHeaders) - .flatExtracting(MultiMap::entries) - .extracting(Map.Entry::getKey, Map.Entry::getValue) - .contains( - tuple(HttpUtil.USER_AGENT_HEADER.toString(), "some_ua"), - tuple(HttpUtil.X_FORWARDED_FOR_HEADER.toString(), "123.123.123.321"), - tuple("Forwarded", "for=123.123.123.321")); + assertThat(result.getValue()) + .extracting(HttpRequest::getUri) + .containsExactly(ENDPOINT_URL + ConsumableBidder.APP_URI_PATH + "0421008445828ceb46f496700a5fa65e"); } @Test - public void makeHttpRequestsShouldSetAdditionalHeadersIfUserBuyerUidIsNotBlank() { + public void makeBidderResponseShouldReturnBidderBidWithNoErrors() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequest( - requestBuilder -> requestBuilder - .user(User.builder().buyeruid("buyer_id").build()), - identity()); + final BidRequest bidRequest = givenSiteBidRequest(identity()); + final BidderCall httpCall = givenHttpCall(bidRequest, + givenBidResponse(bidBuilder -> bidBuilder.impid("123"))); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getHeaders) - .flatExtracting(MultiMap::entries) - .extracting(Map.Entry::getKey, Map.Entry::getValue) - .contains(tuple(HttpUtil.COOKIE_HEADER.toString(), "azk=buyer_id")); + assertThat(result.getBids()).isNotEmpty(); } @Test - public void makeHttpRequestsShouldSetAdditionalHeadersIfSitePageIsNotBlank() { + public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // given - final BidRequest bidRequest = givenBidRequest( - requestBuilder -> requestBuilder - .site(Site.builder().page("http://test.com").build()), - identity()); + final BidRequest bidRequest = givenSiteBidRequest( + impBuilder -> impBuilder + .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).hasSize(1); + assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + } + + @Test + public void makeHttpRequestsShouldReturnEmptyListIfRequiredSiteParametersAreNotPresent() { + final BidRequest bidRequest = givenSiteBidRequest(impBuilder -> impBuilder + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpConsumable.of(11, 32, + 0, "cnsmbl-audio-728x90-slider", null))))); + + final Result>> result = target.makeHttpRequests(bidRequest); // then + assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getHeaders) - .flatExtracting(MultiMap::entries) - .extracting(Map.Entry::getKey, Map.Entry::getValue) - .contains( - tuple(HttpUtil.REFERER_HEADER.toString(), "http://test.com"), - tuple(HttpUtil.ORIGIN_HEADER.toString(), "http://test.com")); + + } + + @Test + public void makeHttpRequestsShouldReturnEmptyListIfRequiredAppParametersAreNotPresent() { + final BidRequest bidRequest = givenAppBidRequest(impBuilder -> impBuilder + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpConsumable.of(null, 32, + null, null, null))))); + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).isEmpty(); + } @Test - public void makeHttpRequestsShouldSetRequestDefaultFields() { + public void makeBidderResponseShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // given - final BidRequest bidRequest = givenBidRequest(identity()); + final BidderCall httpCall = givenHttpCall(null, "invalid"); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), ConsumableBidRequest.class)) - .extracting(ConsumableBidRequest::getIncludePricingData, - ConsumableBidRequest::getEnableBotFiltering, ConsumableBidRequest::getParallel) - .containsOnly(tuple(true, true, true)); - assertThat(result.getValue()) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), ConsumableBidRequest.class)) - .extracting(ConsumableBidRequest::getTime) - .isNotNull(); + assertThat(result.getErrors()).hasSize(1).first().satisfies(error -> { + assertThat(error.getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + }); + assertThat(result.getBids()).isEmpty(); } @Test - public void makeHttpRequestsShouldSetRequestFieldsFromFirstImpExt() { + public void makeBidderResponseShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequestWithTwoImpsAndTwoFormats(); + final BidderCall httpCall = givenHttpCall(null, + mapper.writeValueAsString(null)); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), ConsumableBidRequest.class)) - .extracting(ConsumableBidRequest::getNetworkId, ConsumableBidRequest::getSiteId, - ConsumableBidRequest::getUnitId, ConsumableBidRequest::getUnitName) - .containsOnly(tuple(111, 222, 333, "unit_name")); + assertThat(result.getBids()).isEmpty(); } @Test - public void makeHttpRequestsShouldReturnRequestWithExpectedPlacements() { + public void makeBidderResponseShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequestWithTwoImpsAndTwoFormats(); + final BidderCall httpCall = givenHttpCall(null, + mapper.writeValueAsString(BidResponse.builder().build())); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, null); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), ConsumableBidRequest.class)) - .flatExtracting(ConsumableBidRequest::getPlacements) - .containsOnly( - ConsumablePlacement.builder().divName("firstImp").networkId(111).siteId(222) - .unitId(333).unitName("unit_name").adTypes(singletonList(1)).build(), - ConsumablePlacement.builder().divName("second_imp").networkId(123).siteId(234) - .unitId(345).unitName("unit").adTypes(Arrays.asList(3, 429)).build()); + assertThat(result.getBids()).isEmpty(); } @Test - public void makeHttpRequestsShouldReturnHttpRequestWithCorrectGdprParameters() { + public void makeBidderResponseShouldReturnBannerBidIfBannerIsPresent() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequest(identity()); + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder().id("123").banner(Banner.builder().build()).build())) + .build(); + final BidderCall httpCall = givenHttpCall( + bidRequest, + givenBidResponse(bidBuilder -> bidBuilder.impid("123"))); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); // then - assertThat(result.getValue()).hasSize(1) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), ConsumableBidRequest.class)) - .flatExtracting(ConsumableBidRequest::getGdpr) - .containsOnly(ConsumableBidGdpr.builder().applies(true).consent("consent").build()); + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getBids()) + .extracting(BidderBid::getType) + .containsExactly(BidType.banner); } @Test - public void makeHttpRequestsShouldSetGppAndGppSidWhenGppAndGppSidPresentInRequest() { + public void makeBidderResponseShouldReturnAudioBidIfAudioIsPresent() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequest(bidRequestBuilder -> - bidRequestBuilder.regs(Regs.builder().gpp("ANY_GPP_STRING").gppSid(List.of(1, 2)).build()), - identity()); + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder().id("123").audio(Audio.builder().build()).build())) + .build(); + final BidderCall httpCall = givenHttpCall( + bidRequest, + givenBidResponse(bidBuilder -> bidBuilder.impid("123"))); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getPayload) - .allSatisfy(consumableBidRequest -> { - assertThat(consumableBidRequest.getGpp()).isEqualTo(bidRequest.getRegs().getGpp()); - assertThat(consumableBidRequest.getGppSid()) - .containsExactlyElementsOf(bidRequest.getRegs().getGppSid()); - }); + assertThat(result.getBids()) + .extracting(BidderBid::getType) + .containsExactly(BidType.audio); } @Test - public void makeHttpRequestsShouldNotSetGppAndGppSidWhenGppAndGppSidAbsentInRequest() { + public void makeBidderResponseShouldReturnErrorIfImpNotMatched() throws JsonProcessingException { // given - final BidRequest bidRequest = givenBidRequest(bidRequestBuilder -> - bidRequestBuilder.regs(Regs.builder().gpp(null).gppSid(null).build()), - identity()); + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder().id("123").build())) + .build(); + final BidderCall httpCall = givenHttpCall( + bidRequest, + givenBidResponse(bidBuilder -> bidBuilder.impid("489"))); // when - final Result>> result = target.makeHttpRequests(bidRequest); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getPayload) - .allSatisfy(consumableBidRequest -> { - assertThat(consumableBidRequest.getGpp()).isNullOrEmpty(); - assertThat(consumableBidRequest.getGppSid()).isNullOrEmpty(); - }); + assertThat(result.getBids()).isEmpty(); + assertThat(result.getErrors()).containsExactly(BidderError.badServerResponse("Unmatched impression id 489")); } @Test - public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { + public void makeBidderResponseShouldReturnBidWithVideoExt() throws JsonProcessingException { // given - final BidderCall httpCall = BidderCall.succeededHttp(null, - HttpResponse.of(200, null, "invalid"), null); + final Video video = Video.builder().build(); + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder().id("123").video(video).build())) + .build(); + final BidderCall httpCall = givenHttpCall( + bidRequest, + givenBidResponse( + bidBuilder -> bidBuilder + .impid("123") + .dur(1) + .mtype(2))); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); // then - assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getBids()) + .extracting(BidderBid::getVideoInfo) + .extracting(ExtBidPrebidVideo::getDuration) + .containsExactly(1); } @Test - public void makeBidsShouldSkipDecisionsWithNullPricing() throws JsonProcessingException { + public void makeBidderResponseShouldReturnBannerBidIfMTypeIsOne() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall(identity(), - decision -> decision.pricing(null)); + final Banner banner = Banner.builder().w(300).h(200).build(); + final Video video = Video.builder().build(); + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder() + .id("123") + .banner(banner) + .video(video).build())) + .build(); + final BidderCall httpCall = givenHttpCall( + bidRequest, + givenBidResponse( + bidBuilder -> bidBuilder + .impid("123") + .mtype(1))); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); // then - assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).isEmpty(); + assertThat(result.getBids()) + .extracting(BidderBid::getType) + .containsExactly(BidType.banner); } @Test - public void makeBidsShouldSkipDecisionsWithNullClearPrice() throws JsonProcessingException { + public void makeBidderResponseShouldReturnVideoBidIfMTypeIsTwo() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall(identity(), - decision -> decision.pricing(ConsumablePricing.of(null))); + final Banner banner = Banner.builder().w(300).h(200).build(); + final Video video = Video.builder().build(); + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder() + .id("123") + .banner(banner) + .video(video).build())) + .build(); + final BidderCall httpCall = givenHttpCall( + bidRequest, + givenBidResponse( + bidBuilder -> bidBuilder + .impid("123") + .mtype(2))); // when - final Result> result = target.makeBids(httpCall, null); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); // then - assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).isEmpty(); + assertThat(result.getBids()) + .extracting(BidderBid::getType) + .containsExactly(BidType.video); } @Test - public void makeBidsShouldReturnBannerBidWithExpectedFields() throws JsonProcessingException { + public void makeBidderResponseShouldReturnAudioBidIfMTypeIsThree() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall(identity(), - decision -> decision.pricing(ConsumablePricing.of(11.1)).adId(123L) - .width(300).height(250) - .contents(singletonList(ConsumableContents.of("contents_body")))); + final Banner banner = Banner.builder().w(300).h(200).build(); + final Video video = Video.builder().build(); + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder() + .id("123") + .banner(banner) + .video(video).build())) + .build(); + final BidderCall httpCall = givenHttpCall( + bidRequest, + givenBidResponse( + bidBuilder -> bidBuilder + .impid("123") + .mtype(3))); // when - final Result> result = target.makeBids(httpCall, - givenBidRequestWithTwoImpsAndTwoFormats()); + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .contains(BidderBid.of( - Bid.builder() - .id("request_id").impid("firstImp").price(BigDecimal.valueOf(11.1)) - .adm("contents_body").w(300).h(250).exp(30).crid("123").build(), - BidType.banner, null)); + assertThat(result.getBids()) + .extracting(BidderBid::getType) + .containsExactly(BidType.audio); } - private static BidRequest givenBidRequestWithTwoImpsAndTwoFormats() { - return BidRequest.builder() - .id("request_id") - .imp(Arrays.asList(givenImp(identity()), - Imp.builder() - .id("second_imp") - .banner(Banner.builder() - .format(Arrays.asList(Format.builder().w(468).h(60).build(), - Format.builder().w(486).h(60).build())) - .build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, - ExtImpConsumable.of(123, 234, 345, "unit")))) - .build())) - .user(User.builder() - .ext(ExtUser.builder().consent("consent").build()) - .build()) + @Test + public void makeBidderResponseShouldReturnCorrectTypeExtPrebidTypeInResponse() throws JsonProcessingException { + // given + final Banner banner = Banner.builder().w(300).h(200).build(); + final Video video = Video.builder().build(); + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder() + .id("123") + .banner(banner) + .video(video).build())) .build(); + final BidderCall httpCall = givenHttpCall( + bidRequest, + givenBidResponse( + bidBuilder -> bidBuilder + .impid("123") + .ext(mapper.createObjectNode() + .set("prebid", mapper.createObjectNode().put("type", "video"))))); + + // when + final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getBids()) + .extracting(BidderBid::getType) + .containsExactly(BidType.video); + } + + private static BidRequest givenSiteBidRequest(UnaryOperator... impCustomizers) { + return givenSiteBidRequest(bidRequestBuilder -> bidRequestBuilder.site(Site.builder() + .page("http://www.some.com/page-where-ad-will-be-shown").domain("www.some.com").build()), + List.of(impCustomizers)); } - private static BidRequest givenBidRequest(UnaryOperator bidRequestCustomizer, - UnaryOperator impCustomizer) { + private static BidRequest givenSiteBidRequest( + UnaryOperator bidRequestCustomizer, + List> impCustomizers) { - return bidRequestCustomizer.apply(BidRequest.builder() - .imp(singletonList(givenImp(impCustomizer))) - .regs(Regs.builder().ext(ExtRegs.of(1, null, null, null)).build()) - .user(User.builder() - .ext(ExtUser.builder().consent("consent").build()) - .build())) - .build(); + return bidRequestCustomizer.apply( + BidRequest.builder() + .imp(impCustomizers.stream() + .map(ConsumableBidderTest::givenSiteImp) + .toList())).build(); } - private static BidRequest givenBidRequest(UnaryOperator impCustomizer) { - return givenBidRequest(identity(), impCustomizer); + private static BidRequest givenAppBidRequest(UnaryOperator... impCustomizers) { + return givenAppBidRequest(bidRequestBuilder -> bidRequestBuilder.app(App.builder().id("1") + .bundle("com.foo.bar").build()), List.of(impCustomizers)); } - private static Imp givenImp(UnaryOperator impCustomizer) { - return impCustomizer.apply(Imp.builder() - .id("firstImp") - .banner(Banner.builder() - .format(singletonList(Format.builder().w(120).h(90).build())) - .build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, - ExtImpConsumable.of(111, 222, 333, "unit_name"))))) + private static BidRequest givenAppBidRequest( + UnaryOperator bidRequestCustomizer, + List> impCustomizers) { + + return bidRequestCustomizer.apply( + BidRequest.builder() + .imp(impCustomizers.stream() + .map(ConsumableBidderTest::givenAppImp) + .toList())) .build(); } - private static ConsumableDecision givenDecision( - Function decision) { + private static Imp givenSiteImp(Function impCustomizer) { + return impCustomizer.apply(Imp.builder() + .id("123") + .banner(Banner.builder().w(1).h(1).build()) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpConsumable.of(11, 32, + 42, "cnsmbl-audio-728x90-slider", null))))) + .build(); + } - return decision.apply(ConsumableDecision.builder()) + private static Imp givenAppImp(Function impCustomizer) { + return impCustomizer.apply(Imp.builder() + .id("123") + .banner(Banner.builder().w(1).h(1).build()) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpConsumable.of(null, null, + null, null, "0421008445828ceb46f496700a5fa65e"))))) .build(); } - private static BidderCall givenHttpCall( - Function bidResponse, - Function decision) + private static String givenBidResponse(Function bidCustomizer) throws JsonProcessingException { + return mapper.writeValueAsString(BidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder() + .bid(singletonList(bidCustomizer.apply(Bid.builder() + .ext(mapper.valueToTree(ExtBidPrebid.builder().build()))).build())) + .build())) + .build()); + } - final String body = mapper.writeValueAsString( - bidResponse.apply(ConsumableBidResponse.of(singletonMap("firstImp", givenDecision(decision))))); - + private static BidderCall givenHttpCall(BidRequest bidRequest, String body) { return BidderCall.succeededHttp( - HttpRequest.builder().build(), + HttpRequest.builder().payload(bidRequest).build(), HttpResponse.of(200, null, body), null); } diff --git a/src/test/java/org/prebid/server/it/ConsumableTest.java b/src/test/java/org/prebid/server/it/ConsumableTest.java index c0b10480a04..ec75c72d4be 100644 --- a/src/test/java/org/prebid/server/it/ConsumableTest.java +++ b/src/test/java/org/prebid/server/it/ConsumableTest.java @@ -10,9 +10,7 @@ import java.io.IOException; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; -import static com.github.tomakehurst.wiremock.client.WireMock.matching; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static java.util.Collections.singletonList; @@ -23,19 +21,10 @@ public class ConsumableTest extends IntegrationTest { @Test public void openrtb2AuctionShouldRespondWithBidsFromConsumable() throws IOException, JSONException { // given - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/consumable-exchange")) - .withHeader("Origin", equalTo("http://www.example.com")) - .withHeader("Accept", equalTo("application/json")) - .withHeader("User-Agent", equalTo("userAgent")) - .withHeader("Forwarded", equalTo("for=193.168.244.1")) - .withHeader("Referer", equalTo("http://www.example.com")) - .withHeader("X-Forwarded-For", equalTo("193.168.244.1")) - .withHeader("Host", equalTo("localhost:8090")) - .withHeader("Content-Length", matching("[0-9]*")) - .withHeader("Content-Type", equalTo("application/json;charset=UTF-8")) - .withRequestBody(equalToJson(jsonFrom("openrtb2/consumable/test-consumable-bid-request-1.json"), - true, true)) - .willReturn(aResponse().withBody(jsonFrom("openrtb2/consumable/test-consumable-bid-response-1.json")))); + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/consumable-exchange/sb/rtb")) + .withRequestBody(equalToJson(jsonFrom("openrtb2/consumable/test-consumable-bid-request.json"))) + .willReturn(aResponse().withBody( + jsonFrom("openrtb2/consumable/test-consumable-bid-response.json")))); // when final Response response = responseFor("openrtb2/consumable/test-auction-consumable-request.json", diff --git a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-auction-consumable-request.json b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-auction-consumable-request.json index 6594e1ef945..5ddccf51d02 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-auction-consumable-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-auction-consumable-request.json @@ -1,22 +1,37 @@ { - "id": "request_id", + "id": "test-request-id", "imp": [ { - "id": "imp_id", + "id": "test-imp-id", "banner": { - "w": 300, - "h": 250 + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "consumable": { - "networkId": 123, - "siteId": 345, - "unitId": 4123, - "unitName": "unit_name" + "networkId": 11, + "siteId": 32, + "unitId": 42, + "unitName": "cnsmbl-audio-728x90-slider" } } } ], + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + } + }, "tmax": 5000, "regs": { "ext": { diff --git a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-auction-consumable-response.json b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-auction-consumable-response.json index b90c7449f90..1290f6775fa 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-auction-consumable-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-auction-consumable-response.json @@ -1,25 +1,27 @@ { - "id": "request_id", + "id": "test-request-id", "seatbid": [ { + "seat": "consumable", "bid": [ { - "id": "request_id", - "impid": "imp_id", - "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "w": 300, - "h": 250, + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1, "ext": { + "origbidcpm": 0.5, + "origbidcur": "USD", "prebid": { "type": "banner" - }, - "origbidcpm": 0.5 + } } } ], - "seat": "consumable", "group": 0 } ], diff --git a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-request-1.json b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-request-1.json deleted file mode 100644 index ce0cab43be8..00000000000 --- a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-request-1.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "placements": [ - { - "divName": "imp_id", - "networkId": 123, - "siteId": 345, - "unitId": 4123, - "unitName": "unit_name", - "adTypes": [] - } - ], - "networkId": 123, - "siteId": 345, - "unitId": 4123, - "unitName": "unit_name", - "includePricingData": true, - "url": "http://www.example.com", - "enableBotFiltering": true, - "parallel": true, - "gdpr": { - "applies": false - } -} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-request.json new file mode 100644 index 00000000000..af4f4fbb1ed --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-request.json @@ -0,0 +1,64 @@ +{ + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 250 + } + ] + }, + "secure": 1, + "ext": { + "tid": "${json-unit.any-string}", + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42, + "unitName": "cnsmbl-audio-728x90-slider" + } + } + } + ], + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "ext": { + "prebid": { + "channel": { + "name": "web" + }, + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + }, + "at": 1, + "cur": ["USD"], + "tmax": "${json-unit.any-number}", + "source": { + "tid": "${json-unit.any-string}" + }, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-response-1.json b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-response-1.json deleted file mode 100644 index a09d5ce214a..00000000000 --- a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-response-1.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "decisions": { - "imp_id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 300, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents": [ - { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" - } - ] - } - } -} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-response.json new file mode 100644 index 00000000000..a87813900b0 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/consumable/test-consumable-bid-response.json @@ -0,0 +1,21 @@ +{ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ + { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 + } + ] + } + ], + "cur": "USD" +} From 1b062b4e163c5edc95a6eb44e16aaa9dc3900fc6 Mon Sep 17 00:00:00 2001 From: product-trustedstack <141160331+product-trustedstack@users.noreply.github.com> Date: Fri, 24 May 2024 14:53:08 +0530 Subject: [PATCH 57/62] Trustedstack: New Adapter (#3111) --- .../trustedstack/TrustedstackBidder.java | 127 ++++++++ .../bidder/TrustedstackConfiguration.java | 42 +++ .../resources/bidder-config/trustedstack.yaml | 23 ++ .../static/bidder-params/trustedstack.json | 20 ++ .../trustedstack/TrustedstackBidderTest.java | 297 ++++++++++++++++++ .../prebid/server/it/TrustedstackTest.java | 37 +++ .../test-auction-trustedstack-request.json | 24 ++ .../test-auction-trustedstack-response.json | 38 +++ .../test-trustedstack-bid-request.json | 55 ++++ .../test-trustedstack-bid-response.json | 22 ++ .../server/it/test-application.properties | 2 + 11 files changed, 687 insertions(+) create mode 100644 src/main/java/org/prebid/server/bidder/trustedstack/TrustedstackBidder.java create mode 100644 src/main/java/org/prebid/server/spring/config/bidder/TrustedstackConfiguration.java create mode 100644 src/main/resources/bidder-config/trustedstack.yaml create mode 100644 src/main/resources/static/bidder-params/trustedstack.json create mode 100644 src/test/java/org/prebid/server/bidder/trustedstack/TrustedstackBidderTest.java create mode 100644 src/test/java/org/prebid/server/it/TrustedstackTest.java create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-auction-trustedstack-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-auction-trustedstack-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-trustedstack-bid-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-trustedstack-bid-response.json diff --git a/src/main/java/org/prebid/server/bidder/trustedstack/TrustedstackBidder.java b/src/main/java/org/prebid/server/bidder/trustedstack/TrustedstackBidder.java new file mode 100644 index 00000000000..1a10bd933bb --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/trustedstack/TrustedstackBidder.java @@ -0,0 +1,127 @@ +package org.prebid.server.bidder.trustedstack; + +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import org.apache.commons.collections4.CollectionUtils; +import org.prebid.server.bidder.Bidder; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.exception.PreBidException; +import org.prebid.server.json.DecodeException; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.util.BidderUtil; +import org.prebid.server.util.HttpUtil; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +public class TrustedstackBidder implements Bidder { + + private static final String EXTERNAL_URL_MACRO = "{{PREBID_SERVER_ENDPOINT}}"; + private final String endpointUrl; + private final JacksonMapper mapper; + + public TrustedstackBidder(String endpointUrl, String externalUrl, JacksonMapper mapper) { + this.endpointUrl = HttpUtil.validateUrl(resolveEndpoint(endpointUrl, externalUrl)); + this.mapper = Objects.requireNonNull(mapper); + } + + @Override + public Result>> makeHttpRequests(BidRequest bidRequest) { + return Result.withValue(BidderUtil.defaultRequest(bidRequest, endpointUrl, mapper)); + } + + @Override + public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + final BidResponse bidResponse; + try { + bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); + } catch (DecodeException e) { + return Result.withError(BidderError.badServerResponse(e.getMessage())); + } + + final List errors = new ArrayList<>(); + final List bids = extractBids(httpCall.getRequest().getPayload(), bidResponse, errors); + + return Result.of(bids, errors); + } + + private static List extractBids(BidRequest bidRequest, BidResponse bidResponse, + List errors) { + if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { + return Collections.emptyList(); + } + + final String currency = bidResponse.getCur(); + return bidResponse.getSeatbid().stream() + .filter(Objects::nonNull) + .map(SeatBid::getBid) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .map(bid -> makeBidderBid(bid, bidRequest.getImp(), currency, errors)) + .filter(Objects::nonNull) + .toList(); + } + + private static BidType resolveBidType(Bid bid, List imps) { + final Integer markupType = bid.getMtype(); + if (markupType == null) { + return resolveBidTypeFromImpId(bid.getImpid(), imps); + } + + return switch (markupType) { + case 1 -> BidType.banner; + case 2 -> BidType.video; + case 3 -> BidType.audio; + case 4 -> BidType.xNative; + default -> + throw new PreBidException("Unable to fetch mediaType: %s" + .formatted(bid.getImpid())); + }; + } + + private static BidderBid makeBidderBid(Bid bid, List imps, String cur, List errors) { + final BidType bidType; + try { + bidType = resolveBidType(bid, imps); + } catch (PreBidException e) { + errors.add(BidderError.badServerResponse(e.getMessage())); + return null; + } + + return BidderBid.of(bid, bidType, cur); + } + + private static BidType resolveBidTypeFromImpId(String impId, List imps) { + for (Imp imp : imps) { + if (Objects.equals(impId, imp.getId())) { + if (imp.getBanner() != null) { + return BidType.banner; + } else if (imp.getVideo() != null) { + return BidType.video; + } else if (imp.getXNative() != null) { + return BidType.xNative; + } else if (imp.getAudio() != null) { + return BidType.audio; + } + } + } + + return BidType.banner; + } + + private String resolveEndpoint(String endpointUrl, String externalUrl) { + return Objects.requireNonNull(endpointUrl).replace(EXTERNAL_URL_MACRO, HttpUtil.encodeUrl(externalUrl)); + } +} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TrustedstackConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TrustedstackConfiguration.java new file mode 100644 index 00000000000..679792ee341 --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/bidder/TrustedstackConfiguration.java @@ -0,0 +1,42 @@ +package org.prebid.server.spring.config.bidder; + +import org.prebid.server.bidder.BidderDeps; +import org.prebid.server.bidder.trustedstack.TrustedstackBidder; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; +import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; +import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; +import org.prebid.server.spring.env.YamlPropertySourceFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import javax.validation.constraints.NotBlank; + +@Configuration +@PropertySource(value = "classpath:/bidder-config/trustedstack.yaml", factory = YamlPropertySourceFactory.class) +public class TrustedstackConfiguration { + + private static final String BIDDER_NAME = "trustedstack"; + + @Bean("trustedstackConfigurationProperties") + @ConfigurationProperties("adapters.trustedstack") + BidderConfigurationProperties configurationProperties() { + return new BidderConfigurationProperties(); + } + + @Bean + BidderDeps trustedstackBidderDeps(BidderConfigurationProperties trustedstackConfigurationProperties, + @NotBlank @Value("${external-url}") String externalUrl, + JacksonMapper mapper) { + + return BidderDepsAssembler.forBidder(BIDDER_NAME) + .withConfig(trustedstackConfigurationProperties) + .usersyncerCreator(UsersyncerCreator.create(externalUrl)) + .bidderCreator(config -> + new TrustedstackBidder(config.getEndpoint(), externalUrl, mapper)) + .assemble(); + } +} diff --git a/src/main/resources/bidder-config/trustedstack.yaml b/src/main/resources/bidder-config/trustedstack.yaml new file mode 100644 index 00000000000..466d145e6df --- /dev/null +++ b/src/main/resources/bidder-config/trustedstack.yaml @@ -0,0 +1,23 @@ +adapters: + trustedstack: + endpoint: https://prebid-adapter.trustedstack.com/rtb/pb/trustedstacks2s?src={{PREBID_SERVER_ENDPOINT}} + ortb-version: "2.6" + endpoint-compression: gzip + meta-info: + maintainer-email: product@trustedstack.com + app-media-types: + - banner + - video + - native + site-media-types: + - banner + - video + - native + supported-vendors: + vendor-id: 1288 + usersync: + cookie-family-name: trustedstack + redirect: + url: https://hb.trustedstack.com/cksync?cs=1&type=pbs&ovsid=setstatuscode&bidder=trustedstack&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirect={{redirect_url}} + support-cors: false + uid-macro: '' diff --git a/src/main/resources/static/bidder-params/trustedstack.json b/src/main/resources/static/bidder-params/trustedstack.json new file mode 100644 index 00000000000..8da4b5cbc80 --- /dev/null +++ b/src/main/resources/static/bidder-params/trustedstack.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Trustedstack Adapter Params", + "description": "A schema which validates params accepted by the Trustedstack adapter", + "type": "object", + "properties": { + "cid": { + "type": "string", + "description": "The customer id provided by Trustedstack." + }, + "crid": { + "type": "string", + "description": "The placement id provided by Trustedstack." + } + }, + "required": [ + "cid", + "crid" + ] +} diff --git a/src/test/java/org/prebid/server/bidder/trustedstack/TrustedstackBidderTest.java b/src/test/java/org/prebid/server/bidder/trustedstack/TrustedstackBidderTest.java new file mode 100644 index 00000000000..ac0faf3ee16 --- /dev/null +++ b/src/test/java/org/prebid/server/bidder/trustedstack/TrustedstackBidderTest.java @@ -0,0 +1,297 @@ +package org.prebid.server.bidder.trustedstack; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.request.Video; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import org.junit.Test; +import org.prebid.server.VertxTest; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.HttpResponse; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.prebid.server.proto.openrtb.ext.response.BidType.audio; +import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; +import static org.prebid.server.proto.openrtb.ext.response.BidType.video; +import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative; + +public class TrustedstackBidderTest extends VertxTest { + + private static final String ENDPOINT_URL = "https://test.trustedstack.com?src={{PREBID_SERVER_ENDPOINT}}"; + private static final String EXTERNAL_URL = "external.prebidserver.com"; + + private final TrustedstackBidder target = new TrustedstackBidder(ENDPOINT_URL, EXTERNAL_URL, jacksonMapper); + + @Test + public void creationShouldFailOnInvalidEndpointUrl() { + assertThatIllegalArgumentException() + .isThrownBy(() -> new TrustedstackBidder("invalid_url", EXTERNAL_URL, jacksonMapper)); + } + + @Test + public void makeHttpRequestsShouldNotModifyIncomingRequest() { + // given + final BidRequest bidRequest = givenBidRequest(); + + // when + final Result>> result; + result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1) + .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) + .containsExactly(bidRequest); + } + + @Test + public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { + // given + final BidderCall httpCall = sampleHttpCall(givenBidRequest(), "invalid response"); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).hasSize(1) + .allMatch(error -> error.getType() == BidderError.Type.bad_server_response + && error.getMessage().startsWith("Failed to decode: Unrecognized token")); + } + + @Test + public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall; + httpCall = sampleHttpCall(givenBidRequest(), mapper.writeValueAsString(null)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall; + httpCall = sampleHttpCall(null, mapper.writeValueAsString(BidResponse.builder().build())); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnBannerBidIfBannerIsPresent() throws JsonProcessingException { + // given + final BidderCall httpCall = sampleHttpCall( + givenBidRequest(), + mapper.writeValueAsString(sampleBidResponse(bidBuilder -> bidBuilder.impid("123")))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); + } + + @Test + public void makeBidsShouldReturnBannerMtypeAndAdType() throws JsonProcessingException { + final List bids = new ArrayList<>(); + final Bid bid = Bid.builder().impid("imp_id").mtype(1).build(); + bids.add(bid); + + // given + final BidderCall httpCall = sampleHttpCall( + givenBidRequest(), + mapper.writeValueAsString(sampleMultiFormatBidResponse(bids))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + final BidderBid bannerBid = BidderBid.of(bid, banner, "USD"); + assertThat(result.getValue()).containsExactlyInAnyOrder(bannerBid); + } + + @Test + public void makeBidsShouldReturnVideoMtypeAndAdType() throws JsonProcessingException { + final List bids = new ArrayList<>(); + final Bid bid = Bid.builder().impid("imp_id").mtype(2).build(); + bids.add(bid); + + // given + final BidderCall httpCall = sampleHttpCall( + givenBidRequest(), + mapper.writeValueAsString(sampleMultiFormatBidResponse(bids))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + final BidderBid videoBid = BidderBid.of(bid, video, "USD"); + assertThat(result.getValue()).containsExactlyInAnyOrder(videoBid); + } + + @Test + public void makeBidsShouldReturnAudioMtypeAndAdType() throws JsonProcessingException { + final List bids = new ArrayList<>(); + final Bid bid = Bid.builder().impid("imp_id").mtype(3).build(); + bids.add(bid); + + // given + final BidderCall httpCall = sampleHttpCall( + givenBidRequest(), + mapper.writeValueAsString(sampleMultiFormatBidResponse(bids))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + final BidderBid audioBid = BidderBid.of(bid, audio, "USD"); + assertThat(result.getValue()).containsExactlyInAnyOrder(audioBid); + } + + @Test + public void makeBidsShouldReturnNativeMtypeAndAdType() throws JsonProcessingException { + final List bids = new ArrayList<>(); + final Bid bid = Bid.builder().impid("imp_id").mtype(4).build(); + bids.add(bid); + + // given + final BidderCall httpCall = sampleHttpCall( + givenBidRequest(), + mapper.writeValueAsString(sampleMultiFormatBidResponse(bids))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + final BidderBid xNativeBid = BidderBid.of(bid, xNative, "USD"); + assertThat(result.getValue()).containsExactlyInAnyOrder(xNativeBid); + } + + @Test + public void makeBidsShouldReturnAdTypeAccordingToImpressionIfMtypeIsAbsent() throws JsonProcessingException { + // given + final BidderCall httpCall = sampleHttpCall( + givenVideoBidRequest(), + mapper.writeValueAsString(sampleBidResponse(bidBuilder -> bidBuilder.impid("imp_id")))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1); + final BidderBid videoBid = BidderBid.of(Bid.builder().impid("imp_id").build(), video, "USD"); + assertThat(result.getValue()).containsExactly(videoBid); + } + + @Test + public void makeBidsShouldReturnBannerAdTypeIfMtypeIsAbsentAndIfNoImpressionIdMatches() + throws JsonProcessingException { + // given + final BidderCall httpCall = sampleHttpCall( + givenVideoBidRequest(), + mapper.writeValueAsString(sampleBidResponse(bidBuilder -> bidBuilder.impid("imp_id2")))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1); + final BidderBid bannerBid = BidderBid.of(Bid.builder().impid("imp_id2").build(), banner, "USD"); + assertThat(result.getValue()).containsExactly(bannerBid); + } + + @Test + public void makeBidsShouldReturnErrorIfMtypeIsWrong() throws JsonProcessingException { + // given + final BidderCall httpCall = sampleHttpCall( + givenVideoBidRequest(), + mapper.writeValueAsString(sampleBidResponse(bidBuilder -> bidBuilder.impid("imp_id").mtype(5)))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).hasSize(1); + assertThat(result.getValue()).isEmpty(); + final BidderError error = BidderError.badServerResponse("Unable to fetch mediaType: imp_id"); + assertThat(result.getErrors()).containsExactly(error); + } + + private static BidResponse sampleBidResponse(Function bidCustomizer) { + return BidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder() + .bid(singletonList(bidCustomizer.apply(Bid.builder()).build())) + .build())) + .build(); + } + + private static BidResponse sampleMultiFormatBidResponse(List bids) { + return BidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder() + .bid(bids) + .build())) + .build(); + } + + private static BidderCall sampleHttpCall(BidRequest bidRequest, String body) { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(bidRequest).build(), + HttpResponse.of(200, null, body), + null); + } + + private static BidRequest givenBidRequest() { + return BidRequest.builder() + .id("request_id") + .imp(singletonList(Imp.builder() + .id("imp_id") + .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createObjectNode()))) + .build())) + .build(); + } + + private static BidRequest givenVideoBidRequest() { + return BidRequest.builder() + .id("request_id") + .imp(singletonList(Imp.builder() + .id("imp_id") + .video(Video.builder().build()) + .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createObjectNode()))) + .build())) + .build(); + } +} diff --git a/src/test/java/org/prebid/server/it/TrustedstackTest.java b/src/test/java/org/prebid/server/it/TrustedstackTest.java new file mode 100644 index 00000000000..e3160f47792 --- /dev/null +++ b/src/test/java/org/prebid/server/it/TrustedstackTest.java @@ -0,0 +1,37 @@ +package org.prebid.server.it; + +import io.restassured.response.Response; +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.prebid.server.model.Endpoint; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static java.util.Collections.singletonList; + +@RunWith(SpringRunner.class) +public class TrustedstackTest extends IntegrationTest { + + @Test + public void openrtb2AuctionShouldRespondWithBidsFromTheTrustedstack() throws IOException, JSONException { + // given + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/trustedstack-exchange")) + .withRequestBody(equalToJson(jsonFrom("openrtb2/trustedstack/test-trustedstack-bid-request.json"))) + .willReturn(aResponse().withBody( + jsonFrom("openrtb2/trustedstack/test-trustedstack-bid-response.json")))); + + // when + final Response response = responseFor("openrtb2/trustedstack/test-auction-trustedstack-request.json", + Endpoint.openrtb2_auction); + + // then + assertJsonEquals("openrtb2/trustedstack/test-auction-trustedstack-response.json", response, + singletonList("trustedstack")); + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-auction-trustedstack-request.json b/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-auction-trustedstack-request.json new file mode 100644 index 00000000000..2a6a16c765d --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-auction-trustedstack-request.json @@ -0,0 +1,24 @@ +{ + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "trustedstack": { + "cid": "8CUTSTCID", + "crid": "999999999" + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-auction-trustedstack-response.json b/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-auction-trustedstack-response.json new file mode 100644 index 00000000000..8c8467b76bc --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-auction-trustedstack-response.json @@ -0,0 +1,38 @@ +{ + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "randomid", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "adid": "12345678", + "cid": "987", + "crid": "12345678", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + }, + "origbidcpm": 0.5 + } + } + ], + "seat": "trustedstack", + "group": 0 + } + ], + "cur": "USD", + "ext": { + "responsetimemillis": { + "trustedstack": "{{ trustedstack.response_time_ms }}" + }, + "prebid": { + "auctiontimestamp": 0 + }, + "tmaxrequest": 5000 + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-trustedstack-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-trustedstack-bid-request.json new file mode 100644 index 00000000000..30b509c9a5e --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-trustedstack-bid-request.json @@ -0,0 +1,55 @@ +{ + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "secure": 1, + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "tid": "${json-unit.any-string}", + "bidder": { + "cid": "8CUTSTCID", + "crid": "999999999" + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "gdpr": 0 + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-trustedstack-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-trustedstack-bid-response.json new file mode 100644 index 00000000000..2943d394d9b --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/trustedstack/test-trustedstack-bid-response.json @@ -0,0 +1,22 @@ + { + "id": "tid", + "seatbid": [ + { + "seat": "trustedstack", + "bid": [ + { + "id": "randomid", + "impid": "test-imp-id", + "price": 0.500000, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300 + } + ] + } + ], + "bidid": "bid01" +} diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 7dbefb776a6..c9996b76721 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -407,6 +407,8 @@ adapters.tpmn.enabled=true adapters.tpmn.endpoint=http://localhost:8090/tpmn-exchange adapters.trafficgate.enabled=true adapters.trafficgate.endpoint=http://localhost:8090/trafficgate-exchange +adapters.trustedstack.enabled=true +adapters.trustedstack.endpoint=http://localhost:8090/trustedstack-exchange adapters.ucfunnel.enabled=true adapters.ucfunnel.endpoint=http://localhost:8090/ucfunnel-exchange adapters.undertone.enabled=true From 0ea7194d08d76ea80a0af453d9fb4b490421600a Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Fri, 24 May 2024 11:43:12 +0200 Subject: [PATCH 58/62] Theadx: Add Adapter (#3093) --- .../server/bidder/theadx/TheadxBidder.java | 159 ++++++++++++ .../ext/request/theadx/ExtImpTheadx.java | 22 ++ .../config/bidder/TheadxConfiguration.java | 41 +++ src/main/resources/bidder-config/theadx.yaml | 22 ++ .../static/bidder-params/theadx.json | 45 ++++ .../bidder/theadx/TheadxBidderTest.java | 245 ++++++++++++++++++ .../java/org/prebid/server/it/TheadxTest.java | 39 +++ .../theadx/test-auction-theadx-request.json | 23 ++ .../theadx/test-auction-theadx-response.json | 34 +++ .../theadx/test-theadx-bid-request.json | 57 ++++ .../theadx/test-theadx-bid-response.json | 21 ++ .../server/it/test-application.properties | 2 + 12 files changed, 710 insertions(+) create mode 100644 src/main/java/org/prebid/server/bidder/theadx/TheadxBidder.java create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/request/theadx/ExtImpTheadx.java create mode 100644 src/main/java/org/prebid/server/spring/config/bidder/TheadxConfiguration.java create mode 100644 src/main/resources/bidder-config/theadx.yaml create mode 100644 src/main/resources/static/bidder-params/theadx.json create mode 100644 src/test/java/org/prebid/server/bidder/theadx/TheadxBidderTest.java create mode 100644 src/test/java/org/prebid/server/it/TheadxTest.java create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/theadx/test-auction-theadx-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/theadx/test-auction-theadx-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/theadx/test-theadx-bid-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/theadx/test-theadx-bid-response.json diff --git a/src/main/java/org/prebid/server/bidder/theadx/TheadxBidder.java b/src/main/java/org/prebid/server/bidder/theadx/TheadxBidder.java new file mode 100644 index 00000000000..d144eeca773 --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/theadx/TheadxBidder.java @@ -0,0 +1,159 @@ +package org.prebid.server.bidder.theadx; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Device; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import io.vertx.core.MultiMap; +import io.vertx.core.http.HttpMethod; +import org.prebid.server.bidder.Bidder; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.exception.PreBidException; +import org.prebid.server.json.DecodeException; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.theadx.ExtImpTheadx; +import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.proto.openrtb.ext.response.ExtBidPrebid; +import org.prebid.server.util.BidderUtil; +import org.prebid.server.util.HttpUtil; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +public class TheadxBidder implements Bidder { + + private static final TypeReference> EXT_TYPE_REFERENCE = new TypeReference<>() { + }; + + private static final TypeReference> EXT_PREBID_TYPE_REFERENCE = + new TypeReference<>() { + }; + + private static final String OPENRTB_VERSION = "2.5"; + private static final String X_TEST_HEADER = "X-TEST"; + private static final String X_TEST = "1"; + private static final String X_DEVICE_USER_AGENT_HEADER = "X-Device-User-Agent"; + private static final String X_REAL_IP_HEADER = "X-Real-IP"; + + private final String endpointUrl; + private final JacksonMapper mapper; + + public TheadxBidder(String endpointUrl, JacksonMapper mapper) { + this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); + this.mapper = Objects.requireNonNull(mapper); + } + + @Override + public Result>> makeHttpRequests(BidRequest request) { + final List errors = new ArrayList<>(); + final List modifiedImps = new ArrayList<>(); + + for (Imp imp : request.getImp()) { + try { + final ExtImpTheadx extImp = parseImpExt(imp); + modifiedImps.add(imp.toBuilder().tagid(extImp.getTagId()).build()); + } catch (PreBidException e) { + errors.add(BidderError.badInput(e.getMessage())); + } + } + + final BidRequest modifiedRequest = request.toBuilder().imp(modifiedImps).build(); + return Result.of(Collections.singletonList(makeHttpRequest(modifiedRequest)), errors); + } + + private ExtImpTheadx parseImpExt(Imp imp) { + try { + return mapper.mapper().convertValue(imp.getExt(), EXT_TYPE_REFERENCE).getBidder(); + } catch (IllegalArgumentException e) { + throw new PreBidException("Missing bidder ext in impression with id: " + imp.getId()); + } + } + + private HttpRequest makeHttpRequest(BidRequest request) { + return HttpRequest.builder() + .method(HttpMethod.POST) + .uri(this.endpointUrl) + .impIds(BidderUtil.impIds(request)) + .headers(makeHeaders(request)) + .payload(request) + .body(mapper.encodeToBytes(request)) + .build(); + } + + private static MultiMap makeHeaders(BidRequest bidRequest) { + final Device device = bidRequest.getDevice(); + final MultiMap headers = HttpUtil.headers(); + + headers.set(HttpUtil.X_OPENRTB_VERSION_HEADER, OPENRTB_VERSION); + headers.set(X_TEST_HEADER, X_TEST); + + if (device != null) { + HttpUtil.addHeaderIfValueIsNotEmpty(headers, X_DEVICE_USER_AGENT_HEADER, device.getUa()); + HttpUtil.addHeaderIfValueIsNotEmpty(headers, X_REAL_IP_HEADER, device.getIpv6()); + HttpUtil.addHeaderIfValueIsNotEmpty(headers, X_REAL_IP_HEADER, device.getIp()); + } + + return headers; + } + + @Override + public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + try { + final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); + final List errors = new ArrayList<>(); + return Result.of(extractBids(bidResponse, errors), errors); + } catch (DecodeException | PreBidException e) { + return Result.withError(BidderError.badServerResponse(e.getMessage())); + } + } + + private List extractBids(BidResponse bidResponse, List errors) { + if (bidResponse == null || bidResponse.getSeatbid() == null) { + return Collections.emptyList(); + } + return bidsFromResponse(bidResponse, errors); + } + + private List bidsFromResponse(BidResponse bidResponse, List errors) { + return bidResponse.getSeatbid().stream() + .filter(Objects::nonNull) + .map(SeatBid::getBid) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .map(bid -> makeBid(bid, bidResponse.getCur(), errors)) + .filter(Objects::nonNull) + .toList(); + } + + private BidderBid makeBid(Bid bid, String currency, List errors) { + final BidType mediaType = getMediaType(bid, errors); + return mediaType == null ? null : BidderBid.of(bid, mediaType, currency); + } + + private BidType getMediaType(Bid bid, List errors) { + try { + return Optional.ofNullable(bid.getExt()) + .map(ext -> mapper.mapper().convertValue(ext, EXT_PREBID_TYPE_REFERENCE)) + .map(ExtPrebid::getPrebid) + .map(ExtBidPrebid::getType) + .orElseThrow(IllegalArgumentException::new); + } catch (IllegalArgumentException e) { + errors.add(BidderError.badServerResponse( + "Failed to parse impression \"%s\" mediatype".formatted(bid.getImpid()))); + return null; + } + } +} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/theadx/ExtImpTheadx.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/theadx/ExtImpTheadx.java new file mode 100644 index 00000000000..ff7eb9e86f0 --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/theadx/ExtImpTheadx.java @@ -0,0 +1,22 @@ +package org.prebid.server.proto.openrtb.ext.request.theadx; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Value; + +@Value(staticConstructor = "of") +public class ExtImpTheadx { + + @JsonProperty("tagid") + String tagId; + + @JsonProperty("wid") + Integer inventorySourceId; + + @JsonProperty("pid") + Integer memberId; + + @JsonProperty("pname") + String placementName; + +} + diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TheadxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TheadxConfiguration.java new file mode 100644 index 00000000000..6bb9e397e05 --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/bidder/TheadxConfiguration.java @@ -0,0 +1,41 @@ +package org.prebid.server.spring.config.bidder; + +import org.prebid.server.bidder.BidderDeps; +import org.prebid.server.bidder.theadx.TheadxBidder; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; +import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; +import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; +import org.prebid.server.spring.env.YamlPropertySourceFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import javax.validation.constraints.NotBlank; + +@Configuration +@PropertySource(value = "classpath:/bidder-config/theadx.yaml", factory = YamlPropertySourceFactory.class) +public class TheadxConfiguration { + + private static final String BIDDER_NAME = "theadx"; + + @Bean("theadxConfigurationProperties") + @ConfigurationProperties("adapters.theadx") + BidderConfigurationProperties configurationProperties() { + return new BidderConfigurationProperties(); + } + + @Bean + BidderDeps theadxBidderDeps(BidderConfigurationProperties theadxConfigurationProperties, + @NotBlank @Value("${external-url}") String externalUrl, + JacksonMapper mapper) { + + return BidderDepsAssembler.forBidder(BIDDER_NAME) + .withConfig(theadxConfigurationProperties) + .usersyncerCreator(UsersyncerCreator.create(externalUrl)) + .bidderCreator(config -> new TheadxBidder(config.getEndpoint(), mapper)) + .assemble(); + } +} diff --git a/src/main/resources/bidder-config/theadx.yaml b/src/main/resources/bidder-config/theadx.yaml new file mode 100644 index 00000000000..b9440fa5776 --- /dev/null +++ b/src/main/resources/bidder-config/theadx.yaml @@ -0,0 +1,22 @@ +adapters: + theadx: + endpoint: https://ssp.theadx.com/request?pbs=1 + meta-info: + maintainer-email: ssp@theadx.com + app-media-types: + - banner + - video + - audio + - native + site-media-types: + - banner + - video + - audio + - native + vendor-id: 556 + usersync: + cookie-family-name: theadx + redirect: + url: https://ssp.theadx.com/cookie?redirect_url={{redirect_url}}&?pbs=1 + support-cors: false + uid-macro: '$UID' diff --git a/src/main/resources/static/bidder-params/theadx.json b/src/main/resources/static/bidder-params/theadx.json new file mode 100644 index 00000000000..b6e0adca99b --- /dev/null +++ b/src/main/resources/static/bidder-params/theadx.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Theadx Adapter Params", + "description": "A schema which validates params accepted by the theadx adapter", + "type": "object", + "properties": { + "pid": { + "type": [ + "integer", + "string" + ], + "pattern": "^\\d+$", + "description": "An ID which identifies the partner selling the impression" + }, + "tagid": { + "type": [ + "integer", + "string" + ], + "pattern": "^\\d+$", + "description": "An ID which identifies the placement selling the impression" + }, + "wid": { + "type": [ + "integer", + "string" + ], + "description": "An ID which identifies the Theadx inventory source id" + } + }, + "anyOf": [ + { + "required": [ + "tagid" + ] + }, + { + "required": [ + "pid", + "wid", + "tagid" + ] + } + ] +} diff --git a/src/test/java/org/prebid/server/bidder/theadx/TheadxBidderTest.java b/src/test/java/org/prebid/server/bidder/theadx/TheadxBidderTest.java new file mode 100644 index 00000000000..48bf7fe357f --- /dev/null +++ b/src/test/java/org/prebid/server/bidder/theadx/TheadxBidderTest.java @@ -0,0 +1,245 @@ +package org.prebid.server.bidder.theadx; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Device; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import io.vertx.core.http.HttpMethod; +import org.junit.Test; +import org.prebid.server.VertxTest; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.HttpResponse; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.theadx.ExtImpTheadx; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.function.UnaryOperator; + +import static java.util.Collections.singletonList; +import static java.util.function.UnaryOperator.identity; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.tuple; +import static org.prebid.server.bidder.model.BidderError.Type.bad_server_response; +import static org.prebid.server.util.HttpUtil.ACCEPT_HEADER; +import static org.prebid.server.util.HttpUtil.APPLICATION_JSON_CONTENT_TYPE; +import static org.prebid.server.util.HttpUtil.CONTENT_TYPE_HEADER; +import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; + +public class TheadxBidderTest extends VertxTest { + + private static final String ENDPOINT_URL = "https://test-url.com"; + + private final TheadxBidder target = new TheadxBidder(ENDPOINT_URL, jacksonMapper); + + @Test + public void shouldFailOnBidderCreation() { + assertThatIllegalArgumentException().isThrownBy(() -> new TheadxBidder("invalid_url", jacksonMapper)); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedUrl() { + // given + final ObjectNode invalidExt = mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())); + final BidRequest bidRequest = givenBidRequest( + impBuilder -> impBuilder.id("imp1"), + impBuilder -> impBuilder.id("imp2"), + impBuilder -> impBuilder.id("invalid_imp3").ext(invalidExt)); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri) + .containsExactly(ENDPOINT_URL); + + assertThat(result.getErrors()).hasSize(1).allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing bidder ext in impression with id: invalid_imp3"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); + }); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedHeaders() { + // given + final BidRequest bidRequest = givenBidRequest(identity()).toBuilder() + .device(Device.builder().ip("ip").ipv6("ipv6").ua("ua").build()) + .build(); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).hasSize(1).first() + .extracting(HttpRequest::getHeaders) + .satisfies(headers -> assertThat(headers.get(CONTENT_TYPE_HEADER)) + .isEqualTo(APPLICATION_JSON_CONTENT_TYPE)) + .satisfies(headers -> assertThat(headers.get(ACCEPT_HEADER)) + .isEqualTo(APPLICATION_JSON_VALUE)) + .satisfies(headers -> assertThat(headers.get("x-openrtb-version")) + .isEqualTo("2.5")) + .satisfies(headers -> assertThat(headers.get("x-test")) + .isEqualTo("1")) + .satisfies(headers -> assertThat(headers.get("X-Device-User-Agent")) + .isEqualTo("ua")) + .satisfies(headers -> assertThat(headers.getAll("X-Real-IP")) + .containsOnly("ipv6", "ip")); + assertThat(result.getErrors()).isEmpty(); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedBody() { + // given + final ObjectNode invalidExt = mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())); + final BidRequest bidRequest = givenBidRequest( + impBuilder -> impBuilder.id("imp1").ext(givenImpExt("tagId1")), + impBuilder -> impBuilder.id("imp2").ext(givenImpExt("tagId2")), + impBuilder -> impBuilder.id("invalid_imp3").ext(invalidExt)); + + // when + final Result>> results = target.makeHttpRequests(bidRequest); + + // then + final BidRequest expectedRequest = givenBidRequest( + impBuilder -> impBuilder.id("imp1").tagid("tagId1").ext(givenImpExt("tagId1")), + impBuilder -> impBuilder.id("imp2").tagid("tagId2").ext(givenImpExt("tagId2"))); + assertThat(results.getValue()).hasSize(1) + .extracting(HttpRequest::getBody, HttpRequest::getPayload) + .containsExactly(tuple(jacksonMapper.encodeToBytes(expectedRequest), expectedRequest)); + + assertThat(results.getErrors()).hasSize(1).allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing bidder ext in impression with id: invalid_imp3"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); + }); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedRequestMethod() { + // given + final BidRequest bidRequest = givenBidRequest(identity()); + + // when + final Result>> results = target.makeHttpRequests(bidRequest); + + // then + assertThat(results.getValue()).hasSize(1).first() + .satisfies(request -> assertThat(request.getMethod()).isEqualTo(HttpMethod.POST)); + assertThat(results.getErrors()).isEmpty(); + } + + @Test + public void makeHttpRequestsShouldReturnExpectedImpIds() { + // given + final ObjectNode invalidExt = mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())); + final BidRequest bidRequest = givenBidRequest( + impBuilder -> impBuilder.id("imp1"), + impBuilder -> impBuilder.id("imp2"), + impBuilder -> impBuilder.id("invalid_imp3").ext(invalidExt)); + + // when + final Result>> results = target.makeHttpRequests(bidRequest); + + // then + assertThat(results.getValue()).hasSize(1) + .extracting(HttpRequest::getImpIds) + .containsExactly(Set.of("imp1", "imp2")); + assertThat(results.getErrors()).hasSize(1).allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing bidder ext in impression with id: invalid_imp3"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); + }); + } + + @Test + public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { + // given + final BidderCall httpCall = givenHttpCall("invalid"); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).hasSize(1); + assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().get(0).getType()).isEqualTo(bad_server_response); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnEmptyListWhenBidResponseSeatBidIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnErrorAndEmptyListWhenBidTypeCanBeResolved() throws JsonProcessingException { + // given + final Bid invalidBid1 = Bid.builder().impid("imp_id1").ext(mapper.createObjectNode().put("prebid", 2)).build(); + final Bid invalidBid2 = Bid.builder().impid("imp_id2").ext(mapper.createObjectNode()).build(); + final BidderCall httpCall = givenHttpCall(invalidBid1, invalidBid2); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).hasSize(2) + .extracting(BidderError::getMessage, BidderError::getType) + .containsExactly( + tuple("Failed to parse impression \"imp_id1\" mediatype", bad_server_response), + tuple("Failed to parse impression \"imp_id2\" mediatype", bad_server_response)); + assertThat(result.getValue()).isEmpty(); + } + + private static BidRequest givenBidRequest(UnaryOperator... impCustomizers) { + return BidRequest.builder() + .imp(Arrays.stream(impCustomizers).map(TheadxBidderTest::givenImp).toList()) + .build(); + } + + private static Imp givenImp(UnaryOperator impCustomizer) { + return impCustomizer.apply(Imp.builder().id("imp_id").ext(givenImpExt("tagId"))).build(); + } + + private static ObjectNode givenImpExt(String tagId) { + return mapper.valueToTree(ExtPrebid.of(null, ExtImpTheadx.of(tagId, 1, 1, "placementName"))); + } + + private static String givenBidResponse(Bid... bids) throws JsonProcessingException { + return mapper.writeValueAsString(BidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder().bid(List.of(bids)).build())) + .build()); + } + + private static BidderCall givenHttpCall(Bid... bids) throws JsonProcessingException { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, givenBidResponse(bids)), + null); + } + + private static BidderCall givenHttpCall(String body) { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, body), + null); + } + +} diff --git a/src/test/java/org/prebid/server/it/TheadxTest.java b/src/test/java/org/prebid/server/it/TheadxTest.java new file mode 100644 index 00000000000..56bee659254 --- /dev/null +++ b/src/test/java/org/prebid/server/it/TheadxTest.java @@ -0,0 +1,39 @@ +package org.prebid.server.it; + +import io.restassured.response.Response; +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.prebid.server.model.Endpoint; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static java.util.Collections.singletonList; + +@RunWith(SpringRunner.class) +public class TheadxTest extends IntegrationTest { + + @Test + public void openrtb2AuctionShouldRespondWithBidsFromTheadx() throws IOException, JSONException { + // given + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/theadx-exchange")) + .withRequestBody(equalToJson( + jsonFrom("openrtb2/theadx/test-theadx-bid-request.json"))) + .willReturn(aResponse().withBody( + jsonFrom("openrtb2/theadx/test-theadx-bid-response.json")))); + + // when + final Response response = responseFor("openrtb2/theadx/test-auction-theadx-request.json", + Endpoint.openrtb2_auction); + + // then + assertJsonEquals("openrtb2/theadx/test-auction-theadx-response.json", response, + singletonList("theadx")); + } +} + diff --git a/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-auction-theadx-request.json b/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-auction-theadx-request.json new file mode 100644 index 00000000000..a4243b06de6 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-auction-theadx-request.json @@ -0,0 +1,23 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "theadx": { + "tagid" : "123" + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-auction-theadx-response.json b/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-auction-theadx-response.json new file mode 100644 index 00000000000..6f93c6f15b8 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-auction-theadx-response.json @@ -0,0 +1,34 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 4.7, + "adm": "adm6", + "crid": "crid6", + "ext": { + "prebid": { + "type": "banner" + }, + "origbidcpm": 4.7 + } + } + ], + "seat": "theadx", + "group": 0 + } + ], + "cur": "USD", + "ext": { + "responsetimemillis": { + "theadx": "{{ theadx.response_time_ms }}" + }, + "prebid": { + "auctiontimestamp": 0 + }, + "tmaxrequest": 5000 + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-theadx-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-theadx-bid-request.json new file mode 100644 index 00000000000..2a731ffc2ad --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-theadx-bid-request.json @@ -0,0 +1,57 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "secure": 1, + "banner": { + "w": 300, + "h": 250 + }, + "tagid": "123", + "ext": { + "tid": "${json-unit.any-string}", + "bidder" : { + "tagid" : "123" + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "ext": { + "gdpr": 0 + } + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-theadx-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-theadx-bid-response.json new file mode 100644 index 00000000000..a2b885e889f --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/theadx/test-theadx-bid-response.json @@ -0,0 +1,21 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 4.7, + "adm": "adm6", + "crid": "crid6", + "ext": { + "prebid": { + "type": "banner" + } + } + } + ] + } + ] +} diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index c9996b76721..36922236a83 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -393,6 +393,8 @@ adapters.teads.enabled=true adapters.teads.endpoint=http://localhost:8090/teads-exchange adapters.telaria.enabled=true adapters.telaria.endpoint=http://localhost:8090/telaria-exchange/ +adapters.theadx.enabled=true +adapters.theadx.endpoint=http://localhost:8090/theadx-exchange adapters.triplelift.enabled=true adapters.triplelift.endpoint=http://localhost:8090/triplelift-exchange adapters.tripleliftnative.enabled=true From 38e6aad2dabe2254786bdec2d9536954a1bc5309 Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Fri, 24 May 2024 12:45:05 +0300 Subject: [PATCH 59/62] Bwx: Add new bidder (#3095) --- .../prebid/server/bidder/bwx/BwxBidder.java | 135 +++++++++ .../openrtb/ext/request/bwx/ExtImpBwx.java | 11 + .../config/bidder/BwxConfiguration.java | 41 +++ src/main/resources/bidder-config/bwx.yaml | 15 + .../resources/static/bidder-params/bwx.json | 21 ++ .../server/bidder/bwx/BwxBidderTest.java | 282 ++++++++++++++++++ .../java/org/prebid/server/it/BwxTest.java | 36 +++ .../bwx/test-auction-bwx-request.json | 23 ++ .../bwx/test-auction-bwx-response.json | 36 +++ .../it/openrtb2/bwx/test-bwx-bid-request.json | 56 ++++ .../openrtb2/bwx/test-bwx-bid-response.json | 20 ++ .../server/it/test-application.properties | 2 + 12 files changed, 678 insertions(+) create mode 100644 src/main/java/org/prebid/server/bidder/bwx/BwxBidder.java create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/request/bwx/ExtImpBwx.java create mode 100644 src/main/java/org/prebid/server/spring/config/bidder/BwxConfiguration.java create mode 100644 src/main/resources/bidder-config/bwx.yaml create mode 100644 src/main/resources/static/bidder-params/bwx.json create mode 100644 src/test/java/org/prebid/server/bidder/bwx/BwxBidderTest.java create mode 100644 src/test/java/org/prebid/server/it/BwxTest.java create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bwx/test-auction-bwx-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bwx/test-auction-bwx-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bwx/test-bwx-bid-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/bwx/test-bwx-bid-response.json diff --git a/src/main/java/org/prebid/server/bidder/bwx/BwxBidder.java b/src/main/java/org/prebid/server/bidder/bwx/BwxBidder.java new file mode 100644 index 00000000000..0bd006ff249 --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/bwx/BwxBidder.java @@ -0,0 +1,135 @@ +package org.prebid.server.bidder.bwx; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import io.vertx.core.http.HttpMethod; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.prebid.server.bidder.Bidder; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.exception.PreBidException; +import org.prebid.server.json.DecodeException; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.bwx.ExtImpBwx; +import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.util.HttpUtil; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +public class BwxBidder implements Bidder { + + private static final TypeReference> BWX_EXT_TYPE_REFERENCE = + new TypeReference<>() { + }; + private static final String URL_HOST_MACRO = "{{Host}}"; + private static final String PUBLISHER_ID_MACRO = "{{SourceId}}"; + private final String endpointUrl; + private final JacksonMapper mapper; + + public BwxBidder(String endpointUrl, JacksonMapper mapper) { + this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); + this.mapper = Objects.requireNonNull(mapper); + } + + @Override + public Result>> makeHttpRequests(BidRequest request) { + final List> httpRequests = new ArrayList<>(); + final List errors = new ArrayList<>(); + + for (Imp imp : request.getImp()) { + final ExtImpBwx extImpBwx; + try { + extImpBwx = parseImpExt(imp); + } catch (PreBidException e) { + errors.add(BidderError.badInput(e.getMessage())); + continue; + } + httpRequests.add(createHttpRequest(request, extImpBwx)); + } + + return Result.of(httpRequests, errors); + } + + private ExtImpBwx parseImpExt(Imp imp) { + try { + return mapper.mapper().convertValue(imp.getExt(), BWX_EXT_TYPE_REFERENCE).getBidder(); + } catch (IllegalArgumentException e) { + throw new PreBidException("Missing bidder ext in impression with id: " + imp.getId()); + } + } + + private HttpRequest createHttpRequest(BidRequest request, ExtImpBwx extImpBwx) { + return HttpRequest.builder() + .method(HttpMethod.POST) + .uri(resolveEndpoint(extImpBwx)) + .body(mapper.encodeToBytes(request)) + .payload(request) + .headers(HttpUtil.headers()) + .build(); + } + + private String resolveEndpoint(ExtImpBwx extImpBwx) { + return endpointUrl + .replace(URL_HOST_MACRO, StringUtils.defaultString(extImpBwx.getEnv())) + .replace(PUBLISHER_ID_MACRO, StringUtils.defaultString(extImpBwx.getPid())); + } + + @Override + public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + try { + final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); + return Result.withValues(extractBids(bidResponse)); + } catch (PreBidException | DecodeException e) { + return Result.withError(BidderError.badServerResponse(e.getMessage())); + } + } + + private List extractBids(BidResponse bidResponse) { + if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { + return Collections.emptyList(); + } + + return bidsFromResponse(bidResponse); + } + + private List bidsFromResponse(BidResponse bidResponse) { + return bidResponse.getSeatbid().stream() + .filter(Objects::nonNull) + .map(SeatBid::getBid) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .map(bid -> BidderBid.of(bid, getBidType(bid), bidResponse.getCur())) + .filter(Objects::nonNull) + .toList(); + } + + private static BidType getBidType(Bid bid) { + final Integer markupType = bid.getMtype(); + if (markupType == null) { + throw new PreBidException("Missing MType for bid: " + bid.getId()); + } + + return switch (markupType) { + case 1 -> BidType.banner; + case 2 -> BidType.video; + case 4 -> BidType.xNative; + default -> throw new PreBidException( + "Failed to parse bid mtype: %s for impression id %s".formatted(bid.getMtype(), bid.getImpid()) + ); + }; + } +} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/bwx/ExtImpBwx.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/bwx/ExtImpBwx.java new file mode 100644 index 00000000000..ceb53dde28b --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/bwx/ExtImpBwx.java @@ -0,0 +1,11 @@ +package org.prebid.server.proto.openrtb.ext.request.bwx; + +import lombok.Value; + +@Value(staticConstructor = "of") +public class ExtImpBwx { + + String env; + + String pid; +} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BwxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BwxConfiguration.java new file mode 100644 index 00000000000..6b8ce8bf7d2 --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/bidder/BwxConfiguration.java @@ -0,0 +1,41 @@ +package org.prebid.server.spring.config.bidder; + +import org.prebid.server.bidder.BidderDeps; +import org.prebid.server.bidder.bwx.BwxBidder; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; +import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; +import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; +import org.prebid.server.spring.env.YamlPropertySourceFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import javax.validation.constraints.NotBlank; + +@Configuration +@PropertySource(value = "classpath:/bidder-config/bwx.yaml", factory = YamlPropertySourceFactory.class) +public class BwxConfiguration { + + private static final String BIDDER_NAME = "bwx"; + + @Bean("bwxConfigurationProperties") + @ConfigurationProperties("adapters.bwx") + BidderConfigurationProperties configurationProperties() { + return new BidderConfigurationProperties(); + } + + @Bean + BidderDeps bwxBidderDeps(BidderConfigurationProperties bwxConfigurationProperties, + @NotBlank @Value("${external-url}") String externalUrl, + JacksonMapper mapper) { + + return BidderDepsAssembler.forBidder(BIDDER_NAME) + .withConfig(bwxConfigurationProperties) + .usersyncerCreator(UsersyncerCreator.create(externalUrl)) + .bidderCreator(config -> new BwxBidder(config.getEndpoint(), mapper)) + .assemble(); + } +} diff --git a/src/main/resources/bidder-config/bwx.yaml b/src/main/resources/bidder-config/bwx.yaml new file mode 100644 index 00000000000..ef5a82eece0 --- /dev/null +++ b/src/main/resources/bidder-config/bwx.yaml @@ -0,0 +1,15 @@ +adapters: + bwx: + endpoint: http://rtb.boldwin.live?pid={{SourceId}}&host={{Host}}&pbs=1 + meta-info: + maintainer-email: prebid@bold-win.com + app-media-types: + - banner + - video + - native + site-media-types: + - banner + - video + - native + supported-vendors: + vendor-id: 0 diff --git a/src/main/resources/static/bidder-params/bwx.json b/src/main/resources/static/bidder-params/bwx.json new file mode 100644 index 00000000000..cabe329cdea --- /dev/null +++ b/src/main/resources/static/bidder-params/bwx.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "BoldwinX Adapter Params", + "description": "A schema which validates params accepted by the BoldwinX adapter", + "type": "object", + "properties": { + "pid": { + "type": "string", + "description": "Unique placement ID", + "minLength": 1 + }, + "env": { + "type": "string", + "description": "BoldwinX environment", + "minLength": 1 + } + }, + "required": [ + "pid" + ] +} diff --git a/src/test/java/org/prebid/server/bidder/bwx/BwxBidderTest.java b/src/test/java/org/prebid/server/bidder/bwx/BwxBidderTest.java new file mode 100644 index 00000000000..8c8ec69a662 --- /dev/null +++ b/src/test/java/org/prebid/server/bidder/bwx/BwxBidderTest.java @@ -0,0 +1,282 @@ +package org.prebid.server.bidder.bwx; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import org.junit.Test; +import org.prebid.server.VertxTest; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.HttpResponse; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.bwx.ExtImpBwx; + +import java.util.List; +import java.util.function.UnaryOperator; + +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; +import static java.util.function.UnaryOperator.identity; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; +import static org.prebid.server.proto.openrtb.ext.response.BidType.video; +import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative; + +public class BwxBidderTest extends VertxTest { + + private static final String ENDPOINT_URL = "https://test.endpoint.com/any?hs={{Host}}&src={{SourceId}}"; + + private final BwxBidder target = new BwxBidder(ENDPOINT_URL, jacksonMapper); + + @Test + public void creationShouldFailOnInvalidEndpointUrl() { + assertThatIllegalArgumentException().isThrownBy(() -> new BwxBidder("invalid_url", jacksonMapper)); + } + + @Test + public void makeHttpRequestsShouldMakeOneRequestForAllImps() { + // given + final BidRequest bidRequest = BidRequest.builder() + .imp(asList(givenImp(identity()), givenImp(identity()))) + .build(); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(2) + .extracting(HttpRequest::getPayload) + .extracting(BidRequest::getImp) + .extracting(List::size) + .containsOnly(2); + } + + @Test + public void makeHttpRequestsShouldProperlyResolveMacrosUrl() { + // given + final BidRequest bidRequest = BidRequest.builder() + .imp(List.of(givenImp(identity()))) + .build(); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri) + .containsExactly("https://test.endpoint.com/any?hs=placementId&src=endpointId"); + } + + @Test + public void makeHttpRequestsShouldProperlyResolveMacrosUrlWhenHostAbsent() { + // given + final BidRequest bidRequest = BidRequest.builder() + .imp(List.of(givenImp(impBuilder -> impBuilder.ext(mapper.valueToTree(ExtPrebid.of(null, + ExtImpBwx.of(null, "endpointId"))))))) + .build(); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri) + .containsExactly("https://test.endpoint.com/any?hs=&src=endpointId"); + } + + @Test + public void makeHttpRequestsShouldProperlyResolveMacrosUrlWhenEnvAbsent() { + // given + final BidRequest bidRequest = BidRequest.builder() + .imp(List.of(givenImp(impBuilder -> impBuilder.ext(mapper.valueToTree(ExtPrebid.of(null, + ExtImpBwx.of("hostValue", null))))))) + .build(); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri) + .containsExactly("https://test.endpoint.com/any?hs=hostValue&src="); + } + + @Test + public void makeHttpRequestsShouldValidAndInvalidAtResponse() { + // given + final BidRequest bidRequest = BidRequest.builder() + .imp(asList(givenImp(identity()), givenImp(impBuilder -> impBuilder + .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))))) + .build(); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).hasSize(1); + assertThat(result.getErrors()).hasSize(1) + .extracting(BidderError::getMessage) + .containsExactly("Missing bidder ext in impression with id: 123"); + } + + @Test + public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall( + mapper.writeValueAsString(null)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { + // given + final BidderCall httpCall = givenHttpCall("invalid"); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).hasSize(1) + .allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Failed to decode: Unrecognized token 'invalid':"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + }); + } + + @Test + public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall( + mapper.writeValueAsString(BidResponse.builder().build())); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnxNativeBid() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall( + givenBidResponse(Bid.builder().mtype(4).impid("123").build())); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().impid("123").mtype(4).build(), xNative, "USD")); + } + + @Test + public void makeBidsShouldReturnBannerBid() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall( + givenBidResponse(Bid.builder().mtype(1).impid("123").build())); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().mtype(1).impid("123").build(), banner, "USD")); + } + + @Test + public void makeBidsShouldReturnVideoBid() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall( + givenBidResponse(Bid.builder().mtype(2).impid("123").build())); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().mtype(2).impid("123").build(), video, "USD")); + } + + @Test + public void makeBidsShouldThrowErrorUnableToFetchMediaTypeWhenMTypeEmpty() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall( + givenBidResponse(Bid.builder().id("a1").impid("123").build())); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).hasSize(1) + .allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing MType for bid: a1"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + }); + } + + @Test + public void makeBidsShouldThrowErrorUnableToFetchMediaTypeWhenMTypeUnknownNumber() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall( + givenBidResponse(Bid.builder().mtype(999).impid("123").build())); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).hasSize(1) + .allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Failed to parse bid mtype: 999 for impression id 123"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + }); + } + + private static Imp givenImp(UnaryOperator impCustomizer) { + return impCustomizer.apply(Imp.builder() + .id("123") + .ext(mapper.valueToTree(ExtPrebid.of(null, + ExtImpBwx.of("placementId", "endpointId"))))) + .build(); + } + + private static String givenBidResponse(Bid bid) throws JsonProcessingException { + return mapper.writeValueAsString(BidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder() + .bid(singletonList(bid)) + .build())) + .build()); + } + + private static BidderCall givenHttpCall(String body) { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, body), + null); + } +} diff --git a/src/test/java/org/prebid/server/it/BwxTest.java b/src/test/java/org/prebid/server/it/BwxTest.java new file mode 100644 index 00000000000..6d7110980b6 --- /dev/null +++ b/src/test/java/org/prebid/server/it/BwxTest.java @@ -0,0 +1,36 @@ +package org.prebid.server.it; + +import io.restassured.response.Response; +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.prebid.server.model.Endpoint; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static java.util.Collections.singletonList; + +@RunWith(SpringRunner.class) +public class BwxTest extends IntegrationTest { + + @Test + public void openrtb2AuctionShouldRespondWithBidsFromBwx() throws IOException, JSONException { + // given + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/bwx-exchange")) + .withRequestBody(equalToJson(jsonFrom("openrtb2/bwx/test-bwx-bid-request.json"))) + .willReturn(aResponse().withBody(jsonFrom("openrtb2/bwx/test-bwx-bid-response.json")))); + + // when + final Response response = responseFor("openrtb2/bwx/test-auction-bwx-request.json", + Endpoint.openrtb2_auction); + + // then + assertJsonEquals("openrtb2/bwx/test-auction-bwx-response.json", response, + singletonList("bwx")); + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-auction-bwx-request.json b/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-auction-bwx-request.json new file mode 100644 index 00000000000..e58e62d3bf2 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-auction-bwx-request.json @@ -0,0 +1,23 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 320, + "h": 250 + }, + "ext": { + "bwx": { + "pid": "somePlacementId" + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-auction-bwx-response.json b/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-auction-bwx-response.json new file mode 100644 index 00000000000..6029a55596f --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-auction-bwx-response.json @@ -0,0 +1,36 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 0.01, + "mtype": 1, + "adid": "adid", + "cid": "cid", + "crid": "crid", + "ext": { + "prebid": { + "type": "banner" + }, + "origbidcpm": 0.01 + } + } + ], + "seat": "bwx", + "group": 0 + } + ], + "cur": "USD", + "ext": { + "responsetimemillis": { + "bwx": "{{ bwx.response_time_ms }}" + }, + "prebid": { + "auctiontimestamp": 0 + }, + "tmaxrequest": 5000 + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-bwx-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-bwx-bid-request.json new file mode 100644 index 00000000000..67a366f844c --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-bwx-bid-request.json @@ -0,0 +1,56 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 320, + "h": 250 + }, + "secure" : 1, + "ext" : { + "tid" : "${json-unit.any-string}", + "bidder" : { + "pid" : "somePlacementId" + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "ext": { + "gdpr": 0 + } + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-bwx-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-bwx-bid-response.json new file mode 100644 index 00000000000..24a2e1bd0e3 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/bwx/test-bwx-bid-response.json @@ -0,0 +1,20 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "crid": "crid", + "adid": "adid", + "mtype": 1, + "price": 0.01, + "id": "bid_id", + "impid": "imp_id", + "cid": "cid" + } + ], + "type": "banner", + "cur": "USD" + } + ] +} diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 36922236a83..36a157e1031 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -141,6 +141,8 @@ adapters.boldwin.enabled=true adapters.boldwin.endpoint=http://localhost:8090/boldwin-exchange adapters.brave.enabled=true adapters.brave.endpoint=http://localhost:8090/brave-exchange +adapters.bwx.enabled=true +adapters.bwx.endpoint=http://localhost:8090/bwx-exchange adapters.connectad.enabled=true adapters.connectad.endpoint=http://localhost:8090/connectad-exchange adapters.compass.enabled=true From d8691a9fc4b68fa39c28f417ddb98850fe193a82 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Fri, 24 May 2024 11:56:47 +0200 Subject: [PATCH 60/62] AdView: Support Multi Imp Request (#3101) --- .../server/bidder/adview/AdviewBidder.java | 86 +++++----- .../bidder/adview/AdviewBidderTest.java | 157 +++++++++--------- .../adview/test-adview-bid-response.json | 3 +- .../adview/test-auction-adview-response.json | 1 + 4 files changed, 129 insertions(+), 118 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/adview/AdviewBidder.java b/src/main/java/org/prebid/server/bidder/adview/AdviewBidder.java index cc62739b8f0..89973ed8437 100644 --- a/src/main/java/org/prebid/server/bidder/adview/AdviewBidder.java +++ b/src/main/java/org/prebid/server/bidder/adview/AdviewBidder.java @@ -5,6 +5,7 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Format; import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; import org.apache.commons.collections4.CollectionUtils; @@ -55,20 +56,23 @@ public AdviewBidder(String endpointUrl, @Override public Result>> makeHttpRequests(BidRequest request) { - final Imp firstImp = request.getImp().get(0); - final ExtImpAdview extImpAdview; - final BidRequest modifiedBidRequest; - - try { - extImpAdview = parseExtImp(firstImp); - final Price bidFloorPrice = resolveBidFloor(firstImp, request); - modifiedBidRequest = modifyRequest(request, extImpAdview.getMasterTagId(), bidFloorPrice); - } catch (PreBidException e) { - return Result.withError(BidderError.badInput(e.getMessage())); + final List errors = new ArrayList<>(); + final List> httpRequests = new ArrayList<>(); + + for (Imp imp: request.getImp()) { + try { + final ExtImpAdview extImp = parseExtImp(imp); + final Price bidFloorPrice = resolveBidFloor(imp, request); + final Imp modifiedImp = modifyImp(imp, extImp.getMasterTagId(), bidFloorPrice); + final BidRequest modifiedRequest = modifyRequest(request, modifiedImp); + final String resolvedUrl = resolveEndpoint(extImp.getAccountId()); + httpRequests.add(BidderUtil.defaultRequest(modifiedRequest, resolvedUrl, mapper)); + } catch (PreBidException e) { + errors.add(BidderError.badInput(e.getMessage())); + } } - return Result.withValue( - BidderUtil.defaultRequest(modifiedBidRequest, resolveEndpoint(extImpAdview.getAccountId()), mapper)); + return Result.of(httpRequests, errors); } private ExtImpAdview parseExtImp(Imp imp) { @@ -99,19 +103,13 @@ private Price convertBidFloor(Price bidFloorPrice, String impId, BidRequest bidR } } - private static BidRequest modifyRequest(BidRequest bidRequest, String masterTagId, Price bidFloorPrice) { + private static BidRequest modifyRequest(BidRequest bidRequest, Imp modifiedImp) { return bidRequest.toBuilder() - .imp(modifyImps(bidRequest.getImp(), masterTagId, bidFloorPrice)) + .imp(Collections.singletonList(modifiedImp)) .cur(Collections.singletonList(BIDDER_CURRENCY)) .build(); } - private static List modifyImps(List imps, String masterTagId, Price bidFloorPrice) { - final List modifiedImps = new ArrayList<>(imps); - modifiedImps.set(0, modifyImp(imps.get(0), masterTagId, bidFloorPrice)); - return modifiedImps; - } - private static Imp modifyImp(Imp imp, String masterTagId, Price bidFloorPrice) { return imp.toBuilder() .tagid(masterTagId) @@ -140,40 +138,54 @@ private String resolveEndpoint(String accountId) { public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { try { final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(httpCall.getRequest().getPayload(), bidResponse)); - } catch (DecodeException e) { + final List errors = new ArrayList<>(); + return Result.of(extractBids(bidResponse, errors), errors); + } catch (DecodeException | PreBidException e) { return Result.withError(BidderError.badServerResponse(e.getMessage())); } } - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { + private static List extractBids(BidResponse bidResponse, List errors) { if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { return Collections.emptyList(); } - return bidsFromResponse(bidRequest, bidResponse); + return bidsFromResponse(bidResponse, errors); } - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { + private static List bidsFromResponse(BidResponse bidResponse, List errors) { return bidResponse.getSeatbid().stream() .filter(Objects::nonNull) .map(SeatBid::getBid) .filter(Objects::nonNull) .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidMediaType(bid.getImpid(), bidRequest.getImp()), - bidResponse.getCur())) + .map(bid -> makeBid(bid, bidResponse.getCur(), errors)) + .filter(Objects::nonNull) .toList(); } - private static BidType getBidMediaType(String impId, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(impId)) { - if (imp.getVideo() != null) { - return BidType.video; - } else if (imp.getXNative() != null) { - return BidType.xNative; - } - } + private static BidderBid makeBid(Bid bid, String currency, List errors) { + try { + final BidType mediaType = getBidMediaType(bid); + return BidderBid.of(bid, mediaType, currency); + } catch (PreBidException e) { + errors.add(BidderError.badServerResponse(e.getMessage())); + return null; } - return BidType.banner; + + } + + private static BidType getBidMediaType(Bid bid) { + final Integer markupType = bid.getMtype(); + if (markupType == null) { + throw new PreBidException("Missing MType for bid: " + bid.getId()); + } + + return switch (markupType) { + case 1 -> BidType.banner; + case 2 -> BidType.video; + case 4 -> BidType.xNative; + default -> throw new PreBidException( + "Unable to fetch mediaType " + bid.getMtype() + " in multi-format: " + bid.getImpid()); + }; } } diff --git a/src/test/java/org/prebid/server/bidder/adview/AdviewBidderTest.java b/src/test/java/org/prebid/server/bidder/adview/AdviewBidderTest.java index 592b172df28..0ce0870ad0b 100644 --- a/src/test/java/org/prebid/server/bidder/adview/AdviewBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adview/AdviewBidderTest.java @@ -1,12 +1,11 @@ package org.prebid.server.bidder.adview; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Format; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.request.Video; import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; @@ -30,7 +29,9 @@ import java.math.BigDecimal; import java.util.List; +import java.util.Set; import java.util.function.UnaryOperator; +import java.util.stream.Stream; import static java.util.Collections.singletonList; import static java.util.function.UnaryOperator.identity; @@ -68,7 +69,7 @@ public void creationShouldFailOnInvalidEndpointUrl() { } @Test - public void makeHttpRequestsShouldReturnErrorsOfNotValidImps() { + public void makeHttpRequestsShouldReturnErrorsWhenImpExtIsInvalid() { // given final BidRequest bidRequest = givenBidRequest( impBuilder -> impBuilder @@ -82,24 +83,40 @@ public void makeHttpRequestsShouldReturnErrorsOfNotValidImps() { } @Test - public void makeHttpRequestsShouldSetTagIdOfFirstImp() { + public void makeHttpRequestsShouldSetTagIdForImp() { // given - final BidRequest bidRequest = givenBidRequest(identity()); + final BidRequest bidRequest = givenBidRequest(impBuilder -> impBuilder.ext(givenImpExt("tagId"))); // when final Result>> result = target.makeHttpRequests(bidRequest); // then + final BidRequest expectedRequest = givenBidRequest( + impBuilder -> impBuilder.tagid("tagId").ext(givenImpExt("tagId"))); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) + assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getPayload) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getTagid) - .containsExactly("publisherId"); + .containsExactly(expectedRequest); + } + + @Test + public void makeHttpRequestsShouldCreateHttpRequestPerImp() { + // given + final BidRequest bidRequest = givenBidRequest( + impBuilder -> impBuilder.id("impId1"), + impBuilder -> impBuilder.id("impId2")); + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(2) + .extracting(HttpRequest::getImpIds) + .containsExactly(Set.of("impId1"), Set.of("impId2")); } @Test - public void makeHttpRequestsShouldModifyFirstImpBanner() { + public void makeHttpRequestsShouldModifyImpBanner() { // given final Banner banner = Banner.builder() .w(2) @@ -128,7 +145,10 @@ public void makeHttpRequestsShouldConvertCurrencyIfRequestCurrencyDoesNotMatchBi .willReturn(BigDecimal.TEN); final BidRequest bidRequest = givenBidRequest( - impBuilder -> impBuilder.bidfloor(BigDecimal.ONE).bidfloorcur("EUR")); + impBuilder -> impBuilder.bidfloor(BigDecimal.ONE).bidfloorcur("EUR")) + .toBuilder() + .cur(List.of("EUR", "UAH")) + .build(); // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -140,6 +160,10 @@ public void makeHttpRequestsShouldConvertCurrencyIfRequestCurrencyDoesNotMatchBi .flatExtracting(BidRequest::getImp) .extracting(Imp::getBidfloor, Imp::getBidfloorcur) .containsOnly(tuple(BigDecimal.TEN, "USD")); + assertThat(result.getValue()) + .extracting(HttpRequest::getPayload) + .flatExtracting(BidRequest::getCur) + .containsExactly("USD"); } @Test @@ -199,25 +223,6 @@ public void makeHttpRequestsShouldNotModifyFirstImpBannerIfFirstFormatIsAbsent() .containsExactly(Banner.builder().format(singletonList(null)).w(2).h(2).build()); } - @Test - public void makeHttpRequestsShouldModifyOnlyFirstImp() { - // given - final BidRequest bidRequest = givenBidRequest(identity(), List.of( - identity(), - impBuilder -> impBuilder.id("456").ext(null))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getTagid) - .containsExactlyInAnyOrder(null, "publisherId"); - } - @Test public void makeHttpRequestsShouldCreateCorrectURL() { // given @@ -236,7 +241,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { @Test public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // given - final BidderCall httpCall = givenHttpCall(null, "invalid"); + final BidderCall httpCall = givenHttpCall("invalid"); // when final Result> result = target.makeBids(httpCall, null); @@ -253,8 +258,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { @Test public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().build())); + final BidderCall httpCall = givenHttpCall(mapper.writeValueAsString(BidResponse.builder().build())); // when final Result> result = target.makeBids(httpCall, null); @@ -265,105 +269,98 @@ public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws Jso } @Test - public void makeBidsShouldReturnVideoBidIfVideoIsPresentInRequestImp() throws JsonProcessingException { + public void makeBidsShouldReturnBannerBidSuccessfully() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.video(Video.builder().build())), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + final Bid bannerBid = Bid.builder().impid("1").mtype(1).build(); + + final BidderCall httpCall = givenHttpCall(givenBidResponse(bannerBid)); // when final Result> result = target.makeBids(httpCall, null); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, null)); + assertThat(result.getValue()).containsOnly(BidderBid.of(bannerBid, banner, "USD")); + } @Test - public void makeBidsShouldReturnNativeBidIfVideoIsAbsentAndNativeIsPresentInRequestImp() - throws JsonProcessingException { + public void makeBidsShouldReturnVideoBidSuccessfully() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.banner(null).xNative(Native.builder().build())), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + final Bid videoBid = Bid.builder().impid("2").mtype(2).build(); + final BidderCall httpCall = givenHttpCall(givenBidResponse(videoBid)); // when final Result> result = target.makeBids(httpCall, null); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), xNative, null)); + assertThat(result.getValue()).containsOnly(BidderBid.of(videoBid, video, "USD")); } @Test - public void makeBidsShouldReturnBannerBidIfVideoAndNativeAreAbsentInRequestImp() throws JsonProcessingException { + public void makeBidsShouldReturnNativeBidSuccessfully() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.xNative(null).video(null)), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + final Bid nativeBid = Bid.builder().impid("4").mtype(4).build(); + + final BidderCall httpCall = givenHttpCall(givenBidResponse(nativeBid)); // when final Result> result = target.makeBids(httpCall, null); // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, null)); + assertThat(result.getValue()).containsOnly(BidderBid.of(nativeBid, xNative, "USD")); } @Test - public void makeBidsShouldReturnBannerBidIfBannerAndVideoAreAbsentInRequestImp() throws JsonProcessingException { + public void makeBidsShouldReturnErrorWhenImpTypeIsNotSupported() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.banner(null).video(null)), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + final Bid bannerBid = Bid.builder().impid("id").mtype(1).build(); + final Bid audioBid = Bid.builder().impid("id").mtype(3).build(); + final BidderCall httpCall = givenHttpCall(givenBidResponse(bannerBid, audioBid)); // when final Result> result = target.makeBids(httpCall, null); - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, null)); + assertThat(result.getErrors()) + .containsExactly(BidderError.badServerResponse("Unable to fetch mediaType 3 in multi-format: id")); + assertThat(result.getValue()).containsOnly(BidderBid.of(bannerBid, banner, "USD")); } - private static BidRequest givenBidRequest( - UnaryOperator bidRequestCustomizer, - List> impCustomizers) { - - return bidRequestCustomizer.apply(BidRequest.builder() - .imp(impCustomizers.stream() - .map(AdviewBidderTest::givenImp) - .toList())) + private static BidRequest givenBidRequest(UnaryOperator... impCustomizers) { + return BidRequest.builder() + .cur(List.of("USD")) + .imp(Stream.of(impCustomizers) + .map(AdviewBidderTest::givenImp) + .toList()) .build(); } - private static BidRequest givenBidRequest(UnaryOperator impCustomizer) { - return givenBidRequest(identity(), singletonList(impCustomizer)); - } - private static Imp givenImp(UnaryOperator impCustomizer) { return impCustomizer.apply(Imp.builder() .id("123") .banner(Banner.builder().w(23).h(25).build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, - ExtImpAdview.of("publisherId", "accountId"))))) + .ext(givenImpExt("publisherId"))) .build(); } - private static BidResponse givenBidResponse(UnaryOperator bidCustomizer) { - return BidResponse.builder() + private static ObjectNode givenImpExt(String masterTagId) { + return mapper.valueToTree(ExtPrebid.of(null, ExtImpAdview.of(masterTagId, "accountId"))); + } + + private static String givenBidResponse(Bid... bid) throws JsonProcessingException { + return mapper.writeValueAsString(BidResponse.builder() + .cur("USD") .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bidCustomizer.apply(Bid.builder()).build())) + .bid(List.of(bid)) .build())) - .build(); + .build()); } - private static BidderCall givenHttpCall(BidRequest bidRequest, String body) { + private static BidderCall givenHttpCall(String body) { return BidderCall.succeededHttp( - HttpRequest.builder().payload(bidRequest).build(), + HttpRequest.builder().payload(null).build(), HttpResponse.of(200, null, body), null); } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/adview/test-adview-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/adview/test-adview-bid-response.json index 8ad1ca21f66..e6fa819b842 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/adview/test-adview-bid-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/adview/test-adview-bid-response.json @@ -9,7 +9,8 @@ "price": 0.01, "id": "bid_id", "impid": "imp_id", - "cid": "8048" + "cid": "8048", + "mtype": 1 } ], "type": "banner" diff --git a/src/test/resources/org/prebid/server/it/openrtb2/adview/test-auction-adview-response.json b/src/test/resources/org/prebid/server/it/openrtb2/adview/test-auction-adview-response.json index 689d795c1ba..eccc7f38dec 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/adview/test-auction-adview-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/adview/test-auction-adview-response.json @@ -10,6 +10,7 @@ "adid": "2068416", "cid": "8048", "crid": "24080", + "mtype": 1, "ext": { "origbidcpm": 0.01, "prebid": { From 04bfffe117b053b5f624eab7cd72a85576e7e77e Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Fri, 24 May 2024 12:31:10 +0200 Subject: [PATCH 61/62] SeedingAlliance: Deprecate SeatId (#3097) --- .../SeedingAllianceBidder.java | 20 ++++---- .../ExtImpSeedingAlliance.java | 3 ++ .../static/bidder-params/seedingAlliance.json | 6 ++- .../SeedingAllianceBidderTest.java | 49 ++++++++++++++++--- .../prebid/server/it/SeedingAllianceTest.java | 2 +- .../test-auction-seedingAlliance-request.json | 3 +- .../test-seedingAlliance-bid-request.json | 3 +- 7 files changed, 65 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/seedingAlliance/SeedingAllianceBidder.java b/src/main/java/org/prebid/server/bidder/seedingAlliance/SeedingAllianceBidder.java index 93a8a95a891..d6e8a880778 100644 --- a/src/main/java/org/prebid/server/bidder/seedingAlliance/SeedingAllianceBidder.java +++ b/src/main/java/org/prebid/server/bidder/seedingAlliance/SeedingAllianceBidder.java @@ -41,7 +41,7 @@ public class SeedingAllianceBidder implements Bidder { private static final String EUR_CURRENCY = "EUR"; private static final String AUCTION_PRICE_MACRO = "${AUCTION_PRICE}"; private static final String ACCOUNT_ID_MACRO = "{{AccountId}}"; - private static final String DEFAULT_SEAT_ID = "pbs"; + private static final String DEFAULT_ACCOUNT_ID = "pbs"; private final String endpointUrl; private final JacksonMapper mapper; @@ -53,12 +53,14 @@ public SeedingAllianceBidder(String endpointUrl, JacksonMapper mapper) { @Override public final Result>> makeHttpRequests(BidRequest bidRequest) { - String seatId = null; + String accountId = null; final List modifiedImps = new ArrayList<>(); for (Imp imp: bidRequest.getImp()) { try { final ExtImpSeedingAlliance impExt = parseImpExt(imp); - seatId = impExt.getSeatId(); + accountId = StringUtils.isNotBlank(impExt.getAccountId()) + ? impExt.getAccountId() + : StringUtils.isNotBlank(impExt.getSeatId()) ? impExt.getSeatId() : null; final Imp modifiedImp = imp.toBuilder().tagid(impExt.getAdUnitId()).build(); modifiedImps.add(modifiedImp); } catch (PreBidException e) { @@ -67,7 +69,7 @@ public final Result>> makeHttpRequests(BidRequest b } final BidRequest modifiedBidRequest = modifyBidRequest(bidRequest, modifiedImps); - return Result.withValue(makeHttpRequest(seatId, modifiedBidRequest)); + return Result.withValue(makeHttpRequest(accountId, modifiedBidRequest)); } private ExtImpSeedingAlliance parseImpExt(Imp imp) { @@ -98,10 +100,10 @@ private static List modifyCurrencies(List bidderCurrencies) { return Collections.unmodifiableList(resolvedCurrencies); } - private HttpRequest makeHttpRequest(String seatId, BidRequest modifiedBidRequest) { + private HttpRequest makeHttpRequest(String accountId, BidRequest modifiedBidRequest) { return HttpRequest.builder() .method(HttpMethod.POST) - .uri(makeEndpoint(seatId)) + .uri(makeEndpoint(accountId)) .headers(HttpUtil.headers()) .body(mapper.encodeToBytes(modifiedBidRequest)) .impIds(BidderUtil.impIds(modifiedBidRequest)) @@ -109,9 +111,9 @@ private HttpRequest makeHttpRequest(String seatId, BidRequest modifi .build(); } - private String makeEndpoint(String seatId) { - final String accountId = StringUtils.isNotBlank(seatId) ? seatId : DEFAULT_SEAT_ID; - return endpointUrl.replace(ACCOUNT_ID_MACRO, accountId); + private String makeEndpoint(String accountId) { + final String marcoReplacement = StringUtils.isNotBlank(accountId) ? accountId : DEFAULT_ACCOUNT_ID; + return endpointUrl.replace(ACCOUNT_ID_MACRO, marcoReplacement); } @Override diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/seedingalliance/ExtImpSeedingAlliance.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/seedingalliance/ExtImpSeedingAlliance.java index 58edc92d859..e713106bf38 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/seedingalliance/ExtImpSeedingAlliance.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/seedingalliance/ExtImpSeedingAlliance.java @@ -12,4 +12,7 @@ public class ExtImpSeedingAlliance { @JsonProperty("seatId") String seatId; + @JsonProperty("accountId") + String accountId; + } diff --git a/src/main/resources/static/bidder-params/seedingAlliance.json b/src/main/resources/static/bidder-params/seedingAlliance.json index 52c3d30e087..ceb53dae3f3 100644 --- a/src/main/resources/static/bidder-params/seedingAlliance.json +++ b/src/main/resources/static/bidder-params/seedingAlliance.json @@ -11,7 +11,11 @@ }, "seatId": { "type": "string", - "description": "Seat ID" + "description": "Deprecated, please use accountId" + }, + "accountId": { + "type": "string", + "description": "Account ID of partner" } }, "required": [ diff --git a/src/test/java/org/prebid/server/bidder/seedingAlliance/SeedingAllianceBidderTest.java b/src/test/java/org/prebid/server/bidder/seedingAlliance/SeedingAllianceBidderTest.java index f00d34959ad..d30b5a80632 100644 --- a/src/test/java/org/prebid/server/bidder/seedingAlliance/SeedingAllianceBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/seedingAlliance/SeedingAllianceBidderTest.java @@ -46,7 +46,8 @@ public void creationShouldFailOnInvalidEndpointUrl() { @Test public void makeHttpRequestsShouldCreateUrlWithPbsAccountIdWhenSeatIdIsNotReceived() { // given - final BidRequest bidRequest = givenBidRequest(impBuilder -> impBuilder.ext(givenImpExt("accountId", null))); + final BidRequest bidRequest = givenBidRequest( + impBuilder -> impBuilder.ext(givenImpExt("adUnitId", null, null))); // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -62,7 +63,39 @@ public void makeHttpRequestsShouldCreateUrlWithPbsAccountIdWhenSeatIdIsNotReceiv public void makeHttpRequestsShouldCreateUrlWithSeatIdWhenSeatIdIsReceived() { // given final BidRequest bidRequest = givenBidRequest(impBuilder -> impBuilder.ext( - givenImpExt("accountId", "customSeatId"))); + givenImpExt("adUnitId", "seatId", null))); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri) + .containsExactly("https://randomurl.com/seatId"); + } + + @Test + public void makeHttpRequestsShouldCreateUrlWithSeatIdWhenAccountIdIsReceived() { + // given + final BidRequest bidRequest = givenBidRequest(impBuilder -> impBuilder.ext( + givenImpExt("adUnitId", null, "accountId"))); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri) + .containsExactly("https://randomurl.com/accountId"); + } + + @Test + public void makeHttpRequestsShouldCreateUrlWithSeatIdWhenAccountIdAndSeatIdAreReceived() { + // given + final BidRequest bidRequest = givenBidRequest(impBuilder -> impBuilder.ext( + givenImpExt("adUnitId", "seatId", "accountId"))); // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -71,15 +104,15 @@ public void makeHttpRequestsShouldCreateUrlWithSeatIdWhenSeatIdIsReceived() { assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getUri) - .containsExactly("https://randomurl.com/customSeatId"); + .containsExactly("https://randomurl.com/accountId"); } @Test public void makeHttpRequestsShouldAddAdUnitUdAsTagIdToImps() { // given final BidRequest bidRequest = givenBidRequest( - impBuilder -> impBuilder.id("impId1").tagid("tagId1").ext(givenImpExt("adUnit1", null)), - impBuilder -> impBuilder.id("impId2").ext(givenImpExt("adUnit2", null))); + impBuilder -> impBuilder.id("impId1").tagid("tagId1").ext(givenImpExt("adUnit1", null, null)), + impBuilder -> impBuilder.id("impId2").ext(givenImpExt("adUnit2", null, null))); // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -259,11 +292,11 @@ private static BidRequest givenBidRequest(List currencies) { } private static Imp givenImp(UnaryOperator impCustomizer) { - return impCustomizer.apply(Imp.builder().id("imp_id").ext(givenImpExt("accountId", null))).build(); + return impCustomizer.apply(Imp.builder().id("imp_id").ext(givenImpExt("adUnitId", null, null))).build(); } - private static ObjectNode givenImpExt(String adUnitId, String seatId) { - return mapper.valueToTree(ExtPrebid.of(null, ExtImpSeedingAlliance.of(adUnitId, seatId))); + private static ObjectNode givenImpExt(String adUnitId, String seatId, String accountId) { + return mapper.valueToTree(ExtPrebid.of(null, ExtImpSeedingAlliance.of(adUnitId, seatId, accountId))); } private static BidderCall givenHttpCall(String body) { diff --git a/src/test/java/org/prebid/server/it/SeedingAllianceTest.java b/src/test/java/org/prebid/server/it/SeedingAllianceTest.java index 72e774426b9..3f6ed91fa98 100644 --- a/src/test/java/org/prebid/server/it/SeedingAllianceTest.java +++ b/src/test/java/org/prebid/server/it/SeedingAllianceTest.java @@ -23,7 +23,7 @@ public class SeedingAllianceTest extends IntegrationTest { public void openrtb2AuctionShouldRespondWithBidsFromSeedingAlliance() throws IOException, JSONException { // given WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/seedingAlliance-exchange")) - .withQueryParam("ssp", equalTo("pbs")) + .withQueryParam("ssp", equalTo("accountId")) .withRequestBody(equalToJson( jsonFrom("openrtb2/seedingAlliance/test-seedingAlliance-bid-request.json"))) .willReturn(aResponse().withBody( diff --git a/src/test/resources/org/prebid/server/it/openrtb2/seedingAlliance/test-auction-seedingAlliance-request.json b/src/test/resources/org/prebid/server/it/openrtb2/seedingAlliance/test-auction-seedingAlliance-request.json index d851b1efef2..19955d81e38 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/seedingAlliance/test-auction-seedingAlliance-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/seedingAlliance/test-auction-seedingAlliance-request.json @@ -9,7 +9,8 @@ }, "ext": { "seedingAlliance": { - "adUnitId": "someAdUnitId" + "adUnitId": "someAdUnitId", + "accountId": "accountId" } } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/seedingAlliance/test-seedingAlliance-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/seedingAlliance/test-seedingAlliance-bid-request.json index b6f19d415ec..e91639dc3ba 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/seedingAlliance/test-seedingAlliance-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/seedingAlliance/test-seedingAlliance-bid-request.json @@ -12,7 +12,8 @@ "ext": { "tid": "${json-unit.any-string}", "bidder": { - "adUnitId": "someAdUnitId" + "adUnitId": "someAdUnitId", + "accountId": "accountId" } } } From 90848071e7bd6ee4cc0feecafe7e82cf0f4463bf Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Mon, 27 May 2024 10:43:11 +0300 Subject: [PATCH 62/62] Tests: Increase eids spec (#3171) --- .../functional/model/bidder/BidderName.groovy | 1 + .../request/auction/BidRequestExt.groovy | 2 + .../model/request/auction/Uid.groovy | 1 + .../model/request/auction/UidExt.groovy | 9 + .../server/functional/tests/EidsSpec.groovy | 200 ++++++++++++++++++ 5 files changed, 213 insertions(+) create mode 100644 src/test/groovy/org/prebid/server/functional/model/request/auction/UidExt.groovy create mode 100644 src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy diff --git a/src/test/groovy/org/prebid/server/functional/model/bidder/BidderName.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/BidderName.groovy index a27e542b127..395bb2033b2 100644 --- a/src/test/groovy/org/prebid/server/functional/model/bidder/BidderName.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/BidderName.groovy @@ -5,6 +5,7 @@ import net.minidev.json.annotate.JsonIgnore enum BidderName { + WILDCARD("*"), UNKNOWN("unknown"), BOGUS("bogus"), ALIAS("alias"), diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy index bcc040e7946..f7aee45fb75 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy @@ -9,4 +9,6 @@ class BidRequestExt { Prebid prebid SupplyChain schain AppNexus appnexus + String bc + String platform } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Uid.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Uid.groovy index e562b9a5423..907c46fce01 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Uid.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Uid.groovy @@ -10,6 +10,7 @@ class Uid { String id Integer atype + UidExt ext static Uid getDefaultUid() { new Uid().tap { diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/UidExt.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/UidExt.groovy new file mode 100644 index 00000000000..53ecd62dcbe --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/UidExt.groovy @@ -0,0 +1,9 @@ +package org.prebid.server.functional.model.request.auction + +import groovy.transform.ToString + +@ToString(includeNames = true, ignoreNulls = true) +class UidExt { + + String stype +} diff --git a/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy new file mode 100644 index 00000000000..d8c9122b745 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy @@ -0,0 +1,200 @@ +package org.prebid.server.functional.tests + +import org.prebid.server.functional.model.bidder.Generic +import org.prebid.server.functional.model.bidder.Openx +import org.prebid.server.functional.model.request.auction.BidRequest +import org.prebid.server.functional.model.request.auction.Eid +import org.prebid.server.functional.model.request.auction.EidPermission +import org.prebid.server.functional.model.request.auction.ExtRequestPrebidData +import org.prebid.server.functional.model.request.auction.Uid +import org.prebid.server.functional.model.request.auction.UidExt +import org.prebid.server.functional.model.request.auction.User +import org.prebid.server.functional.model.request.auction.UserExt +import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.PBSUtils + +import static org.prebid.server.functional.model.bidder.BidderName.ALIAS +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC +import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.bidder.BidderName.WILDCARD +import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer + +class EidsSpec extends BaseSpec { + + def "PBS shouldn't populate user.id from user.ext data"() { + given: "Default basic BidRequest with generic bidder" + def bidRequest = BidRequest.defaultBidRequest.tap { + user = new User(ext: new UserExt(eids: [new Eid(source: PBSUtils.randomString, + uids: [new Uid(id: PBSUtils.randomString, ext: new UidExt(stype: PBSUtils.randomString))])])) + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request shouldn't contain user.id" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert !bidderRequest.user.id + } + + def "PBS should send same eids as in original request"() { + given: "Default basic BidRequest with generic bidder" + def eids = [new Eid(source: PBSUtils.randomString, uids: [new Uid(id: PBSUtils.randomString)])] + def bidRequest = BidRequest.defaultBidRequest.tap { + user = new User(eids: eids) + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain requested eids" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.user.eids == eids + } + + def "PBS eids should be passed only to permitted bidders"() { + given: "Default bid request with generic bidder and eids" + def eids = [new Eid(source: PBSUtils.randomString, uids: [new Uid(id: PBSUtils.randomString)])] + def bidRequest = BidRequest.defaultBidRequest.tap { + user = new User(eids: eids) + ext.prebid.data = new ExtRequestPrebidData(eidpermissions: + [new EidPermission(source: PBSUtils.randomString, bidders: [eidsBidder])]) + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain requested eids" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.user.eids == eids + + where: + eidsBidder << [WILDCARD, GENERIC] + } + + def "PBS eids shouldn't be passed to restricted bidders"() { + given: "Default bid request with generic bidder" + def sourceId = PBSUtils.randomString + def eids = [new Eid(source: sourceId, uids: [new Uid(id: sourceId)])] + def bidRequest = BidRequest.defaultBidRequest.tap { + user = new User(eids: eids) + ext.prebid.data = new ExtRequestPrebidData(eidpermissions: [new EidPermission(source: sourceId, bidders: [OPENX])]) + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request shouldn't contain requested eids" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert !bidderRequest.user.eids + } + + def "PBs eid permissions should affect only specified on source"() { + given: "PBs with openx bidder" + def pbsService = pbsServiceFactory.getService( + ["adapters.openx.enabled" : "true", + "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()]) + + and: "Default bid request with eidpremissions and openx bidder" + def eidSource = PBSUtils.randomString + def openxEid = new Eid(source: eidSource, uids: [new Uid(id: PBSUtils.randomString)]) + def genericEid = new Eid(source: PBSUtils.randomString, uids: [new Uid(id: PBSUtils.randomString)]) + def eids = [openxEid, genericEid] + def bidRequest = BidRequest.defaultBidRequest.tap { + user = new User(eids: eids) + imp[0].ext.prebid.bidder.openx = Openx.defaultOpenx + ext.prebid.data = new ExtRequestPrebidData(eidpermissions: [new EidPermission(source: eidSource, bidders: [OPENX])]) + } + + when: "PBS processes auction request" + pbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain two bidder request" + def bidderRequests = bidder.getBidderRequests(bidRequest.id) + assert bidderRequests.size() == 2 + + and: "Generic bidder should contain one eid" + assert bidderRequests.user.eids.sort().first == [genericEid] + + and: "Openx bidder should contain two eids" + assert bidderRequests.user.eids.sort().last.sort() == eids.sort() + } + + def "PBs eid permissions for non existing source should not stop auction"() { + given: "PBs with openx bidder" + def pbsService = pbsServiceFactory.getService( + ["adapters.openx.enabled" : "true", + "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()]) + + and: "Default bid request with eidpremissions and openx bidder" + def firstEid = new Eid(source: PBSUtils.randomString, uids: [new Uid(id: PBSUtils.randomString)]) + def secondEid = new Eid(source: PBSUtils.randomString, uids: [new Uid(id: PBSUtils.randomString)]) + def bidRequest = BidRequest.defaultBidRequest.tap { + user = new User(eids: [firstEid, secondEid]) + imp[0].ext.prebid.bidder.openx = Openx.defaultOpenx + ext.prebid.data = new ExtRequestPrebidData( + eidpermissions: [new EidPermission(source: PBSUtils.randomString, bidders: [OPENX])]) + } + + when: "PBS processes auction request" + pbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain two bidder request" + def bidderRequests = bidder.getBidderRequests(bidRequest.id) + assert bidderRequests.size() == 2 + + and: "Openx and Generic bidder should contain two eid" + bidderRequests.user.eids.each { + assert it.sort() == [secondEid, firstEid].sort() + } + } + + def "PBs missing bidders in eid permissions should throw an error"() { + given: "Default request with eidpremissions and openx bidder" + def bidRequest = BidRequest.defaultBidRequest.tap { + user = new User(eids: [new Eid(source: PBSUtils.randomString, uids: [new Uid(id: PBSUtils.randomString)])]) + imp[0].ext.prebid.bidder.openx = Openx.defaultOpenx + ext.prebid.data = new ExtRequestPrebidData( + eidpermissions: [new EidPermission(source: PBSUtils.randomString, bidders: eidsBidder), + new EidPermission(source: PBSUtils.randomString)]) + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "PBS should throw error" + def exception = thrown(PrebidServerException) + assert exception.responseBody == "Invalid request format: request.ext.prebid.data.eidpermissions[].bidders[] " + + "required values but was empty or null" + + where: + eidsBidder << [[WILDCARD], [], null] + } + + def "PBs eid permissions should honor bidder alias"() { + given: "Default request with eidpremissions and openx bidder" + def sourceId = PBSUtils.randomString + def eid = new Eid(source: sourceId, uids: [new Uid(id: PBSUtils.randomString)]) + def bidRequest = BidRequest.defaultBidRequest.tap { + user = new User(eids: [eid]) + imp[0].ext.prebid.bidder.alias = new Generic() + ext.prebid.tap { + data = new ExtRequestPrebidData(eidpermissions: [new EidPermission(source: sourceId, bidders: [ALIAS])]) + aliases = [(ALIAS.value): GENERIC] + } + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain two bidder request" + def bidderRequests = bidder.getBidderRequests(bidRequest.id) + def sortedEids = bidderRequests.user.sort { it.eids } + assert bidderRequests.size() == 2 + + and: "Generic bidder shouldn't contain eids" + assert !sortedEids[0].eids + + and: "Alias bidder should contain one eids" + assert sortedEids[1].eids == [eid] + } +}