From 16d92005ee524eb98c954945944894c78683e9ed Mon Sep 17 00:00:00 2001 From: dnjswldnd-3513 Date: Mon, 30 Nov 2026 10:42:25 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=8C=8C=EC=9D=BC=20JSON=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=97=90=20Slack=20=EC=9B=B9=ED=9B=85=20=EC=A3=BC?= =?UTF-8?q?=EC=86=8C=EA=B0=80=20=EA=B8=B0=EB=A1=9D=EB=90=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EB=A1=9C=EA=B7=B8=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EB=B2=94=EC=9C=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/logback-spring.xml | 3 +- .../logging/LogbackSecretPropertyTest.java | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/test/java/in/koreatech/koin/unit/global/logging/LogbackSecretPropertyTest.java diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index c4d09e9032..5240406e01 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,5 +1,6 @@ - + + file = (OutputStreamAppender)root.getAppender("FILE"); + + @SuppressWarnings("unchecked") + byte[] encoded = ((Encoder)file.getEncoder()) + .encode(new LoggingEvent(getClass().getName(), root, Level.ERROR, "test", null, null)); + + assertThat(new String(encoded, UTF_8)).contains("test").doesNotContain("slack-webhook-secret-marker"); + assertThat(context.getProperty("SLACK_WEBHOOK_URI")).isNull(); + SlackAppender slack = (SlackAppender)((AsyncAppender)root.getAppender("ASYNC_SLACK")).getAppender("SLACK"); + assertThat(slack.getWebhookUri()).isEqualTo(WEBHOOK); + } finally { + // 다른 테스트가 같은 JVM에서 쓰는 test 프로필 로그 설정으로 되돌린다. + initialize(loggingSystem, profileEnvironment("test")); + } + } + + private MockEnvironment profileEnvironment(String profile) { + MockEnvironment environment = new MockEnvironment(); + environment.setActiveProfiles(profile); + return environment; + } + + private void initialize(LoggingSystem loggingSystem, MockEnvironment environment) { + loggingSystem.cleanUp(); + loggingSystem.beforeInitialize(); + loggingSystem.initialize(new LoggingInitializationContext(environment), null, null); + } +}