Skip to content

Commit 8c69a18

Browse files
committed
fix: three test failures after Http4s600 lazy-val restore
1. Http4s600: add missing POST /management/webui_props (createWebUiProps) OBPAPI6_0_0.routes is Nil — all v6 endpoints must be in Http4s600. The POST endpoint existed in Http4s310 but was never ported to v6. 2. Http4s600: enable v600→v510 bridge for inherited endpoints OBPAPI6_0_0.routes=Nil means there is no Lift fallback for v6 paths not implemented in Http4s600. Endpoints inherited from lower versions (e.g. GET /my/accounts from v3.0.0) must reach their implementation via the bridge cascade. Enable the pre-existing v600ToV510Bridge. 3. RateLimitingUtil: only increment counters for active limits (limit > 0) incrementConsumerCounters was incrementing all period counters on every call regardless of whether a limit was set. When a later test scenario set per_hour=1, the hour counter already had accumulated calls from earlier scenarios (per_second, per_minute), causing immediate 429 on the first call. Skip increment when limit <= 0.
1 parent d3e7a36 commit 8c69a18

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

obp-api/src/main/scala/code/api/util/RateLimitingUtil.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ object RateLimitingUtil extends MdcLoggable {
265265
}
266266

267267
private def incrementConsumerCounters(consumerKey: String, period: LimitCallPeriod, limit: Long): (Long, Long) = {
268-
if (useConsumerLimits) {
268+
if (useConsumerLimits && limit > 0) {
269269
incrementCounter(createUniqueKey(consumerKey, period), period)
270270
} else {
271271
(-1, -1)

obp-api/src/main/scala/code/api/v6_0_0/Http4s600.scala

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,7 @@ object Http4s600 {
17901790
.orElse(getConnectorTraces(req))
17911791
.orElse(getDynamicEntityDiagnostics(req))
17921792
.orElse(cleanupOrphanedDynamicEntityRecords(req))
1793+
.orElse(createWebUiProps(req))
17931794
.orElse(createOrUpdateWebUiProps(req))
17941795
.orElse(deleteWebUiProps(req))
17951796
.orElse(createCustomViewManagement(req))
@@ -2249,6 +2250,36 @@ object Http4s600 {
22492250
Some(canCleanupOrphanedDynamicEntityRecords :: Nil),
22502251
http4sPartialFunction = Some(cleanupOrphanedDynamicEntityRecords))
22512252

2253+
// POST /obp/v6.0.0/management/webui_props
2254+
lazy val createWebUiProps: HttpRoutes[IO] = HttpRoutes.of[IO] {
2255+
case req @ POST -> `prefixPath` / "management" / "webui_props" =>
2256+
EndpointHelpers.withUserAndBodyCreated[WebUiPropsCommons, Any](req) { (user, postedData, cc) =>
2257+
for {
2258+
_ <- NewStyle.function.hasEntitlement("", user.userId, canCreateWebUiProps, Some(cc))
2259+
_ <- NewStyle.function.tryons(
2260+
s"""$InvalidWebUiProps name must be start with webui_, but current post name is: ${postedData.name} """,
2261+
400, Some(cc)) { require(postedData.name.startsWith("webui_")) }
2262+
webUiProps <- Future(MappedWebUiPropsProvider.createOrUpdate(postedData)) map {
2263+
unboxFullOrFail(_, Some(cc))
2264+
}
2265+
} yield (webUiProps: WebUiPropsCommons)
2266+
}
2267+
}
2268+
2269+
resourceDocs += ResourceDoc(
2270+
null, implementedInApiVersion, nameOf(createWebUiProps), "POST",
2271+
"/management/webui_props",
2272+
"Create WebUiProps",
2273+
s"""Create a WebUiProps.
2274+
|
2275+
|${APIUtil.userAuthenticationMessage(true)}
2276+
|""",
2277+
WebUiPropsCommons("webui_api_explorer_url", "https://apiexplorer.openbankproject.com"),
2278+
WebUiPropsCommons("webui_api_explorer_url", "https://apiexplorer.openbankproject.com", Some("web-ui-props-id")),
2279+
List($AuthenticatedUserIsRequired, UserHasMissingRoles, InvalidJsonFormat, UnknownError),
2280+
List(apiTagWebUiProps), Some(List(canCreateWebUiProps)),
2281+
http4sPartialFunction = Some(createWebUiProps))
2282+
22522283
// PUT /obp/v6.0.0/management/webui_props/WEBUI_PROP_NAME
22532284
lazy val createOrUpdateWebUiProps: HttpRoutes[IO] = HttpRoutes.of[IO] {
22542285
case req @ PUT -> `prefixPath` / "management" / "webui_props" / webUiPropName =>
@@ -8501,5 +8532,8 @@ object Http4s600 {
85018532
// A `lazy val` defers the read until first access (from Http4sApp after Boot
85028533
// completes), by which time Impl6 is fully initialised.
85038534
lazy val wrappedRoutesV600Services: HttpRoutes[IO] =
8504-
Implementations6_0_0.allRoutesWithMiddleware
8535+
Kleisli[HttpF, Request[IO], Response[IO]] { req =>
8536+
Implementations6_0_0.allRoutesWithMiddleware.run(req)
8537+
.orElse(Implementations6_0_0.v600ToV510Bridge.run(req))
8538+
}
85058539
}

0 commit comments

Comments
 (0)