review-followup Wave 3: 설정 prefix app.* 통일(P20), Wave 3 종료
- 결정 16: `ca-skeleton.*`·`backend.graphql` 등 → `app.*`(APP_* env 키 이름 유지), selector 키 상수 하나(`CapabilitySelectors`), 바인딩만 되던 `streaming-idle` 삭제 - `StrictSettingsBinder`가 env 오타까지 거부 — 모든 capability(graphql·websocket·mongo는 edge 제약으로 파일만 strict), httpclient 리플렉션 `HttpClientEnvironmentKeys` 삭제 - persistence-jpa가 `APP_DATASOURCE_PASSWORD` secret 요구를 기여(bootstrap이 JPA 스위치를 읽지 않음), Redis ACL fixture에서 pub/sub 권한 제거 - 결함 수정: SMTP 설정 env 이름 충돌(P20-new-1), `bindExcept`가 system env까지 filter(P20-new-2), graphql 빈 deployment-mode 메시지(P20-new-6) - 통합: P30과 충돌 11건(P30의 명시적 bean 구조 유지), P30 코드의 옛 키를 app.*로, persistence-jpa 포맷 - 현황표: 소유자 결정 36(persistence-jpa 설정은 플랫폼 키만 app.persistence-jpa.*로, 공유 기능 트리 예외), 재개 문서에 일시 정지 상태 Wave 3 종료 검증: check · ci verifyDependencyLocks --warning-mode=fail(714 task) · mainCheck · architectureCheck verifyPublicPathSnapshot :app-bootstrap:verifyEnvKeys configContractCheck · :app-bootstrap:integrationTest :sample-portfolio:integrationTest :sample-portfolio:systemTest · integrationCheck · -p build-logic test · -p optional-platforms ci · :app-bootstrap:qualificationBootJar releaseCheck 통과 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8bbf1bf01d
commit
27f23add08
+3
-3
@@ -270,7 +270,7 @@ Kafka 없이 기동합니다. 나머지 기능은 `app-bootstrap/build.gradle`
|
||||
| 외부 HTTP 호출 | `runtimeOnly project(':adapter:outbound:httpclient')` | client 하나 이상: `APP_HTTPCLIENT_CLIENTS_0_*` (`docs/httpclient/env-fields.yaml`) | `APP_HTTPCLIENT_ENABLED` |
|
||||
| 객체 저장소 (S3/로컬) | `runtimeOnly project(':adapter:outbound:objectstorage')` | 전용 env 없음. `app.object-storage.*`의 provider·destination을 `application-*.yml`에 적음 | `app.object-storage.enabled` |
|
||||
| WebSocket (STOMP push) | `runtimeOnly project(':adapter:inbound:websocket')` | 없음(기본값으로 동작). origin은 `APP_WEBSOCKET_ALLOWED_ORIGINS` | `APP_WEBSOCKET_ENABLED` |
|
||||
| gRPC 서버 | `runtimeOnly project(':adapter:inbound:grpc')` | `CA_SKELETON_GRPC_SERVER_ALLOW_INSECURE_LOCAL=true` (지금 받는 listener가 loopback plaintext뿐) | `ca-skeleton.grpc.server.enabled` |
|
||||
| gRPC 서버 | `runtimeOnly project(':adapter:inbound:grpc')` | `APP_GRPC_SERVER_ALLOW_INSECURE_LOCAL=true` (지금 받는 listener가 loopback plaintext뿐) | `app.grpc.server.enabled` |
|
||||
| 파일 서버 (JPA를 함께 가져옴) | `runtimeOnly project(':composition:fileserver-platform')` | `APP_FILESERVER_PLATFORM_STORAGE_ROOT`, `APP_FILESERVER_PLATFORM_OBSERVABILITY_FINGERPRINT_KEY`, 그리고 `FileAccessPolicyPort` bean 또는 `APP_FILESERVER_PLATFORM_SECURITY_ACCESS_POLICY=role-based` | `APP_FILESERVER_PLATFORM_ENABLED` |
|
||||
| 알림 (SMTP/SES, JPA 줄도 필요) | `runtimeOnly project(':composition:notification-platform')` | 키 8종과 각 `_ID`(`APP_NOTIFICATION_PLATFORM_*_KEY`, `*_KEY_ID`), 쓰는 provider 설정(`APP_NOTIFICATION_PLATFORM_SMTP_*` 또는 `_SES_*`) | `APP_NOTIFICATION_PLATFORM_ENABLED` |
|
||||
|
||||
@@ -338,7 +338,7 @@ Kafka·Redis는 위 "기능 추가 = 한 줄 + env" 표의 한 줄로 고릅니
|
||||
현재 canonical activation은 다음 두 설정 트리만 사용합니다.
|
||||
|
||||
```yaml
|
||||
ca-skeleton:
|
||||
app:
|
||||
capabilities:
|
||||
http-client:
|
||||
expected-state: DISABLED
|
||||
@@ -539,7 +539,7 @@ docker compose -f docker-compose.yml -f docker-compose.local.yml up -d --wait db
|
||||
컨테이너로 띄우는 `scripts/bootstrap-local.sh` 경로는 이 호스트 포트를 쓰지 않습니다. compose 가 app
|
||||
컨테이너의 `APP_DATASOURCE_URL` 을 내부 네트워크 주소 `jdbc:postgresql://db:5432/...` 로 덮어씁니다.
|
||||
|
||||
`ca-skeleton.persistence.vendor`(`postgresql` | `h2`)가 어느 vendor 구성을 조립할지 고르는 단일
|
||||
`app.persistence.vendor`(`postgresql` | `h2`)가 어느 vendor 구성을 조립할지 고르는 단일
|
||||
스위치입니다. 값이 둘 중 하나가 아니면 기동이 실패하고, prod 에서 `h2` 이거나 datasource URL 이
|
||||
`jdbc:h2:` 이면 `PersistenceVendorProdSafetyValidator` 가 기동을 거부합니다(env 로 덮어써도 동일).
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ required-class 검사가 이 테스트가 조용히 사라지는 것을 막는
|
||||
- feature-agnostic: `classpath:graphql/**` 스키마와 모든 `@Controller` `@QueryMapping`/
|
||||
`@MutationMapping` 을 generic 하게 합성한다. **WorkLog 등 구체 기능을 이름으로 알지 않는다.**
|
||||
- 있으면 켜진다: 서비스가 `app-bootstrap/build.gradle`에 `runtimeOnly project(':adapter:inbound:graphql')`
|
||||
한 줄로 고른다(기본 조립에는 없다). `APP_GRAPHQL_ENABLED=false`(`backend.graphql.enabled`)만 끄며,
|
||||
한 줄로 고른다(기본 조립에는 없다). `APP_GRAPHQL_ENABLED=false`(`app.graphql.enabled`)만 끄며,
|
||||
그때 `GraphQlActivationEnvironmentPostProcessor`가 Spring GraphQL 자동 설정도 exclude 한다.
|
||||
실제 활성화 시 composition root 는 인증/인가·CORS 정책과 GraphiQL/introspection 운영 설정을 함께
|
||||
명시해야 한다.
|
||||
|
||||
@@ -102,18 +102,18 @@ gRPC 와 달리 spring-graphql / graphql-java 는 Spring Boot BOM 이 관리한
|
||||
버전 명시도, 모듈 스코프 platform import 도 필요 없다 — `build.gradle` 은 BOM-managed 좌표만
|
||||
선언하고, per-module `gradle.lockfile` 이 strict locking 으로 정확한 버전을 고정한다.
|
||||
|
||||
## 설정 — 프레임워크 `spring.graphql.*` + 플랫폼 `backend.graphql.*`
|
||||
## 설정 — 프레임워크 `spring.graphql.*` + 플랫폼 `app.graphql.*`
|
||||
|
||||
전송 계층 설정(path, graphiql, introspection, schema location)은 프레임워크 `spring.graphql.*`
|
||||
가 소유한다. composition-root `application.yml` 에서 설정하며 모듈별 `yml` 은 없다.
|
||||
|
||||
플랫폼 정책은 `spring.graphql.*` 로 표현할 수 없다 — cost/page 한계, preparsed
|
||||
캐시 경계, 관측 label 로 허용할 operation 이름은 전부 이 leaf 의 결정이다. 그래서
|
||||
`GraphQlPlatformProperties` 가 **`backend.graphql`** prefix 로 `@ConfigurationProperties` 를
|
||||
`GraphQlPlatformProperties` 가 **`app.graphql`** prefix 로 `@ConfigurationProperties` 를
|
||||
바인딩한다(`spring.graphql.platform.*` 이 아니다 — 그 prefix 는 존재한 적이 없다).
|
||||
|
||||
```yaml
|
||||
backend:
|
||||
app:
|
||||
graphql:
|
||||
deployment-mode: PRODUCTION_INTERNAL
|
||||
validation-policy-version: v1 # preparsed 캐시 키의 일부
|
||||
|
||||
@@ -67,8 +67,8 @@ dependencies {
|
||||
|
||||
// GraphQlPlatformProperties is a @ConfigurationProperties binding, so this leaf owes the
|
||||
// repository-wide processor parity gate (`verifyConfigurationPropertiesProcessor`) a metadata
|
||||
// declaration — an adopter configuring backend.graphql.* gets IDE completion and validation
|
||||
// from the generated metadata rather than from prose. (The prefix is `backend.graphql`; this
|
||||
// declaration — an adopter configuring app.graphql.* gets IDE completion and validation
|
||||
// from the generated metadata rather than from prose. (The prefix is `app.graphql`; this
|
||||
// comment used to say `spring.graphql.platform.*`, which never existed.)
|
||||
|
||||
// A raw request body can only be capped before something decodes it, and on a servlet stack the
|
||||
|
||||
+43
-7
@@ -16,11 +16,13 @@ import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.env.YamlPropertySourceLoader;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.EnumerablePropertySource;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* Everything about {@code backend.graphql} that has to be settled before a bean exists.
|
||||
* Everything about {@code app.graphql} that has to be settled before a bean exists.
|
||||
*
|
||||
* <p>An environment post-processor rather than a bean: these are the failures that have to arrive
|
||||
* first, naming what an operator set, instead of surfacing as a bean somewhere downstream that
|
||||
@@ -28,8 +30,8 @@ import org.springframework.core.io.ClassPathResource;
|
||||
*
|
||||
* <ol>
|
||||
* <li><b>Contribute the module's settings.</b> {@code config/graphql.yml} maps the {@code
|
||||
* APP_GRAPHQL_*} variables onto {@code backend.graphql.*}, which an environment variable
|
||||
* cannot reach directly. Added last, so a deployment's own value always wins, and loaded only
|
||||
* APP_GRAPHQL_*} variables onto {@code app.graphql.*}, which an environment variable cannot
|
||||
* reach directly. Added last, so a deployment's own value always wins, and loaded only
|
||||
* because the module is on the classpath — removing the module removes its settings.
|
||||
* <li><b>Refuse a retired safety key.</b> See {@link GraphQlRetiredSafetyAxis}.
|
||||
* <li><b>Give the framework's console flags the platform's defaults.</b> Spring Boot answers
|
||||
@@ -37,7 +39,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||
* the lowest precedence, so an operator who sets either key still wins and still gets
|
||||
* validated.
|
||||
* <li><b>Make an explicit off complete.</b> The module is on when present. {@code
|
||||
* backend.graphql.enabled=false} turns off {@link GraphQlRootAutoConfiguration}, but Spring
|
||||
* app.graphql.enabled=false} turns off {@link GraphQlRootAutoConfiguration}, but Spring
|
||||
* GraphQL's own auto-configurations would still publish {@code /graphql} from the schema on
|
||||
* the classpath. So an explicit off appends them — read from Boot's own registration file,
|
||||
* not listed here — to {@code spring.autoconfigure.exclude}, after whatever the deployment
|
||||
@@ -52,7 +54,9 @@ public class GraphQlActivationEnvironmentPostProcessor
|
||||
|
||||
static final String RESOURCE = "config/graphql.yml";
|
||||
|
||||
private static final String SWITCH = "backend.graphql.enabled";
|
||||
private static final String SWITCH = "app.graphql.enabled";
|
||||
|
||||
private static final String DEPLOYMENT_MODE = "app.graphql.deployment-mode";
|
||||
|
||||
private static final String EXCLUDE = "spring.autoconfigure.exclude";
|
||||
|
||||
@@ -63,8 +67,8 @@ public class GraphQlActivationEnvironmentPostProcessor
|
||||
private static final Map<String, String> FRAMEWORK_DEFAULTS =
|
||||
Map.of(
|
||||
"spring.graphql.schema.introspection.enabled",
|
||||
"backend.graphql.console.introspection-enabled",
|
||||
"spring.graphql.graphiql.enabled", "backend.graphql.console.graphiql-enabled");
|
||||
"app.graphql.console.introspection-enabled",
|
||||
"spring.graphql.graphiql.enabled", "app.graphql.console.graphiql-enabled");
|
||||
|
||||
private static final String SOURCE_NAME = "graphQlPlatformConsoleDefaults";
|
||||
|
||||
@@ -76,6 +80,7 @@ public class GraphQlActivationEnvironmentPostProcessor
|
||||
new YamlPropertySourceLoader()
|
||||
.load("graphql-defaults (" + RESOURCE + ")", new ClassPathResource(RESOURCE, classLoader))
|
||||
.forEach(environment.getPropertySources()::addLast);
|
||||
withoutAnUnsetDeploymentMode(environment);
|
||||
} catch (IOException failure) {
|
||||
throw new UncheckedIOException("failed to read " + RESOURCE, failure);
|
||||
}
|
||||
@@ -100,6 +105,37 @@ public class GraphQlActivationEnvironmentPostProcessor
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the shipped {@code deployment-mode} entry when it resolves to nothing.
|
||||
*
|
||||
* <p>The mode has no default on purpose, and {@link GraphQlDeploymentMode} refuses a missing one
|
||||
* by name. The shipped file maps it as {@code ${APP_GRAPHQL_DEPLOYMENT_MODE:}}, though, and under
|
||||
* strict binding ({@code ignoreUnknownFields = false}) a present-but-empty key is reported as
|
||||
* "left unbound" before the named refusal can run. An unset mode is therefore made absent, not
|
||||
* empty; a mode set anywhere — environment, {@code .env}, system property, file — still binds.
|
||||
*/
|
||||
private static void withoutAnUnsetDeploymentMode(ConfigurableEnvironment environment) {
|
||||
String mode = environment.getProperty(DEPLOYMENT_MODE);
|
||||
if (mode != null && !mode.isBlank()) {
|
||||
return;
|
||||
}
|
||||
for (PropertySource<?> source : environment.getPropertySources().stream().toList()) {
|
||||
if (source.getName().startsWith("graphql-defaults")
|
||||
&& source instanceof EnumerablePropertySource<?> enumerable
|
||||
&& enumerable.containsProperty(DEPLOYMENT_MODE)) {
|
||||
Map<String, Object> kept = new LinkedHashMap<>();
|
||||
for (String name : enumerable.getPropertyNames()) {
|
||||
if (!DEPLOYMENT_MODE.equals(name)) {
|
||||
kept.put(name, enumerable.getProperty(name));
|
||||
}
|
||||
}
|
||||
environment
|
||||
.getPropertySources()
|
||||
.replace(source.getName(), new MapPropertySource(source.getName(), kept));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void excludeTheFrameworkAutoConfigurations(
|
||||
ConfigurableEnvironment environment, ClassLoader classLoader) {
|
||||
List<String> excluded =
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public enum GraphQlDeploymentMode {
|
||||
|
||||
/** What an operator has to set, and where, when the mode is missing. */
|
||||
public static final String REQUIRED_MESSAGE =
|
||||
"backend.graphql.deployment-mode is required while backend.graphql.enabled=true; set "
|
||||
"app.graphql.deployment-mode is required while app.graphql.enabled=true; set "
|
||||
+ "APP_GRAPHQL_DEPLOYMENT_MODE to one of LOCAL, DEV, PRODUCTION_INTERNAL, "
|
||||
+ "PRODUCTION_PUBLIC";
|
||||
|
||||
|
||||
+3
-3
@@ -36,8 +36,8 @@ class GraphQlExecutionChainConfiguration {
|
||||
* application knowledge: a deny-by-default skeleton policy would answer nothing and adopters
|
||||
* would replace it with an allow-all one, while an allow-by-default policy shipped into
|
||||
* production would be an unauthorized endpoint. So a development mode gets the permissive default
|
||||
* that lets the schema be explored, and a production {@code backend.graphql.deployment-mode}
|
||||
* refuses to start without an explicit policy.
|
||||
* that lets the schema be explored, and a production {@code app.graphql.deployment-mode} refuses
|
||||
* to start without an explicit policy.
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@@ -49,7 +49,7 @@ class GraphQlExecutionChainConfiguration {
|
||||
if (properties.production()) {
|
||||
throw new GraphQlPlatformConfigurationException(
|
||||
List.of(
|
||||
"backend.graphql.deployment-mode="
|
||||
"app.graphql.deployment-mode="
|
||||
+ properties.deploymentMode()
|
||||
+ " requires an explicit GraphQlAuthorizationPolicy bean; the platform has no "
|
||||
+ "application coordinates to authorize on its own"));
|
||||
|
||||
+27
-10
@@ -23,14 +23,20 @@ import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
* @param deploymentMode the single safety posture; required, see {@link GraphQlDeploymentMode}
|
||||
* @param console query console and introspection exposure
|
||||
* @param limits page and cost ceilings
|
||||
* @param validationPolicyVersion part of the preparsed cache key
|
||||
* @param observedOperationNames operation names allowed as an observation label
|
||||
* @param enabled the capability switch. Conditions read the property; it is a component so that the
|
||||
* tree binds with unknown keys refused ({@code ignoreUnknownFields = false}) — a misspelt
|
||||
* {@code app.graphql.*} key fails startup instead of leaving a default limit in force
|
||||
*/
|
||||
@ConfigurationProperties("backend.graphql")
|
||||
@ConfigurationProperties(prefix = "app.graphql", ignoreUnknownFields = false)
|
||||
public record GraphQlPlatformSettings(
|
||||
GraphQlDeploymentMode deploymentMode,
|
||||
@DefaultValue Console console,
|
||||
@DefaultValue Limits limits,
|
||||
@DefaultValue("v1") String validationPolicyVersion,
|
||||
@DefaultValue Set<String> observedOperationNames) {
|
||||
@DefaultValue Set<String> observedOperationNames,
|
||||
@DefaultValue("true") boolean enabled) {
|
||||
|
||||
public GraphQlPlatformSettings {
|
||||
// Belt and braces for programmatic construction: the binder honours @DefaultValue, but this
|
||||
@@ -109,34 +115,45 @@ public record GraphQlPlatformSettings(
|
||||
Console.disabled(),
|
||||
Limits.defaults(),
|
||||
"v1",
|
||||
Set.of());
|
||||
Set.of(),
|
||||
true);
|
||||
}
|
||||
|
||||
/** Returns a copy running under a different deployment mode. */
|
||||
public GraphQlPlatformSettings withDeploymentMode(GraphQlDeploymentMode mode) {
|
||||
return new GraphQlPlatformSettings(
|
||||
mode, console, limits, validationPolicyVersion, observedOperationNames);
|
||||
mode, console, limits, validationPolicyVersion, observedOperationNames, enabled);
|
||||
}
|
||||
|
||||
/** Returns a copy with GraphiQL enabled or disabled. */
|
||||
public GraphQlPlatformSettings withGraphiqlEnabled(boolean enabled) {
|
||||
return withConsole(new Console(enabled, console.introspectionEnabled()));
|
||||
public GraphQlPlatformSettings withGraphiqlEnabled(boolean graphiql) {
|
||||
return withConsole(new Console(graphiql, console.introspectionEnabled()));
|
||||
}
|
||||
|
||||
/** Returns a copy with introspection enabled or disabled. */
|
||||
public GraphQlPlatformSettings withIntrospectionEnabled(boolean enabled) {
|
||||
return withConsole(new Console(console.graphiqlEnabled(), enabled));
|
||||
public GraphQlPlatformSettings withIntrospectionEnabled(boolean introspection) {
|
||||
return withConsole(new Console(console.graphiqlEnabled(), introspection));
|
||||
}
|
||||
|
||||
/** Returns a copy with a different console policy. */
|
||||
public GraphQlPlatformSettings withConsole(Console replacement) {
|
||||
return new GraphQlPlatformSettings(
|
||||
deploymentMode, replacement, limits, validationPolicyVersion, observedOperationNames);
|
||||
deploymentMode,
|
||||
replacement,
|
||||
limits,
|
||||
validationPolicyVersion,
|
||||
observedOperationNames,
|
||||
enabled);
|
||||
}
|
||||
|
||||
/** Returns a copy with different limits. */
|
||||
public GraphQlPlatformSettings withLimits(Limits replacement) {
|
||||
return new GraphQlPlatformSettings(
|
||||
deploymentMode, console, replacement, validationPolicyVersion, observedOperationNames);
|
||||
deploymentMode,
|
||||
console,
|
||||
replacement,
|
||||
validationPolicyVersion,
|
||||
observedOperationNames,
|
||||
enabled);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -74,7 +74,7 @@ public final class GraphQlPlatformStartupValidator {
|
||||
}
|
||||
throw new GraphQlPlatformConfigurationException(
|
||||
List.of(
|
||||
"backend.graphql.deployment-mode="
|
||||
"app.graphql.deployment-mode="
|
||||
+ mode
|
||||
+ " is not permitted in the "
|
||||
+ runtime.profileName()
|
||||
@@ -121,7 +121,7 @@ public final class GraphQlPlatformStartupValidator {
|
||||
problems.add(
|
||||
"client policy maxPageSize ("
|
||||
+ runtime.clientPolicy().maxPageSize()
|
||||
+ ") exceeds backend.graphql.limits.maximum-page-size ("
|
||||
+ ") exceeds app.graphql.limits.maximum-page-size ("
|
||||
+ runtime.properties().limits().maximumPageSize()
|
||||
+ ")");
|
||||
}
|
||||
@@ -130,14 +130,14 @@ public final class GraphQlPlatformStartupValidator {
|
||||
problems.add(
|
||||
"client policy maxComplexity ("
|
||||
+ runtime.clientPolicy().maxComplexity()
|
||||
+ ") exceeds backend.graphql.limits.maximum-complexity ("
|
||||
+ ") exceeds app.graphql.limits.maximum-complexity ("
|
||||
+ runtime.properties().limits().maximumComplexity()
|
||||
+ ")");
|
||||
}
|
||||
if (runtime.clientPolicy().introspectionAllowed()
|
||||
&& !runtime.properties().console().introspectionEnabled()) {
|
||||
problems.add(
|
||||
"client policy allows introspection while backend.graphql.console.introspection-enabled "
|
||||
"client policy allows introspection while app.graphql.console.introspection-enabled "
|
||||
+ "is false; one of the two is not what the operator configured");
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public final class GraphQlPlatformStartupValidator {
|
||||
&& runtime.frameworkIntrospectionEnabled()
|
||||
!= runtime.properties().console().introspectionEnabled()) {
|
||||
problems.add(
|
||||
"backend.graphql.console.introspection-enabled ("
|
||||
"app.graphql.console.introspection-enabled ("
|
||||
+ runtime.properties().console().introspectionEnabled()
|
||||
+ ") contradicts spring.graphql.schema.introspection.enabled ("
|
||||
+ runtime.frameworkIntrospectionEnabled()
|
||||
@@ -157,7 +157,7 @@ public final class GraphQlPlatformStartupValidator {
|
||||
if (runtime.frameworkGraphiqlEnabled() != null
|
||||
&& runtime.frameworkGraphiqlEnabled() != runtime.properties().console().graphiqlEnabled()) {
|
||||
problems.add(
|
||||
"backend.graphql.console.graphiql-enabled ("
|
||||
"app.graphql.console.graphiql-enabled ("
|
||||
+ runtime.properties().console().graphiqlEnabled()
|
||||
+ ") contradicts spring.graphql.graphiql.enabled ("
|
||||
+ runtime.frameworkGraphiqlEnabled()
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ class GraphQlRequestContextConfiguration {
|
||||
/**
|
||||
* The limits applied to a request when the adopter has not registered a client policy.
|
||||
*
|
||||
* <p>Page size, complexity and introspection follow {@code backend.graphql.*}; the rest are the
|
||||
* <p>Page size, complexity and introspection follow {@code app.graphql.*}; the rest are the
|
||||
* calibration starting points from the design. An adopter replaces this bean rather than editing
|
||||
* a table of constants.
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ class GraphQlRequestContextConfiguration {
|
||||
if (properties.production()) {
|
||||
throw new GraphQlPlatformConfigurationException(
|
||||
List.of(
|
||||
"backend.graphql.deployment-mode="
|
||||
"app.graphql.deployment-mode="
|
||||
+ properties.deploymentMode()
|
||||
+ " requires an explicit GraphQlPrincipalResolver bean; production refuses "
|
||||
+ "anonymous callers, so the anonymous default would reject every request"));
|
||||
|
||||
+9
-9
@@ -8,11 +8,11 @@ import org.springframework.core.env.Environment;
|
||||
/**
|
||||
* The two retired safety keys, refused rather than ignored (GQL-INT-002).
|
||||
*
|
||||
* <p>{@code backend.graphql.production} and {@code backend.graphql.environment} are no longer
|
||||
* record components, and Spring's binder ignores unknown keys by default. Left alone, an operator
|
||||
* who sets the key they have always set gets a clean startup and a silently different safety
|
||||
* posture — which is a worse outcome than the split-brain being fixed, because the old
|
||||
* configuration at least did something.
|
||||
* <p>{@code app.graphql.production} and {@code app.graphql.environment} are no longer record
|
||||
* components, and Spring's binder ignores unknown keys by default. Left alone, an operator who sets
|
||||
* the key they have always set gets a clean startup and a silently different safety posture — which
|
||||
* is a worse outcome than the split-brain being fixed, because the old configuration at least did
|
||||
* something.
|
||||
*
|
||||
* <p>Checked whether or not the replacement is also set. A deployment carrying both is exactly the
|
||||
* state that produced the defect: two keys that can disagree about one question, with the winner
|
||||
@@ -26,10 +26,10 @@ public final class GraphQlRetiredSafetyAxis {
|
||||
|
||||
private static final Map<String, String> RETIRED_KEYS =
|
||||
Map.of(
|
||||
"backend.graphql.production",
|
||||
"app.graphql.production",
|
||||
"it drove anonymous principal handling and allow-by-default authorization while the "
|
||||
+ "environment enum drove introspection, so the two could disagree",
|
||||
"backend.graphql.environment",
|
||||
"app.graphql.environment",
|
||||
"it drove introspection and GraphiQL while the production boolean drove authorization, "
|
||||
+ "so the two could disagree");
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class GraphQlRetiredSafetyAxis {
|
||||
* @return the problems; empty when the capability switch is off or no retired key is present
|
||||
*/
|
||||
public static List<String> problems(Environment environment) {
|
||||
if (!"true".equalsIgnoreCase(environment.getProperty("backend.graphql.enabled", "true"))) {
|
||||
if (!"true".equalsIgnoreCase(environment.getProperty("app.graphql.enabled", "true"))) {
|
||||
return List.of();
|
||||
}
|
||||
List<String> problems = new ArrayList<>();
|
||||
@@ -53,7 +53,7 @@ public final class GraphQlRetiredSafetyAxis {
|
||||
+ " is retired ("
|
||||
+ RETIRED_KEYS.get(key)
|
||||
+ "). Remove it and set APP_GRAPHQL_DEPLOYMENT_MODE "
|
||||
+ "(backend.graphql.deployment-mode) to one of LOCAL, DEV, PRODUCTION_INTERNAL, "
|
||||
+ "(app.graphql.deployment-mode) to one of LOCAL, DEV, PRODUCTION_INTERNAL, "
|
||||
+ "PRODUCTION_PUBLIC.");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -9,17 +9,17 @@ import org.springframework.context.annotation.Import;
|
||||
* The one place that decides whether this application exposes a GraphQL endpoint.
|
||||
*
|
||||
* <p>On when present: an application that selected this module wants GraphQL, so a missing {@code
|
||||
* backend.graphql.enabled} means on. Absent from the build is the ordinary off state.
|
||||
* app.graphql.enabled} means on. Absent from the build is the ordinary off state.
|
||||
*
|
||||
* <p>An inbound adapter's off contract is not only about beans. Spring GraphQL publishes {@code
|
||||
* /graphql} from its own auto-configuration, with no project bean involved, so an explicit {@code
|
||||
* backend.graphql.enabled=false} also excludes those auto-configurations — see {@link
|
||||
* app.graphql.enabled=false} also excludes those auto-configurations — see {@link
|
||||
* GraphQlActivationEnvironmentPostProcessor}. A bean-inventory assertion cannot see a route the
|
||||
* framework published.
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(
|
||||
prefix = "backend.graphql",
|
||||
prefix = "app.graphql",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#
|
||||
# 이 모듈이 직접 읽는다(GraphQlActivationEnvironmentPostProcessor). 우선순위는 가장 낮아서
|
||||
# application*.yml, 환경 변수, 시스템 속성이 항상 이긴다. 환경 변수는 APP_GRAPHQL_* 이고 설정 트리는
|
||||
# backend.graphql.* 라서, 이 파일이 둘을 잇는다. 이 모듈을 빌드에서 빼면 이 파일도 함께 빠진다.
|
||||
backend:
|
||||
# app.graphql.* 라서, 이 파일이 둘을 잇는다. 이 모듈을 빌드에서 빼면 이 파일도 함께 빠진다.
|
||||
app:
|
||||
graphql:
|
||||
# true | false — 모듈이 있으면 켜진다. false 로 끄면 Spring GraphQL 자신의 자동 설정도 빠져서
|
||||
# /graphql 이 열리지 않는다.
|
||||
@@ -29,4 +29,4 @@ backend:
|
||||
info:
|
||||
capabilities:
|
||||
graphql:
|
||||
enabled: ${backend.graphql.enabled:true}
|
||||
enabled: ${app.graphql.enabled:true}
|
||||
|
||||
+2
-2
@@ -51,10 +51,10 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
// The transport is off unless a deployment asks for it, so a boundary qualification has to
|
||||
// ask too. Before the master switch existed this test passed by accident: the endpoint was
|
||||
// published from the classpath.
|
||||
"backend.graphql.enabled=true",
|
||||
"app.graphql.enabled=true",
|
||||
// Required alongside the switch: the safety posture has no default, because the defaults it
|
||||
// used to have were a production enum and a non-production boolean that disagreed.
|
||||
"backend.graphql.deployment-mode=LOCAL",
|
||||
"app.graphql.deployment-mode=LOCAL",
|
||||
"spring.graphql.graphiql.enabled=false",
|
||||
"spring.graphql.schema.introspection.enabled=false",
|
||||
"spring.graphql.schema.locations=classpath:graphql-qualification-no-discovery/",
|
||||
|
||||
+5
-5
@@ -62,7 +62,7 @@ import org.springframework.stereotype.Controller;
|
||||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||
properties = {
|
||||
// The transport is off unless a deployment asks for it, so an execution-path test has to ask.
|
||||
"backend.graphql.enabled=true",
|
||||
"app.graphql.enabled=true",
|
||||
"spring.graphql.graphiql.enabled=false",
|
||||
// The schema permits introspection at the deployment level, and the two flags agree so the
|
||||
// contradiction check stays quiet. What refuses the query is the anonymous profile's client
|
||||
@@ -73,12 +73,12 @@ import org.springframework.stereotype.Controller;
|
||||
"spring.graphql.schema.additional-files="
|
||||
+ "classpath:graphql/skeleton.graphqls,"
|
||||
+ "classpath:graphql-platform/platform.graphqls",
|
||||
"backend.graphql.deployment-mode=LOCAL",
|
||||
"backend.graphql.console.introspection-enabled=true",
|
||||
"backend.graphql.limits.maximum-page-size=100",
|
||||
"app.graphql.deployment-mode=LOCAL",
|
||||
"app.graphql.console.introspection-enabled=true",
|
||||
"app.graphql.limits.maximum-page-size=100",
|
||||
// Small enough that one nested selection exceeds it, large enough that the allowed queries do
|
||||
// not. The unregistered-coordinate default weight is what both sides are measured against.
|
||||
"backend.graphql.limits.maximum-complexity=100"
|
||||
"app.graphql.limits.maximum-complexity=100"
|
||||
})
|
||||
@AutoConfigureTestRestTemplate
|
||||
class GraphQlPlatformExecutionPathTest {
|
||||
|
||||
+1
-2
@@ -27,8 +27,7 @@ class GraphQlBatchLoaderWiringTest {
|
||||
private final ApplicationContextRunner runner =
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(GraphQlRootAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"backend.graphql.enabled=true", "backend.graphql.deployment-mode=LOCAL");
|
||||
.withPropertyValues("app.graphql.enabled=true", "app.graphql.deployment-mode=LOCAL");
|
||||
|
||||
@Test
|
||||
@DisplayName("the platform supplies the whole batch chain when GraphQL is on")
|
||||
|
||||
+14
@@ -1,8 +1,10 @@
|
||||
package dev.caskeleton.adapter.inbound.graphql.autoconfigure;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.catchThrowable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -49,6 +51,18 @@ class GraphQlCapabilityActivationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("mode를 정하지 않으면 strict 바인딩 오류가 아니라 이름 붙은 거절로 기동이 실패한다")
|
||||
void anUnsetModeIsRefusedByNameRatherThanAsAnUnboundKey() {
|
||||
// when
|
||||
Throwable thrown = catchThrowable(() -> start().close());
|
||||
|
||||
// then
|
||||
assertThat(thrown)
|
||||
.hasStackTraceContaining("app.graphql.deployment-mode is required")
|
||||
.hasStackTraceContaining("APP_GRAPHQL_DEPLOYMENT_MODE");
|
||||
}
|
||||
|
||||
private static ConfigurableApplicationContext start(String... arguments) {
|
||||
return new SpringApplicationBuilder(Application.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
|
||||
+37
-21
@@ -26,9 +26,9 @@ import org.springframework.core.env.StandardEnvironment;
|
||||
/**
|
||||
* One deployment mode decides every production-safety behaviour (GQL-INT-002).
|
||||
*
|
||||
* <p>There used to be two axes. {@code backend.graphql.production} defaulted to {@code false} and
|
||||
* {@code backend.graphql.environment} defaulted to {@code PRODUCTION_PUBLIC}, in the same record,
|
||||
* so the shipped default was a deployment that called itself internet-facing production while every
|
||||
* <p>There used to be two axes. {@code app.graphql.production} defaulted to {@code false} and
|
||||
* {@code app.graphql.environment} defaulted to {@code PRODUCTION_PUBLIC}, in the same record, so
|
||||
* the shipped default was a deployment that called itself internet-facing production while every
|
||||
* protection that read the boolean behaved as if it were not. That is not a display inconsistency:
|
||||
* anonymous principal handling, allow-by-default authorization, and part of request protection read
|
||||
* only the boolean, so the enum could say production while the endpoint answered as development.
|
||||
@@ -42,7 +42,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
private final ApplicationContextRunner runner =
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(GraphQlRootAutoConfiguration.class))
|
||||
.withPropertyValues("backend.graphql.enabled=true");
|
||||
.withPropertyValues("app.graphql.enabled=true");
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(GraphQlDeploymentMode.class)
|
||||
@@ -81,15 +81,32 @@ class GraphQlDeploymentModeContractTest {
|
||||
|
||||
assertThat(failure)
|
||||
.isInstanceOf(GraphQlPlatformConfigurationException.class)
|
||||
.hasMessageContaining("backend.graphql.deployment-mode=LOCAL")
|
||||
.hasMessageContaining("app.graphql.deployment-mode=LOCAL")
|
||||
.hasMessageContaining("[PRODUCTION_INTERNAL, PRODUCTION_PUBLIC]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("app.graphql 아래 오타 키는 기동을 실패시킨다")
|
||||
void aMisspelledGraphQlKeyFailsStartup() {
|
||||
// when
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"app.graphql.deployment-mode=LOCAL",
|
||||
"spring.profiles.active=local",
|
||||
"app.graphql.limits.maximum-page-sise=5")
|
||||
.run(
|
||||
context -> {
|
||||
// then
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure()).hasStackTraceContaining("maximum-page-sise");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("the context refuses a mode that does not match its runtime profile")
|
||||
void theContextRefusesAModeForAnotherRuntime() {
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.deployment-mode=DEV", "spring.profiles.active=local")
|
||||
.withPropertyValues("app.graphql.deployment-mode=DEV", "spring.profiles.active=local")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context)
|
||||
@@ -107,7 +124,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
|
||||
assertThat(new GraphQlPlatformStartupValidator().problems(settings))
|
||||
.as("a message that does not name the property sends an operator reading")
|
||||
.anySatisfy(problem -> assertThat(problem).contains("backend.graphql.deployment-mode"));
|
||||
.anySatisfy(problem -> assertThat(problem).contains("app.graphql.deployment-mode"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,7 +161,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"backend.graphql.production", "backend.graphql.environment"})
|
||||
@ValueSource(strings = {"app.graphql.production", "app.graphql.environment"})
|
||||
@DisplayName("a retired safety key is a migration error naming the replacement")
|
||||
void aRetiredKeyIsAMigrationError(String retired) {
|
||||
List<String> problems =
|
||||
@@ -163,8 +180,8 @@ class GraphQlDeploymentModeContractTest {
|
||||
GraphQlRetiredSafetyAxis.problems(
|
||||
environmentWith(
|
||||
Map.of(
|
||||
"backend.graphql.deployment-mode", "LOCAL",
|
||||
"backend.graphql.environment", "PRODUCTION_PUBLIC")));
|
||||
"app.graphql.deployment-mode", "LOCAL",
|
||||
"app.graphql.environment", "PRODUCTION_PUBLIC")));
|
||||
|
||||
assertThat(problems)
|
||||
.as(
|
||||
@@ -175,8 +192,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
@Test
|
||||
@DisplayName("with the master off the retired keys are not read at all")
|
||||
void withTheMasterOffTheNamespaceIsNotValidated() {
|
||||
ConfigurableEnvironment environment =
|
||||
environmentWith(Map.of("backend.graphql.production", "true"));
|
||||
ConfigurableEnvironment environment = environmentWith(Map.of("app.graphql.production", "true"));
|
||||
environment.getPropertySources().addFirst(off());
|
||||
|
||||
assertThat(GraphQlRetiredSafetyAxis.problems(environment))
|
||||
@@ -193,14 +209,14 @@ class GraphQlDeploymentModeContractTest {
|
||||
.hasFailed()
|
||||
.getFailure()
|
||||
.rootCause()
|
||||
.hasMessageContaining("backend.graphql.deployment-mode"));
|
||||
.hasMessageContaining("app.graphql.deployment-mode"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("a development mode gets the permissive authorization default")
|
||||
void aDevelopmentModeGetsThePermissiveDefault() {
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.deployment-mode=LOCAL")
|
||||
.withPropertyValues("app.graphql.deployment-mode=LOCAL")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -216,7 +232,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
@DisplayName("a production mode refuses the permissive default, naming the mode")
|
||||
void aProductionModeRefusesThePermissiveDefault(String mode) {
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.deployment-mode=" + mode)
|
||||
.withPropertyValues("app.graphql.deployment-mode=" + mode)
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context)
|
||||
@@ -231,7 +247,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
@DisplayName("production 은 익명 principal resolver 로 떠서 모든 요청을 거부하는 대신 기동을 거부한다")
|
||||
void aProductionModeRefusesTheAnonymousPrincipalResolver(String mode) {
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.deployment-mode=" + mode)
|
||||
.withPropertyValues("app.graphql.deployment-mode=" + mode)
|
||||
.withBean(
|
||||
GraphQlAuthorizationPolicy.class, () -> GraphQlAuthorizationPolicy.builder().build())
|
||||
.run(
|
||||
@@ -247,7 +263,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
@DisplayName("production 은 인가 정책과 principal resolver 를 둘 다 주면 기동한다")
|
||||
void aProductionModeWithAnExplicitPolicyAndResolverStarts() {
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.deployment-mode=PRODUCTION_INTERNAL")
|
||||
.withPropertyValues("app.graphql.deployment-mode=PRODUCTION_INTERNAL")
|
||||
.withBean(
|
||||
GraphQlAuthorizationPolicy.class, () -> GraphQlAuthorizationPolicy.builder().build())
|
||||
.withBean(GraphQlPrincipalResolver.class, () -> request -> Optional.empty())
|
||||
@@ -258,7 +274,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
@DisplayName("the mode reaches the interceptor that decides what an anonymous caller may do")
|
||||
void theModeReachesTheRequestPath() {
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.deployment-mode=LOCAL")
|
||||
.withPropertyValues("app.graphql.deployment-mode=LOCAL")
|
||||
.run(
|
||||
context -> {
|
||||
GraphQlPlatformSettings settings = context.getBean(GraphQlPlatformSettings.class);
|
||||
@@ -304,7 +320,7 @@ class GraphQlDeploymentModeContractTest {
|
||||
@DisplayName("the platform's console setting is what the framework is given")
|
||||
void thePlatformConsoleSettingReachesTheFramework() {
|
||||
ConfigurableEnvironment environment =
|
||||
environmentWith(Map.of("backend.graphql.console.introspection-enabled", "true"));
|
||||
environmentWith(Map.of("app.graphql.console.introspection-enabled", "true"));
|
||||
|
||||
new GraphQlActivationEnvironmentPostProcessor().postProcessEnvironment(environment, null);
|
||||
|
||||
@@ -331,12 +347,12 @@ class GraphQlDeploymentModeContractTest {
|
||||
environment.getPropertySources().addFirst(source("contract", properties));
|
||||
environment
|
||||
.getPropertySources()
|
||||
.addLast(source("master", Map.of("backend.graphql.enabled", "true")));
|
||||
.addLast(source("master", Map.of("app.graphql.enabled", "true")));
|
||||
return environment;
|
||||
}
|
||||
|
||||
private static MapPropertySource off() {
|
||||
return source("off", Map.of("backend.graphql.enabled", "false"));
|
||||
return source("off", Map.of("app.graphql.enabled", "false"));
|
||||
}
|
||||
|
||||
private static MapPropertySource source(String name, Map<String, String> properties) {
|
||||
|
||||
+1
-2
@@ -27,8 +27,7 @@ class GraphQlObservationWiringTest {
|
||||
AutoConfigurations.of(
|
||||
GraphQlRootAutoConfiguration.class, GraphQlObservationAutoConfiguration.class))
|
||||
.withBean(ObservationRegistry.class, ObservationRegistry::create)
|
||||
.withPropertyValues(
|
||||
"backend.graphql.enabled=true", "backend.graphql.deployment-mode=LOCAL");
|
||||
.withPropertyValues("app.graphql.enabled=true", "app.graphql.deployment-mode=LOCAL");
|
||||
|
||||
@Test
|
||||
void theFrameworkInstrumentationResolvesThePlatformConvention() {
|
||||
|
||||
+18
-21
@@ -41,8 +41,7 @@ class GraphQlPlatformAutoConfigurationTest {
|
||||
// it is testing the missing-mode refusal rather than whatever it meant to test. That
|
||||
// refusal has its own cases in GraphQlDeploymentModeContractTest. Later property values
|
||||
// override earlier ones, so a case that needs a different mode simply names it.
|
||||
.withPropertyValues(
|
||||
"backend.graphql.enabled=true", "backend.graphql.deployment-mode=LOCAL");
|
||||
.withPropertyValues("app.graphql.enabled=true", "app.graphql.deployment-mode=LOCAL");
|
||||
|
||||
@Test
|
||||
void aContextWithOnlyTheDeploymentModeSetBootsWithSafeDefaults() {
|
||||
@@ -81,7 +80,7 @@ class GraphQlPlatformAutoConfigurationTest {
|
||||
@Test
|
||||
void productionRefusesToStartWithoutAnExplicitAuthorizationPolicy() {
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.deployment-mode=PRODUCTION_INTERNAL")
|
||||
.withPropertyValues("app.graphql.deployment-mode=PRODUCTION_INTERNAL")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context)
|
||||
@@ -116,7 +115,7 @@ class GraphQlPlatformAutoConfigurationTest {
|
||||
@Test
|
||||
void aClientPolicyLooserThanTheConfiguredCeilingIsRejectedAtStartup() {
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.limits.maximum-page-size=25")
|
||||
.withPropertyValues("app.graphql.limits.maximum-page-size=25")
|
||||
.withBean(GraphQlClientPolicy.class, () -> GraphQlClientPolicy.defaults(500, 10_000, false))
|
||||
.run(
|
||||
context ->
|
||||
@@ -124,7 +123,7 @@ class GraphQlPlatformAutoConfigurationTest {
|
||||
.hasFailed()
|
||||
.getFailure()
|
||||
.rootCause()
|
||||
.hasMessageContaining("exceeds backend.graphql.limits.maximum-page-size"));
|
||||
.hasMessageContaining("exceeds app.graphql.limits.maximum-page-size"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,8 +136,7 @@ class GraphQlPlatformAutoConfigurationTest {
|
||||
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"backend.graphql.deployment-mode=LOCAL",
|
||||
"backend.graphql.console.introspection-enabled=true")
|
||||
"app.graphql.deployment-mode=LOCAL", "app.graphql.console.introspection-enabled=true")
|
||||
.withBean(GraphQlProperties.class, () -> framework)
|
||||
.run(
|
||||
context ->
|
||||
@@ -156,7 +154,7 @@ class GraphQlPlatformAutoConfigurationTest {
|
||||
framework.getGraphiql().setEnabled(true);
|
||||
|
||||
runner
|
||||
.withPropertyValues("backend.graphql.deployment-mode=LOCAL")
|
||||
.withPropertyValues("app.graphql.deployment-mode=LOCAL")
|
||||
.withBean(GraphQlProperties.class, () -> framework)
|
||||
.run(
|
||||
context ->
|
||||
@@ -174,8 +172,7 @@ class GraphQlPlatformAutoConfigurationTest {
|
||||
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"backend.graphql.deployment-mode=LOCAL",
|
||||
"backend.graphql.console.introspection-enabled=true")
|
||||
"app.graphql.deployment-mode=LOCAL", "app.graphql.console.introspection-enabled=true")
|
||||
.withBean(GraphQlProperties.class, () -> framework)
|
||||
.run(context -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
@@ -200,19 +197,19 @@ class GraphQlPlatformAutoConfigurationTest {
|
||||
String metadata = readClasspathResource("META-INF/spring-configuration-metadata.json");
|
||||
|
||||
assertThat(metadata)
|
||||
.contains("backend.graphql.deployment-mode")
|
||||
.doesNotContain("backend.graphql.production")
|
||||
.doesNotContain("backend.graphql.environment")
|
||||
.contains("backend.graphql.console.graphiql-enabled")
|
||||
.contains("backend.graphql.console.introspection-enabled")
|
||||
.contains("backend.graphql.limits.maximum-page-size")
|
||||
.contains("backend.graphql.limits.maximum-complexity")
|
||||
.contains("app.graphql.deployment-mode")
|
||||
.doesNotContain("app.graphql.production")
|
||||
.doesNotContain("app.graphql.environment")
|
||||
.contains("app.graphql.console.graphiql-enabled")
|
||||
.contains("app.graphql.console.introspection-enabled")
|
||||
.contains("app.graphql.limits.maximum-page-size")
|
||||
.contains("app.graphql.limits.maximum-complexity")
|
||||
// Keys that only failed the boot or were echoed back unused were removed (2026-09-25).
|
||||
.doesNotContain("backend.graphql.cursor.key-ids")
|
||||
.doesNotContain("backend.graphql.unsupported.multipart-upload")
|
||||
.doesNotContain("app.graphql.cursor.key-ids")
|
||||
.doesNotContain("app.graphql.unsupported.multipart-upload")
|
||||
// Servlet-only template (D4): no reactive profile to choose, no event loop to bridge off.
|
||||
.doesNotContain("backend.graphql.execution-profile")
|
||||
.doesNotContain("backend.graphql.unbridged-blocking-resolvers");
|
||||
.doesNotContain("app.graphql.execution-profile")
|
||||
.doesNotContain("app.graphql.unbridged-blocking-resolvers");
|
||||
}
|
||||
|
||||
private static GraphQlProperties frameworkDefaults() {
|
||||
|
||||
+1
-2
@@ -35,8 +35,7 @@ class GraphQlPolicyRequestPathTest {
|
||||
private final ApplicationContextRunner runner =
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(GraphQlRootAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"backend.graphql.enabled=true", "backend.graphql.deployment-mode=LOCAL");
|
||||
.withPropertyValues("app.graphql.enabled=true", "app.graphql.deployment-mode=LOCAL");
|
||||
|
||||
@Test
|
||||
@DisplayName("the policies that are wired reach the request path through the instrumentation")
|
||||
|
||||
+1
-2
@@ -39,8 +39,7 @@ class GraphQlPlatformWebInterceptorRequestBoundsTest {
|
||||
private final ApplicationContextRunner runner =
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(GraphQlRootAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"backend.graphql.enabled=true", "backend.graphql.deployment-mode=LOCAL")
|
||||
.withPropertyValues("app.graphql.enabled=true", "app.graphql.deployment-mode=LOCAL")
|
||||
.withBean(
|
||||
GraphQlClientPolicy.class,
|
||||
() ->
|
||||
|
||||
+1
-2
@@ -44,8 +44,7 @@ class GraphQlRequestStageErrorMappingTest {
|
||||
private final ApplicationContextRunner runner =
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(GraphQlRootAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"backend.graphql.enabled=true", "backend.graphql.deployment-mode=LOCAL");
|
||||
.withPropertyValues("app.graphql.enabled=true", "app.graphql.deployment-mode=LOCAL");
|
||||
|
||||
@Test
|
||||
@DisplayName("principal resolver 가 던진 ApiErrorCarrier 는 요청 단계에서도 자기 code 로 나간다")
|
||||
|
||||
@@ -38,11 +38,11 @@ Package root: `dev.caskeleton.adapter.inbound.grpc`.
|
||||
- 프로덕션 feature RPC 를 스켈레톤에 두는 것 — health/reflection 표면만 (web 의
|
||||
`HealthcheckController` 와 동일 원칙).
|
||||
|
||||
## Config knobs (`ca-skeleton.grpc.server.*`)
|
||||
## Config knobs (`app.grpc.server.*`)
|
||||
|
||||
타입드 `@ConfigurationProperties` 만 두고, 값은 composition-root `application.yml` 에 산다
|
||||
(모듈별 `yml` 없음). prefix가 `ca-skeleton.grpc`가 아니라 `.server`까지인 이유: 바인딩이
|
||||
`ignoreUnknownFields = false`라서, 부모 prefix를 쓰면 벤더 starter의 `ca-skeleton.grpc.platform.*`
|
||||
(모듈별 `yml` 없음). prefix가 `app.grpc`가 아니라 `.server`까지인 이유: 바인딩이
|
||||
`ignoreUnknownFields = false`라서, 부모 prefix를 쓰면 벤더 starter의 `app.grpc.platform.*`
|
||||
키가 들어오는 순간 기동이 실패한다(`GrpcSafeActivationTest`).
|
||||
|
||||
| key | default | 의미 |
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
```
|
||||
|
||||
이 줄을 지우면 서버, 포트, 설정 바인딩이 모두 함께 빠진다.
|
||||
- 켜기와 끄기: 모듈이 있으면 켜진다. `ca-skeleton.grpc.server.enabled=false`로만 끈다.
|
||||
- 켜기와 끄기: 모듈이 있으면 켜진다. `app.grpc.server.enabled=false`로만 끈다.
|
||||
- 필요한 설정: 전용 `APP_*` env 키는 registry에 없다. 켜진 상태에서 지금 구현이 받는 listener는
|
||||
loopback plaintext뿐이라 `ca-skeleton.grpc.server.allow-insecure-local=true`(env
|
||||
`CA_SKELETON_GRPC_SERVER_ALLOW_INSECURE_LOCAL=true`)를 명시해야 기동한다. 선택: `ca-skeleton.grpc.server.port`
|
||||
loopback plaintext뿐이라 `app.grpc.server.allow-insecure-local=true`(env
|
||||
`APP_GRPC_SERVER_ALLOW_INSECURE_LOCAL=true`)를 명시해야 기동한다. 선택: `app.grpc.server.port`
|
||||
(기본 9090), `.bind-address`(기본 127.0.0.1), `.reflection-enabled`, `.shutdown-grace-seconds`.
|
||||
|
||||
## 왜 self-managed Netty 인가
|
||||
|
||||
+3
-3
@@ -11,8 +11,8 @@ import org.springframework.context.annotation.Bean;
|
||||
/**
|
||||
* Wires the gRPC transport machinery. Registered through this module's own {@code
|
||||
* AutoConfiguration.imports}: on when the module is present, off with {@code
|
||||
* ca-skeleton.grpc.server.enabled=false}. The plaintext listener still refuses to start unless
|
||||
* {@code ca-skeleton.grpc.server.allow-insecure-local=true} is explicit.
|
||||
* app.grpc.server.enabled=false}. The plaintext listener still refuses to start unless {@code
|
||||
* app.grpc.server.allow-insecure-local=true} is explicit.
|
||||
*
|
||||
* <p>All collaborators are plain objects composed here, mirroring the clean DI style used across
|
||||
* the skeleton. A feature service is exposed only when its {@link BindableService} bean carries
|
||||
@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean;
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.grpc.server",
|
||||
prefix = "app.grpc.server",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
+2
-2
@@ -10,11 +10,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* gRPC server settings bound from {@code ca-skeleton.grpc.server.*}. Typed configuration only (no
|
||||
* gRPC server settings bound from {@code app.grpc.server.*}. Typed configuration only (no
|
||||
* per-module {@code yml}); values live in the composition-root {@code application.yml}, matching
|
||||
* the ca-skeleton config convention. See README for the self-managed-Netty rationale.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "ca-skeleton.grpc.server", ignoreUnknownFields = false)
|
||||
@ConfigurationProperties(prefix = "app.grpc.server", ignoreUnknownFields = false)
|
||||
@Validated
|
||||
public class GrpcServerSettings {
|
||||
|
||||
|
||||
+5
-5
@@ -70,11 +70,11 @@ class GrpcP1BoundaryWireTest {
|
||||
new ApplicationContextRunner()
|
||||
.withUserConfiguration(GrpcServerConfig.class, FeatureConfiguration.class)
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.enabled=true",
|
||||
"ca-skeleton.grpc.server.port=0",
|
||||
"ca-skeleton.grpc.server.bind-address=127.0.0.1",
|
||||
"ca-skeleton.grpc.server.allow-insecure-local=true",
|
||||
"ca-skeleton.grpc.server.reflection-enabled=false");
|
||||
"app.grpc.server.enabled=true",
|
||||
"app.grpc.server.port=0",
|
||||
"app.grpc.server.bind-address=127.0.0.1",
|
||||
"app.grpc.server.allow-insecure-local=true",
|
||||
"app.grpc.server.reflection-enabled=false");
|
||||
|
||||
@Test
|
||||
void missingAuthenticationMetadataIsRejectedWithAStableContract() {
|
||||
|
||||
+23
-25
@@ -42,15 +42,14 @@ class GrpcSafeActivationTest {
|
||||
@Test
|
||||
void presentWithoutTheSwitchIsOnAndStillRefusesAnImplicitPlaintextListener() {
|
||||
contextRunner
|
||||
.withPropertyValues("ca-skeleton.grpc.server.port=0")
|
||||
.withPropertyValues("app.grpc.server.port=0")
|
||||
.run(context -> assertRootCauseContains(context.getStartupFailure(), "insecure"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void switchedOffCreatesNoGrpcRuntimeBeansOrListener() {
|
||||
contextRunner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.enabled=false", "ca-skeleton.grpc.server.port=0")
|
||||
.withPropertyValues("app.grpc.server.enabled=false", "app.grpc.server.port=0")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).doesNotHaveBean(GrpcServerSettings.class);
|
||||
@@ -63,8 +62,7 @@ class GrpcSafeActivationTest {
|
||||
@Test
|
||||
void enabledTransportRequiresAnExplicitLocalInsecureOverride() {
|
||||
contextRunner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.enabled=true", "ca-skeleton.grpc.server.port=0")
|
||||
.withPropertyValues("app.grpc.server.enabled=true", "app.grpc.server.port=0")
|
||||
.run(context -> assertRootCauseContains(context.getStartupFailure(), "insecure"));
|
||||
}
|
||||
|
||||
@@ -72,10 +70,10 @@ class GrpcSafeActivationTest {
|
||||
void insecureTransportRejectsANonLoopbackBindAddress() {
|
||||
contextRunner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.enabled=true",
|
||||
"ca-skeleton.grpc.server.port=0",
|
||||
"ca-skeleton.grpc.server.bind-address=0.0.0.0",
|
||||
"ca-skeleton.grpc.server.allow-insecure-local=true")
|
||||
"app.grpc.server.enabled=true",
|
||||
"app.grpc.server.port=0",
|
||||
"app.grpc.server.bind-address=0.0.0.0",
|
||||
"app.grpc.server.allow-insecure-local=true")
|
||||
.run(context -> assertRootCauseContains(context.getStartupFailure(), "loopback"));
|
||||
}
|
||||
|
||||
@@ -83,10 +81,10 @@ class GrpcSafeActivationTest {
|
||||
void enabledTransportRejectsAPortOutsideTheTcpRange() {
|
||||
contextRunner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.enabled=true",
|
||||
"ca-skeleton.grpc.server.port=65536",
|
||||
"ca-skeleton.grpc.server.bind-address=127.0.0.1",
|
||||
"ca-skeleton.grpc.server.allow-insecure-local=true")
|
||||
"app.grpc.server.enabled=true",
|
||||
"app.grpc.server.port=65536",
|
||||
"app.grpc.server.bind-address=127.0.0.1",
|
||||
"app.grpc.server.allow-insecure-local=true")
|
||||
.run(context -> assertRootCauseContains(context.getStartupFailure(), "port"));
|
||||
}
|
||||
|
||||
@@ -94,11 +92,11 @@ class GrpcSafeActivationTest {
|
||||
void enabledTransportRejectsANegativeShutdownGrace() {
|
||||
contextRunner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.enabled=true",
|
||||
"ca-skeleton.grpc.server.port=0",
|
||||
"ca-skeleton.grpc.server.bind-address=127.0.0.1",
|
||||
"ca-skeleton.grpc.server.allow-insecure-local=true",
|
||||
"ca-skeleton.grpc.server.shutdown-grace-seconds=-1")
|
||||
"app.grpc.server.enabled=true",
|
||||
"app.grpc.server.port=0",
|
||||
"app.grpc.server.bind-address=127.0.0.1",
|
||||
"app.grpc.server.allow-insecure-local=true",
|
||||
"app.grpc.server.shutdown-grace-seconds=-1")
|
||||
.run(
|
||||
context ->
|
||||
assertRootCauseContains(context.getStartupFailure(), "shutdownGraceSeconds"));
|
||||
@@ -109,10 +107,10 @@ class GrpcSafeActivationTest {
|
||||
contextRunner
|
||||
.withUserConfiguration(FeatureServiceConfiguration.class)
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.enabled=true",
|
||||
"ca-skeleton.grpc.server.port=0",
|
||||
"ca-skeleton.grpc.server.bind-address=127.0.0.1",
|
||||
"ca-skeleton.grpc.server.allow-insecure-local=true")
|
||||
"app.grpc.server.enabled=true",
|
||||
"app.grpc.server.port=0",
|
||||
"app.grpc.server.bind-address=127.0.0.1",
|
||||
"app.grpc.server.allow-insecure-local=true")
|
||||
.run(context -> assertRootCauseContains(context.getStartupFailure(), "authentication"));
|
||||
}
|
||||
|
||||
@@ -120,9 +118,9 @@ class GrpcSafeActivationTest {
|
||||
void theVendorPlatformNamespaceBesideTheAdapterDoesNotFailItsStrictBinding() {
|
||||
contextRunner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.port=0",
|
||||
"ca-skeleton.grpc.server.allow-insecure-local=true",
|
||||
"ca-skeleton.grpc.platform.enabled=true")
|
||||
"app.grpc.server.port=0",
|
||||
"app.grpc.server.allow-insecure-local=true",
|
||||
"app.grpc.platform.enabled=true")
|
||||
.run(context -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -27,10 +27,10 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Boots the skeleton gRPC machinery in a real Spring context on an ephemeral port ({@code
|
||||
* ca-skeleton.grpc.server.port=0}) with ZERO feature services and proves it stands up a working
|
||||
* surface: the {@link GrpcServerRunner} SmartLifecycle starts, the standard {@code grpc.health.v1}
|
||||
* health service reports SERVING, and v1 server reflection lists the built-in services. A real
|
||||
* Netty channel exercises the wire, so this is a genuine transport smoke test, not a wiring mock.
|
||||
* app.grpc.server.port=0}) with ZERO feature services and proves it stands up a working surface:
|
||||
* the {@link GrpcServerRunner} SmartLifecycle starts, the standard {@code grpc.health.v1} health
|
||||
* service reports SERVING, and v1 server reflection lists the built-in services. A real Netty
|
||||
* channel exercises the wire, so this is a genuine transport smoke test, not a wiring mock.
|
||||
*/
|
||||
class GrpcServerRunnerBootTest {
|
||||
|
||||
@@ -38,11 +38,11 @@ class GrpcServerRunnerBootTest {
|
||||
new ApplicationContextRunner()
|
||||
.withUserConfiguration(GrpcServerConfig.class)
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.grpc.server.enabled=true",
|
||||
"ca-skeleton.grpc.server.port=0",
|
||||
"ca-skeleton.grpc.server.bind-address=127.0.0.1",
|
||||
"ca-skeleton.grpc.server.allow-insecure-local=true",
|
||||
"ca-skeleton.grpc.server.reflection-enabled=true");
|
||||
"app.grpc.server.enabled=true",
|
||||
"app.grpc.server.port=0",
|
||||
"app.grpc.server.bind-address=127.0.0.1",
|
||||
"app.grpc.server.allow-insecure-local=true",
|
||||
"app.grpc.server.reflection-enabled=true");
|
||||
|
||||
@Test
|
||||
void skeletonServerStartsAndServesHealthAndReflectionWithNoFeatures() {
|
||||
|
||||
@@ -24,9 +24,9 @@ registry(`src/config/architecture/modules.json`)의 그 leaf `allowed_dependenci
|
||||
|
||||
| 기능 | 켜는 설정 | 만드는 bean |
|
||||
| --- | --- | --- |
|
||||
| MVC virtual thread 실행기 + admission 제한 | `backend.web.advanced.mvc-virtual-threads.enabled=true`, `admission-limit`, `database-pool-size`, `outbound-bulkhead`, `admission-wait` | `applicationTaskExecutor`, `VirtualThreadAdmissionGuard`, `VirtualThreadProfile` |
|
||||
| NDJSON 스트리밍 | `backend.web.advanced.ndjson.enabled=true` | `mvcNdjsonWriter` + 공유 `WebStreamPolicy`·`WebStreamRegistry`·`StreamRecordEncoder` |
|
||||
| JSON text sequence (RFC 7464) | `backend.web.advanced.json-sequence.enabled=true` | `mvcJsonSequenceWriter` + 같은 공유 bean |
|
||||
| MVC virtual thread 실행기 + admission 제한 | `app.web.advanced.mvc-virtual-threads.enabled=true`, `admission-limit`, `database-pool-size`, `outbound-bulkhead`, `admission-wait` | `applicationTaskExecutor`, `VirtualThreadAdmissionGuard`, `VirtualThreadProfile` |
|
||||
| NDJSON 스트리밍 | `app.web.advanced.ndjson.enabled=true` | `mvcNdjsonWriter` + 공유 `WebStreamPolicy`·`WebStreamRegistry`·`StreamRecordEncoder` |
|
||||
| JSON text sequence (RFC 7464) | `app.web.advanced.json-sequence.enabled=true` | `mvcJsonSequenceWriter` + 같은 공유 bean |
|
||||
|
||||
virtual thread 실행기는 `TaskDecorator` bean 을 요구한다(요청 상관관계 전파). 조립 순서는
|
||||
`TaskExecutionAutoConfiguration` 앞이다. 스트리밍 두 기능은 Boot 의 `JsonMapper` bean 으로 레코드를
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Import;
|
||||
@AutoConfiguration
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "backend.web.advanced.json-sequence",
|
||||
prefix = "app.web.advanced.json-sequence",
|
||||
name = "enabled",
|
||||
havingValue = "true")
|
||||
@Import(MvcStreamingSupportConfiguration.class)
|
||||
|
||||
+1
-4
@@ -14,10 +14,7 @@ import org.springframework.context.annotation.Import;
|
||||
/** Wires servlet-side NDJSON streaming only. */
|
||||
@AutoConfiguration
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "backend.web.advanced.ndjson",
|
||||
name = "enabled",
|
||||
havingValue = "true")
|
||||
@ConditionalOnProperty(prefix = "app.web.advanced.ndjson", name = "enabled", havingValue = "true")
|
||||
@Import(MvcStreamingSupportConfiguration.class)
|
||||
public class MvcStreamingExecutorConfiguration {
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ import org.springframework.core.task.support.TaskExecutorAdapter;
|
||||
@EnableConfigurationProperties(VirtualThreadSettings.class)
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "backend.web.advanced.mvc-virtual-threads",
|
||||
prefix = "app.web.advanced.mvc-virtual-threads",
|
||||
name = "enabled",
|
||||
havingValue = "true")
|
||||
public class VirtualThreadMvcConfiguration {
|
||||
|
||||
+2
-2
@@ -7,14 +7,14 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* Settings bound from {@code backend.web.advanced.mvc-virtual-threads.*}.
|
||||
* Settings bound from {@code app.web.advanced.mvc-virtual-threads.*}.
|
||||
*
|
||||
* <p>The downstream budgets are settings rather than something read from the pool at runtime,
|
||||
* deliberately. Reading them would make the check pass automatically — whatever the pool is, the
|
||||
* admission limit would be compared against it and the operator would never be asked to think about
|
||||
* the relationship. Writing them down here is what makes a mismatch visible in a diff.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "backend.web.advanced.mvc-virtual-threads")
|
||||
@ConfigurationProperties(prefix = "app.web.advanced.mvc-virtual-threads")
|
||||
@Validated
|
||||
public class VirtualThreadSettings {
|
||||
|
||||
|
||||
+15
-15
@@ -46,10 +46,10 @@ class MvcAdvancedConfigurationTest {
|
||||
// thread has no relationship to the submitter.
|
||||
new WebApplicationContextRunner()
|
||||
.withPropertyValues(
|
||||
"backend.web.advanced.mvc-virtual-threads.enabled=true",
|
||||
"backend.web.advanced.mvc-virtual-threads.admission-limit=8",
|
||||
"backend.web.advanced.mvc-virtual-threads.database-pool-size=4",
|
||||
"backend.web.advanced.mvc-virtual-threads.outbound-bulkhead=4")
|
||||
"app.web.advanced.mvc-virtual-threads.enabled=true",
|
||||
"app.web.advanced.mvc-virtual-threads.admission-limit=8",
|
||||
"app.web.advanced.mvc-virtual-threads.database-pool-size=4",
|
||||
"app.web.advanced.mvc-virtual-threads.outbound-bulkhead=4")
|
||||
.withUserConfiguration(VirtualThreadMvcConfiguration.class)
|
||||
.run(context -> assertThat(context).hasFailed());
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class MvcAdvancedConfigurationTest {
|
||||
// Four beans with a dependency chain between them. A cycle or a missing dependency here is not
|
||||
// visible from any unit test of the classes involved.
|
||||
runner
|
||||
.withPropertyValues("backend.web.advanced.ndjson.enabled=true")
|
||||
.withPropertyValues("app.web.advanced.ndjson.enabled=true")
|
||||
.withUserConfiguration(MvcStreamingExecutorConfiguration.class)
|
||||
.run(
|
||||
context ->
|
||||
@@ -94,7 +94,7 @@ class MvcAdvancedConfigurationTest {
|
||||
@DisplayName("JSON sequence has its own activation property")
|
||||
void jsonSequenceStartsIndependentlyOfNdjson() {
|
||||
runner
|
||||
.withPropertyValues("backend.web.advanced.json-sequence.enabled=true")
|
||||
.withPropertyValues("app.web.advanced.json-sequence.enabled=true")
|
||||
.withUserConfiguration(MvcJsonSequenceConfiguration.class)
|
||||
.run(
|
||||
context ->
|
||||
@@ -114,10 +114,10 @@ class MvcAdvancedConfigurationTest {
|
||||
// concurrency bound and replaced it with nothing.
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"backend.web.advanced.mvc-virtual-threads.enabled=true",
|
||||
"backend.web.advanced.mvc-virtual-threads.admission-limit=100",
|
||||
"backend.web.advanced.mvc-virtual-threads.database-pool-size=20",
|
||||
"backend.web.advanced.mvc-virtual-threads.outbound-bulkhead=20")
|
||||
"app.web.advanced.mvc-virtual-threads.enabled=true",
|
||||
"app.web.advanced.mvc-virtual-threads.admission-limit=100",
|
||||
"app.web.advanced.mvc-virtual-threads.database-pool-size=20",
|
||||
"app.web.advanced.mvc-virtual-threads.outbound-bulkhead=20")
|
||||
.withUserConfiguration(VirtualThreadMvcConfiguration.class)
|
||||
.run(
|
||||
context -> {
|
||||
@@ -139,10 +139,10 @@ class MvcAdvancedConfigurationTest {
|
||||
// place — the capability switched on and nothing changed.
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"backend.web.advanced.mvc-virtual-threads.enabled=true",
|
||||
"backend.web.advanced.mvc-virtual-threads.admission-limit=8",
|
||||
"backend.web.advanced.mvc-virtual-threads.database-pool-size=4",
|
||||
"backend.web.advanced.mvc-virtual-threads.outbound-bulkhead=4")
|
||||
"app.web.advanced.mvc-virtual-threads.enabled=true",
|
||||
"app.web.advanced.mvc-virtual-threads.admission-limit=8",
|
||||
"app.web.advanced.mvc-virtual-threads.database-pool-size=4",
|
||||
"app.web.advanced.mvc-virtual-threads.outbound-bulkhead=4")
|
||||
.withUserConfiguration(VirtualThreadMvcConfiguration.class)
|
||||
.run(
|
||||
context ->
|
||||
@@ -158,7 +158,7 @@ class MvcAdvancedConfigurationTest {
|
||||
// will not refresh, which is the intended outcome: a node that accepts every arrival and
|
||||
// queues it on budgets that did not grow is worse than a node that does not start.
|
||||
runner
|
||||
.withPropertyValues("backend.web.advanced.mvc-virtual-threads.enabled=true")
|
||||
.withPropertyValues("app.web.advanced.mvc-virtual-threads.enabled=true")
|
||||
.withUserConfiguration(VirtualThreadMvcConfiguration.class)
|
||||
.run(
|
||||
context ->
|
||||
|
||||
+2
-2
@@ -64,8 +64,8 @@ class WebAdvancedRollbackIT {
|
||||
// matchIfMissing = true would pass the test above and fail this one.
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"backend.web.advanced.ndjson.enabled=false",
|
||||
"backend.web.advanced.mvc-virtual-threads.enabled=false")
|
||||
"app.web.advanced.ndjson.enabled=false",
|
||||
"app.web.advanced.mvc-virtual-threads.enabled=false")
|
||||
.withUserConfiguration(
|
||||
MvcStreamingExecutorConfiguration.class,
|
||||
MvcJsonSequenceConfiguration.class,
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.springframework.context.annotation.Import;
|
||||
@AutoConfiguration
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform",
|
||||
prefix = "app.notification.platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import org.springframework.security.web.SecurityFilterChain;
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform.callbacks",
|
||||
prefix = "app.notification.platform.callbacks",
|
||||
name = "enabled",
|
||||
havingValue = "true")
|
||||
public class CallbackMvcSecurityConfiguration {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform.callbacks",
|
||||
prefix = "app.notification.platform.callbacks",
|
||||
name = "enabled",
|
||||
havingValue = "true")
|
||||
public class CallbackRequestConfiguration {
|
||||
|
||||
+2
-3
@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform.callbacks",
|
||||
prefix = "app.notification.platform.callbacks",
|
||||
name = "enabled",
|
||||
havingValue = "true")
|
||||
@RequestMapping("/internal/notification/callbacks")
|
||||
@@ -55,8 +55,7 @@ public final class NotificationCallbackMvcController {
|
||||
public NotificationCallbackMvcController(
|
||||
ProviderCallbackIngress ingestion,
|
||||
CallbackRequestFactory requestFactory,
|
||||
@Value("${ca-skeleton.notification.platform.callbacks.max-body-bytes:65508}")
|
||||
int maxBodyBytes) {
|
||||
@Value("${app.notification.platform.callbacks.max-body-bytes:65508}") int maxBodyBytes) {
|
||||
this.ingestion = Objects.requireNonNull(ingestion, "ingestion");
|
||||
this.requestFactory = Objects.requireNonNull(requestFactory, "requestFactory");
|
||||
if (maxBodyBytes < 1 || maxBodyBytes > MAX_STORABLE_BODY_BYTES) {
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform",
|
||||
prefix = "app.notification.platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform",
|
||||
prefix = "app.notification.platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
+4
-4
@@ -25,7 +25,7 @@ class NotificationWebAutoConfigurationTest {
|
||||
@Test
|
||||
void nothingIsRegisteredWhileThePlatformIsOff() {
|
||||
servlet
|
||||
.withPropertyValues("ca-skeleton.notification.platform.enabled=false")
|
||||
.withPropertyValues("app.notification.platform.enabled=false")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context)
|
||||
@@ -38,7 +38,7 @@ class NotificationWebAutoConfigurationTest {
|
||||
@Test
|
||||
void theSubmissionSurfaceRegistersWithThePlatformAndTheCallbackEndpointStaysOnItsOwnSwitch() {
|
||||
servlet
|
||||
.withPropertyValues("ca-skeleton.notification.platform.enabled=true")
|
||||
.withPropertyValues("app.notification.platform.enabled=true")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context)
|
||||
@@ -54,8 +54,8 @@ class NotificationWebAutoConfigurationTest {
|
||||
.withConfiguration(AutoConfigurations.of(NotificationWebAutoConfiguration.class))
|
||||
.withUserConfiguration(UseCases.class)
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.notification.platform.enabled=true",
|
||||
"ca-skeleton.notification.platform.callbacks.enabled=true")
|
||||
"app.notification.platform.enabled=true",
|
||||
"app.notification.platform.callbacks.enabled=true")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context)
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class CallbackRequestConfigurationTest {
|
||||
@DisplayName("callbacks on supplies both beans the endpoints take")
|
||||
void callbacksOnSuppliesTheBeans() {
|
||||
runner
|
||||
.withPropertyValues("ca-skeleton.notification.platform.callbacks.enabled=true")
|
||||
.withPropertyValues("app.notification.platform.callbacks.enabled=true")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context)
|
||||
|
||||
@@ -62,7 +62,7 @@ production configuration and compare the result with the committed snapshot.
|
||||
|
||||
### JWT / Redis session 상호배타 모드
|
||||
|
||||
`ca-skeleton.security.auth-mode=jwt|redis-session`은 하나만 선택한다. JWT mode는 stateless이고
|
||||
`app.security.auth-mode=jwt|redis-session`은 하나만 선택한다. JWT mode는 stateless이고
|
||||
CSRF/session repository를 만들지 않는다. Redis session mode는 `Secure`, `HttpOnly`, host-only
|
||||
session cookie, `SameSite=Lax`, cookie/header CSRF와 `migrateSession` fixation 방어를 함께 켠다.
|
||||
|
||||
@@ -293,7 +293,7 @@ commit-aware response wrapper 계약을 구현한다. 또한 이 모듈은 HTML
|
||||
- inbound web은 `shared-contract`의 `EdgeRateLimitPort`만 호출한다. Redis key, Lua, local counter와
|
||||
provider 설정을 알지 못한다.
|
||||
- outbound provider activation SSOT는
|
||||
`ca-skeleton.capabilities.rate-limit.provider=disabled|redis`이고, HTTP enforcement의 별도 축은
|
||||
`app.capabilities.rate-limit.provider=disabled|redis`이고, HTTP enforcement의 별도 축은
|
||||
`app.rate-limit.enabled`다. transport가 enabled인데 exact provider가 없거나 중복이면 startup을
|
||||
실패시킨다.
|
||||
- fixed window, sliding counter, token bucket 선택과 policy revision은 Redis provider가 소유한다.
|
||||
|
||||
+1
-4
@@ -29,10 +29,7 @@ import org.springframework.web.client.RestClientException;
|
||||
* README for the design rationale.
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(
|
||||
name = "ca-skeleton.security.auth-mode",
|
||||
havingValue = "jwt",
|
||||
matchIfMissing = true)
|
||||
@ConditionalOnProperty(name = "app.security.auth-mode", havingValue = "jwt", matchIfMissing = true)
|
||||
public class JwtDecoderConfig {
|
||||
|
||||
static final String ERROR_TIMESTAMP_INVALID = "jwt_timestamp_invalid";
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.springframework.session.web.http.DefaultCookieSerializer;
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableSpringHttpSession
|
||||
@ConditionalOnProperty(
|
||||
name = "ca-skeleton.security.auth-mode",
|
||||
name = "app.security.auth-mode",
|
||||
havingValue = "redis-session",
|
||||
matchIfMissing = false)
|
||||
public class RedisSessionWebConfig {
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(
|
||||
name = "ca-skeleton.security.auth-mode",
|
||||
name = "app.security.auth-mode",
|
||||
havingValue = "redis-session",
|
||||
matchIfMissing = false)
|
||||
PrimitiveSessionSecurityContextRepository primitiveSessionSecurityContextRepository() {
|
||||
|
||||
+4
-4
@@ -8,11 +8,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
/**
|
||||
* App-side role→permission mapping source.
|
||||
*
|
||||
* <p>Bound from {@code ca-skeleton.authz.role-permissions.<role> = [resource:action, ...]}. Keys
|
||||
* are <em>raw</em> IdP role names (no {@code ROLE_} prefix), e.g.:
|
||||
* <p>Bound from {@code app.authz.role-permissions.<role> = [resource:action, ...]}. Keys are
|
||||
* <em>raw</em> IdP role names (no {@code ROLE_} prefix), e.g.:
|
||||
*
|
||||
* <pre>
|
||||
* ca-skeleton:
|
||||
* app:
|
||||
* authz:
|
||||
* role-permissions:
|
||||
* user: [worklog:read, worklog:write]
|
||||
@@ -21,7 +21,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
*
|
||||
* <p>See README for the design rationale.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "ca-skeleton.authz")
|
||||
@ConfigurationProperties(prefix = "app.authz")
|
||||
public record RolePermissionPolicy(Map<String, List<String>> rolePermissions) {
|
||||
|
||||
public RolePermissionPolicy {
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import tools.jackson.core.StreamReadFeature;
|
||||
@AutoConfiguration
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "backend.web.mvc",
|
||||
prefix = "app.web.mvc",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import org.springframework.util.unit.DataSize;
|
||||
* @param trustInboundRequestId whether a caller may choose its own request id
|
||||
* @param maxJsonBodySize the largest JSON request body accepted; 1MB when omitted
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "backend.web.mvc")
|
||||
@ConfigurationProperties(prefix = "app.web.mvc")
|
||||
public record WebMvcPlatformSettings(
|
||||
Boolean enabled, Boolean trustInboundRequestId, DataSize maxJsonBodySize) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public record WebMvcPlatformSettings(
|
||||
trustInboundRequestId = trustInboundRequestId != null && trustInboundRequestId;
|
||||
maxJsonBodySize = maxJsonBodySize == null ? DataSize.ofMegabytes(1) : maxJsonBodySize;
|
||||
if (maxJsonBodySize.toBytes() < 1) {
|
||||
throw new IllegalArgumentException("backend.web.mvc.max-json-body-size must be positive");
|
||||
throw new IllegalArgumentException("app.web.mvc.max-json-body-size must be positive");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* HTTP bridge settings bound to the transport-only {@code app.rate-limit} axis.
|
||||
*
|
||||
* <p>The outbound provider is selected independently by {@code
|
||||
* ca-skeleton.capabilities.rate-limit.provider}; enabling this bridge never selects a provider or a
|
||||
* app.capabilities.rate-limit.provider}; enabling this bridge never selects a provider or a
|
||||
* fallback.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "app.rate-limit")
|
||||
|
||||
+6
-10
@@ -7,20 +7,16 @@ import java.util.List;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* CORS settings bound from {@code ca-skeleton.cors.*}. See README for the validation-policy
|
||||
* rationale.
|
||||
*/
|
||||
/** CORS settings bound from {@code app.cors.*}. See README for the validation-policy rationale. */
|
||||
@Validated
|
||||
@ConfigurationProperties(prefix = "ca-skeleton.cors")
|
||||
@ConfigurationProperties(prefix = "app.cors")
|
||||
public record CorsSettings(
|
||||
boolean enabled,
|
||||
List<String> allowedOrigins,
|
||||
List<String> allowedMethods,
|
||||
List<String> allowedHeaders,
|
||||
boolean allowCredentials,
|
||||
@PositiveOrZero(
|
||||
message = "APP_SECURITY_CORS_MAX_AGE (ca-skeleton.cors.max-age-seconds) must be >= 0")
|
||||
@PositiveOrZero(message = "APP_SECURITY_CORS_MAX_AGE (app.cors.max-age-seconds) must be >= 0")
|
||||
long maxAgeSeconds) {
|
||||
|
||||
public CorsSettings {
|
||||
@@ -28,13 +24,13 @@ public record CorsSettings(
|
||||
if (enabled && (allowedOrigins == null || allowedOrigins.isEmpty())) {
|
||||
throw new IllegalArgumentException(
|
||||
"APP_SECURITY_CORS_ENABLED=true requires a non-empty APP_SECURITY_CORS_ORIGINS "
|
||||
+ "(ca-skeleton.cors.allowed-origins)");
|
||||
+ "(app.cors.allowed-origins)");
|
||||
}
|
||||
// A wildcard origin must not be combined with credentials.
|
||||
if (allowCredentials && allowedOrigins != null && allowedOrigins.contains("*")) {
|
||||
throw new IllegalArgumentException(
|
||||
"APP_SECURITY_CORS_ALLOW_CREDENTIALS=true must not be combined with a wildcard "
|
||||
+ "\"*\" in APP_SECURITY_CORS_ORIGINS (ca-skeleton.cors.allowed-origins); "
|
||||
+ "\"*\" in APP_SECURITY_CORS_ORIGINS (app.cors.allowed-origins); "
|
||||
+ "list explicit origins instead");
|
||||
}
|
||||
if (allowedOrigins == null) {
|
||||
@@ -85,7 +81,7 @@ public record CorsSettings(
|
||||
|
||||
private static IllegalArgumentException notAnOrigin(String origin) {
|
||||
return new IllegalArgumentException(
|
||||
"APP_SECURITY_CORS_ORIGINS (ca-skeleton.cors.allowed-origins) entry \""
|
||||
"APP_SECURITY_CORS_ORIGINS (app.cors.allowed-origins) entry \""
|
||||
+ origin
|
||||
+ "\" must be exactly scheme://host[:port] with http or https: no path, trailing"
|
||||
+ " slash, query, fragment, user info, wildcard host or \"null\"");
|
||||
|
||||
+2
-4
@@ -4,10 +4,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Bound from {@code ca-skeleton.presentation.*}. See README for the validation-policy rationale.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "ca-skeleton.presentation")
|
||||
/** Bound from {@code app.presentation.*}. See README for the validation-policy rationale. */
|
||||
@ConfigurationProperties(prefix = "app.presentation")
|
||||
public record PresentationSettings(String apiBasePath) {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PresentationSettings.class);
|
||||
|
||||
+3
-4
@@ -7,10 +7,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
||||
|
||||
/**
|
||||
* Exclusive JWT or Redis-backed browser-session security policy bound from {@code
|
||||
* ca-skeleton.security.*}.
|
||||
* Exclusive JWT or Redis-backed browser-session security policy bound from {@code app.security.*}.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "ca-skeleton.security")
|
||||
@ConfigurationProperties(prefix = "app.security")
|
||||
public record SecuritySettings(
|
||||
AuthenticationMode authMode,
|
||||
String issuerUri,
|
||||
@@ -30,7 +29,7 @@ public record SecuritySettings(
|
||||
this.authMode = authMode == null ? AuthenticationMode.JWT : authMode;
|
||||
if (this.authMode == AuthenticationMode.JWT && (issuerUri == null || issuerUri.isBlank())) {
|
||||
throw new IllegalArgumentException(
|
||||
"APP_SECURITY_JWT_ISSUER (ca-skeleton.security.issuer-uri) is required");
|
||||
"APP_SECURITY_JWT_ISSUER (app.security.issuer-uri) is required");
|
||||
}
|
||||
this.issuerUri = issuerUri == null ? "" : issuerUri.trim();
|
||||
if (audience == null) {
|
||||
|
||||
+12
-12
@@ -167,18 +167,18 @@ class CorsSecurityFilterIntegrationTest {
|
||||
boolean enabled, String origin, boolean credentials, ThrowingConsumer<MockMvc> assertion) {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=jwt",
|
||||
"ca-skeleton.security.issuer-uri=https://issuer.example.test",
|
||||
"ca-skeleton.security.audience=ca-skeleton-api",
|
||||
"ca-skeleton.security.public-paths=/public",
|
||||
"ca-skeleton.cors.enabled=" + enabled,
|
||||
"ca-skeleton.cors.allowed-origins[0]=" + origin,
|
||||
"ca-skeleton.cors.allowed-methods[0]=GET",
|
||||
"ca-skeleton.cors.allowed-methods[1]=POST",
|
||||
"ca-skeleton.cors.allowed-headers[0]=X-Request-ID",
|
||||
"ca-skeleton.cors.allowed-headers[1]=Content-Type",
|
||||
"ca-skeleton.cors.allow-credentials=" + credentials,
|
||||
"ca-skeleton.cors.max-age-seconds=600")
|
||||
"app.security.auth-mode=jwt",
|
||||
"app.security.issuer-uri=https://issuer.example.test",
|
||||
"app.security.audience=ca-skeleton-api",
|
||||
"app.security.public-paths=/public",
|
||||
"app.cors.enabled=" + enabled,
|
||||
"app.cors.allowed-origins[0]=" + origin,
|
||||
"app.cors.allowed-methods[0]=GET",
|
||||
"app.cors.allowed-methods[1]=POST",
|
||||
"app.cors.allowed-headers[0]=X-Request-ID",
|
||||
"app.cors.allowed-headers[1]=Content-Type",
|
||||
"app.cors.allow-credentials=" + credentials,
|
||||
"app.cors.max-age-seconds=600")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
|
||||
+5
-5
@@ -259,11 +259,11 @@ class JwtJwksSecurityFilterIntegrationTest {
|
||||
private void withContext(OidcServer issuer, ThrowingConsumer<MockMvc> assertion) {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=jwt",
|
||||
"ca-skeleton.security.issuer-uri=" + issuer.issuer(),
|
||||
"ca-skeleton.security.audience=" + AUDIENCE,
|
||||
"ca-skeleton.security.public-paths=/public",
|
||||
"ca-skeleton.cors.enabled=false")
|
||||
"app.security.auth-mode=jwt",
|
||||
"app.security.issuer-uri=" + issuer.issuer(),
|
||||
"app.security.audience=" + AUDIENCE,
|
||||
"app.security.public-paths=/public",
|
||||
"app.cors.enabled=false")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
|
||||
+7
-8
@@ -23,8 +23,7 @@ class RedisSessionWebConfigTest {
|
||||
void jwtModeCreatesNoSessionFilterOrCookieSerializer() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=jwt",
|
||||
"ca-skeleton.security.issuer-uri=https://issuer.example")
|
||||
"app.security.auth-mode=jwt", "app.security.issuer-uri=https://issuer.example")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -39,12 +38,12 @@ class RedisSessionWebConfigTest {
|
||||
.withBean(
|
||||
MapSessionRepository.class, () -> new MapSessionRepository(new ConcurrentHashMap<>()))
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=redis-session",
|
||||
"ca-skeleton.security.session.cookie-name=APP_SESSION",
|
||||
"ca-skeleton.security.session.secure=true",
|
||||
"ca-skeleton.security.session.http-only=true",
|
||||
"ca-skeleton.security.session.same-site=Strict",
|
||||
"ca-skeleton.security.session.path=/")
|
||||
"app.security.auth-mode=redis-session",
|
||||
"app.security.session.cookie-name=APP_SESSION",
|
||||
"app.security.session.secure=true",
|
||||
"app.security.session.http-only=true",
|
||||
"app.security.session.same-site=Strict",
|
||||
"app.security.session.path=/")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
|
||||
+16
-16
@@ -53,9 +53,9 @@ class SecurityModeWebContractTest {
|
||||
void redisSessionModeEnablesCsrfAndRotatesAnAuthenticatedSessionIdentifier() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=redis-session",
|
||||
"ca-skeleton.security.public-paths=/probe,/csrf",
|
||||
"ca-skeleton.cors.enabled=false")
|
||||
"app.security.auth-mode=redis-session",
|
||||
"app.security.public-paths=/probe,/csrf",
|
||||
"app.cors.enabled=false")
|
||||
.run(
|
||||
context -> {
|
||||
MockMvc mvc = mvc(context.getBean("springSecurityFilterChain", Filter.class));
|
||||
@@ -96,9 +96,9 @@ class SecurityModeWebContractTest {
|
||||
void redisSessionModeDoesNotCacheUnauthorizedApiRequestsInAFrameworkSessionObject() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=redis-session",
|
||||
"ca-skeleton.security.public-paths=/csrf",
|
||||
"ca-skeleton.cors.enabled=false")
|
||||
"app.security.auth-mode=redis-session",
|
||||
"app.security.public-paths=/csrf",
|
||||
"app.cors.enabled=false")
|
||||
.run(
|
||||
context -> {
|
||||
MockMvc mvc = mvc(context.getBean("springSecurityFilterChain", Filter.class));
|
||||
@@ -117,9 +117,9 @@ class SecurityModeWebContractTest {
|
||||
void redisSessionSecurityFilterPersistsAndRestoresOnlyThePrimitiveAuthenticationSnapshot() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=redis-session",
|
||||
"ca-skeleton.security.public-paths=/login-test,/csrf",
|
||||
"ca-skeleton.cors.enabled=false")
|
||||
"app.security.auth-mode=redis-session",
|
||||
"app.security.public-paths=/login-test,/csrf",
|
||||
"app.cors.enabled=false")
|
||||
.run(
|
||||
context -> {
|
||||
MockMvc mvc = mvc(context.getBean("springSecurityFilterChain", Filter.class));
|
||||
@@ -155,10 +155,10 @@ class SecurityModeWebContractTest {
|
||||
void jwtModeRemainsCsrfDisabledAndStateless() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=jwt",
|
||||
"ca-skeleton.security.issuer-uri=https://issuer.example",
|
||||
"ca-skeleton.security.public-paths=/probe",
|
||||
"ca-skeleton.cors.enabled=false")
|
||||
"app.security.auth-mode=jwt",
|
||||
"app.security.issuer-uri=https://issuer.example",
|
||||
"app.security.public-paths=/probe",
|
||||
"app.cors.enabled=false")
|
||||
.run(
|
||||
context -> {
|
||||
MockMvc mvc = mvc(context.getBean("springSecurityFilterChain", Filter.class));
|
||||
@@ -175,9 +175,9 @@ class SecurityModeWebContractTest {
|
||||
void anUnauthenticatedRejectionCarriesTheAssignedRequestIdInItsMeta() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=jwt",
|
||||
"ca-skeleton.security.issuer-uri=https://issuer.example",
|
||||
"ca-skeleton.cors.enabled=false")
|
||||
"app.security.auth-mode=jwt",
|
||||
"app.security.issuer-uri=https://issuer.example",
|
||||
"app.cors.enabled=false")
|
||||
.run(
|
||||
context -> {
|
||||
// given: the request-id filter sits in front of Spring Security, as registered
|
||||
|
||||
+4
-4
@@ -14,8 +14,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
/**
|
||||
* Binding test for {@link RolePermissionPolicy} (AGENTS.md §설정과 런타임: every new
|
||||
* {@code @ConfigurationProperties} class gets a binding test). Verifies the {@code
|
||||
* ca-skeleton.authz.role-permissions.<role>=<comma list>} YAML/env shape binds to the {@code
|
||||
* Map<String, List<String>>} the registry consumes, and that an absent block is null-safe.
|
||||
* app.authz.role-permissions.<role>=<comma list>} YAML/env shape binds to the {@code Map<String,
|
||||
* List<String>>} the registry consumes, and that an absent block is null-safe.
|
||||
*/
|
||||
class RolePermissionPolicyTest {
|
||||
|
||||
@@ -26,8 +26,8 @@ class RolePermissionPolicyTest {
|
||||
void bindsRoleToPermissionLists() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.authz.role-permissions.user=worklog:read,worklog:write",
|
||||
"ca-skeleton.authz.role-permissions.admin=worklog:read,worklog:write,worklog:close")
|
||||
"app.authz.role-permissions.user=worklog:read,worklog:write",
|
||||
"app.authz.role-permissions.admin=worklog:read,worklog:write,worklog:close")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
excludeAutoConfiguration = SecurityAutoConfiguration.class)
|
||||
@ImportAutoConfiguration(WebMvcPlatformAutoConfiguration.class)
|
||||
@Import(RequestBodyBoundaryTest.Probe.class)
|
||||
@TestPropertySource(properties = "backend.web.mvc.max-json-body-size=64B")
|
||||
@TestPropertySource(properties = "app.web.mvc.max-json-body-size=64B")
|
||||
class RequestBodyBoundaryTest {
|
||||
|
||||
@Autowired MockMvc mvc;
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ class WebMvcPlatformAutoConfigurationTest {
|
||||
@DisplayName("enabled=false turns everything off")
|
||||
void enabledFalseTurnsEverythingOff() {
|
||||
servlet
|
||||
.withPropertyValues("backend.web.mvc.enabled=false")
|
||||
.withPropertyValues("app.web.mvc.enabled=false")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context)
|
||||
|
||||
+20
-20
@@ -31,10 +31,10 @@ class CorsSettingsTest {
|
||||
void allowedMethodsAndHeadersMissingDefaultToApiFriendlyValues() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.cors.enabled=true",
|
||||
"ca-skeleton.cors.allowed-origins=http://localhost:3000",
|
||||
"ca-skeleton.cors.allow-credentials=true",
|
||||
"ca-skeleton.cors.max-age-seconds=3600")
|
||||
"app.cors.enabled=true",
|
||||
"app.cors.allowed-origins=http://localhost:3000",
|
||||
"app.cors.allow-credentials=true",
|
||||
"app.cors.max-age-seconds=3600")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -49,9 +49,9 @@ class CorsSettingsTest {
|
||||
void enabledWithoutOriginsFailsStartup() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.cors.enabled=true",
|
||||
"ca-skeleton.cors.allow-credentials=true",
|
||||
"ca-skeleton.cors.max-age-seconds=3600")
|
||||
"app.cors.enabled=true",
|
||||
"app.cors.allow-credentials=true",
|
||||
"app.cors.max-age-seconds=3600")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasFailed();
|
||||
@@ -64,10 +64,10 @@ class CorsSettingsTest {
|
||||
void negativeMaxAgeFailsStartup() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.cors.enabled=true",
|
||||
"ca-skeleton.cors.allowed-origins=http://localhost:3000",
|
||||
"ca-skeleton.cors.allow-credentials=true",
|
||||
"ca-skeleton.cors.max-age-seconds=-1")
|
||||
"app.cors.enabled=true",
|
||||
"app.cors.allowed-origins=http://localhost:3000",
|
||||
"app.cors.allow-credentials=true",
|
||||
"app.cors.max-age-seconds=-1")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasFailed();
|
||||
@@ -81,10 +81,10 @@ class CorsSettingsTest {
|
||||
// D9 / FETCH-CORS-C3: "*" origin + credentials=true is forbidden and must fail fast.
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.cors.enabled=true",
|
||||
"ca-skeleton.cors.allowed-origins=*",
|
||||
"ca-skeleton.cors.allow-credentials=true",
|
||||
"ca-skeleton.cors.max-age-seconds=600")
|
||||
"app.cors.enabled=true",
|
||||
"app.cors.allowed-origins=*",
|
||||
"app.cors.allow-credentials=true",
|
||||
"app.cors.max-age-seconds=600")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasFailed();
|
||||
@@ -98,10 +98,10 @@ class CorsSettingsTest {
|
||||
// A wildcard origin is fine as long as credentials are not also enabled.
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.cors.enabled=true",
|
||||
"ca-skeleton.cors.allowed-origins=*",
|
||||
"ca-skeleton.cors.allow-credentials=false",
|
||||
"ca-skeleton.cors.max-age-seconds=600")
|
||||
"app.cors.enabled=true",
|
||||
"app.cors.allowed-origins=*",
|
||||
"app.cors.allow-credentials=false",
|
||||
"app.cors.max-age-seconds=600")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -112,7 +112,7 @@ class CorsSettingsTest {
|
||||
@Test
|
||||
void disabledWithoutOriginsIsAllowed() {
|
||||
runner
|
||||
.withPropertyValues("ca-skeleton.cors.enabled=false", "ca-skeleton.cors.max-age-seconds=0")
|
||||
.withPropertyValues("app.cors.enabled=false", "app.cors.max-age-seconds=0")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ class PresentationSettingsTest {
|
||||
@Test
|
||||
void validApiBasePathBindsAsIs() {
|
||||
runner
|
||||
.withPropertyValues("ca-skeleton.presentation.api-base-path=/api")
|
||||
.withPropertyValues("app.presentation.api-base-path=/api")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -41,7 +41,7 @@ class PresentationSettingsTest {
|
||||
@Test
|
||||
void noLeadingSlashWarnsAndPrepends(CapturedOutput output) {
|
||||
runner
|
||||
.withPropertyValues("ca-skeleton.presentation.api-base-path=api")
|
||||
.withPropertyValues("app.presentation.api-base-path=api")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
|
||||
+9
-10
@@ -31,8 +31,7 @@ class SecuritySettingsTest {
|
||||
@Test
|
||||
void audienceMissingWarnsAndDefaultsToEmpty(CapturedOutput output) {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.issuer-uri=http://localhost:8081/realms/ca-skeleton")
|
||||
.withPropertyValues("app.security.issuer-uri=http://localhost:8081/realms/ca-skeleton")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -45,9 +44,9 @@ class SecuritySettingsTest {
|
||||
void publicPathsBindAsList() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.issuer-uri=http://localhost:8081/realms/ca-skeleton",
|
||||
"ca-skeleton.security.audience=ca-skeleton-api",
|
||||
"ca-skeleton.security.public-paths=/api/healthcheck,/api/docs/**")
|
||||
"app.security.issuer-uri=http://localhost:8081/realms/ca-skeleton",
|
||||
"app.security.audience=ca-skeleton-api",
|
||||
"app.security.public-paths=/api/healthcheck,/api/docs/**")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -72,11 +71,11 @@ class SecuritySettingsTest {
|
||||
void redisSessionModeDoesNotRequireJwtAndBindsSecureHostOnlyCookiePolicy() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.security.auth-mode=redis-session",
|
||||
"ca-skeleton.security.session.cookie-name=APP_SESSION",
|
||||
"ca-skeleton.security.session.secure=true",
|
||||
"ca-skeleton.security.session.http-only=true",
|
||||
"ca-skeleton.security.session.same-site=Strict")
|
||||
"app.security.auth-mode=redis-session",
|
||||
"app.security.session.cookie-name=APP_SESSION",
|
||||
"app.security.session.secure=true",
|
||||
"app.security.session.http-only=true",
|
||||
"app.security.session.same-site=Strict")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
|
||||
@@ -14,7 +14,7 @@ server:
|
||||
error:
|
||||
include-stacktrace: never
|
||||
include-message: never
|
||||
backend:
|
||||
app:
|
||||
web:
|
||||
mvc:
|
||||
enabled: true
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/** WebSocket (STOMP) settings bound from {@code app.websocket.*}. */
|
||||
@ConfigurationProperties(prefix = "app.websocket")
|
||||
@ConfigurationProperties(prefix = "app.websocket", ignoreUnknownFields = false)
|
||||
@Validated
|
||||
public class WebSocketSettings {
|
||||
|
||||
|
||||
+15
@@ -2,6 +2,7 @@ package dev.caskeleton.adapter.inbound.websocket.stomp;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
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;
|
||||
@@ -28,6 +29,20 @@ class WebSocketSettingsTest {
|
||||
assertThat(WebSocketSettings.class).hasAnnotation(Validated.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("app.websocket 아래 오타 키는 기동을 실패시킨다")
|
||||
void aMisspelledWebSocketKeyFailsStartup() {
|
||||
// when
|
||||
runner
|
||||
.withPropertyValues("app.websocket.endpont=/live/ws")
|
||||
.run(
|
||||
context -> {
|
||||
// then
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure()).hasStackTraceContaining("endpont");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void enabledSafeSettingsBind() {
|
||||
runner
|
||||
|
||||
@@ -40,7 +40,7 @@ runtimeOnly project(':adapter:outbound:cache-redis') // brings :adapter:outbou
|
||||
those are is this module's `RedisCorrectnessRoleSelectors`, registered in the same file as the
|
||||
runtime's `RedisCorrectnessRequirement` — the runtime asks, it does not list selectors;
|
||||
- the shipped settings `config/module-defaults/cache-redis.yml` — `app.redis.enabled`,
|
||||
`app.rate-limit.*`, and the Redis parts of `ca-skeleton.capabilities.*` (cache, lease, rate-limit,
|
||||
`app.rate-limit.*`, and the Redis parts of `app.capabilities.*` (cache, lease, rate-limit,
|
||||
the Redis idempotency store's tuning). The support leaf's `ModuleDefaultsEnvironmentPostProcessor`
|
||||
loads it below every application setting.
|
||||
|
||||
@@ -65,14 +65,14 @@ Redis is on when this module is present. It has one off switch:
|
||||
|
||||
A semantic role does **not** activate Redis by itself: with the switch off this module
|
||||
contributes no bean at all, whatever a role selector says. Redis idempotency refuses
|
||||
`ca-skeleton.capabilities.idempotency.key-version` other than 1 at startup (no dual-read yet).
|
||||
`app.capabilities.idempotency.key-version` other than 1 at startup (no dual-read yet).
|
||||
|
||||
Current role selectors are:
|
||||
|
||||
- cache: `ca-skeleton.capabilities.cache.bindings.default=redis`
|
||||
- rate limit: `ca-skeleton.capabilities.rate-limit.provider=redis`
|
||||
- lease: `ca-skeleton.capabilities.lease.provider=redis`
|
||||
- idempotency: `ca-skeleton.capabilities.idempotency.provider=redis`
|
||||
- cache: `app.capabilities.cache.bindings.default=redis`
|
||||
- rate limit: `app.capabilities.rate-limit.provider=redis`
|
||||
- lease: `app.capabilities.lease.provider=redis`
|
||||
- idempotency: `app.capabilities.idempotency.provider=redis`
|
||||
|
||||
Only selected capabilities contribute their application port bean.
|
||||
|
||||
@@ -182,7 +182,7 @@ The Redis idempotency adapter stores owner-safe claim state and executes claim/t
|
||||
programs atomically. `RedisIdempotencyConfig` contributes only the `IdempotencyStorePort`; the
|
||||
`IdempotencyExecutor` and its lifecycle policy (lease, replay TTL, retention, codec id, policy
|
||||
revision) come from app-bootstrap `IdempotencySettings`. This leaf reads only `key-version` and
|
||||
`command-timeout` under `ca-skeleton.capabilities.idempotency`.
|
||||
`command-timeout` under `app.capabilities.idempotency`.
|
||||
|
||||
Redis `TIME` determines lease deadlines. A failure after a command may have executed is returned
|
||||
as an indeterminate outcome; the adapter does not convert an ambiguous write into a clean
|
||||
|
||||
+2
-3
@@ -3,6 +3,7 @@ package dev.caskeleton.adapter.outbound.cache.redis.capability;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.cache.RedisCacheRegionAdapter;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.config.RedisRuntimeSettings;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.connection.RedisRuntimeOwner;
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilitySelectors;
|
||||
import dev.caskeleton.application.cache.CacheRegionPort;
|
||||
import dev.caskeleton.application.outbound.SecretSourcePort;
|
||||
import java.time.Clock;
|
||||
@@ -31,9 +32,7 @@ class RedisCacheConfig {
|
||||
* @return the cache region port
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(
|
||||
name = "ca-skeleton.capabilities.cache.bindings.default",
|
||||
havingValue = "redis")
|
||||
@ConditionalOnProperty(name = CapabilitySelectors.CACHE_DEFAULT_BINDING, havingValue = "redis")
|
||||
CacheRegionPort<String, byte[]> redisDefaultCacheRegion(
|
||||
RedisRuntimeOwner owner,
|
||||
RedisRuntimeSettings redis,
|
||||
|
||||
+15
-5
@@ -7,9 +7,9 @@ import dev.caskeleton.application.outbound.SecretSourcePort;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Composes the Redis semantic ports the deployment's role selectors asked for.
|
||||
@@ -37,7 +37,6 @@ import org.springframework.context.annotation.Import;
|
||||
* the deployment's {@code ~} pattern can actually fence.
|
||||
*/
|
||||
@AutoConfiguration(after = RedisRuntimeAutoConfiguration.class)
|
||||
@EnableConfigurationProperties(RedisCapabilitySettings.class)
|
||||
// The global switch, not a role selector. A role selector says which capability composes; it
|
||||
// never says Redis exists.
|
||||
@ConditionalOnProperty(prefix = "app.redis", name = "enabled", havingValue = "true")
|
||||
@@ -52,13 +51,24 @@ import org.springframework.context.annotation.Import;
|
||||
})
|
||||
public class RedisCapabilityConfig {
|
||||
|
||||
/**
|
||||
* The per-role settings, bound strictly and only while Redis is on.
|
||||
*
|
||||
* @param environment the environment to bind from
|
||||
* @return the bound settings
|
||||
*/
|
||||
@Bean
|
||||
RedisCapabilitySettings redisCapabilitySettings(Environment environment) {
|
||||
return RedisCapabilitySettings.bind(environment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bridges the deployment's configured secret backend into the Redis runtime.
|
||||
*
|
||||
* <p>Without it the runtime falls back to reading the process environment directly, which quietly
|
||||
* bypasses whichever backend {@code ca-skeleton.secret-source.strategy} selected — so a
|
||||
* deployment using a secret manager would resolve its Redis credential from an environment
|
||||
* variable that is not supposed to hold it.
|
||||
* bypasses whichever backend {@code app.secret-source.strategy} selected — so a deployment using
|
||||
* a secret manager would resolve its Redis credential from an environment variable that is not
|
||||
* supposed to hold it.
|
||||
*
|
||||
* @param secretSource the configured backend
|
||||
* @return the runtime's view of it
|
||||
|
||||
+36
-8
@@ -1,29 +1,58 @@
|
||||
package dev.caskeleton.adapter.outbound.cache.redis.capability;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilitySelectors;
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilityStartupValidationException;
|
||||
import dev.caskeleton.adapter.outbound.support.StrictSettingsBinder;
|
||||
import java.time.Duration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
import java.util.Set;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* The per-capability knobs the Redis composition reads.
|
||||
*
|
||||
* <p>One class rather than four, bound at {@code ca-skeleton.capabilities}, because the
|
||||
* capabilities share the decisions that matter: which provider is selected, how long a command may
|
||||
* take, and where the material that digests a caller's identifier comes from. Splitting them
|
||||
* produced four near-identical records and four places to forget the same setting.
|
||||
* <p>One class rather than four, bound at {@code app.capabilities}, because the capabilities share
|
||||
* the decisions that matter: which provider is selected, how long a command may take, and where the
|
||||
* material that digests a caller's identifier comes from. Splitting them produced four
|
||||
* near-identical records and four places to forget the same setting.
|
||||
*
|
||||
* <p>What is deliberately <em>not</em> here is a namespace. Each capability used to carry its own
|
||||
* {@code namespace-application} and {@code namespace-environment}, which is how the deployment
|
||||
* ended up with four key prefixes, none of which matched the ACL pattern that was supposed to fence
|
||||
* it in. The namespace now comes from {@code app.redis.namespace}, once, and every capability
|
||||
* renders below it.
|
||||
*
|
||||
* <p>Bound strictly ({@link #bind}) by the gated composition, so a misspelt key under {@code
|
||||
* app.capabilities} fails startup. The idempotency lifecycle policy under the same prefix belongs
|
||||
* to {@code composition:idempotency} and is left to it.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "ca-skeleton.capabilities")
|
||||
public class RedisCapabilitySettings {
|
||||
|
||||
/**
|
||||
* Idempotency keys under the prefix that {@code composition:idempotency} binds, not this class.
|
||||
*/
|
||||
static final Set<String> LIFECYCLE_OWNED_KEYS =
|
||||
Set.of(
|
||||
"idempotency.processing-lease",
|
||||
"idempotency.replay-ttl",
|
||||
"idempotency.failure-retention",
|
||||
"idempotency.response-codec-id",
|
||||
"idempotency.policy-revision",
|
||||
"idempotency.reaper-interval");
|
||||
|
||||
/**
|
||||
* Binds {@link CapabilitySelectors#ROOT} strictly, leaving the idempotency lifecycle policy to
|
||||
* its owner.
|
||||
*
|
||||
* @param environment the environment to bind from
|
||||
* @return the bound settings
|
||||
*/
|
||||
static RedisCapabilitySettings bind(Environment environment) {
|
||||
return StrictSettingsBinder.bindExcept(
|
||||
environment, CapabilitySelectors.ROOT, RedisCapabilitySettings.class, LIFECYCLE_OWNED_KEYS);
|
||||
}
|
||||
|
||||
private final Cache cache = new Cache();
|
||||
private final RateLimit rateLimit = new RateLimit();
|
||||
private final Lease lease = new Lease();
|
||||
@@ -33,7 +62,6 @@ public class RedisCapabilitySettings {
|
||||
return cache;
|
||||
}
|
||||
|
||||
@NestedConfigurationProperty
|
||||
public RateLimit getRateLimit() {
|
||||
return rateLimit;
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
package dev.caskeleton.adapter.outbound.cache.redis.capability;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.config.RedisCorrectnessRequirement;
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilitySelectors;
|
||||
import java.util.List;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@@ -48,35 +49,35 @@ public final class RedisCorrectnessRoleSelectors implements RedisCorrectnessRequ
|
||||
static final List<Role> ROLES =
|
||||
List.of(
|
||||
new Role(
|
||||
"ca-skeleton.capabilities.cache.bindings.default",
|
||||
CapabilitySelectors.CACHE_DEFAULT_BINDING,
|
||||
"disabled",
|
||||
"redis",
|
||||
false,
|
||||
false,
|
||||
List.of("APP_CACHE_REDIS_PASSWORD", "APP_CACHE_REDIS_KEY_HMAC_SECRET")),
|
||||
new Role(
|
||||
"ca-skeleton.security.auth-mode",
|
||||
"app.security.auth-mode",
|
||||
"jwt",
|
||||
"redis-session",
|
||||
true,
|
||||
false,
|
||||
List.of("APP_SESSION_REDIS_PASSWORD", "APP_SESSION_REDIS_KEY_HMAC_SECRET")),
|
||||
new Role(
|
||||
"ca-skeleton.capabilities.idempotency.provider",
|
||||
CapabilitySelectors.IDEMPOTENCY_PROVIDER,
|
||||
"disabled",
|
||||
"redis",
|
||||
true,
|
||||
true,
|
||||
List.of("APP_IDEMPOTENCY_REDIS_KEY_HMAC_SECRET")),
|
||||
new Role(
|
||||
"ca-skeleton.capabilities.rate-limit.provider",
|
||||
CapabilitySelectors.RATE_LIMIT_PROVIDER,
|
||||
"disabled",
|
||||
"redis",
|
||||
true,
|
||||
true,
|
||||
List.of("APP_RATE_LIMIT_REDIS_PASSWORD", "APP_RATE_LIMIT_REDIS_KEY_HMAC_SECRET")),
|
||||
new Role(
|
||||
"ca-skeleton.capabilities.lease.provider",
|
||||
CapabilitySelectors.LEASE_PROVIDER,
|
||||
"disabled",
|
||||
"redis",
|
||||
true,
|
||||
|
||||
+4
-5
@@ -4,6 +4,7 @@ import dev.caskeleton.adapter.outbound.cache.redis.idempotency.IdempotencyScript
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.idempotency.RedisIdempotencyStoreAdapter;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.config.RedisRuntimeSettings;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.connection.RedisRuntimeOwner;
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilitySelectors;
|
||||
import dev.caskeleton.adapter.outbound.support.startup.StartupPhase;
|
||||
import dev.caskeleton.adapter.outbound.support.startup.StartupValidationContext;
|
||||
import dev.caskeleton.application.idempotency.IdempotencyStorePort;
|
||||
@@ -29,9 +30,7 @@ class RedisIdempotencyConfig {
|
||||
* @return the store port
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(
|
||||
name = "ca-skeleton.capabilities.idempotency.provider",
|
||||
havingValue = "redis")
|
||||
@ConditionalOnProperty(name = CapabilitySelectors.IDEMPOTENCY_PROVIDER, havingValue = "redis")
|
||||
IdempotencyStorePort redisIdempotencyStore(
|
||||
RedisRuntimeOwner owner,
|
||||
RedisRuntimeSettings redis,
|
||||
@@ -42,10 +41,10 @@ class RedisIdempotencyConfig {
|
||||
// A new key version would orphan every replay record written under the old one; refused
|
||||
// until a migration can read the previous keyspace during the replay-retention window.
|
||||
StartupValidationContext.forPhase(StartupPhase.ADAPTER_ENABLEMENT)
|
||||
.reject("ca-skeleton.capabilities.idempotency.key-version=" + idempotency.getKeyVersion())
|
||||
.reject("app.capabilities.idempotency.key-version=" + idempotency.getKeyVersion())
|
||||
.failIfViolated(
|
||||
"Redis idempotency key-version rotation is unsupported without dual-read",
|
||||
"keep ca-skeleton.capabilities.idempotency.key-version=1 until a migration can read "
|
||||
"keep app.capabilities.idempotency.key-version=1 until a migration can read "
|
||||
+ "the previous keyspace during the replay-retention window.");
|
||||
}
|
||||
return new RedisIdempotencyStoreAdapter(
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import dev.caskeleton.adapter.outbound.cache.redis.lease.LeaseScripts;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.lease.RedisDistributedLeaseAdapter;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.config.RedisRuntimeSettings;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.connection.RedisRuntimeOwner;
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilitySelectors;
|
||||
import dev.caskeleton.application.lease.DistributedLeasePort;
|
||||
import java.time.Clock;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -24,7 +25,7 @@ class RedisLeaseConfig {
|
||||
* @return the lease port
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "ca-skeleton.capabilities.lease.provider", havingValue = "redis")
|
||||
@ConditionalOnProperty(name = CapabilitySelectors.LEASE_PROVIDER, havingValue = "redis")
|
||||
DistributedLeasePort redisDistributedLeasePort(
|
||||
RedisRuntimeOwner owner,
|
||||
RedisRuntimeSettings redis,
|
||||
|
||||
+5
-6
@@ -8,6 +8,7 @@ import dev.caskeleton.adapter.outbound.cache.redis.ratelimit.RateLimitScripts;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.ratelimit.RedisEdgeRateLimitAdapter;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.config.RedisRuntimeSettings;
|
||||
import dev.caskeleton.adapter.outbound.cache.redis.runtime.connection.RedisRuntimeOwner;
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilitySelectors;
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilityStartupValidationException;
|
||||
import dev.caskeleton.shared.ratelimit.EdgeRateLimitPort;
|
||||
import dev.caskeleton.shared.ratelimit.RateParameters;
|
||||
@@ -44,9 +45,7 @@ class RedisRateLimitConfig {
|
||||
* @return the rate limit port
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(
|
||||
name = "ca-skeleton.capabilities.rate-limit.provider",
|
||||
havingValue = "redis")
|
||||
@ConditionalOnProperty(name = CapabilitySelectors.RATE_LIMIT_PROVIDER, havingValue = "redis")
|
||||
EdgeRateLimitPort redisEdgeRateLimitPort(
|
||||
RedisRuntimeOwner owner,
|
||||
RedisRuntimeSettings redis,
|
||||
@@ -55,7 +54,7 @@ class RedisRateLimitConfig {
|
||||
Environment environment) {
|
||||
RedisCapabilitySettings.RateLimit rateLimit = capabilities.getRateLimit();
|
||||
// The id the HTTP boundary sends when a route names none. One key, app.rate-limit.*, read by
|
||||
// both sides: a second copy under ca-skeleton.capabilities bound to the same env var could be
|
||||
// both sides: a second copy under app.capabilities bound to the same env var could be
|
||||
// overridden alone, and this check would then approve a policy nobody requests.
|
||||
String defaultPolicyId = environment.getProperty(DEFAULT_POLICY_ID, "api-default");
|
||||
return new RedisEdgeRateLimitAdapter(
|
||||
@@ -75,7 +74,7 @@ class RedisRateLimitConfig {
|
||||
// port reports as a deployment error on every call rather than once at startup.
|
||||
throw new CapabilityStartupValidationException(
|
||||
"the Redis rate limiter is selected but no policy is configured under"
|
||||
+ " ca-skeleton.capabilities.rate-limit.policies");
|
||||
+ " app.capabilities.rate-limit.policies");
|
||||
}
|
||||
Map<String, RateLimitPolicy> policies = new LinkedHashMap<>();
|
||||
rateLimit
|
||||
@@ -126,7 +125,7 @@ class RedisRateLimitConfig {
|
||||
// limit it believes is permissive and is not.
|
||||
throw new CapabilityStartupValidationException(
|
||||
"only fail-closed is supported for the Redis rate limiter, but"
|
||||
+ " ca-skeleton.capabilities.rate-limit.failure-policy is '"
|
||||
+ " app.capabilities.rate-limit.failure-policy is '"
|
||||
+ rateLimit.getFailurePolicy()
|
||||
+ "'");
|
||||
}
|
||||
|
||||
-2
@@ -18,8 +18,6 @@ app:
|
||||
default-policy-id: ${APP_RATE_LIMIT_DEFAULT_POLICY_ID:api-default}
|
||||
hash-key-version: ${APP_RATE_LIMIT_HASH_KEY_VERSION:1}
|
||||
caller-deadline-budget: 2s
|
||||
|
||||
ca-skeleton:
|
||||
capabilities:
|
||||
# Every capability below renders its keys under one namespace — app.redis.namespace, which is
|
||||
# {environment}:{service}:{domain}. The per-capability namespace-application /
|
||||
|
||||
+47
-16
@@ -59,11 +59,11 @@ class RedisCapabilityCompositionTest {
|
||||
"app.redis.namespace.domain=shared",
|
||||
"app.redis.authentication.credential-reference="
|
||||
+ "secret://ca-skeleton-application@environment/APP_REDIS_PASSWORD",
|
||||
"ca-skeleton.capabilities.cache.key-hmac-secret-reference="
|
||||
"app.capabilities.cache.key-hmac-secret-reference="
|
||||
+ "secret://environment/APP_CACHE_REDIS_KEY_HMAC_SECRET",
|
||||
"ca-skeleton.capabilities.rate-limit.policies.api-default.algorithm=sliding-counter",
|
||||
"ca-skeleton.capabilities.rate-limit.policies.api-default.limit=100",
|
||||
"ca-skeleton.capabilities.rate-limit.policies.api-default.window=1s");
|
||||
"app.capabilities.rate-limit.policies.api-default.algorithm=sliding-counter",
|
||||
"app.capabilities.rate-limit.policies.api-default.limit=100",
|
||||
"app.capabilities.rate-limit.policies.api-default.window=1s");
|
||||
|
||||
@Test
|
||||
@DisplayName("Redis on with no role selected composes a runtime and no semantic port")
|
||||
@@ -83,7 +83,7 @@ class RedisCapabilityCompositionTest {
|
||||
@DisplayName("the cache binding composes a cache region and nothing else")
|
||||
void cacheBindingComposesTheCacheRegion() {
|
||||
runner
|
||||
.withPropertyValues("ca-skeleton.capabilities.cache.bindings.default=redis")
|
||||
.withPropertyValues("app.capabilities.cache.bindings.default=redis")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -106,7 +106,7 @@ class RedisCapabilityCompositionTest {
|
||||
"app.redis.enabled=true",
|
||||
"app.redis.nodes=redis-a:6379",
|
||||
"app.redis.authentication.credential-reference=secret://u@environment/PW",
|
||||
"ca-skeleton.capabilities.rate-limit.provider=redis")
|
||||
"app.capabilities.rate-limit.provider=redis")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasFailed();
|
||||
@@ -121,7 +121,7 @@ class RedisCapabilityCompositionTest {
|
||||
// given
|
||||
ApplicationContextRunner limiter =
|
||||
runner.withPropertyValues(
|
||||
"ca-skeleton.capabilities.rate-limit.provider=redis",
|
||||
"app.capabilities.rate-limit.provider=redis",
|
||||
"app.rate-limit.default-policy-id=missing-policy");
|
||||
|
||||
// when & then
|
||||
@@ -133,15 +133,46 @@ class RedisCapabilityCompositionTest {
|
||||
+ " policies"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("app.capabilities 아래 오타 키는 기동을 실패시킨다")
|
||||
void aMisspelledCapabilityKeyFailsStartup() {
|
||||
// when
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"app.capabilities.lease.provider=redis", "app.capabilities.lease.drift-budgt=5ms")
|
||||
.run(
|
||||
context -> {
|
||||
// then
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure()).hasStackTraceContaining("drift-budgt");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("멱등성 lifecycle 키는 composition:idempotency의 것이라 Redis 설정이 거부하지 않는다")
|
||||
void theIdempotencyLifecycleKeysAreLeftToTheirOwner() {
|
||||
// when
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"app.capabilities.idempotency.provider=redis",
|
||||
"app.capabilities.idempotency.replay-ttl=1h",
|
||||
"app.capabilities.idempotency.processing-lease=10s")
|
||||
.run(
|
||||
context -> {
|
||||
// then
|
||||
assertThat(context).hasNotFailed();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("every selected role composes at once, under one namespace")
|
||||
void allRolesComposeTogether() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.capabilities.cache.bindings.default=redis",
|
||||
"ca-skeleton.capabilities.rate-limit.provider=redis",
|
||||
"ca-skeleton.capabilities.lease.provider=redis",
|
||||
"ca-skeleton.capabilities.idempotency.provider=redis")
|
||||
"app.capabilities.cache.bindings.default=redis",
|
||||
"app.capabilities.rate-limit.provider=redis",
|
||||
"app.capabilities.lease.provider=redis",
|
||||
"app.capabilities.idempotency.provider=redis")
|
||||
.run(
|
||||
context -> {
|
||||
assertThat(context).hasNotFailed();
|
||||
@@ -156,13 +187,13 @@ class RedisCapabilityCompositionTest {
|
||||
void redisIdempotencyRefusesAKeyVersionRotationUntilDualReadExists() {
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"ca-skeleton.capabilities.idempotency.provider=redis",
|
||||
"ca-skeleton.capabilities.idempotency.key-version=2")
|
||||
"app.capabilities.idempotency.provider=redis",
|
||||
"app.capabilities.idempotency.key-version=2")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context.getStartupFailure())
|
||||
.hasRootCauseInstanceOf(StartupFailureException.class)
|
||||
.hasStackTraceContaining("ca-skeleton.capabilities.idempotency.key-version=2")
|
||||
.hasStackTraceContaining("app.capabilities.idempotency.key-version=2")
|
||||
.hasStackTraceContaining("unsupported without dual-read"));
|
||||
}
|
||||
|
||||
@@ -174,8 +205,8 @@ class RedisCapabilityCompositionTest {
|
||||
.withUserConfiguration(Support.class)
|
||||
.withPropertyValues(
|
||||
"app.redis.enabled=false",
|
||||
"ca-skeleton.capabilities.cache.bindings.default=redis",
|
||||
"ca-skeleton.capabilities.lease.provider=redis")
|
||||
"app.capabilities.cache.bindings.default=redis",
|
||||
"app.capabilities.lease.provider=redis")
|
||||
.run(context -> assertThat(redisBeans(context)).isEmpty());
|
||||
}
|
||||
|
||||
|
||||
+6
-7
@@ -22,23 +22,23 @@ class RedisProductionSecretsTest {
|
||||
static Stream<Arguments> selectedRoles() {
|
||||
return Stream.of(
|
||||
Arguments.of(
|
||||
"ca-skeleton.capabilities.cache.bindings.default",
|
||||
"app.capabilities.cache.bindings.default",
|
||||
"redis",
|
||||
List.of("APP_CACHE_REDIS_PASSWORD", "APP_CACHE_REDIS_KEY_HMAC_SECRET")),
|
||||
Arguments.of(
|
||||
"ca-skeleton.security.auth-mode",
|
||||
"app.security.auth-mode",
|
||||
"redis-session",
|
||||
List.of("APP_SESSION_REDIS_PASSWORD", "APP_SESSION_REDIS_KEY_HMAC_SECRET")),
|
||||
Arguments.of(
|
||||
"ca-skeleton.capabilities.idempotency.provider",
|
||||
"app.capabilities.idempotency.provider",
|
||||
"redis",
|
||||
List.of("APP_IDEMPOTENCY_REDIS_KEY_HMAC_SECRET")),
|
||||
Arguments.of(
|
||||
"ca-skeleton.capabilities.rate-limit.provider",
|
||||
"app.capabilities.rate-limit.provider",
|
||||
"redis",
|
||||
List.of("APP_RATE_LIMIT_REDIS_PASSWORD", "APP_RATE_LIMIT_REDIS_KEY_HMAC_SECRET")),
|
||||
Arguments.of(
|
||||
"ca-skeleton.capabilities.lease.provider",
|
||||
"app.capabilities.lease.provider",
|
||||
"redis",
|
||||
List.of("APP_LEASE_REDIS_KEY_HMAC_SECRET")));
|
||||
}
|
||||
@@ -68,8 +68,7 @@ class RedisProductionSecretsTest {
|
||||
void aRoleSelectingAnotherProviderRequiresNothingOfRedis() {
|
||||
// given
|
||||
MockEnvironment environment =
|
||||
new MockEnvironment()
|
||||
.withProperty("ca-skeleton.capabilities.rate-limit.provider", "disabled");
|
||||
new MockEnvironment().withProperty("app.capabilities.rate-limit.provider", "disabled");
|
||||
|
||||
// when
|
||||
List<String> required = secrets.requiredSecrets(environment);
|
||||
|
||||
+2
-2
@@ -114,7 +114,7 @@ class RedisReadinessGroupPostProcessorTest {
|
||||
@DisplayName("cache-only: Redis is on, readiness still does not gate on it")
|
||||
void cacheOnlyDoesNotGateReadiness() throws IOException {
|
||||
Map<String, Object> properties = redisOn();
|
||||
properties.put("ca-skeleton.capabilities.cache.bindings.default", "redis");
|
||||
properties.put("app.capabilities.cache.bindings.default", "redis");
|
||||
try (ConfigurableApplicationContext context = boot(properties)) {
|
||||
HealthEndpointGroup readiness = context.getBean(HealthEndpointGroups.class).get("readiness");
|
||||
assertThat(context.getBeansOfType(HealthIndicator.class))
|
||||
@@ -132,7 +132,7 @@ class RedisReadinessGroupPostProcessorTest {
|
||||
@DisplayName("a correctness role: the contributor exists and readiness gates on it")
|
||||
void correctnessRoleGatesReadiness() throws IOException {
|
||||
Map<String, Object> properties = redisOn();
|
||||
properties.put("ca-skeleton.capabilities.lease.provider", "redis");
|
||||
properties.put("app.capabilities.lease.provider", "redis");
|
||||
try (ConfigurableApplicationContext context = boot(properties)) {
|
||||
HealthEndpointGroup readiness = context.getBean(HealthEndpointGroups.class).get("readiness");
|
||||
assertThat(context.getBeansOfType(HealthIndicator.class)).containsKey("redisRequired");
|
||||
|
||||
-179
@@ -1,179 +0,0 @@
|
||||
package dev.caskeleton.adapter.outbound.httpclient.autoconfigure;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilityStartupValidationException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.RecordComponent;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.core.env.SystemEnvironmentPropertySource;
|
||||
|
||||
/**
|
||||
* The environment surface of {@link HttpClientPlatformSettings}, derived from the record tree.
|
||||
*
|
||||
* <p>This exists because strict binding cannot see a misspelled environment variable. Spring
|
||||
* resolves {@code APP_HTTPCLIENT_CLIENTS_0_BASE_URL} to {@code app.httpclient.clients[0].base-url}
|
||||
* by mapping the requested property name back to an environment name, but it <em>enumerates</em>
|
||||
* the same variable as {@code app.httpclient.clients[0].base.url} — underscores become dots, never
|
||||
* hyphens. {@code NoUnboundElementsBindHandler} compares against that enumeration, so pointing it
|
||||
* at the system environment reports correctly-spelled variables as unbound while still saying
|
||||
* nothing about a genuinely misspelled one. The check therefore runs the other way round: derive
|
||||
* the names the settings tree accepts, and reject an {@code APP_HTTPCLIENT_} variable that is not
|
||||
* among them.
|
||||
*
|
||||
* <p>Without it {@code APP_HTTPCLIENT_CLIENTS_0_TIMEUOT_TOTAL_CALL} would leave the client running
|
||||
* the default four-second budget while the deployment's manifest says six, and nothing anywhere
|
||||
* would mention it.
|
||||
*/
|
||||
final class HttpClientEnvironmentKeys {
|
||||
|
||||
/** Environment form of {@link HttpClientPlatformSettings#PREFIX}, with its trailing separator. */
|
||||
static final String ENV_PREFIX = "APP_HTTPCLIENT_";
|
||||
|
||||
/** Deepest list nesting {@link #indexLetter} can name. */
|
||||
private static final int MAXIMUM_LIST_DEPTH = 1;
|
||||
|
||||
private static final java.util.regex.Pattern SEGMENT_SEPARATOR =
|
||||
java.util.regex.Pattern.compile("_");
|
||||
|
||||
private HttpClientEnvironmentKeys() {}
|
||||
|
||||
/**
|
||||
* Maps each leaf property path to the environment variable template that sets it.
|
||||
*
|
||||
* <p>A list index is rendered as a letter rather than a number, so the result describes a
|
||||
* template rather than one deployment's cardinality: {@code N} for the outermost list, {@code M}
|
||||
* inside it.
|
||||
*
|
||||
* @return leaf property path to environment variable template, in declaration order
|
||||
*/
|
||||
static Map<String, String> fieldToEnvTemplate() {
|
||||
Map<String, String> templates = new LinkedHashMap<>();
|
||||
collect(HttpClientPlatformSettings.class, "APP_HTTPCLIENT", "", 0, templates);
|
||||
return templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refuses an {@code APP_HTTPCLIENT_} variable that maps to no field.
|
||||
*
|
||||
* @param environment the environment to inspect; sources other than the system environment are
|
||||
* covered by strict binding and are not re-checked here
|
||||
* @throws IllegalStateException listing every unrecognised variable, so an operator fixes them in
|
||||
* one pass rather than one restart at a time
|
||||
*/
|
||||
static void rejectUnrecognised(Environment environment) {
|
||||
if (!(environment instanceof ConfigurableEnvironment configurable)) {
|
||||
return;
|
||||
}
|
||||
Set<String> accepted = Set.copyOf(fieldToEnvTemplate().values());
|
||||
Set<String> unrecognised = new TreeSet<>();
|
||||
for (PropertySource<?> source : configurable.getPropertySources()) {
|
||||
if (!(source instanceof SystemEnvironmentPropertySource environmentSource)) {
|
||||
continue;
|
||||
}
|
||||
for (String name : environmentSource.getPropertyNames()) {
|
||||
String canonical = name.toUpperCase(Locale.ROOT);
|
||||
if (canonical.startsWith(ENV_PREFIX) && !accepted.contains(asTemplate(canonical))) {
|
||||
unrecognised.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!unrecognised.isEmpty()) {
|
||||
throw new CapabilityStartupValidationException(
|
||||
"unrecognised HTTP client environment variables "
|
||||
+ unrecognised
|
||||
+ "; see docs/httpclient/env-fields.yaml for the accepted names");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces each index with the letter its depth uses, so a concrete variable can be looked up.
|
||||
*
|
||||
* <p>Only a wholly numeric segment is an index. A field whose name happens to end in digits stays
|
||||
* literal, which is why {@code DRAFT12} would not be mistaken for a position.
|
||||
*/
|
||||
private static String asTemplate(String environmentName) {
|
||||
// -1 keeps trailing empty segments, so a stray trailing underscore stays visible and is
|
||||
// rejected rather than normalised away into a name that happens to match.
|
||||
String[] segments = SEGMENT_SEPARATOR.split(environmentName, -1);
|
||||
int listDepth = 0;
|
||||
StringBuilder template = new StringBuilder(environmentName.length());
|
||||
for (int index = 0; index < segments.length; index++) {
|
||||
if (index > 0) {
|
||||
template.append('_');
|
||||
}
|
||||
String segment = segments[index];
|
||||
if (!segment.isEmpty() && segment.chars().allMatch(Character::isDigit)) {
|
||||
if (listDepth > MAXIMUM_LIST_DEPTH) {
|
||||
// Deeper than any field can express, so it cannot name one. Left literal, which no
|
||||
// template matches, so the variable is reported rather than silently accepted.
|
||||
template.append(segment);
|
||||
continue;
|
||||
}
|
||||
template.append(indexLetter(listDepth));
|
||||
listDepth++;
|
||||
} else {
|
||||
template.append(segment);
|
||||
}
|
||||
}
|
||||
return template.toString();
|
||||
}
|
||||
|
||||
private static void collect(
|
||||
Class<?> type, String envPrefix, String pathPrefix, int listDepth, Map<String, String> into) {
|
||||
for (RecordComponent component : type.getRecordComponents()) {
|
||||
String property = camelToKebab(component.getName());
|
||||
String path = pathPrefix.isEmpty() ? property : pathPrefix + "." + property;
|
||||
String env = envPrefix + "_" + camelToScreamingSnake(component.getName());
|
||||
Class<?> componentType = component.getType();
|
||||
if (componentType.isRecord()) {
|
||||
collect(componentType, env, path, listDepth, into);
|
||||
continue;
|
||||
}
|
||||
if (List.class.isAssignableFrom(componentType)) {
|
||||
String index = indexLetter(listDepth);
|
||||
Class<?> element = elementTypeOf(component);
|
||||
if (element != null && element.isRecord()) {
|
||||
collect(element, env + "_" + index, path + "[" + index + "]", listDepth + 1, into);
|
||||
} else {
|
||||
into.put(path + "[" + index + "]", env + "_" + index);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
into.put(path, env);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@code N} for the outermost list, {@code M} inside it. No settings field nests deeper. */
|
||||
private static String indexLetter(int depth) {
|
||||
return switch (depth) {
|
||||
case 0 -> "N";
|
||||
case 1 -> "M";
|
||||
default ->
|
||||
throw new IllegalStateException(
|
||||
"list nesting deeper than the environment template can express");
|
||||
};
|
||||
}
|
||||
|
||||
private static Class<?> elementTypeOf(RecordComponent component) {
|
||||
if (component.getGenericType() instanceof ParameterizedType parameterized
|
||||
&& parameterized.getActualTypeArguments()[0] instanceof Class<?> element) {
|
||||
return element;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String camelToKebab(String name) {
|
||||
return name.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
private static String camelToScreamingSnake(String name) {
|
||||
return name.replaceAll("([a-z0-9])([A-Z])", "$1_$2").toUpperCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -187,8 +187,7 @@ public record HttpClientPlatformSettings(
|
||||
@DefaultValue("1s") Duration requestWriteIdle,
|
||||
@DefaultValue("2s") Duration responseHeader,
|
||||
@DefaultValue("3s") Duration readIdle,
|
||||
@DefaultValue("4s") Duration totalCall,
|
||||
@DefaultValue("30s") Duration streamingIdle) {}
|
||||
@DefaultValue("4s") Duration totalCall) {}
|
||||
|
||||
/** Redirect policy; disabled by default (design §12.4). */
|
||||
public record Redirect(
|
||||
|
||||
+7
-16
@@ -2,32 +2,23 @@ package dev.caskeleton.adapter.outbound.httpclient.autoconfigure;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.StrictSettingsBinder;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.SystemEnvironmentPropertySource;
|
||||
|
||||
/**
|
||||
* Binds {@link HttpClientPlatformSettings} strictly, and only when asked.
|
||||
*
|
||||
* <p>The mechanics live in {@link StrictSettingsBinder} (BOOT-011). What stays here is this
|
||||
* platform's one genuine difference: strictness needs two mechanisms because one does not cover
|
||||
* both surfaces.
|
||||
*
|
||||
* <p>Property sources that enumerate their keys in property form — YAML, properties files, test
|
||||
* overrides — are checked by the shared binder's unbound-element handler. The system environment is
|
||||
* excluded from it and checked by {@link HttpClientEnvironmentKeys#rejectUnrecognised} instead:
|
||||
* Spring enumerates {@code APP_HTTPCLIENT_CLIENTS_0_BASE_URL} as {@code ...clients[0].base.url}
|
||||
* while binding it as {@code ...clients[0].base-url}, so leaving it to the handler would reject
|
||||
* every correctly spelled variable and still miss the misspelled ones.
|
||||
* <p>The mechanics live in {@link StrictSettingsBinder} (BOOT-011), including the check this
|
||||
* platform used to carry alone: a misspelt {@code APP_HTTPCLIENT_*} variable is refused by name.
|
||||
* Spring enumerates the system environment in a form strict binding cannot compare, so the shared
|
||||
* binder checks it the other way round — against the names of the fields it bound — for every
|
||||
* capability rather than, as before, for this one settings type by reflection over its records
|
||||
* (S3-lead-2).
|
||||
*/
|
||||
final class HttpClientPlatformSettingsBinder {
|
||||
|
||||
private HttpClientPlatformSettingsBinder() {}
|
||||
|
||||
static HttpClientPlatformSettings bind(Environment environment) {
|
||||
HttpClientEnvironmentKeys.rejectUnrecognised(environment);
|
||||
return StrictSettingsBinder.bind(
|
||||
environment,
|
||||
HttpClientPlatformSettings.PREFIX,
|
||||
HttpClientPlatformSettings.class,
|
||||
source -> !(source.getUnderlyingSource() instanceof SystemEnvironmentPropertySource));
|
||||
environment, HttpClientPlatformSettings.PREFIX, HttpClientPlatformSettings.class);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -94,8 +94,7 @@ public final class HttpClientProfileFactory {
|
||||
timeout.requestWriteIdle(),
|
||||
timeout.responseHeader(),
|
||||
timeout.readIdle(),
|
||||
timeout.totalCall(),
|
||||
timeout.streamingIdle());
|
||||
timeout.totalCall());
|
||||
}
|
||||
|
||||
private AuthenticationSettings authentication(
|
||||
|
||||
+2
-5
@@ -7,8 +7,7 @@ import java.util.Objects;
|
||||
* Stage timeouts and the total call budget (design §15.1).
|
||||
*
|
||||
* <p>{@link #totalCall()} is the upper budget for everything, including pool acquire and retry
|
||||
* backoff. {@link #streamingIdle()} is deliberately separate so a long-lived SSE stream is not
|
||||
* killed by the request-shaped total budget (design §15.3).
|
||||
* backoff.
|
||||
*/
|
||||
public record TimeoutSettings(
|
||||
// Hostname resolution budget. Currently unenforced: neither the Apache classic client nor the
|
||||
@@ -21,8 +20,7 @@ public record TimeoutSettings(
|
||||
Duration requestWriteIdle,
|
||||
Duration responseHeader,
|
||||
Duration readIdle,
|
||||
Duration totalCall,
|
||||
Duration streamingIdle) {
|
||||
Duration totalCall) {
|
||||
|
||||
/**
|
||||
* The shipped {@code timeout.dns} default.
|
||||
@@ -41,6 +39,5 @@ public record TimeoutSettings(
|
||||
Objects.requireNonNull(responseHeader, "response header timeout");
|
||||
Objects.requireNonNull(readIdle, "read idle timeout");
|
||||
Objects.requireNonNull(totalCall, "total call timeout");
|
||||
Objects.requireNonNull(streamingIdle, "streaming idle timeout");
|
||||
}
|
||||
}
|
||||
|
||||
+49
-1
@@ -6,11 +6,14 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import dev.caskeleton.adapter.outbound.httpclient.profile.HttpProtocol;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.RecordComponent;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -43,7 +46,7 @@ class HttpClientPlatformEnvManifestTest {
|
||||
@Test
|
||||
@DisplayName("the manifest and the settings tree describe the same fields")
|
||||
void theManifestAndTheSettingsTreeAgree() {
|
||||
Map<String, String> derived = HttpClientEnvironmentKeys.fieldToEnvTemplate();
|
||||
Map<String, String> derived = fieldToEnvTemplate();
|
||||
|
||||
assertThat(derived).as("the derivation itself must find something").isNotEmpty();
|
||||
assertThat(manifest())
|
||||
@@ -205,4 +208,49 @@ class HttpClientPlatformEnvManifestTest {
|
||||
throw new UncheckedIOException(path + " could not be read", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps each leaf property path of the settings tree to the environment variable template that
|
||||
* sets it — the manifest's content, derived.
|
||||
*
|
||||
* <p>A list index is rendered as a letter rather than a number, so the result describes a
|
||||
* template rather than one deployment's cardinality: {@code N} for the outermost list, {@code M}
|
||||
* inside it. This lives in the test: the runtime refuses a misspelt variable through the shared
|
||||
* strict binder and needs no reflective copy of the tree (S3-lead-2).
|
||||
*/
|
||||
private static Map<String, String> fieldToEnvTemplate() {
|
||||
Map<String, String> templates = new LinkedHashMap<>();
|
||||
collect(HttpClientPlatformSettings.class, "APP_HTTPCLIENT", "", 0, templates);
|
||||
return templates;
|
||||
}
|
||||
|
||||
private static void collect(
|
||||
Class<?> type, String envPrefix, String pathPrefix, int listDepth, Map<String, String> into) {
|
||||
for (RecordComponent component : type.getRecordComponents()) {
|
||||
String property = component.getName().replaceAll("([a-z0-9])([A-Z])", "$1-$2");
|
||||
property = property.toLowerCase(Locale.ROOT);
|
||||
String path = pathPrefix.isEmpty() ? property : pathPrefix + "." + property;
|
||||
String env = envPrefix + "_" + property.replace('-', '_').toUpperCase(Locale.ROOT);
|
||||
Class<?> componentType = component.getType();
|
||||
if (componentType.isRecord()) {
|
||||
collect(componentType, env, path, listDepth, into);
|
||||
continue;
|
||||
}
|
||||
if (List.class.isAssignableFrom(componentType)) {
|
||||
String index = listDepth == 0 ? "N" : "M";
|
||||
Class<?> element =
|
||||
component.getGenericType() instanceof ParameterizedType parameterized
|
||||
&& parameterized.getActualTypeArguments()[0] instanceof Class<?> resolved
|
||||
? resolved
|
||||
: null;
|
||||
if (element != null && element.isRecord()) {
|
||||
collect(element, env + "_" + index, path + "[" + index + "]", listDepth + 1, into);
|
||||
} else {
|
||||
into.put(path + "[" + index + "]", env + "_" + index);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
into.put(path, env);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -52,8 +52,7 @@ public final class ClientProfiles {
|
||||
Duration.ofSeconds(1),
|
||||
Duration.ofSeconds(2),
|
||||
Duration.ofSeconds(3),
|
||||
Duration.ofSeconds(4),
|
||||
Duration.ofSeconds(30));
|
||||
Duration.ofSeconds(4));
|
||||
}
|
||||
|
||||
public static ResponseLimits responseLimits() {
|
||||
@@ -110,8 +109,7 @@ public final class ClientProfiles {
|
||||
base.requestWriteIdle(),
|
||||
Duration.ofMillis(200),
|
||||
base.readIdle(),
|
||||
totalCall,
|
||||
base.streamingIdle()))
|
||||
totalCall))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
-2
@@ -7,7 +7,6 @@ import dev.caskeleton.application.outbox.OutboxMessagePublishPort;
|
||||
import dev.caskeleton.application.outbox.OutboxRelayFailureReportPort;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -21,7 +20,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
* was wanted, and nothing can publish.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(MessagingSettings.class)
|
||||
public class MessagingConfig {
|
||||
|
||||
/** The {@code dependency_name} the relay's failure log carries when no broker is named. */
|
||||
|
||||
+36
-2
@@ -1,17 +1,51 @@
|
||||
package dev.caskeleton.adapter.outbound.messaging;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import dev.caskeleton.adapter.outbound.support.StrictSettingsBinder;
|
||||
import java.util.Set;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* The application bridge's own setting under {@code app.messaging}.
|
||||
*
|
||||
* <p>The tree is shared with the vendored {@code messaging:*} platform, which owns every other
|
||||
* top-level entry and validates the inside of its own sections. The bridge binds the tree strictly
|
||||
* except for those entries, so a misspelt top-level key — {@code app.messaging.prodcer-id}, {@code
|
||||
* app.messaging.destinatons} — fails startup instead of binding nothing on either side.
|
||||
*
|
||||
* @param producerId the explicit logical producing-service identity used by the canonical platform
|
||||
* bridge; blank means that bridge is not exposed
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "app.messaging")
|
||||
public record MessagingSettings(String producerId) {
|
||||
|
||||
/** The tree the bridge and the platform share. */
|
||||
static final String PREFIX = "app.messaging";
|
||||
|
||||
/**
|
||||
* Top-level entries the vendored platform binds or reads. Its own validator checks inside them.
|
||||
*/
|
||||
static final Set<String> PLATFORM_KEYS =
|
||||
Set.of(
|
||||
"enabled",
|
||||
"broker",
|
||||
"brokers",
|
||||
"destinations",
|
||||
"security",
|
||||
"backpressure",
|
||||
"shutdown",
|
||||
"admin");
|
||||
|
||||
public MessagingSettings {
|
||||
producerId = (producerId == null) ? "" : producerId.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds {@code app.messaging} strictly, leaving the platform's entries to the platform.
|
||||
*
|
||||
* @param environment the environment to bind from
|
||||
* @return the bound settings
|
||||
*/
|
||||
public static MessagingSettings bind(Environment environment) {
|
||||
return StrictSettingsBinder.bindExcept(
|
||||
environment, PREFIX, MessagingSettings.class, PLATFORM_KEYS);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-2
@@ -11,11 +11,11 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -36,10 +36,20 @@ import org.springframework.util.StringUtils;
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
@EnableConfigurationProperties(MessagingSettings.class)
|
||||
@Import(MessagingConfig.class)
|
||||
public class MessagingBridgeRootAutoConfiguration {
|
||||
|
||||
/**
|
||||
* The bridge setting, bound strictly and only while the bridge is on.
|
||||
*
|
||||
* @param environment the environment to bind from
|
||||
* @return the bound settings
|
||||
*/
|
||||
@Bean
|
||||
MessagingSettings messagingBridgeSettings(Environment environment) {
|
||||
return MessagingSettings.bind(environment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects canonical application integration events to the central messaging platform.
|
||||
*
|
||||
|
||||
+34
@@ -6,6 +6,7 @@ import dev.caskeleton.adapter.outbound.messaging.MessagingSettings;
|
||||
import dev.caskeleton.application.messaging.event.IntegrationEventPublishPort;
|
||||
import dev.caskeleton.application.outbox.OutboxMessagePublishPort;
|
||||
import dev.caskeleton.messaging.schema.EncodedMessagePublisher;
|
||||
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;
|
||||
@@ -75,6 +76,39 @@ class MessagingPlatformBridgeAutoConfigurationTest {
|
||||
.hasMessageContaining("no IntegrationEventPublishPort exists"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("app.messaging 최상위 오타 키는 기동을 실패시킨다")
|
||||
void aMisspelledTopLevelMessagingKeyFailsStartup() {
|
||||
// when
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"app.messaging.producer-id=portfolio-service", "app.messaging.prodcer-id=typo")
|
||||
.run(
|
||||
context -> {
|
||||
// then
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure()).hasStackTraceContaining("prodcer-id");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("플랫폼이 가진 app.messaging 하위 트리는 bridge가 거부하지 않는다")
|
||||
void thePlatformsOwnSectionsAreLeftToThePlatform() {
|
||||
// when
|
||||
runner
|
||||
.withPropertyValues(
|
||||
"app.messaging.producer-id=portfolio-service",
|
||||
"app.messaging.broker=kafka",
|
||||
"app.messaging.brokers.kafka.type=kafka",
|
||||
"app.messaging.backpressure.global-limit=64",
|
||||
"app.messaging.admin.enabled=false")
|
||||
.run(
|
||||
context -> {
|
||||
// then
|
||||
assertThat(context).hasNotFailed();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void switchedOffHoldsNothing() {
|
||||
new ApplicationContextRunner()
|
||||
|
||||
+19
-2
@@ -4,12 +4,14 @@ import dev.caskeleton.adapter.outbound.notification.core.FailOpenNotificationPro
|
||||
import dev.caskeleton.adapter.outbound.notification.core.NotificationProvider;
|
||||
import dev.caskeleton.adapter.outbound.notification.core.RoutingNotifier;
|
||||
import dev.caskeleton.adapter.outbound.support.FailOpenDependencyLogger;
|
||||
import dev.caskeleton.adapter.outbound.support.StrictSettingsBinder;
|
||||
import dev.caskeleton.application.notification.NotificationPort;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Assembles the {@link RoutingNotifier} from every contributed {@link NotificationProvider} bean,
|
||||
@@ -23,9 +25,24 @@ import org.springframework.context.annotation.Configuration;
|
||||
* config cannot forget it.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(NotificationRoutesSettings.class)
|
||||
public class NotificationConfig {
|
||||
|
||||
/** Keys under {@code app.notification} that another owner binds or reads. */
|
||||
private static final Set<String> FOREIGN_KEYS =
|
||||
Set.of("platform", "slack-webhook", "google-email");
|
||||
|
||||
/**
|
||||
* The route table, bound strictly.
|
||||
*
|
||||
* @param environment the environment to bind from
|
||||
* @return the bound routes
|
||||
*/
|
||||
@Bean
|
||||
public NotificationRoutesSettings notificationRoutesSettings(Environment environment) {
|
||||
return StrictSettingsBinder.bindExcept(
|
||||
environment, "app.notification", NotificationRoutesSettings.class, FOREIGN_KEYS);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NotificationPort notificationPort(
|
||||
ObjectProvider<List<NotificationProvider>> providers,
|
||||
|
||||
+4
-2
@@ -4,7 +4,6 @@ import dev.caskeleton.adapter.outbound.notification.core.RoutingNotifier;
|
||||
import dev.caskeleton.application.notification.NotificationChannel;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Routes binding for the multi-provider notification template: {@code
|
||||
@@ -18,9 +17,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* (every referenced providerId has an enabled provider) is validated fail-fast by {@link
|
||||
* RoutingNotifier} at construction time.
|
||||
*
|
||||
* <p>Bound strictly by {@link NotificationConfig}: a misspelt key under {@code app.notification}
|
||||
* fails startup. The platform tree and the two R0 provider gates under the same prefix belong to
|
||||
* their own owners and are left to them.
|
||||
*
|
||||
* @param routes channel → (route → providerId list), default empty
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "app.notification")
|
||||
public record NotificationRoutesSettings(
|
||||
Map<NotificationChannel, Map<String, List<String>>> routes) {
|
||||
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
|
||||
/**
|
||||
* Makes an explicit {@code ca-skeleton.notification.platform.enabled=false} complete.
|
||||
* Makes an explicit {@code app.notification.platform.enabled=false} complete.
|
||||
*
|
||||
* <p>The platform's own configurations stand down on the switch, but Spring Boot's mail
|
||||
* auto-configurations arrive with this module's {@code spring-boot-starter-mail} and read no switch
|
||||
@@ -29,7 +29,7 @@ import org.springframework.core.env.MapPropertySource;
|
||||
*/
|
||||
class NotificationActivationEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
|
||||
|
||||
static final String SWITCH = "ca-skeleton.notification.platform.enabled";
|
||||
static final String SWITCH = "app.notification.platform.enabled";
|
||||
|
||||
static final String EXCLUDE = "spring.autoconfigure.exclude";
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
/** Provider-side callback verification contributors. */
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform",
|
||||
prefix = "app.notification.platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
+2
-5
@@ -1,12 +1,10 @@
|
||||
package dev.caskeleton.adapter.outbound.notification.platform.autoconfigure;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.notification.NotificationConfig;
|
||||
import dev.caskeleton.adapter.outbound.notification.NotificationRoutesSettings;
|
||||
import dev.caskeleton.adapter.outbound.notification.email.google.GoogleEmailNotificationAdapterConfig;
|
||||
import dev.caskeleton.adapter.outbound.notification.slack.webhook.SlackNotificationAdapterConfig;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
@@ -14,16 +12,15 @@ import org.springframework.context.annotation.Import;
|
||||
*
|
||||
* <p>The reusable Notification leaf owns its Spring composition. The application composition root
|
||||
* only decides whether this artifact is present. Present means on; {@code
|
||||
* ca-skeleton.notification.platform.enabled=false} turns it off, and {@link
|
||||
* app.notification.platform.enabled=false} turns it off, and {@link
|
||||
* NotificationActivationEnvironmentPostProcessor} takes Boot's mail auto-configuration off with it.
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform",
|
||||
prefix = "app.notification.platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
@EnableConfigurationProperties(NotificationRoutesSettings.class)
|
||||
@Import({
|
||||
NotificationPlatformCoreConfig.class,
|
||||
NotificationPlatformRuntimeConfig.class,
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform",
|
||||
prefix = "app.notification.platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
+26
-3
@@ -5,15 +5,17 @@ import dev.caskeleton.adapter.outbound.notification.platform.template.JacksonNot
|
||||
import dev.caskeleton.adapter.outbound.notification.platform.template.JsonSchemaVariableValidator;
|
||||
import dev.caskeleton.adapter.outbound.notification.platform.template.NotificationTemplateEngine;
|
||||
import dev.caskeleton.adapter.outbound.notification.platform.template.PlaceholderTemplateEngine;
|
||||
import dev.caskeleton.adapter.outbound.support.StrictSettingsBinder;
|
||||
import dev.caskeleton.application.notification.platform.dispatch.NotificationVariablesCodecPort;
|
||||
import dev.caskeleton.application.notification.platform.security.ContactPointProtector;
|
||||
import dev.caskeleton.application.notification.platform.security.SecretMaterialProvider;
|
||||
import dev.caskeleton.application.notification.platform.template.TemplateVariableValidator;
|
||||
import java.util.Set;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Internal notification platform core wiring.
|
||||
@@ -23,14 +25,35 @@ import org.springframework.context.annotation.Configuration;
|
||||
* without keys would fail on the first delivery instead of at startup.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(NotificationPlatformSettings.class)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform",
|
||||
prefix = "app.notification.platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
class NotificationPlatformCoreConfig {
|
||||
|
||||
/** The platform tree. */
|
||||
static final String PREFIX = "app.notification.platform";
|
||||
|
||||
/**
|
||||
* Keys under the platform tree that other settings bind ({@code smtp}, {@code secrets}) or the
|
||||
* notification composition reads ({@code default-locale}).
|
||||
*/
|
||||
private static final Set<String> FOREIGN_KEYS = Set.of("smtp", "secrets", "default-locale");
|
||||
|
||||
/**
|
||||
* The platform settings, bound strictly: a misspelt key fails startup rather than leaving its
|
||||
* default in force.
|
||||
*
|
||||
* @param environment the environment to bind from
|
||||
* @return the bound settings
|
||||
*/
|
||||
@Bean
|
||||
NotificationPlatformSettings notificationPlatformSettings(Environment environment) {
|
||||
return StrictSettingsBinder.bindExcept(
|
||||
environment, PREFIX, NotificationPlatformSettings.class, FOREIGN_KEYS);
|
||||
}
|
||||
|
||||
/** Canonical variables codec. */
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnProperty(
|
||||
prefix = "ca-skeleton.notification.platform",
|
||||
prefix = "app.notification.platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user