Skip to content

Commit d2f1190

Browse files
committed
fixed failing test case
1 parent b80887e commit d2f1190

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/McpTokenServiceCEImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public McpTokenServiceCEImpl(
7272
}
7373

7474
// CE: 2 live keys. EE overrides to 10.
75-
protected int getMaxActiveKeysPerUser() {
75+
public int getMaxActiveKeysPerUser() {
7676
return 2;
7777
}
7878

@@ -103,6 +103,7 @@ private Mono<Void> validateMCPEnabled() {
103103

104104
return Mono.just(organization);
105105
})
106+
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INTERNAL_SERVER_ERROR)))
106107
.then();
107108
}
108109

app/server/appsmith-server/src/test/java/com/appsmith/server/services/McpTokenServiceImplTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,15 @@ void should_rejectCreate_whenKeySpanDaysIsNotAllowed() {
198198
}
199199

200200
@Test
201-
void should_rejectCreate_whenUserAlreadyHasTenLiveKeys() {
202-
when(mcpKeyRepository.countByUserIdAndRevokedAtIsNull(user.getId())).thenReturn(Mono.just(10L));
201+
void should_rejectCreate_whenUserAlreadyHasMaxActiveKeys() {
202+
Long maxPossibleKeysPerUser = Long.valueOf(service.getMaxActiveKeysPerUser());
203+
when(mcpKeyRepository.countByUserIdAndRevokedAtIsNull(user.getId()))
204+
.thenReturn(Mono.just(maxPossibleKeysPerUser));
203205

204206
StepVerifier.create(service.create(user, "Claude Desktop", 30))
205-
.expectErrorSatisfies(error ->
206-
assertThat(error).isInstanceOf(AppsmithException.class).hasMessageContaining("maximum of 10"))
207+
.expectErrorSatisfies(error -> assertThat(error)
208+
.isInstanceOf(AppsmithException.class)
209+
.hasMessageContaining("maximum of " + maxPossibleKeysPerUser))
207210
.verify();
208211
}
209212

0 commit comments

Comments
 (0)