From 18727fae99092d9e1bb2c454ac8c6f73d8627cdc Mon Sep 17 00:00:00 2001 From: Kay Schubert Date: Fri, 1 Sep 2023 12:15:02 +0200 Subject: [PATCH] JSON logging fails due to one dependency missing, others mismatched - JSON logging requires jakarta.xml.bind-api - logstash version 7.4 requires logback > 1.2, but Spring requires logback 1.2 - logstash needs to be lowered to version 7.2 (last version that is compatible to logback 1.2) --- CHANGELOG.md | 4 ++ pom.xml | 9 ++- .../keycloak/config/jsonlog/JsonLogTest.java | 60 +++++++++++++++++++ src/test/resources/logback-test.xml | 22 ++++++- 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/test/java/de/adorsys/keycloak/config/jsonlog/JsonLogTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 388f18b78..2dece5e2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Changed +- Fix issue [#907](/adorsys/keycloak-config-cli/issues/907): + - add missing dependency jakarta.xml.bind-api + - lower logstash version from 7.4 to 7.2: 7.2 is the last version to support logback 1.2, which is the version required for Spring and other components used here ## [5.8.0] - 2023-07-14 ### Added diff --git a/pom.xml b/pom.xml index 87e6bfda4..cb06c1258 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ 1.1.2 2.1.1 2.0.0 - 7.4 + 7.2 3.0.0-M5 3.0.1 1.5.3 @@ -89,6 +89,7 @@ 3.1.0 2.1.2 2.1.1 + 4.0.0 2.1.2 5.8.4 4.7.3.5 @@ -255,6 +256,12 @@ ${jakarta.annotation.version} + + jakarta.xml.bind + jakarta.xml.bind-api + ${jakarta.bind-api.version} + + jakarta.mail jakarta.mail-api diff --git a/src/test/java/de/adorsys/keycloak/config/jsonlog/JsonLogTest.java b/src/test/java/de/adorsys/keycloak/config/jsonlog/JsonLogTest.java new file mode 100644 index 000000000..9da865728 --- /dev/null +++ b/src/test/java/de/adorsys/keycloak/config/jsonlog/JsonLogTest.java @@ -0,0 +1,60 @@ +/*- + * ---license-start + * keycloak-config-cli + * --- + * Copyright (C) 2017 - 2021 adorsys GmbH & Co. KG @ https://adorsys.com + * --- + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ---license-end + */ + +package de.adorsys.keycloak.config.jsonlog; + +import de.adorsys.keycloak.config.extensions.GithubActionsExtension; +import de.adorsys.keycloak.config.properties.ImportConfigProperties; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +// From: https://tuhrig.de/testing-configurationproperties-in-spring-boot/ +@ExtendWith(SpringExtension.class) +@ExtendWith(GithubActionsExtension.class) +@SpringBootTest(classes = {JsonLogTest.TestConfiguration.class}) +@TestPropertySource(properties = { + "spring.main.log-startup-info=true", + "spring.profiles.active=json-log", + "import.files.locations=default", +}) +class JsonLogTest { + + @Autowired + ConfigurableApplicationContext applicationContext; + + @Test + void startupUsingJsonLoggingShouldWork() { + assertThat(applicationContext.isActive(), is(true)); + } + + @EnableConfigurationProperties(ImportConfigProperties.class) + public static class TestConfiguration { + // nothing + } +} diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 5af97aa15..269d26fe9 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -1,6 +1,26 @@ - + + + + + + + + + + + + + + + + + + + + +