From 1185b36a6da0616b7de79a6607e4c5f9eeb4504a Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 13 Nov 2026 06:34:32 +0900 Subject: [PATCH 1/3] =?UTF-8?q?test:=20=EA=B1=B0=EC=A7=93=20=ED=86=B5?= =?UTF-8?q?=EA=B3=BC=C2=B7=ED=9D=94=EB=93=A4=EB=A6=BC=C2=B7=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=EC=86=8C=20=EC=9D=BD=EA=B8=B0=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=EB=A5=BC=20=EB=A7=89=EB=8F=84=EB=A1=9D=20=EC=8B=9C=ED=97=98?= =?UTF-8?q?=EC=9D=84=20=EA=B3=A0=EC=B9=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: - GraphQlDeploymentModeRegistryParityTest가 태그 없이 test에서 docs/registries/env-keys.yaml을 읽었다. 입력을 선언하지 않아 test 캐시가 registry 변경을 놓쳤고, modules.json을 거슬러 올라가 저장소 루트 가드를 우회했다(build-logic/AGENTS.md 「저장소 파일을 읽는 테스트」). - 「값을 싣지 않는다」 단언 넷(WebSecurityContextBridgeTest, scalar 둘)이 예외 타입을 보지 않아, 메시지 null인 NPE로 바꿔도 통과했다. - FileserverAdminControllerRequestBodyValidationTest는 @RequestBody가 하나도 없는 controller에도 통과했다. - GraphQlRequestDeadlineTest가 sleep(500) 뒤에 하위 필드 부재를 단언했다. 부하에 따라 기다림이 짧으면 거짓 통과다. - 두 동작을 한 시험에서 보던 셋(표 입력 반복문, when 둘). 고친 것: - registry 대조 시험에 document-contract 태그를 달고 graphql leaf에 mainStage lane graphqlDocumentContractTest를 둔다(lane은 다음 커밋의 build.gradle에 있다. 그 파일의 다른 변경과 같이 간다). - 부재 단언에 예외 타입(CoercingParseValueException, UntrustedTenantInputException)을 먼저 둔다. - admin 시험은 @RequestBody 매개변수 목록을 고정한 뒤 @Valid를 본다. - deadline 시험은 slowNode 실행이 끝났다는 신호(Instrumentation beginExecution 완료, 세대 번호로 이전 시험의 늦은 완료를 거른다)를 기다린 뒤 부재를 본다. - 표 입력(scalar 넷의 부재 단언 포함)은 @ParameterizedTest로, 두 동작은 시험 둘로 나눴다. 고친 시험은 GWT와 catchThrowable로 when을 하나로 둔다. - decisions 2.1에 「시험 형식 일괄 전환 안 함」(리뷰 README 6절 ④) 행을 더했다. Refs: RR9-03-17, RR9-03-18, RR9-03-19, RR9-03-20, RR9-03-22 --- docs/work/reference/decisions.md | 1 + .../runtime/GraphQlRequestDeadlineTest.java | 10 +++- .../runtime/RuntimeLimitsTestSupport.java | 38 +++++++++++++ ...aphQlDeploymentModeRegistryParityTest.java | 15 ++++- .../GraphQlMutationResultMapperTest.java | 13 ++++- .../HmacGraphQlCursorCodecTest.java | 4 ++ .../scalar/GraphQlScalarContractTest.java | 35 ++++++++++-- .../scalar/GraphQlScalarSymmetryTest.java | 1 + .../WebSecurityContextBridgeTest.java | 55 +++++++++++++++---- ...inControllerRequestBodyValidationTest.java | 29 ++++++++-- 10 files changed, 172 insertions(+), 29 deletions(-) diff --git a/docs/work/reference/decisions.md b/docs/work/reference/decisions.md index db1f8aa0..a1429d19 100644 --- a/docs/work/reference/decisions.md +++ b/docs/work/reference/decisions.md @@ -58,6 +58,7 @@ | 개선 매뉴얼을 먼저(지난 것) | 다음 개선 작업 전에 repo마다 개선 매뉴얼을 만든다 → 2026-11-06 「매뉴얼 체계」로 바뀜 | 소유자 | 2026-11-05 | 2026-11-05 총괄 세션 brief | | 스킬 | 리뷰·수정에 알맞은 스킬을 쓴다 | 소유자 | 2026-11-05 | `1103` 2절 | | `@DisplayName` 언어 | 한국어(기본값 영어를 거부) | 소유자 | 2026-09-25 | 결정 5, `.claude/rules/java-tests.md` 규칙 2 | +| 시험 형식 일괄 전환 | 영어 `@DisplayName`과 `// when` 없는 시험을 한꺼번에 바꾸지 않는다. 규칙(`.claude/rules/java-tests.md`)은 그대로이고, 고치는 시험에 적용한다. 한꺼번에 바꾸면 수천 줄의 diff가 결함 수정을 가린다 | 기본값(소유자가 뒤집을 수 있다) | 2026-11-12 | 2026-11-12 전체 리뷰 기록 README 6절 ④ | | 학습 문서(지난 것) | 삭제된 코드를 설명하는 학습 문서(지금 `docs/history/study/*.ko.md`, `docs/history/packages/*-superpowers-package/`)는 현재 코드에 맞게 갱신 → 2026-11-07 갱신하지 않고 기록으로 보관(머리 블록만 단다)으로 바뀜 | 소유자 | 2026-09-25 | 결정 6, design-docs `repo-structure/README.md` 3.2절 | | 문서 체계 | 문서를 수명으로 나눈다. 살아 있는 문서는 제자리에 두고 한국어로 옮긴다. 기록은 `docs/history/`, 설계서는 `docs/design/`, 결정 기록은 `docs/adr/`에 둔다. 폴더 이름은 짝 프론트와 같이 쓴다 | 소유자 | 2026-11-07 | design-docs `repo-structure/README.md` 3.2절, 적용은 `docs/README.md` | | 한국어의 범위 | 살아 있는 문서는 본문까지 한국어로 쓴다. 기록 문서는 맨 위에 한국어 머리 블록(상태·작성일·요약·현재 정본)을 달고 본문은 원문 그대로 둔다. 상태는 한국어 고정 어휘다 | 소유자 | 2026-11-07 | design-docs `repo-structure/README.md` 3.2절 | diff --git a/src/adapter/inbound/graphql/src/systemTest/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlRequestDeadlineTest.java b/src/adapter/inbound/graphql/src/systemTest/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlRequestDeadlineTest.java index 6bf15a36..dc59e246 100644 --- a/src/adapter/inbound/graphql/src/systemTest/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlRequestDeadlineTest.java +++ b/src/adapter/inbound/graphql/src/systemTest/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlRequestDeadlineTest.java @@ -98,8 +98,9 @@ class GraphQlRequestDeadlineTest { assertThat(finished) .as("the running resolver is not interrupted; it finishes on its own thread") .isTrue(); - // Room for graphql-java to have dispatched the child, had the cancellation not stopped it. - Thread.sleep(500); + assertThat(SlowWork.slowExecutionEnded.await(5, TimeUnit.SECONDS)) + .as("the execution ends after its last field, so a child that was going to start has") + .isTrue(); assertThat(SlowWork.DETAIL_INVOCATIONS) .as("a cancelled execution must not start new fields once the client has been answered") .hasValue(0); @@ -114,5 +115,10 @@ class GraphQlRequestDeadlineTest { GraphQlClientPolicy shortBudgetClientPolicy() { return RuntimeLimitsTestSupport.policyWithExecutionBudget(BUDGET); } + + @Bean + graphql.execution.instrumentation.Instrumentation slowExecutionEndSignal() { + return SlowWork.executionEndSignal(); + } } } diff --git a/src/adapter/inbound/graphql/src/systemTest/java/dev/caskeleton/adapter/inbound/graphql/runtime/RuntimeLimitsTestSupport.java b/src/adapter/inbound/graphql/src/systemTest/java/dev/caskeleton/adapter/inbound/graphql/runtime/RuntimeLimitsTestSupport.java index cc8529d2..9f79efd6 100644 --- a/src/adapter/inbound/graphql/src/systemTest/java/dev/caskeleton/adapter/inbound/graphql/runtime/RuntimeLimitsTestSupport.java +++ b/src/adapter/inbound/graphql/src/systemTest/java/dev/caskeleton/adapter/inbound/graphql/runtime/RuntimeLimitsTestSupport.java @@ -2,6 +2,13 @@ package dev.caskeleton.adapter.inbound.graphql.runtime; import dev.caskeleton.adapter.inbound.graphql.HealthGraphqlController; import dev.caskeleton.adapter.inbound.graphql.policy.GraphQlClientPolicy; +import graphql.ExecutionResult; +import graphql.execution.instrumentation.Instrumentation; +import graphql.execution.instrumentation.InstrumentationContext; +import graphql.execution.instrumentation.InstrumentationState; +import graphql.execution.instrumentation.SimpleInstrumentationContext; +import graphql.execution.instrumentation.SimplePerformantInstrumentation; +import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters; import java.net.URI; import java.time.Duration; import java.util.concurrent.CountDownLatch; @@ -85,12 +92,43 @@ final class RuntimeLimitsTestSupport { static final AtomicInteger DETAIL_INVOCATIONS = new AtomicInteger(); static volatile CountDownLatch slowFinished = new CountDownLatch(1); + /** + * Counted down when a {@code slowNode} execution begun after the last {@link #reset()} has + * ended. The point after which a child field can no longer start, so an absence asserted after + * it is an absence and not a guess at how long the engine needs. + */ + static volatile CountDownLatch slowExecutionEnded = new CountDownLatch(1); + + private static final AtomicInteger GENERATION = new AtomicInteger(); + private SlowWork() {} static void reset() { SLOW_STARTED.set(0); DETAIL_INVOCATIONS.set(0); slowFinished = new CountDownLatch(1); + slowExecutionEnded = new CountDownLatch(1); + GENERATION.incrementAndGet(); + } + + /** Signals the end of each {@code slowNode} execution begun in the current generation. */ + static Instrumentation executionEndSignal() { + return new SimplePerformantInstrumentation() { + @Override + public InstrumentationContext beginExecution( + InstrumentationExecutionParameters parameters, InstrumentationState state) { + int generation = GENERATION.get(); + CountDownLatch ended = slowExecutionEnded; + boolean slow = + parameters.getQuery() != null && parameters.getQuery().contains("slowNode"); + return SimpleInstrumentationContext.whenCompleted( + (result, failure) -> { + if (slow && generation == GENERATION.get()) { + ended.countDown(); + } + }); + } + }; } } diff --git a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/autoconfigure/GraphQlDeploymentModeRegistryParityTest.java b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/autoconfigure/GraphQlDeploymentModeRegistryParityTest.java index f255abc9..d752acc4 100644 --- a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/autoconfigure/GraphQlDeploymentModeRegistryParityTest.java +++ b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/autoconfigure/GraphQlDeploymentModeRegistryParityTest.java @@ -8,6 +8,8 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; /** @@ -16,7 +18,11 @@ import org.junit.jupiter.api.Test; *

A mode the registry documents but the enum cannot bind fails at startup with a type-conversion * error; a mode the enum has but the registry omits is one no operator is told about. Which runtime * accepts each mode is held by {@code GraphQlDeploymentModeContractTest}. + * + *

Tagged {@code document-contract}: it reads a repository document, so it runs in the leaf's + * main-stage lane {@code graphqlDocumentContractTest}, never in the cached {@code test}. */ +@Tag("document-contract") class GraphQlDeploymentModeRegistryParityTest { private static final Pattern ALLOWED_VALUES = @@ -24,11 +30,16 @@ class GraphQlDeploymentModeRegistryParityTest { "name: APP_GRAPHQL_DEPLOYMENT_MODE.*?allowed_values: \\[([^\\]]*)\\]", Pattern.DOTALL); @Test + @DisplayName("registry의 APP_GRAPHQL_DEPLOYMENT_MODE 허용 값은 enum이 받는 값과 정확히 같다") void theRegistryListsExactlyTheModesTheEnumHas() throws IOException { + // given String registry = Files.readString(repositoryRoot().resolve("docs/registries/env-keys.yaml")); - Matcher matcher = ALLOWED_VALUES.matcher(registry); - assertThat(matcher.find()).isTrue(); + // when + Matcher matcher = ALLOWED_VALUES.matcher(registry); + + // then + assertThat(matcher.find()).as("the registry row and its allowed_values").isTrue(); assertThat(Arrays.stream(matcher.group(1).split(",")).map(String::trim)) .as("the registry is what an operator sets APP_GRAPHQL_DEPLOYMENT_MODE from") .containsExactlyInAnyOrderElementsOf( diff --git a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/mutation/GraphQlMutationResultMapperTest.java b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/mutation/GraphQlMutationResultMapperTest.java index ded2370e..5a5f6921 100644 --- a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/mutation/GraphQlMutationResultMapperTest.java +++ b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/mutation/GraphQlMutationResultMapperTest.java @@ -41,9 +41,13 @@ class GraphQlMutationResultMapperTest { } @Test - void oneRootFieldCallsOneUseCase() { + void oneRootFieldThatCallsOneUseCaseIsAccepted() { assertThatCode(() -> GraphQlMutationContractValidator.requireSingleUseCase(CREATE_ORDER, 1)) .doesNotThrowAnyException(); + } + + @Test + void oneRootFieldThatCallsTwoUseCasesIsRefused() { assertThatThrownBy(() -> GraphQlMutationContractValidator.requireSingleUseCase(CREATE_ORDER, 2)) .isInstanceOf(GraphQlMutationContractException.class) .hasMessageContaining("one use case"); @@ -58,6 +62,13 @@ class GraphQlMutationResultMapperTest { () -> GraphQlMutationContractValidator.rejectRequestWideTransaction(roots, true)) .isInstanceOf(GraphQlMutationContractException.class) .hasMessageContaining("not a shared transaction"); + } + + @Test + void severalRootMutationsWithoutARequestWideTransactionAreAccepted() { + List roots = + List.of(CREATE_ORDER, new GraphQlMutationCoordinate("Mutation.createInvoice")); + assertThatCode( () -> GraphQlMutationContractValidator.rejectRequestWideTransaction(roots, false)) .doesNotThrowAnyException(); diff --git a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/pagination/HmacGraphQlCursorCodecTest.java b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/pagination/HmacGraphQlCursorCodecTest.java index bad9cd32..f3b9d3d3 100644 --- a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/pagination/HmacGraphQlCursorCodecTest.java +++ b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/pagination/HmacGraphQlCursorCodecTest.java @@ -232,6 +232,10 @@ class HmacGraphQlCursorCodecTest { void framingRejectsADeclaredLengthLongerThanTheBody() { assertThatThrownBy(() -> GraphQlCursorFraming.readAll("99:short")) .isInstanceOf(GraphQlCursorException.class); + } + + @Test + void framingAcceptsADeclaredLengthThatMatchesTheBody() { assertThatCode(() -> GraphQlCursorFraming.readAll("5:hello")).doesNotThrowAnyException(); } diff --git a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/scalar/GraphQlScalarContractTest.java b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/scalar/GraphQlScalarContractTest.java index eb56b126..136180fc 100644 --- a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/scalar/GraphQlScalarContractTest.java +++ b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/scalar/GraphQlScalarContractTest.java @@ -2,6 +2,7 @@ package dev.caskeleton.adapter.inbound.graphql.scalar; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.catchThrowable; import dev.caskeleton.adapter.inbound.graphql.schema.GraphQlScalarDefinition; import dev.caskeleton.adapter.inbound.graphql.schema.GraphQlScalarManifest; @@ -13,7 +14,13 @@ import java.time.Instant; import java.time.LocalDate; import java.util.Map; import java.util.UUID; +import java.util.function.Function; +import java.util.stream.Stream; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** Stable custom scalar serialization and coercion contract (Stable plan Task 13). */ class GraphQlScalarContractTest { @@ -79,14 +86,30 @@ class GraphQlScalarContractTest { assertThat(LongScalar.serialize(42L)).isEqualTo("42"); } - @Test - void coercionErrorsDoNotEchoTheOffendingValue() { + static Stream parsers() { + return Stream.of( + Arguments.of("UUID", (Function) UuidScalar::parse), + Arguments.of("Date", (Function) DateScalar::parse), + Arguments.of("BigDecimal", (Function) BigDecimalScalar::parse), + Arguments.of("Long", (Function) LongScalar::parse)); + } + + @ParameterizedTest(name = "{0}") + @MethodSource("parsers") + @DisplayName("scalar 변환 오류는 거절한 값을 메시지에 싣지 않는다") + void coercionErrorsDoNotEchoTheOffendingValue(String scalar, Function parse) { + // given String secret = "4111-1111-1111-1111"; - assertThatThrownBy(() -> UuidScalar.parse(secret)).hasMessageNotContaining(secret); - assertThatThrownBy(() -> DateScalar.parse(secret)).hasMessageNotContaining(secret); - assertThatThrownBy(() -> BigDecimalScalar.parse(secret)).hasMessageNotContaining(secret); - assertThatThrownBy(() -> LongScalar.parse(secret)).hasMessageNotContaining(secret); + // when + Throwable refused = catchThrowable(() -> parse.apply(secret)); + + // then + // The type first: a message that merely lacks the value also passes for an NPE thrown before + // the scalar ever looked at it, which is not the refusal this test is about. + assertThat(refused) + .isInstanceOf(CoercingParseValueException.class) + .hasMessageNotContaining(secret); } @Test diff --git a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/scalar/GraphQlScalarSymmetryTest.java b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/scalar/GraphQlScalarSymmetryTest.java index 62a05f39..89a49592 100644 --- a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/scalar/GraphQlScalarSymmetryTest.java +++ b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/scalar/GraphQlScalarSymmetryTest.java @@ -81,6 +81,7 @@ class GraphQlScalarSymmetryTest { String secret = "9".repeat(500); assertThatThrownBy(() -> BigDecimalScalar.parse(secret)) + .isInstanceOf(graphql.schema.CoercingParseValueException.class) .hasMessageNotContaining(secret) .hasMessageNotContaining("999"); } diff --git a/src/adapter/inbound/web-advanced/src/test/java/dev/caskeleton/adapter/inbound/web/advanced/security/WebSecurityContextBridgeTest.java b/src/adapter/inbound/web-advanced/src/test/java/dev/caskeleton/adapter/inbound/web/advanced/security/WebSecurityContextBridgeTest.java index 8f5540bf..e10dc5b8 100644 --- a/src/adapter/inbound/web-advanced/src/test/java/dev/caskeleton/adapter/inbound/web/advanced/security/WebSecurityContextBridgeTest.java +++ b/src/adapter/inbound/web-advanced/src/test/java/dev/caskeleton/adapter/inbound/web/advanced/security/WebSecurityContextBridgeTest.java @@ -1,13 +1,15 @@ package dev.caskeleton.adapter.inbound.web.advanced.security; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.catchThrowable; import java.util.Map; import java.util.Set; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; /** * A tenant a caller chose is a cross-tenant read waiting to happen. @@ -40,22 +42,51 @@ class WebSecurityContextBridgeTest { assertThatThrownBy( () -> bridge.resolve(AuthenticationView.anonymous(), Map.of("tenant", "tenant-attacker"))) + .isInstanceOf(UntrustedTenantInputException.class) .hasMessageNotContaining("tenant-attacker"); } - @Test - @DisplayName("every spelling of a tenant input is refused") - void everySpellingOfATenantInputIsRefused() { + @ParameterizedTest(name = "{0}") + @ValueSource(strings = {"X-Tenant-Id", "tenant-id", "TenantId", "TENANT"}) + @DisplayName("tenant 입력은 어떤 철자로 와도 거절된다") + void everySpellingOfATenantInputIsRefused(String name) { + // given WebTenantContextResolver resolver = new WebTenantContextResolver(); - for (String name : new String[] {"X-Tenant-Id", "tenant-id", "TenantId", "TENANT"}) { - assertThatThrownBy(() -> resolver.rejectTenantInput(Map.of(name, "t"))) - .as("a case or hyphen variant is the same header to a proxy") - .isInstanceOf(UntrustedTenantInputException.class); - } - assertThatCode(() -> resolver.rejectTenantInput(Map.of("Accept", "application/json"))) - .doesNotThrowAnyException(); - assertThatCode(() -> resolver.rejectTenantInput(null)).doesNotThrowAnyException(); + // when + Throwable refused = catchThrowable(() -> resolver.rejectTenantInput(Map.of(name, "t"))); + + // then + assertThat(refused) + .as("a case or hyphen variant is the same header to a proxy") + .isInstanceOf(UntrustedTenantInputException.class); + } + + @Test + @DisplayName("tenant가 아닌 입력은 거절되지 않는다") + void anInputThatNamesNoTenantIsNotRefused() { + // given + WebTenantContextResolver resolver = new WebTenantContextResolver(); + + // when + Throwable refused = + catchThrowable(() -> resolver.rejectTenantInput(Map.of("Accept", "application/json"))); + + // then + assertThat(refused).isNull(); + } + + @Test + @DisplayName("입력이 없으면 거절되지 않는다") + void noInputIsNotRefused() { + // given + WebTenantContextResolver resolver = new WebTenantContextResolver(); + + // when + Throwable refused = catchThrowable(() -> resolver.rejectTenantInput(null)); + + // then + assertThat(refused).isNull(); } @Test diff --git a/src/adapter/inbound/web-fileserver/src/test/java/dev/caskeleton/adapter/inbound/web/fileserver/admin/FileserverAdminControllerRequestBodyValidationTest.java b/src/adapter/inbound/web-fileserver/src/test/java/dev/caskeleton/adapter/inbound/web/fileserver/admin/FileserverAdminControllerRequestBodyValidationTest.java index 55382dd8..60649b09 100644 --- a/src/adapter/inbound/web-fileserver/src/test/java/dev/caskeleton/adapter/inbound/web/fileserver/admin/FileserverAdminControllerRequestBodyValidationTest.java +++ b/src/adapter/inbound/web-fileserver/src/test/java/dev/caskeleton/adapter/inbound/web/fileserver/admin/FileserverAdminControllerRequestBodyValidationTest.java @@ -7,12 +7,12 @@ import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.util.ArrayList; import java.util.List; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.web.bind.annotation.RequestBody; /** - * W4 red team BE-INPUT-002 — every {@code @RequestBody} on the admin controller must also carry - * {@code @Valid}. + * Every {@code @RequestBody} on the admin controller must also carry {@code @Valid}. * *

{@code reconcileOrphans} shipped a {@code @RequestBody} without {@code @Valid}, unlike every * sibling handler (relocate/force-delete/…). Harmless today because {@code @@ -24,20 +24,37 @@ import org.springframework.web.bind.annotation.RequestBody; class FileserverAdminControllerRequestBodyValidationTest { @Test + @DisplayName("admin controller의 @RequestBody 매개변수는 모두 @Valid를 함께 단다") void everyRequestBodyParameterAlsoCarriesValid() { + // given + List bodies = new ArrayList<>(); List offenders = new ArrayList<>(); + + // when for (Method method : FileserverAdminController.class.getDeclaredMethods()) { for (Parameter parameter : method.getParameters()) { - if (parameter.isAnnotationPresent(RequestBody.class) - && !parameter.isAnnotationPresent(Valid.class)) { - offenders.add(method.getName() + "(" + parameter.getType().getSimpleName() + ")"); + if (!parameter.isAnnotationPresent(RequestBody.class)) { + continue; + } + String handler = method.getName() + "(" + parameter.getType().getSimpleName() + ")"; + bodies.add(handler); + if (!parameter.isAnnotationPresent(Valid.class)) { + offenders.add(handler); } } } + + // then + assertThat(bodies) + .as( + "the handlers this test is about; an empty list would pass the check below for a" + + " controller that lost its bodies or a scan that found nothing") + .containsExactlyInAnyOrder( + "reconcileOrphans(OrphanReconcileHttpRequest)", "forceDelete(ForceDeleteHttpRequest)"); assertThat(offenders) .as( "admin @RequestBody handlers without @Valid would silently drop any Bean Validation " - + "constraint added to their DTO later (BE-INPUT-002)") + + "constraint added to their DTO later") .isEmpty(); } } From cbfa776270a7b51ea5cc66a247998be0df1134cb Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 13 Nov 2026 06:34:32 +0900 Subject: [PATCH 2/3] =?UTF-8?q?build!:=20=EC=8B=9C=ED=97=98=20classpath?= =?UTF-8?q?=C2=B7=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EA=B3=A0=EC=A0=95=C2=B7?= =?UTF-8?q?=EC=B9=B4=ED=83=88=EB=A1=9C=EA=B7=B8=C2=B7API=20surface=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=EC=9D=84=20=EC=A0=95=EB=B3=B8=EB=8C=80?= =?UTF-8?q?=EB=A1=9C=20=EB=A7=9E=EC=B6=98=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: - ca.spring-library가 모든 spring leaf(30)의 testImplementation에 spring-boot-starter-webmvc-test를 넣어, MockMvc를 쓰지 않는 23 leaf가 Tomcat을 시험 classpath에 resolve하고 lock했다. - container-images.properties 머리말은 「digest로 고정」이라는데 postgres-17·18이 tag만이었다. 머리말은 「쓰는 lane만 다시 돈다」고 했지만 파일 전체가 모든 Test task의 입력이라 이미지 하나만 바꿔도 모든 lane이 다시 돈다. postgres-16-4는 아무도 읽지 않았다. - libs.versions.toml에 아무도 읽지 않는 칸이 있었다(라이브러리 9, 버전 4, 루트에 적용하지 않는 플러그인 4). - config/spotbugs/exclude.xml에 없는 클래스의 항목이 있었다(exclude-test.xml에 이미 있다). - notification의 API surface가 상대 경로로 application-notification 소스를 가리켰고, ApiSurface 플러그인은 없는 추가 root를 말없이 건너뛰어 승인 update가 줄어든 표면을 기록할 수 있었다. - verify-mongodb-platform.sh가 고르는 클래스가 없는 :app-bootstrap:test --tests '*CleanArchitectureTest'를 불러 늘 실패했고, 이미지 기록이 카탈로그와 다른 tag였다. 고친 것: - 규약은 spring-boot-starter-test만 준다. 시험이 실제로 쓰는 것을 leaf가 직접 선언한다. MockMvc를 쓰는 web·web-advanced·web-fileserver·web-notification· app-bootstrap은 webmvc-test starter, graphql은 TestRestTemplate의 spring-boot-resttestclient, durable-operation은 WebApplicationContextRunner의 spring-web, 시험이 JSON을 읽는 objectstorage·persistence-jpa·persistence-mongo· notification-platform은 jackson-databind, redis-runtime은 jackson-annotations (compileOnly, 본 코드와 같은 이유)다. 모든 Java source set을 한 빌드에서 컴파일해 빠진 곳이 없음을 확인하고 lockfile을 다시 만들었다(Tomcat·webmvc 시험 자동설정이 빠짐). graphql·persistence-mongo AGENTS의 허용·시험 목록을 같이 고쳤다. - postgres 17·18을 desktop runner에서 받은 digest로 고정했다(17.11, 18.6). 목록을 읽을 때 digest 없는 값을 GradleException으로 거절한다(ContainerImageCatalogTest). 머리말을 실제 캐시 동작으로 고쳤고 postgres-16-4를 지웠다. persistence-jpa release registry의 PostgreSQL tag는 아무도 읽지 않아 지우고, 이미지는 카탈로그가 정한다고 적었다. - 카탈로그의 미사용 칸을 지우고 머리말을 지금 쓰임에 맞췄다. - 죽은 spotbugs 항목을 지웠다. - notification은 project(':application-notification')로 root를 잡고, 없는 추가 root는 설정 단계에서 실패한다(ApiSurfaceConventionTest). - mongo 스크립트는 :app-bootstrap:architectureTest를 부르고, 이미지 기록은 카탈로그 mongo-8 값을 읽는다. - graphql build.gradle에 앞 커밋의 document-contract lane을 함께 둔다. 저장소 루트 (ca.repository.root)와 읽는 registry 파일은 그 lane만 받고, 시험은 그 속성으로만 루트를 읽는다(cwd에서 거슬러 찾지 않는다). 버린 대안: 이미지마다 쓰는 lane을 선언해 입력을 나누기 — lane 수십 개에 키 목록을 다시 적어야 하고 빠뜨리면 캐시가 거짓 통과한다. 검증: 아래 PR 본문(desktop resolveAndLockAll·build-logic test·모든 source set 컴파일· leaf check). BREAKING CHANGE: ca.spring-library가 시험 classpath에 spring-boot-starter-webmvc-test를 넣지 않는다. MockMvc·TestRestTemplate·Jackson을 그 starter로 받던 파생 leaf는 의존을 직접 선언해야 시험이 컴파일된다. 카탈로그의 digest 없는 이미지와 없는 API surface 추가 root는 설정 단계에서 실패한다. version catalog의 미사용 칸을 지웠다. 할 일은 docs/upgrade/2026-11-round9-build.md다. Refs: RR9-04-06, RR9-04-11, RR9-04-12, RR9-04-13, RR9-04-14, RR9-04-15, RR9-04-16 --- .../apisurface/ApiSurfacePlugin.java | 20 +++++-- .../SpringLibraryConventionPlugin.java | 11 ++-- .../java/JavaConventionsPlugin.java | 21 +++++++- .../apisurface/ApiSurfaceConventionTest.java | 21 ++++++++ .../java/ContainerImageCatalogTest.java | 50 +++++++++++++++++ config/spotbugs/exclude.xml | 10 ---- docs/upgrade/2026-11-round9-build.md | 25 +++++++++ gradle/container-images.properties | 18 +++---- gradle/libs.versions.toml | 54 +++++-------------- src/adapter/inbound/graphql/AGENTS.md | 9 +++- src/adapter/inbound/graphql/build.gradle | 21 ++++++++ src/adapter/inbound/graphql/gradle.lockfile | 3 -- ...aphQlDeploymentModeRegistryParityTest.java | 16 +++--- src/adapter/inbound/grpc/gradle.lockfile | 22 -------- src/adapter/inbound/messaging/gradle.lockfile | 27 ++-------- src/adapter/inbound/web-advanced/build.gradle | 3 ++ .../inbound/web-fileserver/build.gradle | 3 ++ .../inbound/web-notification/build.gradle | 3 ++ src/adapter/inbound/web/build.gradle | 3 ++ src/adapter/inbound/websocket/gradle.lockfile | 4 -- .../outbound/cache-redis/gradle.lockfile | 22 -------- .../outbound/fileserver/gradle.lockfile | 23 -------- .../outbound/httpclient/gradle.lockfile | 18 ------- .../outbound/identifier/gradle.lockfile | 23 -------- .../outbound/messaging-kafka/gradle.lockfile | 28 ++-------- .../outbound/messaging/gradle.lockfile | 18 ------- .../outbound/notification/build.gradle | 4 +- .../outbound/notification/gradle.lockfile | 18 ------- .../outbound/objectstorage/build.gradle | 2 + .../outbound/objectstorage/gradle.lockfile | 19 ------- .../persistence-fileserver/gradle.lockfile | 24 +-------- .../outbound/persistence-jpa/build.gradle | 2 + .../outbound/persistence-jpa/gradle.lockfile | 19 ------- .../release/release-registry.json | 12 +++-- .../outbound/persistence-mongo/AGENTS.md | 2 +- .../outbound/persistence-mongo/build.gradle | 2 + .../persistence-mongo/gradle.lockfile | 19 ------- .../persistence-notification/gradle.lockfile | 22 -------- .../outbound/redis-runtime/build.gradle | 3 ++ .../outbound/redis-runtime/gradle.lockfile | 24 +-------- .../outbound/redis-sdk/gradle.lockfile | 23 -------- src/adapter/outbound/support/gradle.lockfile | 22 -------- src/bootstrap/app/build.gradle | 3 ++ src/bootstrap/durable-operation/build.gradle | 3 ++ .../durable-operation/gradle.lockfile | 39 ++++++-------- .../fileserver-platform/gradle.lockfile | 39 ++++++-------- src/bootstrap/idempotency/gradle.lockfile | 24 +-------- .../notification-platform/build.gradle | 2 + .../notification-platform/gradle.lockfile | 33 +++++------- src/bootstrap/outbox-relay/gradle.lockfile | 22 -------- src/bootstrap/service-runtime/gradle.lockfile | 21 -------- 51 files changed, 298 insertions(+), 581 deletions(-) create mode 100644 build-logic/src/test/java/dev/caskeleton/buildlogic/java/ContainerImageCatalogTest.java create mode 100644 docs/upgrade/2026-11-round9-build.md diff --git a/build-logic/src/main/java/dev/caskeleton/buildlogic/apisurface/ApiSurfacePlugin.java b/build-logic/src/main/java/dev/caskeleton/buildlogic/apisurface/ApiSurfacePlugin.java index a022deaa..9f261c36 100644 --- a/build-logic/src/main/java/dev/caskeleton/buildlogic/apisurface/ApiSurfacePlugin.java +++ b/build-logic/src/main/java/dev/caskeleton/buildlogic/apisurface/ApiSurfacePlugin.java @@ -34,10 +34,22 @@ public final class ApiSurfacePlugin implements Plugin { if (extension.getSourceRoot() != null && !extension.getSourceRoot().isBlank()) { sourcePaths.add(extension.getSourceRoot()); } - extension.getAdditionalSourceRoots().stream() - .filter(path -> path != null && !path.isBlank()) - .forEach(sourcePaths::add); - List roots = sourcePaths.stream().map(project::file).toList(); + List additional = + extension.getAdditionalSourceRoots().stream() + .filter(path -> path != null && !path.isBlank()) + .map(project::file) + .toList(); + // A missing additional root used to be skipped without a word, so an approved update + // recorded a surface with a whole module's types gone (2026-11-12 review). + List missing = additional.stream().filter(root -> !root.isDirectory()).toList(); + if (!missing.isEmpty()) { + throw new GradleException( + project.getPath() + + " apiSurface.additionalSourceRoots names a folder that does not exist: " + + missing); + } + List roots = new ArrayList<>(sourcePaths.stream().map(project::file).toList()); + roots.addAll(additional); String verifyTaskName = "verify" + label + "ApiSurface"; String updateTaskName = "update" + label + "ApiSurface"; String approvalProperty = "approve" + label + "ApiSurfaceChange"; diff --git a/build-logic/src/main/java/dev/caskeleton/buildlogic/convention/SpringLibraryConventionPlugin.java b/build-logic/src/main/java/dev/caskeleton/buildlogic/convention/SpringLibraryConventionPlugin.java index f4757d60..46905c75 100644 --- a/build-logic/src/main/java/dev/caskeleton/buildlogic/convention/SpringLibraryConventionPlugin.java +++ b/build-logic/src/main/java/dev/caskeleton/buildlogic/convention/SpringLibraryConventionPlugin.java @@ -3,6 +3,14 @@ package dev.caskeleton.buildlogic.convention; import org.gradle.api.Plugin; import org.gradle.api.Project; +/** + * Quality conventions plus the Spring Boot test starter for a Spring library leaf. + * + *

Only {@code spring-boot-starter-test}. The web MVC test starter (MockMvc, {@code @WebMvcTest}, + * and an embedded Tomcat with them) used to be added to every leaf here, so thirty leaves resolved + * and locked a servlet container for tests that never start one. A leaf whose tests use MockMvc + * declares {@code spring-boot-starter-webmvc-test} in its own build script (2026-11-12 review). + */ public final class SpringLibraryConventionPlugin implements Plugin { @Override public void apply(Project project) { @@ -10,8 +18,5 @@ public final class SpringLibraryConventionPlugin implements Plugin { project .getDependencies() .add("testImplementation", "org.springframework.boot:spring-boot-starter-test"); - project - .getDependencies() - .add("testImplementation", "org.springframework.boot:spring-boot-starter-webmvc-test"); } } diff --git a/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java b/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java index e3cf9012..7b75200e 100644 --- a/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java +++ b/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java @@ -310,7 +310,14 @@ public final class JavaConventionsPlugin implements Plugin { return catalog; } - private static Map containerImages(File catalog) { + /** + * The catalog, refused when an image is not pinned by digest. + * + *

The catalog's header promises digests: a red lane should mean this repository changed, not + * that a registry moved a tag. Two images were tag-only for weeks with a note to pin them later + * (2026-11-12 review), and nothing noticed, so the promise is checked where the file is read. + */ + static Map containerImages(File catalog) { Properties properties = new Properties(); try (var in = Files.newInputStream(catalog.toPath())) { properties.load(in); @@ -319,6 +326,18 @@ public final class JavaConventionsPlugin implements Plugin { } Map images = new TreeMap<>(); properties.stringPropertyNames().forEach(key -> images.put(key, properties.getProperty(key))); + List unpinned = + images.entrySet().stream() + .filter(entry -> !entry.getValue().contains("@sha256:")) + .map(Map.Entry::getKey) + .toList(); + if (!unpinned.isEmpty()) { + throw new GradleException( + catalog.getName() + + ": pin every image by digest (repository@sha256:...), with its tag in a comment;" + + " not pinned: " + + unpinned); + } return Map.copyOf(images); } } diff --git a/build-logic/src/test/java/dev/caskeleton/buildlogic/apisurface/ApiSurfaceConventionTest.java b/build-logic/src/test/java/dev/caskeleton/buildlogic/apisurface/ApiSurfaceConventionTest.java index 06869bc6..ab4550d8 100644 --- a/build-logic/src/test/java/dev/caskeleton/buildlogic/apisurface/ApiSurfaceConventionTest.java +++ b/build-logic/src/test/java/dev/caskeleton/buildlogic/apisurface/ApiSurfaceConventionTest.java @@ -173,6 +173,27 @@ class ApiSurfaceConventionTest { """); } + @Test + @org.junit.jupiter.api.DisplayName("없는 추가 source root는 건너뛰지 않고 그 경로를 짚어 실패한다") + void aMissingAdditionalSourceRootFailsInsteadOfShrinkingTheSurface() throws Exception { + // given + Files.writeString( + projectDir.resolve("build.gradle"), + Files.readString(projectDir.resolve("build.gradle")) + .replace( + "baseline = file('surface.txt')", + "baseline = file('surface.txt')\n additionalSourceRoots = ['../moved/src/main/java']")); + + // when + BuildResult result = + runner("updateFixtureApiSurface", "-PapproveFixtureApiSurfaceChange").buildAndFail(); + + // then + assertTrue( + result.getOutput().contains("additionalSourceRoots names a folder that does not exist"), + result.getOutput()); + } + private void writeConfiguredBuild(String sourceRoot) throws Exception { Files.writeString( projectDir.resolve("build.gradle"), diff --git a/build-logic/src/test/java/dev/caskeleton/buildlogic/java/ContainerImageCatalogTest.java b/build-logic/src/test/java/dev/caskeleton/buildlogic/java/ContainerImageCatalogTest.java new file mode 100644 index 00000000..2c5035c7 --- /dev/null +++ b/build-logic/src/test/java/dev/caskeleton/buildlogic/java/ContainerImageCatalogTest.java @@ -0,0 +1,50 @@ +package dev.caskeleton.buildlogic.java; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import org.gradle.api.GradleException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +class ContainerImageCatalogTest { + + @Test + @DisplayName("digest 없이 tag만 적은 이미지는 목록을 읽는 단계에서 그 키를 짚어 실패한다") + void aTagOnlyImageFailsNamingItsKey(@TempDir Path directory) throws IOException { + // given + Path catalog = directory.resolve("container-images.properties"); + Files.writeString( + catalog, + "pinned=postgres@sha256:" + + "0".repeat(64) + + "\nfloating=postgres:17-alpine\n"); + + // when + Throwable failure = catchThrowable(() -> JavaConventionsPlugin.containerImages(catalog.toFile())); + + // then + assertThat(failure) + .isInstanceOf(GradleException.class) + .hasMessageEndingWith("not pinned: [floating]"); + } + + @Test + @DisplayName("모든 이미지가 digest로 고정된 목록은 키와 값을 그대로 돌려준다") + void aDigestPinnedCatalogIsReadAsIs(@TempDir Path directory) throws IOException { + // given + Path catalog = directory.resolve("container-images.properties"); + String image = "postgres@sha256:" + "a".repeat(64); + Files.writeString(catalog, "# postgres:17-alpine\npostgres-17=" + image + "\n"); + + // when + var images = JavaConventionsPlugin.containerImages(catalog.toFile()); + + // then + assertThat(images).containsExactly(java.util.Map.entry("postgres-17", image)); + } +} diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml index 99a0419c..2ee07473 100644 --- a/config/spotbugs/exclude.xml +++ b/config/spotbugs/exclude.xml @@ -59,16 +59,6 @@ - - - - - - -