Skip to content

Commit

Permalink
FIX #714
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinovega committed Aug 30, 2024
1 parent af3dddb commit d5914e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion daikoku/app/utils/ApiService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2329,7 +2329,10 @@ class ApiService(
AppError.PlanNotFound
)
_ <- EitherT.cond[Future][AppError, Unit](
tenant.display != TenantDisplay.Environment || tenant.environmentAggregationApiKeysSecurity.forall(s => s && plan.customName == parentPlan.customName),
tenant.display != TenantDisplay.Environment || (tenant.environmentAggregationApiKeysSecurity match {
case Some(true) => plan.customName == parentPlan.customName
case _ => true
}),
(),
AppError.SecurityError(s"Environment Subscription Aggregation security is enabled, a subscription cannot be extended by another environment")
)
Expand Down
2 changes: 1 addition & 1 deletion daikoku/javascript/tests/connectedUser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ test('aggregation mode', async ({ page, request }) => {
await page.getByText('Plans').click();
await page.locator('.usage-plan__card').filter({ hasText: 'not test plan' }).getByRole('button').click();
await page.locator('div').filter({ hasText: /^Consumers$/ }).click();
await page.getByRole('button', { name: 'Subscribe with a new api key' }).click();
// await page.getByRole('button', { name: 'Subscribe with a new api key' }).click();
await page.getByRole('link', { name: 'Go home' }).click();

//subscribe second api with aggregation
Expand Down
7 changes: 3 additions & 4 deletions daikoku/test/daikoku/ApiControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ class ApiControllerSpec()
body = Json.obj().some
)(tenant, session)

respPersonal.status mustBe 401
respPersonal.status mustBe 403

val respOrg = httpJsonCallBlocking(
path =
Expand Down Expand Up @@ -4533,7 +4533,7 @@ class ApiControllerSpec()
body = Json.obj().some
)(tenant, loginWithBlocking(user, tenant))

resp.status mustBe Status.UNAUTHORIZED
resp.status mustBe Status.FORBIDDEN
}
"not be extended subscription that we have already a parent" in {
val parentSub = ApiSubscription(
Expand Down Expand Up @@ -7180,7 +7180,6 @@ class ApiControllerSpec()
respProd.status mustBe 200

//disabled security

setupEnvBlocking(
tenants = Seq(tenantEnvMode.copy(
otoroshiSettings = Set(
Expand All @@ -7193,7 +7192,7 @@ class ApiControllerSpec()
clientId = otoroshiAdminApiKey.clientId
)
),
environmentAggregationApiKeysSecurity = Some(true),
environmentAggregationApiKeysSecurity = Some(false),
aggregationApiKeysSecurity = Some(true)
)),
users = Seq(user, userAdmin),
Expand Down

0 comments on commit d5914e3

Please sign in to comment.