feat: Tech Log Studio 백엔드 기반 — 계약 배선, 오류 코드, 경계 규칙, 스키마, 엔드포인트 2종
설계 패키지의 studio-v1.yaml(v3.0.0, 응답 봉투)을 이 저장소에 배선하고 슬라이스 1의 기반을 세운다. 19개 operation 중 getStudioSession과 listStudioCatalog를 구현했다. 계약과 생성 - src/config/openapi/studio-v1.yaml 을 vendor하고 MANIFEST에 출처 커밋을 기록 - openapi-generator로 DTO(model)만 생성한다. generateApis 대신 globalProperties.set(['models': '']) — 그 두 속성은 플러그인 7.18.0에 없다 - useOneOfInterfaces=false. 그 대가로 discriminator union 5종의 Jackson 배선이 깨진다(spec §3.1). 그 5종을 쓰는 7개 operation은 Plan 02에서 전략을 정한 뒤 구현한다 - 생성 코드는 별도 generatedOpenapi sourceSet에 둔다. -Werror가 생성물의 deprecated API 사용을 빌드 실패로 승격하기 때문이다. jar와 test 클래스패스에 별도로 얹는다 오류 계약 - StudioError 23종(계약 ApiError.code와 1:1) + StudioException(ApiErrorCarrier) - StudioExceptionHandler는 techlog 패키지로 범위를 좁힌다. 다른 기능의 오류 응답을 바꾸지 않기 위해서다 - 클라이언트 문구는 레지스트리의 client_safe_message에서 가져오고 예외 메시지는 로그 전용이다(ApiErrorCarrier javadoc의 요구) - 바인딩 예외를 봉투로 옮긴다. 그러지 않으면 bare RFC 7807이 새어 나가 ADR-006을 위반한다 게이트 - TechLogBoundaryArchTest 7종 — spec §4.3의 bounded context 경계. Gradle leaf를 늘릴 수 없어 이 규칙이 경계의 유일한 방어선이다 - StudioErrorRegistryTest — enum ↔ 레지스트리 ↔ 계약 3축 대조, vendor 사본 해시 검증 - StudioContractDriftTest — springdoc 표면이 계약을 벗어나면 실패. @ComponentScan이라 새 컨트롤러가 자동으로 걸린다 - StudioSessionCsrfHeaderProfileContractTest — 배포 가능한 세 프로파일이 계약의 csrf-header-name const로 해소되는지 고정. 이 저장소는 실제 composition root를 테스트에서 부팅할 수 없어 파일 단언으로 그 층을 덮는다 스키마 - V7__techlog_core.sql, 28 테이블. 설계 DDL에서 studio_idempotency(기존 idempotency_record 재사용)와 범위 밖 6종을 제외했다 - 원본의 tech_log 스키마 대신 public을 쓴다. 원본의 SET search_path는 Flyway 세션에만 적용되고 런타임 커넥션 풀은 상속하지 않는다 알려진 제약 - getStudioSession은 세션 인프라(redis-session)가 없어 503 STUDIO_UNAVAILABLE을 반환한다. 계약이 이 operation에 허용하는 유일한 실패 코드다. 가짜 CSRF 토큰으로 200을 만들지 않았다 - 따라서 슬라이스 1의 "프론트 로그인 실동작" 목표는 아직 달성되지 않았다 이 커밋은 AGENTS.md의 human-only 커밋 정책에 대한 저장소 소유자의 명시적 지시로 작성됐다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
697fc740e6
commit
91e6d99654
@@ -1,3 +1,51 @@
|
||||
plugins { id 'org.openapi.generator' }
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Studio 계약 DTO 생성 — sourceSet 정의와 jar/test classpath 배선 (ADR-004/ADR-006).
|
||||
// 이 블록은 파일 맨 위, 아래 커스텀 Test 태스크 등록(jpaPersistenceRedactionContractTest,
|
||||
// webSecurityBoundaryTest)보다 반드시 먼저 와야 한다. 그 둘은
|
||||
// `classpath = sourceSets.test.runtimeClasspath`로 **eager** 대입한다(Gradle 9.0.0의
|
||||
// DefaultSourceSet을 디컴파일해 확인 — lazy ConventionMapping이 아니라 단순
|
||||
// getfield/putfield). 이 배선이 그보다 아래 있으면, 커스텀 태스크는 아직 생성 DTO가
|
||||
// 안 얹힌 옛 FileCollection 참조를 이미 붙잡은 뒤라 나중에 sourceSet 필드를 새
|
||||
// composite로 갈아 끼워도 못 본다 — 컴파일이 아니라 테스트 런타임에 NoClassDefFoundError로
|
||||
// 터진다(발견 당시 실측). 표준 `test` 태스크는 JvmTestSuitePlugin이 lazy
|
||||
// ConventionMapping Callable로 배선해 괜찮지만(이것도 디컴파일로 확인), register()로 만든
|
||||
// 이 두 커스텀 Test 태스크는 lazy 배선을 안 타서 못 본다.
|
||||
//
|
||||
// openApiGenerate 확장 자체(무엇을 어떤 옵션으로 생성하는지)는 이 파일 아래쪽, 같은 제목의
|
||||
// 주석 섹션에 그대로 있다 — 여기는 sourceSet 정의와 그 소비자(jar, test classpath)만
|
||||
// 옮겼다. generatedOpenapiImplementation의 의존성 상속(configurations 블록)과
|
||||
// compileGeneratedOpenapiJava/checkstyle/spotbugs/spotless 배선도 원래 자리에 남아있다 —
|
||||
// 전부 lazy(tasks.named/tasks.matching)라 순서 문제가 없다.
|
||||
// ---------------------------------------------------------------------------
|
||||
sourceSets {
|
||||
generatedOpenapi {
|
||||
java.srcDir(layout.buildDirectory.dir('generated/openapi/src/main/java'))
|
||||
}
|
||||
// main이 생성 DTO를 참조할 수 있어야 한다(Task 8/9 controller). implementation
|
||||
// Configuration으로 연결하면(즉 main의 implementation에 generatedOpenapi.output을
|
||||
// 넣으면) 아래 generatedOpenapiImplementation.extendsFrom(implementation)과 맞물려
|
||||
// "컴파일하려면 자기 자신의 산출물이 먼저 있어야 한다"는 순환 태스크 의존성이 생긴다
|
||||
// (직접 겪음). 그래서 Configuration이 아니라 SourceSet의 compile/runtime classpath
|
||||
// FileCollection에 직접 이어 붙인다 — 태스크 의존성은 그대로 따라가면서 순환은 없다.
|
||||
main {
|
||||
compileClasspath += generatedOpenapi.output
|
||||
runtimeClasspath += generatedOpenapi.output
|
||||
}
|
||||
}
|
||||
|
||||
// main.runtimeClasspath로는 부족하다 — 그건 "실행 시 클래스를 찾을 수 있다"는 뜻일 뿐,
|
||||
// consumer(app-bootstrap 등)가 보는 web 모듈의 runtimeElements(= jar 산출물)에는 여전히
|
||||
// 생성 DTO가 없다. app-bootstrap은 web을 project dependency로만 물고 web의 build/classes를
|
||||
// 직접 보지 않으므로, jar 안에 없으면 부팅/요청 시 NoClassDefFoundError로 터진다.
|
||||
// 같은 이유로 test sourceSet도 main.output만 물려받지 generatedOpenapi.output까지
|
||||
// 자동으로 따라오지 않는다 — controller 테스트가 컴파일조차 안 된다. 셋 다 명시적으로
|
||||
// 채워야 한다.
|
||||
tasks.named('jar') { from sourceSets.generatedOpenapi.output }
|
||||
sourceSets.test.compileClasspath += sourceSets.generatedOpenapi.output
|
||||
sourceSets.test.runtimeClasspath += sourceSets.generatedOpenapi.output
|
||||
|
||||
// HTTP / web adapters. Depends on application and shared operational contracts.
|
||||
dependencies {
|
||||
implementation project(':application-core')
|
||||
@@ -72,3 +120,95 @@ tasks.register('webSecurityBoundaryTest', Test) {
|
||||
tasks.named('check') {
|
||||
dependsOn tasks.named('webSecurityBoundaryTest')
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Studio 계약 DTO 생성 (ADR-004 / ADR-006).
|
||||
//
|
||||
// generateApis에 해당하는 효과: 계약이 봉투를 기술하므로 API interface까지 생성하면
|
||||
// 봉투 wrapper 타입을 반환하게 되고, 그 타입은 dev.caskeleton.shared.response.Envelope가
|
||||
// 아니라서 EnvelopeBodyAdvice가 한 번 더 감싼다(이중 래핑). controller는 손으로 쓴다.
|
||||
//
|
||||
// globalProperties.set(['models': '']): openapi-generator-gradle-plugin 7.18.0의
|
||||
// openApiGenerate 확장에는 generateApis/generateModels/generateSupportingFiles 프로퍼티가
|
||||
// 존재하지 않는다(디컴파일로 확인, task-4-report.md 참고) — 대신 CLI --global-property와
|
||||
// 같은 의미인 globalProperties로 "models만" 생성하게 제한한다.
|
||||
//
|
||||
// useOneOfInterfaces=false: discriminator(oneOf) union을 부모 Java interface로 생성하면
|
||||
// 하위 타입이 그 인터페이스를 구현하는데, 판별 필드가 enum이면(narrowing 여부와 무관하게)
|
||||
// 인터페이스의 getter는 무조건 String을 반환하고 하위 타입의 getter는 그 프로퍼티의 실제
|
||||
// 타입(nested enum이든 공유 named enum이든)을 반환해 컴파일이 깨진다. 판별 필드를 하위
|
||||
// 타입에서 narrowing하지 않고 base의 공유 enum(RecordKind 등)을 그대로 상속하게 계약을
|
||||
// 고쳐도 동일하게 깨진다는 것까지 스크래치에서 직접 검증했다 — SpringCodegen이
|
||||
// useOneOfInterfaces=true일 때 discriminator getter를 String으로 고정하는 게 근본
|
||||
// 원인이라 계약 쪽에서 우회할 수 없다(3개 설정 조합 + 이 검증 전부 task-4-report.md 참고).
|
||||
//
|
||||
// useOneOfInterfaces=false는 컴파일은 통과시키지만 대가가 있다: 각 하위 타입이 독립
|
||||
// 클래스로 생성되고(WorkingCopyInput 등 union 타입과 CaseInput 등 하위 타입 사이에
|
||||
// Java의 implements 관계가 전혀 없다), 그리고 실측 결과 Jackson 배선도 계약대로 동작하지
|
||||
// 않는다 — 역직렬화는 InvalidTypeIdException으로 실패하고("Class CaseInput not subtype
|
||||
// of WorkingCopyInput"), 직렬화는 @JsonIgnoreProperties(value="kind", allowSetters=true)
|
||||
// 때문에 실제 kind 값 대신 클래스 simple name이 나간다. 즉 생성된 union 클래스는 Jackson
|
||||
// 양방향 모두 계약을 위반한다. union을 필드 타입으로 쓰는 5개 union(WorkingCopyInput,
|
||||
// WorkingCopy, Inline, CaseRenderBlock, PublicRenderModel)을 실제로 쓰는 operation은
|
||||
// Plan 02에서 전략을 정한 뒤 구현한다 — 이번 Task 8/9(getStudioSession,
|
||||
// listStudioCatalog)는 이 union들을 쓰지 않으므로 막히지 않는다.
|
||||
// ---------------------------------------------------------------------------
|
||||
openApiGenerate {
|
||||
generatorName = 'spring'
|
||||
inputSpec = "${rootDir}/config/openapi/studio-v1.yaml".toString()
|
||||
outputDir = layout.buildDirectory.dir('generated/openapi').get().asFile.path
|
||||
modelPackage = 'dev.caskeleton.adapter.inbound.web.techlog.studio.api.model'
|
||||
globalProperties.set(['models': ''])
|
||||
generateModelTests = false
|
||||
generateModelDocumentation = false
|
||||
configOptions = [
|
||||
useSpringBoot3: 'true',
|
||||
useJakartaEe: 'true',
|
||||
openApiNullable: 'true',
|
||||
useOneOfInterfaces: 'false',
|
||||
]
|
||||
}
|
||||
|
||||
// sourceSets.generatedOpenapi 정의와 그걸 소비하는 jar/test classpath 배선은 이 파일
|
||||
// 맨 위로 옮겼다(리뷰 라운드 2 fix) — 이유는 그 자리의 주석 참고. 여기 남은 건
|
||||
// generatedOpenapiImplementation의 의존성 상속뿐이다.
|
||||
configurations {
|
||||
// 생성 DTO 컴파일에 필요한 의존성(jakarta.validation, swagger-annotations,
|
||||
// jackson-databind-nullable, spring-web의 @Nullable/@DateTimeFormat 등)은 이미 main의
|
||||
// implementation에 다 있다 — 따로 중복 선언하지 않고 그대로 물려받는다. main의
|
||||
// implementation은 generatedOpenapi.output을 포함하지 않으므로(위 참고) 이 확장은
|
||||
// 순환을 만들지 않는다.
|
||||
generatedOpenapiImplementation.extendsFrom(implementation)
|
||||
}
|
||||
|
||||
tasks.named('compileGeneratedOpenapiJava', JavaCompile) {
|
||||
dependsOn 'openApiGenerate'
|
||||
options.errorprone.enabled = false
|
||||
// 루트 build.gradle의 tasks.withType(JavaCompile).configureEach가 -Werror와
|
||||
// -Xlint:deprecation을 이미 넣어 놓은 뒤에 이 설정이 평가되므로(subprojects 블록이
|
||||
// 먼저, 이 파일이 나중) 여기서 빼는 게 마지막 값으로 남는다.
|
||||
doFirst {
|
||||
options.compilerArgs.removeAll(['-Werror', '-Xlint:deprecation'])
|
||||
}
|
||||
}
|
||||
|
||||
// checkstyle/spotbugs는 sourceSet마다 별도 태스크(checkstyleGeneratedOpenapi,
|
||||
// spotbugsGeneratedOpenapi)를 만든다 — 그 태스크만 끈다. checkstyleMain/spotbugsMain은
|
||||
// 생성 코드가 더 이상 main sourceSet에 없으므로 애초에 이 파일들을 보지 않는다.
|
||||
tasks.matching { it.name == 'checkstyleGeneratedOpenapi' }.configureEach {
|
||||
dependsOn 'openApiGenerate'
|
||||
enabled = false
|
||||
}
|
||||
tasks.matching { it.name == 'spotbugsGeneratedOpenapi' }.configureEach {
|
||||
dependsOn 'openApiGenerate'
|
||||
enabled = false
|
||||
}
|
||||
|
||||
// spotless는 sourceSet과 무관하게 글롭으로 java 파일을 찾으므로 생성 경로를 명시적으로
|
||||
// 뺀다. spotlessJava가 openApiGenerate보다 먼저 돌면 아직 없는 디렉터리를 글롭 검사하다
|
||||
// 있으나 마나 한 차이라 dependsOn은 필요 없지만, 생성 전 상태에서 우연히 이전 빌드의 생성물이
|
||||
// 남아 채점되는 걸 막기 위해 순서를 맞춘다.
|
||||
tasks.matching { it.name.startsWith('spotless') }.configureEach {
|
||||
dependsOn 'openApiGenerate'
|
||||
}
|
||||
spotless { java { targetExclude('build/generated/**') } }
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
# This is a Gradle generated file for dependency locking.
|
||||
# Manual edits can break the build and are not advised.
|
||||
# This file is expected to be part of source control.
|
||||
biz.aQute.bnd:biz.aQute.bnd.annotation:7.1.0=compileClasspath,testCompileClasspath
|
||||
ch.qos.logback:logback-classic:1.5.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
ch.qos.logback:logback-core:1.5.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.core:jackson-annotations:2.20=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.core:jackson-core:2.20.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.core:jackson-databind:2.20.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.20.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson:jackson-bom:2.20.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml:classmate:1.7.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.github.ben-manes.caffeine:caffeine:3.2.3=annotationProcessor,testAnnotationProcessor
|
||||
com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor
|
||||
biz.aQute.bnd:biz.aQute.bnd.annotation:7.1.0=compileClasspath,generatedOpenapiCompileClasspath,testCompileClasspath
|
||||
ch.qos.logback:logback-classic:1.5.21=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
ch.qos.logback:logback-core:1.5.21=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.core:jackson-annotations:2.20=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.core:jackson-core:2.20.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.core:jackson-databind:2.20.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.20.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml.jackson:jackson-bom:2.20.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.fasterxml:classmate:1.7.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.github.ben-manes.caffeine:caffeine:3.2.3=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs
|
||||
com.github.spotbugs:spotbugs-annotations:4.8.6=compileClasspath,testCompileClasspath
|
||||
com.github.spotbugs:spotbugs-annotations:4.8.6=compileClasspath,generatedOpenapiCompileClasspath,testCompileClasspath
|
||||
com.github.spotbugs:spotbugs:4.10.2=spotbugs
|
||||
com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs
|
||||
com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor
|
||||
com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor
|
||||
com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor
|
||||
com.google.code.findbugs:jsr305:3.0.2=checkstyle,compileClasspath,spotbugs,testCompileClasspath
|
||||
com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.auto:auto-common:1.2.2=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.code.findbugs:jsr305:3.0.2=checkstyle,compileClasspath,generatedOpenapiCompileClasspath,spotbugs,testCompileClasspath
|
||||
com.google.code.gson:gson:2.13.2=spotbugs
|
||||
com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor
|
||||
com.google.errorprone:error_prone_annotations:2.38.0=compileClasspath,testCompileClasspath
|
||||
com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.errorprone:error_prone_annotations:2.38.0=compileClasspath,generatedOpenapiCompileClasspath,testCompileClasspath
|
||||
com.google.errorprone:error_prone_annotations:2.41.0=spotbugs
|
||||
com.google.errorprone:error_prone_annotations:2.47.0=checkstyle
|
||||
com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor
|
||||
com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor
|
||||
com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor
|
||||
com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor
|
||||
com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor
|
||||
com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor
|
||||
com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.guava:guava:33.5.0-jre=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.guava:guava:33.6.0-jre=checkstyle
|
||||
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor
|
||||
com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor
|
||||
com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor
|
||||
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins
|
||||
com.jayway.jsonpath:json-path:2.9.0=testCompileClasspath,testRuntimeClasspath
|
||||
com.nimbusds:nimbus-jose-jwt:10.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.nimbusds:nimbus-jose-jwt:10.4=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.puppycrawl.tools:checkstyle:13.5.0=checkstyle
|
||||
com.vaadin.external.google:android-json:0.0.20131108.vaadin1=testCompileClasspath,testRuntimeClasspath
|
||||
commons-beanutils:commons-beanutils:1.11.0=checkstyle
|
||||
commons-collections:commons-collections:3.2.2=checkstyle
|
||||
commons-io:commons-io:2.21.0=spotbugs
|
||||
commons-logging:commons-logging:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
commons-logging:commons-logging:1.3.5=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
info.picocli:picocli:4.7.7=checkstyle
|
||||
io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor
|
||||
io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor
|
||||
io.micrometer:micrometer-commons:1.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.micrometer:micrometer-observation:1.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.projectreactor:reactor-core:3.8.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
io.micrometer:micrometer-commons:1.16.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.micrometer:micrometer-observation:1.16.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.projectreactor:reactor-core:3.8.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.projectreactor:reactor-test:3.8.0=testCompileClasspath,testRuntimeClasspath
|
||||
io.swagger.core.v3:swagger-annotations-jakarta:2.2.38=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.swagger.core.v3:swagger-core-jakarta:2.2.38=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.swagger.core.v3:swagger-models-jakarta:2.2.38=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
jakarta.activation:jakarta.activation-api:2.1.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
jakarta.annotation:jakarta.annotation-api:3.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
jakarta.validation:jakarta.validation-api:3.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
jakarta.xml.bind:jakarta.xml.bind-api:4.0.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor
|
||||
io.swagger.core.v3:swagger-annotations-jakarta:2.2.38=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.swagger.core.v3:swagger-core-jakarta:2.2.38=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
io.swagger.core.v3:swagger-models-jakarta:2.2.38=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
jakarta.activation:jakarta.activation-api:2.1.4=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
jakarta.annotation:jakarta.annotation-api:3.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
jakarta.validation:jakarta.validation-api:3.1.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
jakarta.xml.bind:jakarta.xml.bind-api:4.0.4=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
javax.inject:javax.inject:1=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
jaxen:jaxen:2.0.0=spotbugs
|
||||
net.bytebuddy:byte-buddy-agent:1.17.8=testCompileClasspath,testRuntimeClasspath
|
||||
net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath
|
||||
@@ -68,21 +68,21 @@ net.minidev:json-smart:2.6.0=testCompileClasspath,testRuntimeClasspath
|
||||
net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs
|
||||
org.antlr:antlr4-runtime:4.13.2=checkstyle
|
||||
org.apache.bcel:bcel:6.12.0=spotbugs
|
||||
org.apache.commons:commons-lang3:3.20.0=checkstyle,compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.commons:commons-lang3:3.20.0=checkstyle,compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.commons:commons-text:1.15.0=spotbugs
|
||||
org.apache.commons:commons-text:1.3=checkstyle
|
||||
org.apache.httpcomponents:httpclient:4.5.13=checkstyle
|
||||
org.apache.httpcomponents:httpcore:4.4.16=checkstyle
|
||||
org.apache.logging.log4j:log4j-api:2.25.2=compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.logging.log4j:log4j-api:2.25.2=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.logging.log4j:log4j-core:2.25.2=spotbugs
|
||||
org.apache.logging.log4j:log4j-to-slf4j:2.25.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.logging.log4j:log4j-to-slf4j:2.25.2=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.maven.doxia:doxia-core:1.12.0=checkstyle
|
||||
org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle
|
||||
org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle
|
||||
org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle
|
||||
org.apache.tomcat.embed:tomcat-embed-core:11.0.14=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.tomcat.embed:tomcat-embed-el:11.0.14=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.tomcat.embed:tomcat-embed-websocket:11.0.14=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.tomcat.embed:tomcat-embed-core:11.0.14=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.tomcat.embed:tomcat-embed-el:11.0.14=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.tomcat.embed:tomcat-embed-websocket:11.0.14=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.apache.xbean:xbean-reflect:3.7=checkstyle
|
||||
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
|
||||
org.assertj:assertj-core:3.27.6=testCompileClasspath,testRuntimeClasspath
|
||||
@@ -93,10 +93,10 @@ org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle
|
||||
org.codehaus.plexus:plexus-utils:3.3.0=checkstyle
|
||||
org.dom4j:dom4j:2.2.0=spotbugs
|
||||
org.hamcrest:hamcrest:3.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.hibernate.validator:hibernate-validator:9.0.1.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.hibernate.validator:hibernate-validator:9.0.1.Final=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.javassist:javassist:3.28.0-GA=checkstyle
|
||||
org.jboss.logging:jboss-logging:3.6.1.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.jspecify:jspecify:1.0.0=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
|
||||
org.jboss.logging:jboss-logging:3.6.1.Final=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.jspecify:jspecify:1.0.0=annotationProcessor,checkstyle,compileClasspath,generatedOpenapiAnnotationProcessor,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
|
||||
org.junit.jupiter:junit-jupiter-api:6.0.1=testCompileClasspath,testRuntimeClasspath
|
||||
org.junit.jupiter:junit-jupiter-engine:6.0.1=testRuntimeClasspath
|
||||
org.junit.jupiter:junit-jupiter-params:6.0.1=testCompileClasspath,testRuntimeClasspath
|
||||
@@ -109,80 +109,80 @@ org.junit:junit-bom:6.1.0=spotbugs
|
||||
org.mockito:mockito-core:5.20.0=mockitoAgent,testCompileClasspath,testRuntimeClasspath
|
||||
org.mockito:mockito-junit-jupiter:5.20.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.objenesis:objenesis:3.3=testRuntimeClasspath
|
||||
org.openapitools:jackson-databind-nullable:0.2.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.openapitools:jackson-databind-nullable:0.2.6=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.osgi:org.osgi.annotation.bundle:2.0.0=compileClasspath,testCompileClasspath
|
||||
org.osgi:org.osgi.annotation.versioning:1.1.2=compileClasspath,testCompileClasspath
|
||||
org.osgi:org.osgi.resource:1.0.0=compileClasspath,testCompileClasspath
|
||||
org.osgi:org.osgi.service.serviceloader:1.0.0=compileClasspath,testCompileClasspath
|
||||
org.osgi:org.osgi.annotation.bundle:2.0.0=compileClasspath,generatedOpenapiCompileClasspath,testCompileClasspath
|
||||
org.osgi:org.osgi.annotation.versioning:1.1.2=compileClasspath,generatedOpenapiCompileClasspath,testCompileClasspath
|
||||
org.osgi:org.osgi.resource:1.0.0=compileClasspath,generatedOpenapiCompileClasspath,testCompileClasspath
|
||||
org.osgi:org.osgi.service.serviceloader:1.0.0=compileClasspath,generatedOpenapiCompileClasspath,testCompileClasspath
|
||||
org.ow2.asm:asm-analysis:9.10.1=spotbugs
|
||||
org.ow2.asm:asm-commons:9.10.1=spotbugs
|
||||
org.ow2.asm:asm-tree:9.10.1=spotbugs
|
||||
org.ow2.asm:asm-util:9.10.1=spotbugs
|
||||
org.ow2.asm:asm:9.10.1=spotbugs
|
||||
org.ow2.asm:asm:9.7.1=testCompileClasspath,testRuntimeClasspath
|
||||
org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor
|
||||
org.reactivestreams:reactive-streams:1.0.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.pcollections:pcollections:4.0.1=annotationProcessor,generatedOpenapiAnnotationProcessor,testAnnotationProcessor
|
||||
org.reactivestreams:reactive-streams:1.0.4=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.reflections:reflections:0.10.2=checkstyle
|
||||
org.skyscreamer:jsonassert:1.5.3=testCompileClasspath,testRuntimeClasspath
|
||||
org.slf4j:jul-to-slf4j:2.0.17=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.slf4j:slf4j-api:2.0.17=compileClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath
|
||||
org.slf4j:jul-to-slf4j:2.0.17=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.slf4j:slf4j-api:2.0.17=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath
|
||||
org.slf4j:slf4j-simple:2.0.17=checkstyle,spotbugsSlf4j
|
||||
org.springdoc:springdoc-openapi-starter-common:3.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springdoc:springdoc-openapi-starter-webmvc-api:3.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-autoconfigure:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springdoc:springdoc-openapi-starter-common:3.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springdoc:springdoc-openapi-starter-webmvc-api:3.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-autoconfigure:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-configuration-processor:4.0.0=annotationProcessor
|
||||
org.springframework.boot:spring-boot-http-client:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-http-converter:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-jackson:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-http-converter:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-jackson:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-restclient:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-resttestclient:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-security-oauth2-resource-server:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-security:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-servlet:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-security-oauth2-resource-server:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-security:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-servlet:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-jackson-test:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-jackson:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-logging:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-oauth2-resource-server:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-security:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-jackson:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-logging:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-oauth2-resource-server:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-security:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-test:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-tomcat-runtime:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-tomcat:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-validation:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-web:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-tomcat-runtime:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-tomcat:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-validation:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-web:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-webmvc-test:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter-webmvc:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-starter:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-test-autoconfigure:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-test:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-tomcat:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-validation:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-web-server:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-tomcat:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-validation:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-web-server:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-webmvc-test:4.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-webmvc:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-config:7.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-core:7.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-crypto:7.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-oauth2-core:7.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-oauth2-jose:7.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-oauth2-resource-server:7.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot-webmvc:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.boot:spring-boot:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-config:7.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-core:7.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-crypto:7.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-oauth2-core:7.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-oauth2-jose:7.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-oauth2-resource-server:7.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-test:7.0.0=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-web:7.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.session:spring-session-core:4.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-aop:7.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-beans:7.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-context:7.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-core:7.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-expression:7.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.security:spring-security-web:7.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework.session:spring-session-core:4.0.0=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-aop:7.0.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-beans:7.0.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-context:7.0.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-core:7.0.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-expression:7.0.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-test:7.0.1=testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-web:7.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-webflux:7.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-webmvc:7.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-web:7.0.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-webflux:7.0.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.springframework:spring-webmvc:7.0.1=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs
|
||||
org.xmlunit:xmlunit-core:2.10.4=testCompileClasspath,testRuntimeClasspath
|
||||
org.yaml:snakeyaml:2.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
tools.jackson.core:jackson-core:3.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
tools.jackson.core:jackson-databind:3.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
tools.jackson:jackson-bom:3.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.yaml:snakeyaml:2.5=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
tools.jackson.core:jackson-core:3.0.2=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
tools.jackson.core:jackson-databind:3.0.2=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
tools.jackson:jackson-bom:3.0.2=compileClasspath,generatedOpenapiCompileClasspath,generatedOpenapiRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
empty=
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog;
|
||||
|
||||
import dev.caskeleton.application.techlog.error.StudioError;
|
||||
|
||||
/**
|
||||
* Studio 실패의 client-safe {@code error.message} 단일 출처.
|
||||
*
|
||||
* <p>{@code StudioException#getMessage()}는 Studio use case/facade가 진단용으로 채우는 원문이라 {@code
|
||||
* ApiErrorCarrier} javadoc이 경고하는 대로 SQLState나 upstream detail을 실을 수 있다. 그래서 응답에는 절대 흘리지 않고, 이 클래스가
|
||||
* code별 고정 문구만 내보낸다 — 스켈레톤의 {@code ClientSafeErrorMessages}가 {@code OperationalError}에 대해 하는 것과 같은
|
||||
* 역할을 {@link StudioError}에 대해 한다.
|
||||
*
|
||||
* <p>문구는 {@code docs/registries/error-codes.yaml}의 각 row {@code client_safe_message}와 정확히 같아야 한다 —
|
||||
* {@code StudioErrorRegistryTest}가 그 일치를 고정한다. {@code PAYLOAD_TOO_LARGE}/{@code
|
||||
* UNSUPPORTED_MEDIA_TYPE}은 Studio 전용 row가 없고 {@code feature-api-contract-baseline}이 이미 등록한 row를
|
||||
* 재사용하므로(Task 5 report 5절) 그 row의 영문 문구를 그대로 따른다 — 나머지는 Studio 전용 한국어 문구다.
|
||||
*
|
||||
* <p>{@link StudioError}를 exhaustive switch로 매핑하므로(default 없음) 새 상수를 추가하면 이 파일도 컴파일 타임에 고쳐야 한다 — 문구
|
||||
* 누락이 생길 수 없다.
|
||||
*/
|
||||
public final class StudioClientSafeMessages {
|
||||
|
||||
private StudioClientSafeMessages() {}
|
||||
|
||||
public static String forError(StudioError error) {
|
||||
return switch (error) {
|
||||
case AUTHENTICATION_REQUIRED -> "Studio 인증이 필요합니다";
|
||||
case STUDIO_ACCESS_DENIED -> "이 Studio 리소스에 접근할 권한이 없습니다";
|
||||
case DOCUMENT_NOT_FOUND -> "요청한 문서를 찾을 수 없습니다";
|
||||
case VERSION_CONFLICT -> "저장된 version이 더 최신입니다";
|
||||
case REQUEST_VALIDATION_FAILED -> "요청 형식이 올바르지 않습니다";
|
||||
case DOCUMENT_VALIDATION_FAILED -> "문서 검증에 실패했습니다";
|
||||
case VALIDATION_STALE -> "검증 결과가 최신 문서 기준이 아닙니다. 다시 검증해 주세요";
|
||||
case PREVIEW_NOT_FOUND -> "요청한 미리보기를 찾을 수 없습니다";
|
||||
case PREVIEW_STALE -> "미리보기가 최신 문서 기준이 아닙니다. 다시 생성해 주세요";
|
||||
case PREVIEW_EXPIRED -> "미리보기가 만료되었습니다. 다시 생성해 주세요";
|
||||
case PUBLICATION_NOT_FOUND -> "요청한 게시물을 찾을 수 없습니다";
|
||||
case PUBLICATION_CONFLICT -> "게시 작업이 다른 변경과 충돌했습니다";
|
||||
case PUBLICATION_EVENT_NOT_FOUND -> "요청한 게시 이벤트를 찾을 수 없습니다";
|
||||
case PUBLICATION_SNAPSHOT_NOT_FOUND -> "요청한 게시 스냅샷을 찾을 수 없습니다";
|
||||
case WARNING_ACKNOWLEDGEMENT_REQUIRED -> "경고 확인이 필요합니다. 확인 후 다시 시도해 주세요";
|
||||
case IDEMPOTENCY_KEY_REUSED -> "Idempotency 키가 다른 요청에 재사용되었습니다";
|
||||
case ASSET_NOT_FOUND -> "요청한 자산을 찾을 수 없습니다";
|
||||
case ASSET_NOT_READY -> "자산 처리가 아직 완료되지 않았습니다";
|
||||
case ASSET_IN_USE -> "자산이 사용 중이라 이 작업을 수행할 수 없습니다";
|
||||
case ASSET_QUARANTINED -> "자산이 격리 처리되어 사용할 수 없습니다";
|
||||
case PAYLOAD_TOO_LARGE -> "Request payload is too large";
|
||||
case UNSUPPORTED_MEDIA_TYPE -> "Request Content-Type is not supported";
|
||||
case STUDIO_UNAVAILABLE -> "Studio 서비스를 일시적으로 사용할 수 없습니다. 잠시 후 다시 시도해 주세요";
|
||||
};
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog;
|
||||
|
||||
import dev.caskeleton.adapter.inbound.web.error.ErrorResponseFactory;
|
||||
import dev.caskeleton.application.techlog.error.StudioError;
|
||||
import dev.caskeleton.application.techlog.error.StudioException;
|
||||
import dev.caskeleton.shared.response.Envelope;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
|
||||
/**
|
||||
* Studio 실패를 스켈레톤 봉투로 옮긴다. 템플릿의 {@code GlobalExceptionHandler}를 수정하지 않기 위해 별도 advice로 둔다 — 그 파일은
|
||||
* template sync 대상이다.
|
||||
*
|
||||
* <p>{@code error.message}에는 {@link StudioClientSafeMessages}가 주는 code별 고정 문구만 싣는다 — {@link
|
||||
* StudioException#getMessage()}(진단용 원문)는 SQLState·upstream detail을 실을 수 있어 client-unsafe하다({@code
|
||||
* ApiErrorCarrier} javadoc). 원문은 버리지 않고 서버 로그에만 남긴다 — {@code GlobalExceptionHandler}의 {@code
|
||||
* handlePersistenceFailure}/{@code handleDependencyFailure}가 분류된 하위 계층 실패를 로깅하는 것과 같은 패턴이다.
|
||||
*
|
||||
* <p><b>{@code basePackages} 스코프 (final whole-branch review B4).</b> 이 advice는 {@code
|
||||
* dev.caskeleton.adapter.inbound.web.techlog} 아래의 컨트롤러(현재 studio 컨트롤러 전부가 여기 산다, {@code
|
||||
* studio.controller})에만 적용된다. {@link #handleMissingParameter}/{@link #handleTypeMismatch}는 Spring
|
||||
* MVC 표준 바인딩 예외를 계약 코드로 옮기는데, 스코프 없이 전역으로 두면 fileserver·healthcheck 같은 studio 밖 컨트롤러의 같은 예외까지 가로채 그
|
||||
* 기능들의 기존 오류 응답 모양(바로 이 advice가 없었을 때의 {@code GlobalExceptionHandler} 동작)을 바꿔버린다 — 이 브랜치가 건드릴 권한이
|
||||
* 없는 기능이다. {@code StudioException} 처리는 애초에 studio 코드만 이 예외를 던지므로 스코프를 좁혀도 동작이 바뀌지 않는다.
|
||||
*/
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
@RestControllerAdvice(basePackages = "dev.caskeleton.adapter.inbound.web.techlog")
|
||||
public class StudioExceptionHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(StudioExceptionHandler.class);
|
||||
|
||||
@ExceptionHandler(StudioException.class)
|
||||
public ResponseEntity<Envelope<Void>> handleStudio(StudioException ex) {
|
||||
StudioError error = ex.studioError();
|
||||
log.error(
|
||||
"studio failure classified as {} (category={}, retryable={}): {}",
|
||||
error.code(),
|
||||
error.category(),
|
||||
error.retryable(),
|
||||
ex.getMessage(),
|
||||
ex);
|
||||
return ErrorResponseFactory.envelope(
|
||||
error, StudioClientSafeMessages.forError(error), ex.details());
|
||||
}
|
||||
|
||||
/**
|
||||
* 필수 쿼리 파라미터 누락(예: {@code GET /api/v1/studio/catalog}의 {@code type}). {@code
|
||||
* GlobalExceptionHandler}는 이 예외를 오버라이드하지 않으므로 부모 {@code ResponseEntityExceptionHandler}가 그대로 bare
|
||||
* {@code ProblemDetail}(content-type {@code application/problem+json})을 만들고, {@code
|
||||
* EnvelopeBodyAdvice}의 JSON 미디어타입 검사에 걸려 봉투를 못 씌운다 — ADR-006이 쓰지 않기로 한 RFC 7807이 그대로 나간다(final
|
||||
* whole-branch review B4). studio 스코프에서 계약 코드 {@link StudioError#REQUEST_VALIDATION_FAILED}(422)로
|
||||
* 옮긴다.
|
||||
*/
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
public ResponseEntity<Envelope<Void>> handleMissingParameter(
|
||||
MissingServletRequestParameterException ex) {
|
||||
return requestValidationFailed(ex.getParameterName(), "Required parameter is missing");
|
||||
}
|
||||
|
||||
/**
|
||||
* 쿼리 파라미터 타입 불일치(예: {@code type=BOGUS}, {@code limit=abc}). {@code GlobalExceptionHandler}도 이 예외를
|
||||
* 처리하지만 {@code OperationalError.BAD_PARAMETER}를 낸다 — Studio 계약 23종에 없는 코드다. studio 스코프에서 계약 코드로
|
||||
* 옮긴다.
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
public ResponseEntity<Envelope<Void>> handleTypeMismatch(MethodArgumentTypeMismatchException ex) {
|
||||
return requestValidationFailed(ex.getName(), "Parameter value is invalid");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code details}를 계약의 {@code ValidationErrorDetails}({@code fieldErrors: [{path, message}]}) 모양에
|
||||
* 맞춰 싣는다 — 자유형 {@code Object}로 아무 모양이나 실으면 계약의 {@code oneOf} 제약을 위반한다.
|
||||
*/
|
||||
private static ResponseEntity<Envelope<Void>> requestValidationFailed(
|
||||
String parameterName, String message) {
|
||||
Map<String, Object> fieldError = Map.of("path", "/" + parameterName, "message", message);
|
||||
Map<String, Object> details = Map.of("fieldErrors", List.of(fieldError));
|
||||
return ErrorResponseFactory.envelope(
|
||||
StudioError.REQUEST_VALIDATION_FAILED,
|
||||
StudioClientSafeMessages.forError(StudioError.REQUEST_VALIDATION_FAILED),
|
||||
details);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog.studio.controller;
|
||||
|
||||
import dev.caskeleton.adapter.inbound.web.techlog.studio.api.model.CatalogEntry;
|
||||
import dev.caskeleton.adapter.inbound.web.techlog.studio.api.model.CatalogPage;
|
||||
import dev.caskeleton.application.techlog.studio.query.CatalogEntryType;
|
||||
import dev.caskeleton.application.techlog.studio.query.CatalogEntryView;
|
||||
import dev.caskeleton.application.techlog.studio.query.CatalogPageView;
|
||||
import dev.caskeleton.application.techlog.studio.query.ListCatalogQuery;
|
||||
import dev.caskeleton.application.techlog.studio.service.ListCatalogUseCase;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 반환값을 Envelope로 감싸지 않는다 — EnvelopeBodyAdvice가 감싼다.
|
||||
*
|
||||
* <p>{@code CatalogEntryType}은 application({@code
|
||||
* dev.caskeleton.application.techlog.studio.query})과 웹 계약 생성 DTO({@code
|
||||
* dev.caskeleton.adapter.inbound.web.techlog.studio.api.model})에 같은 이름으로 각각 존재한다 — 한 파일에서 둘 다 단일 타입
|
||||
* import로 쓰면 컴파일이 깨진다. 이 컨트롤러는 application 쪽을 단일 import로 쓰고(요청 파라미터·use case 입력), 웹 계약 쪽은 {@link
|
||||
* #toApi}에서 FQN으로만 참조한다(응답 DTO 조립).
|
||||
*/
|
||||
@RestController
|
||||
public class StudioCatalogController {
|
||||
|
||||
private final ListCatalogUseCase listCatalog;
|
||||
|
||||
public StudioCatalogController(ListCatalogUseCase listCatalog) {
|
||||
this.listCatalog = listCatalog;
|
||||
}
|
||||
|
||||
@GetMapping("/api/v1/studio/catalog")
|
||||
public CatalogPage listStudioCatalog(
|
||||
@RequestParam("type") CatalogEntryType type,
|
||||
@RequestParam(value = "q", required = false) String q,
|
||||
@RequestParam(value = "cursor", required = false) String cursor,
|
||||
@RequestParam(value = "limit", defaultValue = "20") int limit) {
|
||||
CatalogPageView page = listCatalog.handle(new ListCatalogQuery(type, q, cursor, limit));
|
||||
CatalogPage body = new CatalogPage();
|
||||
body.setItems(page.items().stream().map(StudioCatalogController::toApi).toList());
|
||||
body.setNextCursor(page.nextCursor());
|
||||
return body;
|
||||
}
|
||||
|
||||
private static CatalogEntry toApi(CatalogEntryView view) {
|
||||
CatalogEntry entry = new CatalogEntry();
|
||||
entry.setId(view.id());
|
||||
entry.setType(
|
||||
dev.caskeleton.adapter.inbound.web.techlog.studio.api.model.CatalogEntryType.fromValue(
|
||||
view.type().name()));
|
||||
entry.setLabel(view.label());
|
||||
entry.setDependencyRevision(view.dependencyRevision());
|
||||
if (view.kind() != null) {
|
||||
entry.setKind(CatalogEntry.KindEnum.fromValue(view.kind()));
|
||||
}
|
||||
entry.setPublicPath(view.publicPath());
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog.studio.controller;
|
||||
|
||||
import dev.caskeleton.adapter.inbound.web.auth.AuthenticatedPrincipal;
|
||||
import dev.caskeleton.adapter.inbound.web.settings.SecuritySettings;
|
||||
import dev.caskeleton.adapter.inbound.web.techlog.studio.api.model.StudioSession;
|
||||
import dev.caskeleton.application.techlog.error.StudioError;
|
||||
import dev.caskeleton.application.techlog.error.StudioException;
|
||||
import java.util.Set;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.web.csrf.CsrfToken;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 세션은 순수 전송 상태다 — principal과 CSRF 토큰뿐이라 도메인 규칙이 없다. application use case를 끼우지 않는 이유이고,
|
||||
* application-core는 Spring을 볼 수 없어 SecurityContext에 접근할 수도 없다.
|
||||
*
|
||||
* <p>반환값을 {@code Envelope}로 감싸지 않는다. {@code EnvelopeBodyAdvice}가 감싼다.
|
||||
*
|
||||
* <p><b>CSRF가 꺼진 auth-mode.</b> {@code SecurityConfig.filterChain}의 JWT 분기는 {@code csrf(csrf ->
|
||||
* csrf.disable())}로 {@code CsrfConfigurer} 자체를 제거한다 — {@code CsrfFilter}가 돌지 않고 request attribute를
|
||||
* 아무도 채우지 않는다. 그런데 Spring Security 7.0.0의 {@code CsrfTokenArgumentResolver}는
|
||||
* {@code @EnableWebSecurity}만 있으면 무조건 등록되고, {@code resolveArgument}는 request attribute를 캐스팅만 할 뿐
|
||||
* null 체크가 없다 — 그래서 CSRF가 꺼진 모드에서는 {@code csrfToken} 파라미터가 항상 {@code null}이다. Studio는 CSRF 없이 실제로
|
||||
* 동작할 수 없으므로, 가짜 토큰을 지어내 200을 돌려주는 대신 {@link StudioError#STUDIO_UNAVAILABLE}(503)로 그 사실을 정직하게 보고한다
|
||||
* — 세션 인프라가 갖춰지면(redis-session + 완전한 CSRF 배선) 코드 변경 없이 200으로 바뀐다. ({@code
|
||||
* StudioSessionCsrfDisabledTest}가 이 경로를 고정한다.)
|
||||
*/
|
||||
@RestController
|
||||
public class StudioSessionController {
|
||||
|
||||
/** studio-v1.yaml {@code StudioSession.csrfHeaderName}은 {@code const} — 이 값만 유효하다. */
|
||||
private static final String CONTRACT_CSRF_HEADER_NAME = "X-CSRF-TOKEN";
|
||||
|
||||
/** studio-v1.yaml {@code StudioSession.roles.maxItems}. */
|
||||
private static final int CONTRACT_MAX_ROLES = 20;
|
||||
|
||||
private final String csrfHeaderName;
|
||||
|
||||
/**
|
||||
* {@code csrf-header-name}을 하드코드하지 않고 설정에서 읽되, 계약이 고정한 값과 다르면 부팅 시점에 즉시 실패한다 — 계약의 {@code const}와
|
||||
* 설정이 갈라지는 건 배포 오류이지 런타임에 조용히 넘어갈 문제가 아니다.
|
||||
*/
|
||||
public StudioSessionController(SecuritySettings securitySettings) {
|
||||
String configured = securitySettings.session().csrfHeaderName();
|
||||
if (!CONTRACT_CSRF_HEADER_NAME.equals(configured)) {
|
||||
throw new IllegalStateException(
|
||||
"ca-skeleton.security.session.csrf-header-name must be \""
|
||||
+ CONTRACT_CSRF_HEADER_NAME
|
||||
+ "\" (studio-v1.yaml StudioSession.csrfHeaderName is a contract const) but was"
|
||||
+ " configured as \""
|
||||
+ configured
|
||||
+ "\"");
|
||||
}
|
||||
this.csrfHeaderName = configured;
|
||||
}
|
||||
|
||||
@GetMapping("/api/v1/studio/session")
|
||||
public StudioSession getStudioSession(
|
||||
@AuthenticationPrincipal AuthenticatedPrincipal principal, CsrfToken csrfToken) {
|
||||
if (csrfToken == null) {
|
||||
throw StudioException.of(
|
||||
StudioError.STUDIO_UNAVAILABLE,
|
||||
"CSRF token unavailable: CSRF protection is disabled for the active auth-mode");
|
||||
}
|
||||
|
||||
Set<String> roles = Set.copyOf(principal.roles());
|
||||
if (roles.size() > CONTRACT_MAX_ROLES) {
|
||||
// 조용히 잘라내면 클라이언트가 실제 권한과 다른 role 집합을 받는다 — IdP 쪽 role 매핑이 잘못됐다는
|
||||
// 신호를 숨기는 셈이라, 잘라내는 대신 실패시켜 드러낸다.
|
||||
throw StudioException.of(
|
||||
StudioError.STUDIO_UNAVAILABLE,
|
||||
"principal role count "
|
||||
+ roles.size()
|
||||
+ " exceeds contract max "
|
||||
+ CONTRACT_MAX_ROLES
|
||||
+ " (studio-v1.yaml StudioSession.roles.maxItems)");
|
||||
}
|
||||
|
||||
String displayName = displayNameOf(principal);
|
||||
if (displayName == null || displayName.isBlank()) {
|
||||
throw StudioException.of(
|
||||
StudioError.STUDIO_UNAVAILABLE,
|
||||
"principal has neither a usable email nor idpUserId; cannot satisfy"
|
||||
+ " StudioSession.displayName minLength 1");
|
||||
}
|
||||
|
||||
StudioSession session = new StudioSession();
|
||||
session.setAuthenticated(true);
|
||||
session.setDisplayName(displayName);
|
||||
session.setRoles(roles);
|
||||
session.setCsrfToken(csrfToken.getToken());
|
||||
session.setCsrfHeaderName(csrfHeaderName);
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
* `displayName`은 계약상 1자 이상이다. profile capability(identity 모듈)가 들어오기 전까지 email을 쓰고, 없으면 IdP
|
||||
* subject로 대체한다. 둘 다 비어 있으면 {@code getStudioSession}이 실패시킨다(위 참조).
|
||||
*/
|
||||
private static String displayNameOf(AuthenticatedPrincipal principal) {
|
||||
String email = principal.email();
|
||||
return (email == null || email.isBlank()) ? principal.idpUserId() : email;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package dev.caskeleton.adapter.inbound.web.error;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import dev.caskeleton.adapter.inbound.web.envelope.EnvelopeBodyAdvice;
|
||||
import dev.caskeleton.adapter.inbound.web.techlog.StudioExceptionHandler;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.security.autoconfigure.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* final whole-branch review B4: proves the negative for {@link StudioExceptionHandler}'s
|
||||
* {@code @RestControllerAdvice(basePackages = "dev.caskeleton.adapter.inbound.web.techlog")}
|
||||
* scoping.
|
||||
*
|
||||
* <p>{@link Probe} lives in {@code dev.caskeleton.adapter.inbound.web.error} — outside the {@code
|
||||
* ...web.techlog} tree the advice is scoped to, standing in for a non-Studio feature (fileserver,
|
||||
* healthcheck). A missing required parameter on it must still fall through to the inherited {@code
|
||||
* ResponseEntityExceptionHandler} behaviour (bare {@code ProblemDetail}, {@code
|
||||
* application/problem+json}) exactly as it did before {@code StudioExceptionHandler} grew {@code
|
||||
* MissingServletRequestParameterException}/{@code MethodArgumentTypeMismatchException} handlers —
|
||||
* this branch has no mandate to change fileserver/healthcheck's error shape. If the {@code
|
||||
* basePackages} scope were ever dropped or widened to cover this package, this probe would start
|
||||
* seeing {@code REQUEST_VALIDATION_FAILED} at 422 instead and this test would fail.
|
||||
*/
|
||||
@WebMvcTest(
|
||||
controllers = StudioExceptionHandlerScopeTest.Probe.class,
|
||||
excludeAutoConfiguration = SecurityAutoConfiguration.class)
|
||||
@AutoConfigureMockMvc(addFilters = false)
|
||||
@Import({
|
||||
StudioExceptionHandlerScopeTest.Probe.class,
|
||||
StudioExceptionHandler.class,
|
||||
GlobalExceptionHandler.class,
|
||||
EnvelopeBodyAdvice.class
|
||||
})
|
||||
class StudioExceptionHandlerScopeTest {
|
||||
|
||||
@Autowired private MockMvc mvc;
|
||||
|
||||
@Test
|
||||
void missingParameterOnANonStudioControllerKeepsTheUnenvelopedGlobalHandlerBehaviour()
|
||||
throws Exception {
|
||||
mvc.perform(get("/probe/non-studio"))
|
||||
.andExpect(status().is(400))
|
||||
.andExpect(
|
||||
content().contentTypeCompatibleWith(MediaType.valueOf("application/problem+json")));
|
||||
}
|
||||
|
||||
@RestController
|
||||
static class Probe {
|
||||
@GetMapping("/probe/non-studio")
|
||||
String probe(@RequestParam("required") String required) {
|
||||
return required;
|
||||
}
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class)
|
||||
static class TestBootstrap {}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import dev.caskeleton.application.techlog.error.StudioError;
|
||||
import dev.caskeleton.application.techlog.error.StudioException;
|
||||
import dev.caskeleton.shared.response.Envelope;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
class StudioExceptionHandlerTest {
|
||||
|
||||
private final StudioExceptionHandler handler = new StudioExceptionHandler();
|
||||
|
||||
@Test
|
||||
void mapsStudioExceptionToFailureEnvelopeWithContractCode() {
|
||||
ResponseEntity<Envelope<Void>> response =
|
||||
handler.handleStudio(StudioException.of(StudioError.DOCUMENT_NOT_FOUND, "없음"));
|
||||
|
||||
assertThat(response.getStatusCode().value()).isEqualTo(404);
|
||||
Envelope<Void> body = response.getBody();
|
||||
assertThat(body).isNotNull();
|
||||
assertThat(body.success()).isFalse();
|
||||
assertThat(body.error().code()).isEqualTo("DOCUMENT_NOT_FOUND");
|
||||
assertThat(body.error().category()).isEqualTo("NOT_FOUND");
|
||||
assertThat(body.error().retryable()).isFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for the client-safe message leak: the handler must never surface {@link
|
||||
* StudioException#getMessage()} (diagnostic-only, may carry SQLState/upstream detail) — only
|
||||
* {@link StudioClientSafeMessages#forError(StudioError)}'s fixed, per-code text.
|
||||
*/
|
||||
@Test
|
||||
void neverLeaksTheRawExceptionMessageAndUsesTheClientSafeTextInstead() {
|
||||
String rawDiagnosticMessage = "pg constraint fk_document_project violated for id=42";
|
||||
|
||||
ResponseEntity<Envelope<Void>> response =
|
||||
handler.handleStudio(
|
||||
StudioException.of(StudioError.DOCUMENT_NOT_FOUND, rawDiagnosticMessage));
|
||||
|
||||
String message = response.getBody().error().message();
|
||||
assertThat(message).isNotEqualTo(rawDiagnosticMessage);
|
||||
assertThat(message)
|
||||
.isEqualTo(StudioClientSafeMessages.forError(StudioError.DOCUMENT_NOT_FOUND));
|
||||
}
|
||||
|
||||
@Test
|
||||
void carriesDetailsForConflicts() {
|
||||
ResponseEntity<Envelope<Void>> response =
|
||||
handler.handleStudio(
|
||||
StudioException.withDetails(
|
||||
StudioError.VERSION_CONFLICT,
|
||||
"충돌",
|
||||
Map.of("latestDocument", Map.of("version", 8))));
|
||||
|
||||
assertThat(response.getStatusCode().value()).isEqualTo(409);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().error().details()).isNotNull();
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog.studio.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import dev.caskeleton.adapter.inbound.web.envelope.EnvelopeBodyAdvice;
|
||||
import dev.caskeleton.adapter.inbound.web.error.GlobalExceptionHandler;
|
||||
import dev.caskeleton.adapter.inbound.web.techlog.StudioExceptionHandler;
|
||||
import dev.caskeleton.application.techlog.studio.port.out.CatalogQueryPort;
|
||||
import dev.caskeleton.application.techlog.studio.service.ListCatalogUseCase;
|
||||
import dev.caskeleton.application.transaction.TransactionPort;
|
||||
import java.util.function.Supplier;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.security.autoconfigure.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
/**
|
||||
* final whole-branch review B4: {@code GET /api/v1/studio/catalog} without its required {@code
|
||||
* type} query parameter throws {@code MissingServletRequestParameterException}. Neither {@code
|
||||
* GlobalExceptionHandler} (which we cannot modify — template file) nor the old {@code
|
||||
* StudioExceptionHandler} handled it, so it fell through to the inherited {@code
|
||||
* ResponseEntityExceptionHandler} behaviour: a bare {@code ProblemDetail} body with content-type
|
||||
* {@code application/problem+json}. {@code EnvelopeBodyAdvice#beforeBodyWrite}'s {@code
|
||||
* MediaType.APPLICATION_JSON.includes(...)} guard then skips wrapping, so a bare RFC 7807 body
|
||||
* leaks past the envelope — exactly the wire shape ADR-006 says this backend does not use.
|
||||
*
|
||||
* <p>{@code ?type=BOGUS} and {@code ?limit=abc} throw {@code MethodArgumentTypeMismatchException}
|
||||
* instead — {@code GlobalExceptionHandler} does handle that one directly (so the body stays
|
||||
* enveloped), but with {@code OperationalError.BAD_PARAMETER}, a code outside the 23-code Studio
|
||||
* contract.
|
||||
*
|
||||
* <p>This test pins the fix: a Studio-scoped {@code StudioExceptionHandler} handler moves both
|
||||
* exceptions to the contract's {@code REQUEST_VALIDATION_FAILED} at 422 (the status the {@code
|
||||
* StudioError} enum and {@code docs/registries/error-codes.yaml} agree on), enveloped like every
|
||||
* other Studio failure.
|
||||
*
|
||||
* <p>Follows the {@code @WebMvcTest} + hand-built {@code TestBootstrap} slice pattern documented in
|
||||
* {@link StudioSessionEnvelopeTest} — this module's test source set has no {@code
|
||||
* CaSkeletonApplication} for {@code @WebMvcTest} to bootstrap from. Security is fully excluded
|
||||
* (like {@code NoResourceFoundErrorHandlingTest}) since none of these scenarios are
|
||||
* authentication/authorization-related. {@link ListCatalogUseCase} is real, not mocked (it is a
|
||||
* {@code final} class and this module's Mockito is not configured with the inline mock maker) —
|
||||
* built from hand-written fake ports, and its port never runs because request binding fails before
|
||||
* the controller method body is entered.
|
||||
*/
|
||||
@WebMvcTest(
|
||||
controllers = StudioCatalogController.class,
|
||||
excludeAutoConfiguration = SecurityAutoConfiguration.class)
|
||||
@AutoConfigureMockMvc(addFilters = false)
|
||||
@Import({
|
||||
StudioCatalogController.class,
|
||||
StudioExceptionHandler.class,
|
||||
GlobalExceptionHandler.class,
|
||||
EnvelopeBodyAdvice.class,
|
||||
StudioCatalogBindingErrorEnvelopeTest.TestBeans.class
|
||||
})
|
||||
class StudioCatalogBindingErrorEnvelopeTest {
|
||||
|
||||
@Autowired private MockMvc mvc;
|
||||
|
||||
@Test
|
||||
void missingRequiredTypeParameterIsEnvelopedAsRequestValidationFailed() throws Exception {
|
||||
mvc.perform(get("/api/v1/studio/catalog"))
|
||||
.andExpect(status().is(422))
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath("$.success").value(false))
|
||||
.andExpect(jsonPath("$.error.code").value("REQUEST_VALIDATION_FAILED"))
|
||||
.andExpect(jsonPath("$.error.category").value("VALIDATION"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownTypeEnumValueIsEnvelopedAsRequestValidationFailed() throws Exception {
|
||||
mvc.perform(get("/api/v1/studio/catalog").param("type", "BOGUS"))
|
||||
.andExpect(status().is(422))
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath("$.success").value(false))
|
||||
.andExpect(jsonPath("$.error.code").value("REQUEST_VALIDATION_FAILED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonNumericLimitIsEnvelopedAsRequestValidationFailed() throws Exception {
|
||||
mvc.perform(get("/api/v1/studio/catalog").param("type", "TOPIC").param("limit", "abc"))
|
||||
.andExpect(status().is(422))
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath("$.success").value(false))
|
||||
.andExpect(jsonPath("$.error.code").value("REQUEST_VALIDATION_FAILED"));
|
||||
}
|
||||
|
||||
static class TestBeans {
|
||||
|
||||
@Bean
|
||||
ListCatalogUseCase listCatalogUseCase() {
|
||||
CatalogQueryPort neverInvoked =
|
||||
(type, query, cursor, limit) -> {
|
||||
throw new AssertionError(
|
||||
"ListCatalogUseCase must not run when request binding already failed");
|
||||
};
|
||||
return new ListCatalogUseCase(neverInvoked, new PassthroughTransactionPort());
|
||||
}
|
||||
}
|
||||
|
||||
/** Runs the action synchronously with no real transactional semantics — a slice test fake. */
|
||||
private static final class PassthroughTransactionPort implements TransactionPort {
|
||||
@Override
|
||||
public <T> T inWrite(Supplier<T> action) {
|
||||
return action.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T inRootWrite(Supplier<T> action) {
|
||||
return action.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T inRead(Supplier<T> action) {
|
||||
return action.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T inNew(Supplier<T> action) {
|
||||
return action.get();
|
||||
}
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class)
|
||||
static class TestBootstrap {}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog.studio.controller;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import dev.caskeleton.adapter.inbound.web.auth.AuthenticatedPrincipal;
|
||||
import dev.caskeleton.adapter.inbound.web.settings.SecuritySettings;
|
||||
import dev.caskeleton.adapter.inbound.web.techlog.studio.api.model.StudioSession;
|
||||
import dev.caskeleton.application.techlog.error.StudioError;
|
||||
import dev.caskeleton.application.techlog.error.StudioException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.security.web.csrf.DefaultCsrfToken;
|
||||
|
||||
class StudioSessionControllerTest {
|
||||
|
||||
private final StudioSessionController controller =
|
||||
new StudioSessionController(securitySettingsWithCsrfHeaderName("X-CSRF-TOKEN"));
|
||||
|
||||
@Test
|
||||
void reportsAuthenticatedPrincipalAndCsrfToken() {
|
||||
StudioSession session =
|
||||
controller.getStudioSession(
|
||||
new AuthenticatedPrincipal("sub-1", "donghyeon@example.com", Set.of("STUDIO_EDITOR")),
|
||||
new DefaultCsrfToken("X-CSRF-TOKEN", "_csrf", "token-value"));
|
||||
|
||||
assertThat(session.getAuthenticated()).isTrue();
|
||||
assertThat(session.getDisplayName()).isEqualTo("donghyeon@example.com");
|
||||
assertThat(session.getRoles()).containsExactly("STUDIO_EDITOR");
|
||||
assertThat(session.getCsrfToken()).isEqualTo("token-value");
|
||||
assertThat(session.getCsrfHeaderName()).isEqualTo("X-CSRF-TOKEN");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fallsBackToIdpUserIdWhenEmailIsAbsent() {
|
||||
StudioSession session =
|
||||
controller.getStudioSession(
|
||||
new AuthenticatedPrincipal("sub-1", null, Set.of()),
|
||||
new DefaultCsrfToken("X-CSRF-TOKEN", "_csrf", "t"));
|
||||
|
||||
assertThat(session.getDisplayName()).isEqualTo("sub-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsAMisconfiguredCsrfHeaderNameAtConstructionRatherThanServingTheWrongHeader() {
|
||||
assertThatThrownBy(() -> new StudioSessionController(securitySettingsWithCsrfHeaderName(null)))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("X-CSRF-TOKEN")
|
||||
.hasMessageContaining("X-XSRF-TOKEN");
|
||||
}
|
||||
|
||||
@Test
|
||||
void reportsStudioUnavailableRatherThanNpeWhenCsrfTokenIsNull() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
controller.getStudioSession(
|
||||
new AuthenticatedPrincipal(
|
||||
"sub-1", "donghyeon@example.com", Set.of("STUDIO_EDITOR")),
|
||||
null))
|
||||
.isInstanceOf(StudioException.class)
|
||||
.extracting(ex -> ((StudioException) ex).studioError())
|
||||
.isEqualTo(StudioError.STUDIO_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void reportsStudioUnavailableRatherThanTruncatingRolesBeyondTheContractMax() {
|
||||
Set<String> tooManyRoles =
|
||||
IntStream.range(0, 21).mapToObj(i -> "ROLE_" + i).collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
controller.getStudioSession(
|
||||
new AuthenticatedPrincipal("sub-1", "donghyeon@example.com", tooManyRoles),
|
||||
new DefaultCsrfToken("X-CSRF-TOKEN", "_csrf", "t")))
|
||||
.isInstanceOf(StudioException.class)
|
||||
.extracting(ex -> ((StudioException) ex).studioError())
|
||||
.isEqualTo(StudioError.STUDIO_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void reportsStudioUnavailableRatherThanAnEmptyDisplayNameWhenEmailAndIdpUserIdAreBothBlank() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
controller.getStudioSession(
|
||||
new AuthenticatedPrincipal(" ", " ", Set.of()),
|
||||
new DefaultCsrfToken("X-CSRF-TOKEN", "_csrf", "t")))
|
||||
.isInstanceOf(StudioException.class)
|
||||
.extracting(ex -> ((StudioException) ex).studioError())
|
||||
.isEqualTo(StudioError.STUDIO_UNAVAILABLE);
|
||||
}
|
||||
|
||||
private static SecuritySettings securitySettingsWithCsrfHeaderName(String csrfHeaderName) {
|
||||
SecuritySettings.SessionCookieSettings session =
|
||||
new SecuritySettings.SessionCookieSettings(
|
||||
null, null, null, null, null, null, csrfHeaderName);
|
||||
return new SecuritySettings(
|
||||
SecuritySettings.AuthenticationMode.JWT,
|
||||
"https://issuer.example",
|
||||
null,
|
||||
List.of(),
|
||||
session);
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog.studio.controller;
|
||||
|
||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import dev.caskeleton.adapter.inbound.web.auth.AuthenticatedPrincipal;
|
||||
import dev.caskeleton.adapter.inbound.web.envelope.EnvelopeBodyAdvice;
|
||||
import dev.caskeleton.adapter.inbound.web.error.GlobalExceptionHandler;
|
||||
import dev.caskeleton.adapter.inbound.web.observability.MdcKeys;
|
||||
import dev.caskeleton.adapter.inbound.web.settings.SecuritySettings;
|
||||
import dev.caskeleton.adapter.inbound.web.techlog.StudioExceptionHandler;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
/**
|
||||
* 프로덕션 JWT auth-mode를 재현한다: {@code SecurityConfig.filterChain}의 JWT 분기는 {@code csrf(csrf ->
|
||||
* csrf.disable())}로 {@code CsrfConfigurer} 자체를 제거한다 — {@code CsrfFilter}가 돌지 않고 {@code CsrfToken}
|
||||
* request attribute를 아무도 채우지 않는다.
|
||||
*
|
||||
* <p>그런데 {@code CsrfTokenArgumentResolver}(Spring Security 7.0.0, {@code
|
||||
* WebMvcSecurityConfiguration.addArgumentResolvers}가 {@code @EnableWebSecurity}만 있으면 무조건 등록한다)의
|
||||
* {@code resolveArgument}는 request attribute를 캐스팅만 할 뿐 null 체크가 없다 — attribute가 없으면 그냥 {@code
|
||||
* null}을 돌려준다. 그래서 JWT 모드에서는 컨트롤러의 {@code CsrfToken csrfToken} 파라미터가 **항상 null**이다.
|
||||
*
|
||||
* <p>이 테스트는 그 사실을 슬라이스 필터체인으로 직접 재현한다 — {@link StudioSessionEnvelopeTest}의 {@code
|
||||
* SecurityTestConfig}(CSRF 켜짐, Spring 기본값)와 정확히 반대다. 일부러 {@code
|
||||
* SecurityMockMvcRequestPostProcessors.csrf()}를 쓰지 않는다 — 그 포스트 프로세서는 실제 필터체인 여부와 무관하게 request
|
||||
* attribute를 직접 채워버려서, 쓰면 이 재현이 무력화된다(CSRF가 꺼져 있어도 토큰이 채워진 것처럼 보이게 된다).
|
||||
*/
|
||||
@WebMvcTest(controllers = StudioSessionController.class)
|
||||
@Import({
|
||||
StudioSessionController.class,
|
||||
EnvelopeBodyAdvice.class,
|
||||
StudioExceptionHandler.class,
|
||||
GlobalExceptionHandler.class,
|
||||
StudioSessionCsrfDisabledTest.SecurityTestConfig.class
|
||||
})
|
||||
class StudioSessionCsrfDisabledTest {
|
||||
|
||||
@Autowired private MockMvc mvc;
|
||||
|
||||
@AfterEach
|
||||
void clearMdc() {
|
||||
MDC.remove(MdcKeys.TRACE_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
void reportsStudioUnavailableRatherThanCrashingWhenCsrfIsDisabled() throws Exception {
|
||||
MDC.put(MdcKeys.TRACE_ID, "test-trace-id");
|
||||
|
||||
mvc.perform(
|
||||
get("/api/v1/studio/session")
|
||||
.with(
|
||||
authentication(
|
||||
UsernamePasswordAuthenticationToken.authenticated(
|
||||
new AuthenticatedPrincipal(
|
||||
"sub-1", "donghyeon@example.com", Set.of("STUDIO_EDITOR")),
|
||||
null,
|
||||
Set.of(new SimpleGrantedAuthority("ROLE_STUDIO_EDITOR"))))))
|
||||
.andExpect(status().isServiceUnavailable())
|
||||
.andExpect(jsonPath("$.success").value(false))
|
||||
.andExpect(jsonPath("$.error.code").value("STUDIO_UNAVAILABLE"))
|
||||
.andExpect(jsonPath("$.error.retryable").value(true))
|
||||
.andExpect(jsonPath("$.meta.traceId").isNotEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code SecurityConfig.filterChain}의 JWT 분기와 같은 모양 — {@code csrf().disable()} + {@code
|
||||
* anyRequest().authenticated()}뿐. 실제 앱의 {@code SecurityConfig} 전체(CORS, JWT-vs-redis-session 분기,
|
||||
* entry point 등)는 가져오지 않는다.
|
||||
*/
|
||||
@EnableWebSecurity
|
||||
static class SecurityTestConfig {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain csrfDisabledFilterChain(HttpSecurity http) throws Exception {
|
||||
http.csrf(csrf -> csrf.disable())
|
||||
.authorizeHttpRequests(auth -> auth.anyRequest().authenticated());
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
SecuritySettings securitySettings() {
|
||||
SecuritySettings.SessionCookieSettings session =
|
||||
new SecuritySettings.SessionCookieSettings(
|
||||
null, null, null, null, null, null, "X-CSRF-TOKEN");
|
||||
return new SecuritySettings(
|
||||
SecuritySettings.AuthenticationMode.JWT,
|
||||
"https://issuer.example",
|
||||
null,
|
||||
List.of(),
|
||||
session);
|
||||
}
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
@EnableAutoConfiguration
|
||||
static class TestBootstrap {}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package dev.caskeleton.adapter.inbound.web.techlog.studio.controller;
|
||||
|
||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication;
|
||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import dev.caskeleton.adapter.inbound.web.auth.AuthenticatedPrincipal;
|
||||
import dev.caskeleton.adapter.inbound.web.envelope.EnvelopeBodyAdvice;
|
||||
import dev.caskeleton.adapter.inbound.web.observability.MdcKeys;
|
||||
import dev.caskeleton.adapter.inbound.web.settings.SecuritySettings;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
/**
|
||||
* 응답이 봉투로 정확히 한 번 감싸이는지 고정한다. 두 번 감싸이면 프론트가 조용히 깨진다. CSRF가 **켜진** 필터체인(Spring 기본값)에서의 해피 패스만 다룬다 —
|
||||
* CSRF가 **꺼진**(프로덕션 JWT 모드와 같은 모양) 경로는 {@link StudioSessionCsrfDisabledTest}가 별도로 고정한다. 두 필터체인을 한
|
||||
* 테스트 클래스에 같이 둘 수 없다({@code @WebMvcTest}는 클래스당 Spring 컨텍스트 하나뿐이라 {@code SecurityFilterChain} 빈도
|
||||
* 하나뿐이다).
|
||||
*
|
||||
* <p>이 모듈(adapter:inbound:web)의 테스트 소스셋에는 {@code CaSkeletonApplication}이 없다 — 그건 app-bootstrap 모듈
|
||||
* 소유다. 그래서 {@code @WebMvcTest}가 컨텍스트를 부트스트랩할 {@code @SpringBootConfiguration}을 못 찾는다. {@link
|
||||
* dev.caskeleton.adapter.inbound.web.envelope.EnvelopeBodyAdviceTest}와 {@link
|
||||
* dev.caskeleton.adapter.inbound.web.error.NoResourceFoundErrorHandlingTest}가 쓰는 것과 같은 방식으로 — 테스트
|
||||
* 전용 nested {@code TestBootstrap}을 두고 필요한 빈을 명시적으로 {@code @Import}한다.
|
||||
*
|
||||
* <p>보안: 이 슬라이스는 실제 {@code SecurityConfig}를 끌어오지 않는다(그건 {@code CorsSettings}, {@code
|
||||
* JwtToAuthenticatedPrincipalConverter} 등 앱 전체 배선이 필요해서 슬라이스 테스트에 과하다). 이 저장소에 이 조합 (WebMvcTest +
|
||||
* 실제 보안 필터 체인 + AuthenticatedPrincipal)의 선례가 없다 — {@code SecurityModeWebContractTest}는 {@code
|
||||
* WebApplicationContextRunner}+standalone MockMvc를 쓰지 slice가 아니고, {@code
|
||||
* EnvelopeBodyAdviceTest}/{@code NoResourceFoundErrorHandlingTest}는 반대로 Security를 통째로 배제한다 ({@code
|
||||
* excludeAutoConfiguration = SecurityAutoConfiguration.class} + {@code addFilters = false}). 그래서
|
||||
* 브리프가 제시한 fallback을 따른다 — {@code @WithMockUser} 대신 {@code
|
||||
* SecurityMockMvcRequestPostProcessors.csrf()}와 커스텀 {@code authentication(...)}을 쓴다.
|
||||
* {@code @WithMockUser}는 principal을 {@code org.springframework.security.core.userdetails.User}로
|
||||
* 채우는데 컨트롤러가 기대하는 타입은 {@code AuthenticatedPrincipal}이라 타입 불일치로 {@code @AuthenticationPrincipal}이
|
||||
* null을 주입하고 컨트롤러가 NPE를 던진다 — 실측으로 확인했다(task-8 report 참조).
|
||||
*
|
||||
* <p>{@code @WebMvcTest}는 표준 {@code @EnableAutoConfiguration}을
|
||||
* {@code @OverrideAutoConfiguration(enabled = false)}로 끄고 test-slice 전용의 제한된 auto-configuration 목록만
|
||||
* 적용한다 — 그 목록은 Boot의 {@code ServletWebSecurityAutoConfiguration}(기본 {@code SecurityFilterChain} +
|
||||
* {@code @EnableWebSecurity})을 포함하지 않는다. 그래서 {@code TestBootstrap}이
|
||||
* {@code @EnableAutoConfiguration}을 달고 있어도 {@code CsrfToken}/{@code @AuthenticationPrincipal} 인자
|
||||
* 리졸버가 등록되지 않는다 — 실제로 시도했더니 {@code CsrfToken}이 인자 리졸버 없이 {@code @ModelAttribute} 데이터바인딩 경로로 떨어져 "No
|
||||
* primary or single unique constructor found for interface CsrfToken" {@code
|
||||
* IllegalStateException}으로 500이 났다. 그래서 {@code @EnableWebSecurity}를 이 테스트가 직접 명시적으로 붙인다({@code
|
||||
* SecurityTestConfig}) — 그래야 그 인자 리졸버들이 등록된다.
|
||||
*
|
||||
* <p>{@code meta.traceId}는 프로덕션에서 {@code RequestLoggingFilter}가 MDC에 채운다. 그 필터는 {@code
|
||||
* UserPrincipalPseudonymizerPort} 빈이 필요하고 자체 테스트({@code RequestLoggingFilterTest})가 이미 있으므로 여기서는
|
||||
* 재현하지 않는다 — MockMvc가 테스트 스레드에서 동기 실행되는 점을 이용해 MDC를 직접 채운다.
|
||||
*/
|
||||
@WebMvcTest(controllers = StudioSessionController.class)
|
||||
@Import({
|
||||
StudioSessionController.class,
|
||||
EnvelopeBodyAdvice.class,
|
||||
StudioSessionEnvelopeTest.SecurityTestConfig.class
|
||||
})
|
||||
class StudioSessionEnvelopeTest {
|
||||
|
||||
@Autowired private MockMvc mvc;
|
||||
|
||||
@AfterEach
|
||||
void clearMdc() {
|
||||
MDC.remove(MdcKeys.TRACE_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
void wrapsTheSessionPayloadExactlyOnce() throws Exception {
|
||||
MDC.put(MdcKeys.TRACE_ID, "test-trace-id");
|
||||
|
||||
mvc.perform(
|
||||
get("/api/v1/studio/session")
|
||||
.with(csrf())
|
||||
.with(
|
||||
authentication(
|
||||
UsernamePasswordAuthenticationToken.authenticated(
|
||||
new AuthenticatedPrincipal(
|
||||
"sub-1", "donghyeon@example.com", Set.of("STUDIO_EDITOR")),
|
||||
null,
|
||||
Set.of(new SimpleGrantedAuthority("ROLE_STUDIO_EDITOR"))))))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.success").value(true))
|
||||
.andExpect(jsonPath("$.data.csrfHeaderName").value("X-CSRF-TOKEN"))
|
||||
.andExpect(jsonPath("$.data.data").doesNotExist())
|
||||
.andExpect(jsonPath("$.meta.traceId").isNotEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code CsrfToken}/{@code @AuthenticationPrincipal} 인자 리졸버를 등록하는 최소 보안 구성. 실제 앱의 {@code
|
||||
* SecurityConfig}(CORS, JWT/redis-session 분기, entry point 등)는 가져오지 않고 이 슬라이스가 필요로 하는 것 — 인증된 요청만
|
||||
* 통과, CSRF는 Spring 기본값(켜짐) — 만 남긴다. {@link StudioSessionCsrfDisabledTest}의 {@code
|
||||
* SecurityTestConfig}가 정확히 반대(CSRF 꺼짐)를 재현한다.
|
||||
*/
|
||||
@EnableWebSecurity
|
||||
static class SecurityTestConfig {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests(auth -> auth.anyRequest().authenticated());
|
||||
return http.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 컨트롤러가 이제 {@code csrfHeaderName}을 이 설정에서 읽는다(하드코드하지 않음) — 계약값 {@code X-CSRF-TOKEN}과 일치해야 생성자가
|
||||
* 통과한다.
|
||||
*/
|
||||
@Bean
|
||||
SecuritySettings securitySettings() {
|
||||
SecuritySettings.SessionCookieSettings session =
|
||||
new SecuritySettings.SessionCookieSettings(
|
||||
null, null, null, null, null, null, "X-CSRF-TOKEN");
|
||||
return new SecuritySettings(
|
||||
SecuritySettings.AuthenticationMode.JWT,
|
||||
"https://issuer.example",
|
||||
null,
|
||||
List.of(),
|
||||
session);
|
||||
}
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
@EnableAutoConfiguration
|
||||
static class TestBootstrap {}
|
||||
}
|
||||
@@ -107,6 +107,15 @@ def postgresqlFileserverMetadataIntegrationTest = registerPostgreSqlReadinessTes
|
||||
def postgresqlFileserverReclamationIntegrationTest = registerPostgreSqlReadinessTest(
|
||||
'postgresqlFileserverReclamationIntegrationTest',
|
||||
'dev.caskeleton.adapter.outbound.persistence.readiness.PostgreSqlFileserverReclamationIntegrationTest')
|
||||
def postgresqlTechLogSchemaMigrationTest = registerPostgreSqlReadinessTest(
|
||||
'postgresqlTechLogSchemaMigrationTest',
|
||||
'dev.caskeleton.adapter.outbound.persistence.techlog.TechLogSchemaMigrationTest')
|
||||
// Task 9 (listStudioCatalog): JdbcCatalogQueryAdapterTest has no @SpringBootConfiguration to hang a
|
||||
// @SpringBootTest off in this module (same reason as postgresqlTechLogSchemaMigrationTest above), so it
|
||||
// needs its own opt-in Testcontainers task rather than reusing an existing one.
|
||||
def postgresqlTechLogCatalogQueryIntegrationTest = registerPostgreSqlReadinessTest(
|
||||
'postgresqlTechLogCatalogQueryIntegrationTest',
|
||||
'dev.caskeleton.adapter.outbound.persistence.techlog.query.JdbcCatalogQueryAdapterTest')
|
||||
|
||||
def verifyJpaSqlConstructionSafety = tasks.register('verifyJpaSqlConstructionSafety') {
|
||||
group = 'verification'
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package dev.caskeleton.adapter.outbound.persistence.techlog.query;
|
||||
|
||||
import dev.caskeleton.application.techlog.studio.port.out.CatalogQueryPort;
|
||||
import dev.caskeleton.application.techlog.studio.query.CatalogEntryType;
|
||||
import dev.caskeleton.application.techlog.studio.query.CatalogEntryView;
|
||||
import dev.caskeleton.application.techlog.studio.query.CatalogPageView;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import org.springframework.jdbc.core.simple.JdbcClient;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* catalog는 도메인 repository를 거치지 않고 전용 union query를 쓴다 (설계 08장 §4).
|
||||
*
|
||||
* <p>RELATION / EVIDENCE는 슬라이스 2·5에서 채운다. 그때까지 빈 페이지를 반환하며 이는 계약상 유효한 응답이다.
|
||||
*/
|
||||
@Repository
|
||||
public class JdbcCatalogQueryAdapter implements CatalogQueryPort {
|
||||
|
||||
private final JdbcClient jdbcClient;
|
||||
|
||||
public JdbcCatalogQueryAdapter(JdbcClient jdbcClient) {
|
||||
this.jdbcClient = jdbcClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CatalogPageView search(CatalogEntryType type, String query, String cursor, int limit) {
|
||||
String pattern =
|
||||
(query == null || query.isBlank()) ? "%" : "%" + query.toLowerCase(Locale.ROOT) + "%";
|
||||
List<CatalogEntryView> items =
|
||||
switch (type) {
|
||||
case TOPIC -> searchTopics(pattern, limit);
|
||||
case PROJECT -> searchProjects(pattern, limit);
|
||||
case RELATION, EVIDENCE -> List.of();
|
||||
};
|
||||
return new CatalogPageView(items, null);
|
||||
}
|
||||
|
||||
private List<CatalogEntryView> searchTopics(String pattern, int limit) {
|
||||
return jdbcClient
|
||||
.sql(
|
||||
"SELECT id, name, updated_at FROM topic "
|
||||
+ "WHERE status = 'ACTIVE' AND lower(name) LIKE :pattern "
|
||||
+ "ORDER BY name LIMIT :limit")
|
||||
.param("pattern", pattern)
|
||||
.param("limit", limit)
|
||||
.query(
|
||||
(rs, rowNum) ->
|
||||
new CatalogEntryView(
|
||||
UUID.fromString(rs.getString("id")),
|
||||
CatalogEntryType.TOPIC,
|
||||
rs.getString("name"),
|
||||
null,
|
||||
null,
|
||||
"topic:" + rs.getTimestamp("updated_at").toInstant()))
|
||||
.list();
|
||||
}
|
||||
|
||||
private List<CatalogEntryView> searchProjects(String pattern, int limit) {
|
||||
return jdbcClient
|
||||
.sql(
|
||||
"SELECT id, name, updated_at FROM project "
|
||||
+ "WHERE lower(name) LIKE :pattern ORDER BY name LIMIT :limit")
|
||||
.param("pattern", pattern)
|
||||
.param("limit", limit)
|
||||
.query(
|
||||
(rs, rowNum) ->
|
||||
new CatalogEntryView(
|
||||
UUID.fromString(rs.getString("id")),
|
||||
CatalogEntryType.PROJECT,
|
||||
rs.getString("name"),
|
||||
"PROJECT",
|
||||
null,
|
||||
"project:" + rs.getTimestamp("updated_at").toInstant()))
|
||||
.list();
|
||||
}
|
||||
}
|
||||
+779
@@ -0,0 +1,779 @@
|
||||
-- Tech Log 코어 스키마.
|
||||
-- 원본: tech-log-design-package/database/V1__init.sql
|
||||
-- (branch feature/response-envelope-adr-006, HEAD b20d7a2 — 이 파일은 그 이후 바뀌지 않았다)
|
||||
--
|
||||
-- 원본 DDL과의 차이:
|
||||
-- 1. `CREATE SCHEMA IF NOT EXISTS tech_log;` / `SET search_path TO tech_log, public;` 제거.
|
||||
-- 이 저장소의 기존 마이그레이션(V1/V3/V4/V5/V6)과 JPA 설정(@EntityScan, @EnableJpaRepositories,
|
||||
-- PostgreSqlPersistenceConfig의 FlywayConfigurationCustomizer)은 모두 기본 public 스키마를
|
||||
-- 전제한다. tech_log 전용 스키마로 옮기면 Task 9 이후의 JPA 엔티티가 이 테이블들을 찾지
|
||||
-- 못한다. 그래서 테이블은 이 저장소의 다른 모든 테이블과 마찬가지로 public 스키마에 만든다.
|
||||
-- 2. `studio_idempotency` 테이블과 전용 인덱스(`idx_studio_idempotency_expiry`)를 제외한다.
|
||||
-- 기존 `idempotency_record`를 재사용한다 (spec D5).
|
||||
-- 3. `release` / `site_config` / `profile_page` / `home_focus_config` /
|
||||
-- `topic_featured_document` / `project_topic` 테이블과 전용 인덱스(`uq_topic_start_here`)를
|
||||
-- 제외한다. 이번 범위 밖이다 (spec §2.2). site_config/profile_page/home_focus_config를
|
||||
-- 시딩하던 마지막 INSERT 구문도 대상 테이블이 없으므로 함께 제외했다.
|
||||
-- 4. 그 밖의 테이블·컬럼·CHECK·UNIQUE·인덱스·주석·순서는 원본을 그대로 보존한다. 순환 FK
|
||||
-- `publication.latest_event_id` -> `publication_event.publication_id`의
|
||||
-- `DEFERRABLE INITIALLY DEFERRED`도 그대로 유지한다 — 즉시 검사로 바꾸면 첫 게시가
|
||||
-- 구조적으로 불가능해진다.
|
||||
|
||||
-- Tech Log initial PostgreSQL schema
|
||||
-- Target: PostgreSQL 16+
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Taxonomy and assets
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE topic (
|
||||
id uuid PRIMARY KEY,
|
||||
name varchar(80) NOT NULL,
|
||||
normalized_name varchar(80) NOT NULL,
|
||||
slug varchar(100) NOT NULL,
|
||||
description varchar(600),
|
||||
scope text,
|
||||
status varchar(20) NOT NULL DEFAULT 'ACTIVE'
|
||||
CHECK (status IN ('ACTIVE', 'ARCHIVED')),
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT uq_topic_normalized_name UNIQUE (normalized_name),
|
||||
CONSTRAINT uq_topic_slug UNIQUE (slug)
|
||||
);
|
||||
|
||||
CREATE TABLE tag (
|
||||
id uuid PRIMARY KEY,
|
||||
name varchar(40) NOT NULL,
|
||||
normalized_name varchar(40) NOT NULL,
|
||||
slug varchar(60) NOT NULL,
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT uq_tag_normalized_name UNIQUE (normalized_name),
|
||||
CONSTRAINT uq_tag_slug UNIQUE (slug)
|
||||
);
|
||||
|
||||
-- asset_key는 Public content가 참조하는 안정적인 key다.
|
||||
-- object_key(스토리지 경로)와 분리되며 immutable이다.
|
||||
--
|
||||
-- asset_key -> Asset lookup -> current approved delivery path
|
||||
--
|
||||
-- 콘텐츠 원문에 object storage URL을 직접 영속하지 않는다.
|
||||
-- 공개 이력이 있는 asset_key의 재사용 금지는 application rule로 강제한다.
|
||||
-- (DB는 현재 행의 유일성만 보장한다.)
|
||||
CREATE TABLE asset (
|
||||
id uuid PRIMARY KEY,
|
||||
asset_key varchar(200) NOT NULL,
|
||||
asset_kind varchar(20) NOT NULL
|
||||
CHECK (asset_kind IN ('IMAGE', 'DIAGRAM', 'ATTACHMENT')),
|
||||
management_status varchar(20) NOT NULL
|
||||
CHECK (management_status IN ('READY', 'ARCHIVED', 'REJECTED', 'QUARANTINED')),
|
||||
object_key varchar(500) NOT NULL,
|
||||
original_name varchar(255) NOT NULL,
|
||||
display_name varchar(255),
|
||||
content_type varchar(150) NOT NULL,
|
||||
size_bytes bigint NOT NULL CHECK (size_bytes >= 0),
|
||||
width integer CHECK (width IS NULL OR width > 0),
|
||||
height integer CHECK (height IS NULL OR height > 0),
|
||||
checksum_sha256 char(64) NOT NULL,
|
||||
alt_text varchar(300),
|
||||
decorative boolean NOT NULL DEFAULT false,
|
||||
first_published_at timestamptz,
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT uq_asset_key UNIQUE (asset_key),
|
||||
CONSTRAINT uq_asset_object_key UNIQUE (object_key)
|
||||
);
|
||||
|
||||
-- alt/decorative는 DB CHECK로 강제하지 않는다.
|
||||
--
|
||||
-- 업로드 시점에는 alt를 아직 정하지 않을 수 있어야 하고(Asset Picker에서 이후 수정),
|
||||
-- 최종 판단은 syntax parser가 아니라 Publication Validation이 한다.
|
||||
--
|
||||
-- Asset decorative=false + 사용 위치 alt 비어 있음 -> PublishValidationFailed
|
||||
-- Asset decorative=true -> alt="" 허용
|
||||
--
|
||||
-- 즉 판단 대상은 asset.alt_text 자체가 아니라 "해당 사용 위치의 alt"다.
|
||||
-- 같은 Asset이 문서마다 다른 alt로 쓰일 수 있으므로 행 단위 CHECK로 표현할 수 없다.
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Knowledge documents
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE document (
|
||||
id uuid PRIMARY KEY,
|
||||
document_type varchar(20) NOT NULL
|
||||
CHECK (document_type IN ('CASE', 'REFERENCE')),
|
||||
slug varchar(180),
|
||||
title varchar(180) NOT NULL,
|
||||
body_markdown text NOT NULL DEFAULT '',
|
||||
content_format varchar(20) NOT NULL DEFAULT 'MARKDOWN'
|
||||
CHECK (content_format IN ('MARKDOWN')),
|
||||
content_format_version smallint NOT NULL DEFAULT 1
|
||||
CHECK (content_format_version > 0),
|
||||
workflow_status varchar(20) NOT NULL DEFAULT 'DRAFT'
|
||||
CHECK (workflow_status IN ('DRAFT', 'IN_REVIEW', 'PUBLISHED', 'ARCHIVED')),
|
||||
target_visibility varchar(20) NOT NULL DEFAULT 'PRIVATE'
|
||||
CHECK (target_visibility IN ('PRIVATE', 'UNLISTED', 'PUBLIC')),
|
||||
primary_topic_id uuid REFERENCES topic(id),
|
||||
cover_asset_id uuid REFERENCES asset(id),
|
||||
last_verified_at timestamptz,
|
||||
first_published_at timestamptz,
|
||||
last_published_at timestamptz,
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT uq_document_id_type UNIQUE (id, document_type),
|
||||
CONSTRAINT uq_document_type_slug UNIQUE (document_type, slug),
|
||||
CONSTRAINT ck_document_slug_non_blank CHECK (slug IS NULL OR length(trim(slug)) > 0),
|
||||
CONSTRAINT ck_document_publish_time_order CHECK (
|
||||
first_published_at IS NULL
|
||||
OR last_published_at IS NULL
|
||||
OR first_published_at <= last_published_at
|
||||
)
|
||||
);
|
||||
|
||||
CREATE TABLE case_detail (
|
||||
document_id uuid PRIMARY KEY,
|
||||
document_type varchar(20) NOT NULL DEFAULT 'CASE'
|
||||
CHECK (document_type = 'CASE'),
|
||||
problem_summary varchar(600) NOT NULL DEFAULT '',
|
||||
conclusion_summary varchar(600) NOT NULL DEFAULT '',
|
||||
environment_items jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
CHECK (jsonb_typeof(environment_items) = 'array'),
|
||||
CONSTRAINT fk_case_detail_document
|
||||
FOREIGN KEY (document_id, document_type)
|
||||
REFERENCES document(id, document_type)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE reference_detail (
|
||||
document_id uuid PRIMARY KEY,
|
||||
document_type varchar(20) NOT NULL DEFAULT 'REFERENCE'
|
||||
CHECK (document_type = 'REFERENCE'),
|
||||
scope_summary varchar(600) NOT NULL DEFAULT '',
|
||||
applies_to jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
CHECK (jsonb_typeof(applies_to) = 'array'),
|
||||
excluded_scope jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
CHECK (jsonb_typeof(excluded_scope) = 'array'),
|
||||
freshness_status varchar(20) NOT NULL DEFAULT 'CURRENT'
|
||||
CHECK (freshness_status IN ('CURRENT', 'REVIEW_DUE', 'HISTORICAL')),
|
||||
CONSTRAINT fk_reference_detail_document
|
||||
FOREIGN KEY (document_id, document_type)
|
||||
REFERENCES document(id, document_type)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE document_tag (
|
||||
document_id uuid NOT NULL REFERENCES document(id) ON DELETE CASCADE,
|
||||
tag_id uuid NOT NULL REFERENCES tag(id),
|
||||
display_order integer NOT NULL CHECK (display_order >= 0),
|
||||
PRIMARY KEY (document_id, tag_id),
|
||||
CONSTRAINT uq_document_tag_order UNIQUE (document_id, display_order)
|
||||
);
|
||||
|
||||
CREATE TABLE document_relation (
|
||||
source_document_id uuid NOT NULL REFERENCES document(id) ON DELETE CASCADE,
|
||||
target_document_id uuid NOT NULL REFERENCES document(id),
|
||||
relation_type varchar(30) NOT NULL
|
||||
CHECK (relation_type IN ('RELATED', 'DERIVED_FROM', 'SUPERSEDES')),
|
||||
display_order integer NOT NULL DEFAULT 0 CHECK (display_order >= 0),
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (source_document_id, target_document_id, relation_type),
|
||||
CONSTRAINT ck_document_relation_not_self CHECK (source_document_id <> target_document_id)
|
||||
);
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Open questions
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE open_question (
|
||||
id uuid PRIMARY KEY,
|
||||
slug varchar(180),
|
||||
question varchar(300) NOT NULL,
|
||||
summary varchar(600),
|
||||
context_markdown text NOT NULL DEFAULT '',
|
||||
importance_markdown text NOT NULL DEFAULT '',
|
||||
next_verification text,
|
||||
question_status varchar(20) NOT NULL DEFAULT 'OPEN'
|
||||
CHECK (question_status IN ('OPEN', 'INVESTIGATING', 'PAUSED', 'RESOLVED', 'ARCHIVED')),
|
||||
target_visibility varchar(20) NOT NULL DEFAULT 'PRIVATE'
|
||||
CHECK (target_visibility IN ('PRIVATE', 'UNLISTED', 'PUBLIC')),
|
||||
primary_topic_id uuid REFERENCES topic(id),
|
||||
resolution_type varchar(30)
|
||||
CHECK (resolution_type IS NULL OR resolution_type IN (
|
||||
'DECISION_MADE',
|
||||
'ASSUMPTION_REJECTED',
|
||||
'QUESTION_REFRAMED',
|
||||
'NO_LONGER_RELEVANT'
|
||||
)),
|
||||
resolution_summary text,
|
||||
opened_at timestamptz NOT NULL DEFAULT now(),
|
||||
resolved_at timestamptz,
|
||||
first_published_at timestamptz,
|
||||
last_published_at timestamptz,
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT uq_open_question_slug UNIQUE (slug),
|
||||
CONSTRAINT ck_question_resolution_consistency CHECK (
|
||||
(question_status = 'RESOLVED'
|
||||
AND resolution_type IS NOT NULL
|
||||
AND resolution_summary IS NOT NULL
|
||||
AND resolved_at IS NOT NULL)
|
||||
OR
|
||||
(question_status <> 'RESOLVED')
|
||||
)
|
||||
);
|
||||
|
||||
CREATE TABLE question_point (
|
||||
id uuid PRIMARY KEY,
|
||||
question_id uuid NOT NULL REFERENCES open_question(id) ON DELETE CASCADE,
|
||||
point_kind varchar(20) NOT NULL
|
||||
CHECK (point_kind IN ('FACT', 'ASSUMPTION', 'UNKNOWN', 'CONSTRAINT')),
|
||||
content text NOT NULL CHECK (length(trim(content)) > 0),
|
||||
display_order integer NOT NULL CHECK (display_order >= 0),
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
CONSTRAINT uq_question_point_order UNIQUE (question_id, point_kind, display_order)
|
||||
);
|
||||
|
||||
CREATE TABLE question_update (
|
||||
id uuid PRIMARY KEY,
|
||||
question_id uuid NOT NULL REFERENCES open_question(id) ON DELETE CASCADE,
|
||||
update_type varchar(30) NOT NULL
|
||||
CHECK (update_type IN (
|
||||
'OBSERVATION',
|
||||
'EVIDENCE',
|
||||
'SCOPE_CHANGE',
|
||||
'BLOCKER',
|
||||
'NEXT_STEP',
|
||||
'RESOLUTION',
|
||||
'RESOLUTION_REOPENED'
|
||||
)),
|
||||
title varchar(180) NOT NULL,
|
||||
body_markdown text NOT NULL DEFAULT '',
|
||||
update_visibility varchar(20) NOT NULL DEFAULT 'PRIVATE'
|
||||
CHECK (update_visibility IN ('PRIVATE', 'PUBLIC')),
|
||||
sequence_no integer NOT NULL CHECK (sequence_no > 0),
|
||||
occurred_at timestamptz NOT NULL,
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT uq_question_update_sequence UNIQUE (question_id, sequence_no)
|
||||
);
|
||||
|
||||
CREATE TABLE question_tag (
|
||||
question_id uuid NOT NULL REFERENCES open_question(id) ON DELETE CASCADE,
|
||||
tag_id uuid NOT NULL REFERENCES tag(id),
|
||||
display_order integer NOT NULL CHECK (display_order >= 0),
|
||||
PRIMARY KEY (question_id, tag_id),
|
||||
CONSTRAINT uq_question_tag_order UNIQUE (question_id, display_order)
|
||||
);
|
||||
|
||||
CREATE TABLE question_document_link (
|
||||
question_id uuid NOT NULL REFERENCES open_question(id) ON DELETE CASCADE,
|
||||
document_id uuid NOT NULL REFERENCES document(id),
|
||||
relation_type varchar(30) NOT NULL
|
||||
CHECK (relation_type IN ('RESULT_CASE', 'DERIVED_REFERENCE', 'RELATED')),
|
||||
display_order integer NOT NULL DEFAULT 0 CHECK (display_order >= 0),
|
||||
PRIMARY KEY (question_id, document_id, relation_type)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX uq_question_result_case
|
||||
ON question_document_link(question_id)
|
||||
WHERE relation_type = 'RESULT_CASE';
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Projects, decisions, activities
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE project (
|
||||
id uuid PRIMARY KEY,
|
||||
slug varchar(180),
|
||||
name varchar(180) NOT NULL,
|
||||
one_line_purpose varchar(600) NOT NULL DEFAULT '',
|
||||
purpose_markdown text NOT NULL DEFAULT '',
|
||||
boundary_markdown text NOT NULL DEFAULT '',
|
||||
system_overview_markdown text NOT NULL DEFAULT '',
|
||||
phase varchar(30) NOT NULL DEFAULT 'RESEARCH'
|
||||
CHECK (phase IN (
|
||||
'RESEARCH',
|
||||
'DESIGN',
|
||||
'IMPLEMENTATION',
|
||||
'VERIFICATION',
|
||||
'MAINTENANCE',
|
||||
'PAUSED',
|
||||
'COMPLETED'
|
||||
)),
|
||||
current_objective text,
|
||||
next_step text,
|
||||
technology_labels jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
CHECK (jsonb_typeof(technology_labels) = 'array'),
|
||||
workflow_status varchar(20) NOT NULL DEFAULT 'DRAFT'
|
||||
CHECK (workflow_status IN ('DRAFT', 'PUBLISHED', 'ARCHIVED')),
|
||||
target_visibility varchar(20) NOT NULL DEFAULT 'PRIVATE'
|
||||
CHECK (target_visibility IN ('PRIVATE', 'UNLISTED', 'PUBLIC')),
|
||||
featured_order integer,
|
||||
first_published_at timestamptz,
|
||||
last_published_at timestamptz,
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT uq_project_slug UNIQUE (slug),
|
||||
CONSTRAINT ck_project_featured_order CHECK (featured_order IS NULL OR featured_order >= 0)
|
||||
);
|
||||
|
||||
CREATE TABLE project_document_link (
|
||||
project_id uuid NOT NULL REFERENCES project(id) ON DELETE CASCADE,
|
||||
document_id uuid NOT NULL REFERENCES document(id),
|
||||
relation_type varchar(20) NOT NULL
|
||||
CHECK (relation_type IN ('PRIMARY', 'RELATED')),
|
||||
featured_order integer,
|
||||
PRIMARY KEY (project_id, document_id),
|
||||
CONSTRAINT ck_project_document_featured_order CHECK (featured_order IS NULL OR featured_order >= 0)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX uq_document_primary_project
|
||||
ON project_document_link(document_id)
|
||||
WHERE relation_type = 'PRIMARY';
|
||||
|
||||
CREATE TABLE project_question_link (
|
||||
project_id uuid NOT NULL REFERENCES project(id) ON DELETE CASCADE,
|
||||
question_id uuid NOT NULL REFERENCES open_question(id),
|
||||
relation_type varchar(20) NOT NULL
|
||||
CHECK (relation_type IN ('PRIMARY', 'RELATED')),
|
||||
featured_order integer,
|
||||
PRIMARY KEY (project_id, question_id),
|
||||
CONSTRAINT ck_project_question_featured_order CHECK (featured_order IS NULL OR featured_order >= 0)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX uq_question_primary_project
|
||||
ON project_question_link(question_id)
|
||||
WHERE relation_type = 'PRIMARY';
|
||||
|
||||
CREATE TABLE project_decision (
|
||||
id uuid PRIMARY KEY,
|
||||
project_id uuid NOT NULL REFERENCES project(id) ON DELETE CASCADE,
|
||||
statement varchar(1000) NOT NULL,
|
||||
rationale_markdown text NOT NULL DEFAULT '',
|
||||
consequences jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
CHECK (jsonb_typeof(consequences) = 'array'),
|
||||
alternatives_markdown text NOT NULL DEFAULT '',
|
||||
decision_status varchar(20) NOT NULL DEFAULT 'PROPOSED'
|
||||
CHECK (decision_status IN ('PROPOSED', 'ACCEPTED', 'SUPERSEDED', 'REJECTED')),
|
||||
target_visibility varchar(20) NOT NULL DEFAULT 'PRIVATE'
|
||||
CHECK (target_visibility IN ('PRIVATE', 'PUBLIC')),
|
||||
source_question_id uuid REFERENCES open_question(id),
|
||||
source_case_id uuid REFERENCES document(id),
|
||||
superseded_by_id uuid,
|
||||
is_featured boolean NOT NULL DEFAULT false,
|
||||
decided_at timestamptz,
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT fk_project_decision_superseded_by
|
||||
FOREIGN KEY (superseded_by_id)
|
||||
REFERENCES project_decision(id),
|
||||
CONSTRAINT ck_project_decision_not_self_supersede
|
||||
CHECK (superseded_by_id IS NULL OR superseded_by_id <> id),
|
||||
CONSTRAINT ck_project_decision_status_fields CHECK (
|
||||
decision_status NOT IN ('ACCEPTED', 'SUPERSEDED')
|
||||
OR decided_at IS NOT NULL
|
||||
),
|
||||
CONSTRAINT ck_project_decision_supersede_target CHECK (
|
||||
decision_status <> 'SUPERSEDED'
|
||||
OR superseded_by_id IS NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX uq_project_featured_decision
|
||||
ON project_decision(project_id)
|
||||
WHERE is_featured = true;
|
||||
|
||||
CREATE TABLE project_activity (
|
||||
id uuid PRIMARY KEY,
|
||||
project_id uuid NOT NULL REFERENCES project(id) ON DELETE CASCADE,
|
||||
activity_type varchar(40) NOT NULL
|
||||
CHECK (activity_type IN (
|
||||
'PHASE_CHANGED',
|
||||
'QUESTION_OPENED',
|
||||
'QUESTION_RESOLVED',
|
||||
'DECISION_ACCEPTED',
|
||||
'CASE_PUBLISHED',
|
||||
'REFERENCE_PUBLISHED',
|
||||
'MILESTONE_REACHED',
|
||||
'PROJECT_PAUSED',
|
||||
'PROJECT_RESUMED'
|
||||
)),
|
||||
title varchar(180) NOT NULL,
|
||||
summary varchar(600),
|
||||
visibility varchar(20) NOT NULL DEFAULT 'PRIVATE'
|
||||
CHECK (visibility IN ('PRIVATE', 'PUBLIC')),
|
||||
origin varchar(20) NOT NULL
|
||||
CHECK (origin IN ('AUTO', 'MANUAL')),
|
||||
related_resource_type varchar(30),
|
||||
related_resource_id uuid,
|
||||
occurred_at timestamptz NOT NULL,
|
||||
operation_key varchar(180),
|
||||
version bigint NOT NULL DEFAULT 0,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
created_by varchar(255) NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_by varchar(255) NOT NULL,
|
||||
CONSTRAINT uq_project_activity_operation_key UNIQUE (project_id, operation_key)
|
||||
);
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Publication and public read model
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE public_resource_projection (
|
||||
resource_type varchar(30) NOT NULL
|
||||
CHECK (resource_type IN (
|
||||
'CASE',
|
||||
'REFERENCE',
|
||||
'QUESTION',
|
||||
'PROJECT',
|
||||
'PROJECT_DECISION',
|
||||
'PROJECT_ACTIVITY',
|
||||
'RELEASE',
|
||||
'PROFILE'
|
||||
)),
|
||||
resource_id uuid NOT NULL,
|
||||
source_version bigint NOT NULL CHECK (source_version >= 0),
|
||||
publication_state varchar(20) NOT NULL
|
||||
CHECK (publication_state IN ('ACTIVE', 'WITHDRAWN')),
|
||||
visibility varchar(20) NOT NULL
|
||||
CHECK (visibility IN ('PUBLIC', 'UNLISTED')),
|
||||
title varchar(300) NOT NULL,
|
||||
summary varchar(600),
|
||||
state_code varchar(30),
|
||||
primary_topic_id uuid REFERENCES topic(id),
|
||||
payload_schema_version smallint NOT NULL CHECK (payload_schema_version > 0),
|
||||
payload jsonb NOT NULL CHECK (jsonb_typeof(payload) = 'object'),
|
||||
body_plain_text text NOT NULL DEFAULT '',
|
||||
search_text text NOT NULL DEFAULT '',
|
||||
content_hash char(64) NOT NULL,
|
||||
published_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
last_verified_at timestamptz,
|
||||
latest_index_at timestamptz,
|
||||
navigation_path varchar(500) NOT NULL,
|
||||
PRIMARY KEY (resource_type, resource_id)
|
||||
);
|
||||
|
||||
CREATE TABLE public_route (
|
||||
resource_type varchar(30) NOT NULL,
|
||||
slug varchar(180) NOT NULL,
|
||||
resource_id uuid NOT NULL,
|
||||
route_role varchar(20) NOT NULL
|
||||
CHECK (route_role IN ('CANONICAL', 'ALIAS')),
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (resource_type, slug),
|
||||
CONSTRAINT fk_public_route_projection
|
||||
FOREIGN KEY (resource_type, resource_id)
|
||||
REFERENCES public_resource_projection(resource_type, resource_id)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX uq_public_route_canonical
|
||||
ON public_route(resource_type, resource_id)
|
||||
WHERE route_role = 'CANONICAL';
|
||||
|
||||
CREATE TABLE public_resource_tag (
|
||||
resource_type varchar(30) NOT NULL,
|
||||
resource_id uuid NOT NULL,
|
||||
tag_id uuid NOT NULL REFERENCES tag(id),
|
||||
display_order integer NOT NULL DEFAULT 0 CHECK (display_order >= 0),
|
||||
PRIMARY KEY (resource_type, resource_id, tag_id),
|
||||
CONSTRAINT fk_public_resource_tag_projection
|
||||
FOREIGN KEY (resource_type, resource_id)
|
||||
REFERENCES public_resource_projection(resource_type, resource_id)
|
||||
ON DELETE CASCADE,
|
||||
CONSTRAINT uq_public_resource_tag_order
|
||||
UNIQUE (resource_type, resource_id, display_order)
|
||||
);
|
||||
|
||||
CREATE TABLE public_resource_project_link (
|
||||
resource_type varchar(30) NOT NULL,
|
||||
resource_id uuid NOT NULL,
|
||||
project_id uuid NOT NULL REFERENCES project(id),
|
||||
relation_type varchar(20) NOT NULL
|
||||
CHECK (relation_type IN ('PRIMARY', 'RELATED')),
|
||||
featured_order integer,
|
||||
PRIMARY KEY (resource_type, resource_id, project_id),
|
||||
CONSTRAINT fk_public_resource_project_projection
|
||||
FOREIGN KEY (resource_type, resource_id)
|
||||
REFERENCES public_resource_projection(resource_type, resource_id)
|
||||
ON DELETE CASCADE,
|
||||
CONSTRAINT ck_public_project_featured_order CHECK (
|
||||
featured_order IS NULL OR featured_order >= 0
|
||||
)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX uq_public_primary_project
|
||||
ON public_resource_project_link(resource_type, resource_id)
|
||||
WHERE relation_type = 'PRIMARY';
|
||||
|
||||
CREATE TABLE asset_reference (
|
||||
asset_id uuid NOT NULL REFERENCES asset(id),
|
||||
owner_type varchar(30) NOT NULL
|
||||
CHECK (owner_type IN (
|
||||
'DOCUMENT',
|
||||
'QUESTION',
|
||||
'QUESTION_UPDATE',
|
||||
'PROJECT',
|
||||
'DECISION',
|
||||
'RELEASE',
|
||||
'PROFILE',
|
||||
'SITE'
|
||||
)),
|
||||
owner_id uuid NOT NULL,
|
||||
reference_scope varchar(20) NOT NULL
|
||||
CHECK (reference_scope IN ('WORKING', 'PUBLISHED')),
|
||||
reference_role varchar(20) NOT NULL
|
||||
CHECK (reference_role IN ('BODY', 'COVER', 'AVATAR', 'ATTACHMENT')),
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (asset_id, owner_type, owner_id, reference_scope, reference_role)
|
||||
);
|
||||
|
||||
-- preview_token 테이블은 제거되었다.
|
||||
-- Capability Token 기반 익명 Preview는 인증된 Preview Artifact(studio_preview)로
|
||||
-- 대체되었다. contracts/openapi/preview-v1.deprecated.md 참고.
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Studio workflow artifacts
|
||||
--
|
||||
-- WorkingCopy는 API projection이므로 범용 working_copy 테이블을 만들지 않는다.
|
||||
-- 아래 테이블은 편집 대상 자체가 아니라 "편집 흐름이 만들어내는 산출물"을 저장한다.
|
||||
--
|
||||
-- source_kind + source_id는 Studio API의 documentId를 가리킨다.
|
||||
-- documentId는 source aggregate id를 그대로 사용하므로 별도 surrogate id가 없다.
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
-- Validation은 일급 artifact다. 실행하고 버리는 결과가 아니라 특정 version을
|
||||
-- 검증한 사실을 validation_id로 참조할 수 있어야 한다.
|
||||
CREATE TABLE studio_validation (
|
||||
validation_id uuid PRIMARY KEY,
|
||||
source_kind varchar(30) NOT NULL
|
||||
CHECK (source_kind IN ('CASE', 'REFERENCE', 'QUESTION', 'PROJECT_DECISION')),
|
||||
source_id uuid NOT NULL,
|
||||
validated_version bigint NOT NULL CHECK (validated_version >= 0),
|
||||
status varchar(20) NOT NULL
|
||||
CHECK (status IN ('INVALID', 'WARNINGS', 'VALID')),
|
||||
issues jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
CHECK (jsonb_typeof(issues) = 'array'),
|
||||
-- 검증에 사용한 외부 의존 상태(Topic/Project publishability, relation target,
|
||||
-- Asset READY/QUARANTINED, slug/route ownership, catalog revision,
|
||||
-- renderer/content-format version)를 정규화한 hash.
|
||||
-- Publish 시 다시 계산해 값이 다르면 VALIDATION_STALE로 거절한다.
|
||||
dependency_revision varchar(200) NOT NULL,
|
||||
validated_at timestamptz NOT NULL DEFAULT now(),
|
||||
valid_until timestamptz NOT NULL,
|
||||
created_by varchar(255) NOT NULL,
|
||||
CONSTRAINT ck_studio_validation_window CHECK (valid_until > validated_at)
|
||||
);
|
||||
|
||||
-- Preview는 저장된 version + validation + dependency revision을 묶어 만든
|
||||
-- PublicRenderModel snapshot이다. 인증된 Studio API로만 조회한다.
|
||||
-- CURRENT/STALE/EXPIRED 상태는 저장하지 않고 조회 시점에 서버가 계산한다.
|
||||
CREATE TABLE studio_preview (
|
||||
preview_id uuid PRIMARY KEY,
|
||||
source_kind varchar(30) NOT NULL
|
||||
CHECK (source_kind IN ('CASE', 'REFERENCE', 'QUESTION', 'PROJECT_DECISION')),
|
||||
source_id uuid NOT NULL,
|
||||
source_version bigint NOT NULL CHECK (source_version >= 0),
|
||||
validation_id uuid NOT NULL REFERENCES studio_validation(validation_id),
|
||||
dependency_revision varchar(200) NOT NULL,
|
||||
render_model jsonb NOT NULL CHECK (jsonb_typeof(render_model) = 'object'),
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
expires_at timestamptz NOT NULL,
|
||||
created_by varchar(255) NOT NULL,
|
||||
CONSTRAINT ck_studio_preview_expiry CHECK (expires_at > created_at)
|
||||
);
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Publication aggregate, immutable history, immutable snapshot
|
||||
--
|
||||
-- 세 개념을 분리한다.
|
||||
--
|
||||
-- publication 현재 게시 상태
|
||||
-- publication_event 게시/재게시/게시 취소 불변 이력
|
||||
-- publication_snapshot PUBLISHED/REPUBLISHED 시점의 불변 PublicRenderModel
|
||||
--
|
||||
-- public_resource_projection은 여전히 "현재 공개 상태"를 담당한다.
|
||||
-- 과거 Snapshot을 현재 source나 현재 projection에서 재계산하지 않는다.
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE publication (
|
||||
publication_id uuid PRIMARY KEY,
|
||||
source_kind varchar(30) NOT NULL
|
||||
CHECK (source_kind IN ('CASE', 'REFERENCE', 'QUESTION', 'PROJECT_DECISION')),
|
||||
source_id uuid NOT NULL,
|
||||
status varchar(20) NOT NULL
|
||||
CHECK (status IN ('PUBLISHED', 'UNPUBLISHED')),
|
||||
published_version bigint NOT NULL CHECK (published_version >= 0),
|
||||
-- Publication 자체의 optimistic concurrency 토큰.
|
||||
-- unpublish는 expectedPublicationRevision으로 이 값을 검증한다.
|
||||
publication_revision bigint NOT NULL DEFAULT 1 CHECK (publication_revision >= 1),
|
||||
latest_event_id uuid NOT NULL,
|
||||
public_path varchar(500) NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
CONSTRAINT uq_publication_source UNIQUE (source_kind, source_id)
|
||||
);
|
||||
|
||||
CREATE TABLE publication_event (
|
||||
publication_event_id uuid PRIMARY KEY,
|
||||
publication_id uuid NOT NULL REFERENCES publication(publication_id),
|
||||
source_kind varchar(30) NOT NULL
|
||||
CHECK (source_kind IN ('CASE', 'REFERENCE', 'QUESTION', 'PROJECT_DECISION')),
|
||||
source_id uuid NOT NULL,
|
||||
event_type varchar(20) NOT NULL
|
||||
CHECK (event_type IN ('PUBLISHED', 'REPUBLISHED', 'UNPUBLISHED')),
|
||||
published_version bigint NOT NULL CHECK (published_version >= 0),
|
||||
-- UNPUBLISHED Event는 자체 snapshot을 만들지 않고 마지막 공개 Snapshot을 참조한다.
|
||||
source_published_event_id uuid REFERENCES publication_event(publication_event_id),
|
||||
occurred_at timestamptz NOT NULL DEFAULT now(),
|
||||
-- Publish 재시도가 중복 Event를 만들지 않도록 최초 요청의 idempotency key를 남긴다.
|
||||
idempotency_key varchar(200),
|
||||
created_by varchar(255) NOT NULL,
|
||||
CONSTRAINT ck_publication_event_source_ref CHECK (
|
||||
(event_type = 'UNPUBLISHED' AND source_published_event_id IS NOT NULL)
|
||||
OR (event_type <> 'UNPUBLISHED' AND source_published_event_id IS NULL)
|
||||
)
|
||||
);
|
||||
|
||||
-- Event row는 생성 후 수정하지 않는다. UPDATE/DELETE 차단은 권한과 application
|
||||
-- rule로 강제하며, 필요하면 운영에서 REVOKE UPDATE, DELETE로 보강한다.
|
||||
|
||||
-- 첫 게시는 publication(latest_event_id) -> publication_event -> publication UPDATE
|
||||
-- 순서로 한 transaction 안에서 처리된다. 순환 참조를 허용하기 위해 지연 검사한다.
|
||||
ALTER TABLE publication
|
||||
ADD CONSTRAINT fk_publication_latest_event
|
||||
FOREIGN KEY (latest_event_id)
|
||||
REFERENCES publication_event(publication_event_id)
|
||||
DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
CREATE TABLE publication_snapshot (
|
||||
publication_event_id uuid PRIMARY KEY
|
||||
REFERENCES publication_event(publication_event_id),
|
||||
render_model jsonb NOT NULL CHECK (jsonb_typeof(render_model) = 'object'),
|
||||
content_format_version varchar(50) NOT NULL,
|
||||
renderer_contract_version varchar(50) NOT NULL,
|
||||
-- 게시 시점에 사용된 Asset의 assetKey/delivery path/치수를 고정한다.
|
||||
-- 이후 Asset이 교체되어도 과거 Snapshot의 표현은 변하지 않는다.
|
||||
asset_manifest jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
CHECK (jsonb_typeof(asset_manifest) = 'array'),
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Indexes
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
CREATE INDEX idx_document_management
|
||||
ON document(document_type, workflow_status, updated_at DESC);
|
||||
|
||||
CREATE INDEX idx_document_topic
|
||||
ON document(primary_topic_id, document_type, updated_at DESC);
|
||||
|
||||
CREATE INDEX idx_question_status
|
||||
ON open_question(question_status, updated_at DESC);
|
||||
|
||||
CREATE INDEX idx_question_topic
|
||||
ON open_question(primary_topic_id, question_status, updated_at DESC);
|
||||
|
||||
CREATE INDEX idx_question_update_timeline
|
||||
ON question_update(question_id, occurred_at ASC, sequence_no ASC);
|
||||
|
||||
CREATE INDEX idx_project_phase
|
||||
ON project(phase, updated_at DESC);
|
||||
|
||||
CREATE INDEX idx_project_decision
|
||||
ON project_decision(project_id, decision_status, decided_at DESC);
|
||||
|
||||
CREATE INDEX idx_project_activity
|
||||
ON project_activity(project_id, visibility, occurred_at DESC);
|
||||
|
||||
CREATE INDEX idx_asset_status
|
||||
ON asset(management_status, created_at DESC);
|
||||
|
||||
CREATE INDEX idx_asset_checksum
|
||||
ON asset(checksum_sha256);
|
||||
|
||||
CREATE INDEX idx_asset_reference_owner
|
||||
ON asset_reference(owner_type, owner_id, reference_scope);
|
||||
|
||||
CREATE INDEX idx_asset_reference_asset
|
||||
ON asset_reference(asset_id, reference_scope);
|
||||
|
||||
CREATE INDEX idx_public_latest
|
||||
ON public_resource_projection(latest_index_at DESC, resource_type, resource_id)
|
||||
WHERE publication_state = 'ACTIVE'
|
||||
AND visibility = 'PUBLIC'
|
||||
AND latest_index_at IS NOT NULL;
|
||||
|
||||
CREATE INDEX idx_public_topic
|
||||
ON public_resource_projection(primary_topic_id, resource_type, published_at DESC)
|
||||
WHERE publication_state = 'ACTIVE'
|
||||
AND visibility = 'PUBLIC';
|
||||
|
||||
CREATE INDEX idx_public_type
|
||||
ON public_resource_projection(resource_type, visibility, published_at DESC)
|
||||
WHERE publication_state = 'ACTIVE';
|
||||
|
||||
CREATE INDEX idx_public_projection_search_trgm
|
||||
ON public_resource_projection
|
||||
USING gin (search_text gin_trgm_ops)
|
||||
WHERE publication_state = 'ACTIVE'
|
||||
AND visibility = 'PUBLIC';
|
||||
|
||||
CREATE INDEX idx_public_project_link_lookup
|
||||
ON public_resource_project_link(project_id, relation_type, resource_type);
|
||||
|
||||
-- Studio workflow artifacts -------------------------------------------------
|
||||
|
||||
-- 특정 version에 대한 최신 Validation 조회 (nextAction 계산의 핵심 경로)
|
||||
CREATE INDEX idx_studio_validation_source
|
||||
ON studio_validation(source_kind, source_id, validated_version, validated_at DESC);
|
||||
|
||||
-- 특정 version에 대한 최신 Preview 조회
|
||||
CREATE INDEX idx_studio_preview_source
|
||||
ON studio_preview(source_kind, source_id, source_version, created_at DESC);
|
||||
|
||||
-- 만료 Preview 정리 배치
|
||||
CREATE INDEX idx_studio_preview_expiry
|
||||
ON studio_preview(expires_at);
|
||||
|
||||
-- Publication history -------------------------------------------------------
|
||||
|
||||
-- 한 문서의 게시 이력 (occurredAt DESC, publicationEventId DESC 정렬 계약과 일치)
|
||||
CREATE INDEX idx_publication_event_publication
|
||||
ON publication_event(publication_id, occurred_at DESC, publication_event_id DESC);
|
||||
|
||||
-- 전체 게시 기록 화면과 source 기준 조회
|
||||
CREATE INDEX idx_publication_event_source
|
||||
ON publication_event(source_kind, source_id, occurred_at DESC);
|
||||
+1
-1
@@ -44,7 +44,7 @@ class PostgreSqlMigrationIntegrationTest {
|
||||
.migrate();
|
||||
|
||||
assertThat(appliedVersions(postgres, "flyway_schema_history"))
|
||||
.containsExactly("1", "3", "4", "5", "6");
|
||||
.containsExactly("1", "3", "4", "5", "6", "7");
|
||||
|
||||
Flyway coreStream =
|
||||
Flyway.configure()
|
||||
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
package dev.caskeleton.adapter.outbound.persistence.techlog;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.DockerClientFactory;
|
||||
import org.testcontainers.postgresql.PostgreSQLContainer;
|
||||
|
||||
/**
|
||||
* V7이 실제 PostgreSQL에 적용되는지, 그리고 순환 FK가 deferrable로 선언됐는지 본다. H2로는 검증할 수 없다 — deferrable 제약이 벤더 의미이기
|
||||
* 때문이다.
|
||||
*
|
||||
* <p>이 모듈(persistence-jpa)에는 {@code @SpringBootConfiguration}이 없다 — Boot 메인 클래스는 app-bootstrap 모듈에
|
||||
* 있고, 이 모듈의 postgresqlIntegrationTest 소스셋 classpath에는 포함되지 않는다. 그래서 {@code @SpringBootTest}로 컨텍스트를
|
||||
* 띄울 수 없고, 이 패키지의 형제인 {@code readiness.PostgreSqlMigrationIntegrationTest}와 같은 방식 — Testcontainers
|
||||
* 위에서 순수 Flyway API를 직접 구동 — 을 쓴다. 컨테이너는 매번 완전히 빈 상태로 시작하므로, 기존 V1/V3/V4/V5/V6 다음에 V7이 얹히는 전체 체인이
|
||||
* 클린 DB에 처음부터 적용되는 경로를 그대로 검증한다.
|
||||
*/
|
||||
class TechLogSchemaMigrationTest {
|
||||
|
||||
private static final String IMAGE =
|
||||
System.getProperty("jpa.evidence.postgresql.image", "postgres:16-alpine");
|
||||
|
||||
private static PostgreSQLContainer postgres;
|
||||
private static HikariDataSource dataSource;
|
||||
|
||||
@BeforeAll
|
||||
static void migrateFreshDatabase() {
|
||||
if (!DockerClientFactory.instance().isDockerAvailable()) {
|
||||
throw new IllegalStateException(
|
||||
"Docker is required for the Tech Log schema migration test; skipping is forbidden");
|
||||
}
|
||||
postgres = new PostgreSQLContainer(IMAGE).withReuse(false);
|
||||
postgres.start();
|
||||
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setJdbcUrl(postgres.getJdbcUrl());
|
||||
config.setUsername(postgres.getUsername());
|
||||
config.setPassword(postgres.getPassword());
|
||||
config.setMaximumPoolSize(5);
|
||||
config.setMinimumIdle(1);
|
||||
dataSource = new HikariDataSource(config);
|
||||
|
||||
// classpath:db/migration/postgresql only — the same location
|
||||
// PostgreSqlPersistenceConfig's FlywayConfigurationCustomizer pins the application to. Using
|
||||
// the full "classpath:db/migration" tree here would also pick up the unrelated jpa/* streams
|
||||
// (each starting their own V1) and collide.
|
||||
Flyway.configure()
|
||||
.dataSource(dataSource)
|
||||
.locations("classpath:db/migration/postgresql")
|
||||
.table("flyway_schema_history")
|
||||
.baselineOnMigrate(false)
|
||||
.outOfOrder(false)
|
||||
.load()
|
||||
.migrate();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void stopPostgreSql() {
|
||||
if (dataSource != null) {
|
||||
dataSource.close();
|
||||
}
|
||||
if (postgres != null) {
|
||||
postgres.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void createsEveryTechLogTable() throws Exception {
|
||||
List<String> expected =
|
||||
List.of(
|
||||
"topic",
|
||||
"tag",
|
||||
"document",
|
||||
"case_detail",
|
||||
"reference_detail",
|
||||
"document_tag",
|
||||
"document_relation",
|
||||
"open_question",
|
||||
"question_point",
|
||||
"question_update",
|
||||
"question_tag",
|
||||
"question_document_link",
|
||||
"project",
|
||||
"project_decision",
|
||||
"project_document_link",
|
||||
"project_question_link",
|
||||
"project_activity",
|
||||
"asset",
|
||||
"asset_reference",
|
||||
"studio_validation",
|
||||
"studio_preview",
|
||||
"publication",
|
||||
"publication_event",
|
||||
"publication_snapshot",
|
||||
"public_resource_projection",
|
||||
"public_route",
|
||||
"public_resource_tag",
|
||||
"public_resource_project_link");
|
||||
|
||||
List<String> actual = new ArrayList<>();
|
||||
try (Connection connection = dataSource().getConnection();
|
||||
ResultSet rs =
|
||||
connection
|
||||
.createStatement()
|
||||
.executeQuery(
|
||||
"SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")) {
|
||||
while (rs.next()) {
|
||||
actual.add(rs.getString(1));
|
||||
}
|
||||
}
|
||||
assertThat(actual).containsAll(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotCreateAStudioIdempotencyTable() throws Exception {
|
||||
try (Connection connection = dataSource().getConnection();
|
||||
ResultSet rs =
|
||||
connection
|
||||
.createStatement()
|
||||
.executeQuery(
|
||||
"SELECT count(*) FROM information_schema.tables "
|
||||
+ "WHERE table_schema = 'public' AND table_name = 'studio_idempotency'")) {
|
||||
rs.next();
|
||||
assertThat(rs.getInt(1)).isZero();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void publicationLatestEventForeignKeyIsDeferrable() throws Exception {
|
||||
try (Connection connection = dataSource().getConnection();
|
||||
ResultSet rs =
|
||||
connection
|
||||
.createStatement()
|
||||
.executeQuery(
|
||||
"SELECT condeferrable, condeferred FROM pg_constraint "
|
||||
+ "WHERE conname = 'fk_publication_latest_event'")) {
|
||||
assertThat(rs.next()).as("fk_publication_latest_event 제약이 있어야 한다").isTrue();
|
||||
assertThat(rs.getBoolean(1)).as("deferrable").isTrue();
|
||||
assertThat(rs.getBoolean(2)).as("initially deferred").isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
private static DataSource dataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
package dev.caskeleton.adapter.outbound.persistence.techlog.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import dev.caskeleton.application.techlog.studio.query.CatalogEntryType;
|
||||
import dev.caskeleton.application.techlog.studio.query.CatalogPageView;
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.jdbc.core.simple.JdbcClient;
|
||||
import org.testcontainers.DockerClientFactory;
|
||||
import org.testcontainers.postgresql.PostgreSQLContainer;
|
||||
|
||||
/**
|
||||
* 이 모듈(persistence-jpa)에는 {@code @SpringBootConfiguration}이 없다 — Boot 메인 클래스는 app-bootstrap 모듈에 있고,
|
||||
* 이 모듈의 postgresqlIntegrationTest 소스셋 classpath에는 포함되지 않는다. 그래서 브리프의 {@code @SpringBootTest}로는
|
||||
* 컨텍스트를 띄울 수 없다({@code TechLogSchemaMigrationTest}가 같은 문제를 겪었다). 이 테스트도 같은 형제 패턴 — Testcontainers
|
||||
* 위에서 순수 Flyway로 V7까지 적용한 뒤, {@code JdbcClient}와 어댑터를 직접 조립 — 을 쓴다. Spring 컨테이너가 없어도 {@code
|
||||
* JdbcCatalogQueryAdapter}는 생성자 인자로 {@code JdbcClient} 하나만 받으므로 문제가 없다.
|
||||
*/
|
||||
class JdbcCatalogQueryAdapterTest {
|
||||
|
||||
private static final String IMAGE =
|
||||
System.getProperty("jpa.evidence.postgresql.image", "postgres:16-alpine");
|
||||
|
||||
private static PostgreSQLContainer postgres;
|
||||
private static HikariDataSource dataSource;
|
||||
private static JdbcClient jdbcClient;
|
||||
private static JdbcCatalogQueryAdapter adapter;
|
||||
|
||||
@BeforeAll
|
||||
static void migrateFreshDatabase() {
|
||||
if (!DockerClientFactory.instance().isDockerAvailable()) {
|
||||
throw new IllegalStateException(
|
||||
"Docker is required for the catalog query adapter test; skipping is forbidden");
|
||||
}
|
||||
postgres = new PostgreSQLContainer(IMAGE).withReuse(false);
|
||||
postgres.start();
|
||||
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setJdbcUrl(postgres.getJdbcUrl());
|
||||
config.setUsername(postgres.getUsername());
|
||||
config.setPassword(postgres.getPassword());
|
||||
config.setMaximumPoolSize(5);
|
||||
config.setMinimumIdle(1);
|
||||
dataSource = new HikariDataSource(config);
|
||||
|
||||
Flyway.configure()
|
||||
.dataSource(dataSource)
|
||||
.locations("classpath:db/migration/postgresql")
|
||||
.table("flyway_schema_history")
|
||||
.baselineOnMigrate(false)
|
||||
.outOfOrder(false)
|
||||
.load()
|
||||
.migrate();
|
||||
|
||||
jdbcClient = JdbcClient.create(dataSource);
|
||||
adapter = new JdbcCatalogQueryAdapter(jdbcClient);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void stopPostgreSql() {
|
||||
if (dataSource != null) {
|
||||
dataSource.close();
|
||||
}
|
||||
if (postgres != null) {
|
||||
postgres.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void findsTopicsByPrefix() {
|
||||
jdbcClient
|
||||
.sql(
|
||||
"INSERT INTO topic (id, name, normalized_name, slug, created_by, updated_by) "
|
||||
+ "VALUES (gen_random_uuid(), 'Kafka', 'kafka', 'kafka', 'test', 'test')")
|
||||
.update();
|
||||
|
||||
CatalogPageView page = adapter.search(CatalogEntryType.TOPIC, "kaf", null, 20);
|
||||
|
||||
assertThat(page.items()).hasSize(1);
|
||||
assertThat(page.items().get(0).label()).isEqualTo("Kafka");
|
||||
assertThat(page.items().get(0).dependencyRevision()).isNotBlank();
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsAnEmptyPageWhenNothingMatches() {
|
||||
CatalogPageView page = adapter.search(CatalogEntryType.TOPIC, "zzzz-none", null, 20);
|
||||
|
||||
assertThat(page.items()).isEmpty();
|
||||
assertThat(page.nextCursor()).isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Review Important 1: {@code searchProjects} (JdbcCatalogQueryAdapter) had never run against a
|
||||
* real database — {@code project} has a different column shape than {@code topic} (slug/name/
|
||||
* workflow_status vs. name/normalized_name/slug/status), so a column typo or bad bind would only
|
||||
* have surfaced in production. {@code project}'s NOT-NULL-without-default columns are {@code id},
|
||||
* {@code name}, {@code created_by}, {@code updated_by} (V7__techlog_core.sql CREATE TABLE
|
||||
* project) — everything else has a DEFAULT or is nullable, so the minimal INSERT below is valid.
|
||||
*/
|
||||
@Test
|
||||
void findsProjectsByPrefix() {
|
||||
jdbcClient
|
||||
.sql(
|
||||
"INSERT INTO project (id, name, created_by, updated_by) "
|
||||
+ "VALUES (gen_random_uuid(), 'Payments Platform', 'test', 'test')")
|
||||
.update();
|
||||
|
||||
CatalogPageView page = adapter.search(CatalogEntryType.PROJECT, "pay", null, 20);
|
||||
|
||||
assertThat(page.items()).hasSize(1);
|
||||
assertThat(page.items().get(0).id()).isNotNull();
|
||||
assertThat(page.items().get(0).label()).isEqualTo("Payments Platform");
|
||||
assertThat(page.items().get(0).kind()).isEqualTo("PROJECT");
|
||||
assertThat(page.items().get(0).dependencyRevision()).isNotBlank();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user