Skip to content

Commit 8f72ec8

Browse files
authored
Merge pull request #1772 from DependencyTrack/dependabot/maven/quarkus.platform.version-3.22.0
2 parents 4d0cc27 + e991bfb commit 8f72ec8

26 files changed

+1300
-939
lines changed

commons-kstreams/src/test/java/org/dependencytrack/kstreams/statestore/StateStoreUtilTest.java

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,76 +18,29 @@
1818
*/
1919
package org.dependencytrack.kstreams.statestore;
2020

21-
import io.quarkus.test.junit.QuarkusTest;
22-
import io.quarkus.test.junit.QuarkusTestProfile;
23-
import io.quarkus.test.junit.TestProfile;
24-
import jakarta.inject.Inject;
2521
import org.apache.kafka.streams.state.internals.InMemoryKeyValueBytesStoreSupplier;
26-
import org.apache.kafka.streams.state.internals.RocksDBKeyValueBytesStoreSupplier;
2722
import org.junit.jupiter.api.Test;
28-
import org.junit.platform.suite.api.SelectClasses;
29-
import org.junit.platform.suite.api.Suite;
3023

3124
import java.util.Map;
3225

3326
import static org.assertj.core.api.Assertions.assertThat;
3427

35-
@Suite
36-
@SelectClasses(value = {
37-
StateStoreUtilTest.ConfigurableKeyValueStoreWithoutQuarkusConfigTest.class,
38-
StateStoreUtilTest.ConfigurableKeyValueStoreWitQuarkusConfigTest.class,
39-
StateStoreUtilTest.DefaultChangelogTopicConfigTest.class
40-
})
4128
class StateStoreUtilTest {
4229

43-
static class ConfigurableKeyValueStoreWithoutQuarkusConfigTest {
44-
45-
@Test
46-
void test() {
47-
assertThat(StateStoreUtil.configurableKeyValueStore("storeName"))
48-
.isInstanceOf(InMemoryKeyValueBytesStoreSupplier.class);
49-
}
50-
30+
@Test
31+
void configurableKeyValueStoreWithoutQuarkusConfigTest() {
32+
assertThat(StateStoreUtil.configurableKeyValueStore("storeName"))
33+
.isInstanceOf(InMemoryKeyValueBytesStoreSupplier.class);
5134
}
5235

53-
@QuarkusTest
54-
@TestProfile(ConfigurableKeyValueStoreWitQuarkusConfigTest.TestProfile.class)
55-
static class ConfigurableKeyValueStoreWitQuarkusConfigTest {
56-
57-
public static class TestProfile implements QuarkusTestProfile {
58-
59-
@Override
60-
public Map<String, String> getConfigOverrides() {
61-
return Map.of(
62-
"state-store.type", "rocks_db"
63-
);
64-
}
65-
}
66-
67-
@Inject // Force injection, otherwise Quarkus will not discover the config mapping.
68-
@SuppressWarnings("unused")
69-
StateStoreConfig stateStoreConfig;
70-
71-
@Test
72-
void test() {
73-
assertThat(StateStoreUtil.configurableKeyValueStore("storeName"))
74-
.isInstanceOf(RocksDBKeyValueBytesStoreSupplier.class);
75-
}
76-
77-
}
78-
79-
static class DefaultChangelogTopicConfigTest {
80-
81-
@Test
82-
void test() {
83-
assertThat(StateStoreUtil.defaultChangelogTopicConfig())
84-
.containsExactlyInAnyOrderEntriesOf(Map.of(
85-
"cleanup.policy", "compact",
86-
"segment.bytes", "67108864",
87-
"max.compaction.lag.ms", "1"
88-
));
89-
}
90-
36+
@Test
37+
void defaultChangelogTopicConfigTest() {
38+
assertThat(StateStoreUtil.defaultChangelogTopicConfig())
39+
.containsExactlyInAnyOrderEntriesOf(Map.of(
40+
"cleanup.policy", "compact",
41+
"segment.bytes", "67108864",
42+
"max.compaction.lag.ms", "1"
43+
));
9144
}
9245

9346
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* This file is part of Dependency-Track.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* Copyright (c) OWASP Foundation. All Rights Reserved.
18+
*/
19+
package org.dependencytrack.kstreams.statestore;
20+
21+
import io.quarkus.test.junit.QuarkusTest;
22+
import io.quarkus.test.junit.QuarkusTestProfile;
23+
import io.quarkus.test.junit.TestProfile;
24+
import org.apache.kafka.streams.state.internals.RocksDBKeyValueBytesStoreSupplier;
25+
import org.junit.jupiter.api.Test;
26+
27+
import jakarta.inject.Inject;
28+
import java.util.Map;
29+
30+
import static org.assertj.core.api.Assertions.assertThat;
31+
32+
@QuarkusTest
33+
@TestProfile(StateStoreUtilWithQuarkusConfigTest.TestProfile.class)
34+
class StateStoreUtilWithQuarkusConfigTest {
35+
36+
public static class TestProfile implements QuarkusTestProfile {
37+
38+
@Override
39+
public Map<String, String> getConfigOverrides() {
40+
return Map.of(
41+
"state-store.type", "rocks_db"
42+
);
43+
}
44+
}
45+
46+
@Inject // Force injection, otherwise Quarkus will not discover the config mapping.
47+
@SuppressWarnings("unused")
48+
StateStoreConfig stateStoreConfig;
49+
50+
@Test
51+
void test() {
52+
assertThat(StateStoreUtil.configurableKeyValueStore("storeName"))
53+
.isInstanceOf(RocksDBKeyValueBytesStoreSupplier.class);
54+
}
55+
56+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* This file is part of Dependency-Track.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* Copyright (c) OWASP Foundation. All Rights Reserved.
18+
*/
19+
package org.dependencytrack.common;
20+
21+
import com.github.tomakehurst.wiremock.client.WireMock;
22+
import com.github.tomakehurst.wiremock.http.Body;
23+
import com.github.tomakehurst.wiremock.http.ContentTypeHeader;
24+
import io.micrometer.core.instrument.MeterRegistry;
25+
import io.quarkiverse.wiremock.devservice.ConnectWireMock;
26+
import io.quarkus.test.junit.QuarkusTest;
27+
import io.quarkus.test.junit.QuarkusTestProfile;
28+
import io.quarkus.test.junit.TestProfile;
29+
import org.apache.http.HttpHeaders;
30+
import org.apache.http.HttpStatus;
31+
import org.apache.http.client.methods.CloseableHttpResponse;
32+
import org.apache.http.client.methods.HttpGet;
33+
import org.apache.http.client.methods.HttpUriRequest;
34+
import org.apache.http.impl.client.CloseableHttpClient;
35+
import org.apache.http.util.EntityUtils;
36+
import org.junit.jupiter.api.AfterEach;
37+
import org.junit.jupiter.api.Assertions;
38+
import org.junit.jupiter.api.Test;
39+
40+
import jakarta.inject.Inject;
41+
import java.io.IOException;
42+
import java.util.Map;
43+
44+
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
45+
import static com.github.tomakehurst.wiremock.client.WireMock.get;
46+
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
47+
48+
@QuarkusTest
49+
@TestProfile(org.dependencytrack.common.HttpClientConfigWithNoProxyDomainTest.TestProfile.class)
50+
@ConnectWireMock
51+
class HttpClientConfigWithNoProxyDomainTest {
52+
53+
public static class TestProfile implements QuarkusTestProfile {
54+
55+
@Override
56+
public Map<String, String> getConfigOverrides() {
57+
return Map.of(
58+
"client.http.config.proxy-timeout-connection", "20",
59+
"client.http.config.proxy-timeout-pool", "40",
60+
"client.http.config.proxy-timeout-socket", "20",
61+
"client.http.config.proxy-username", "domain\\test",
62+
"client.http.config.proxy-password", "domain#test",
63+
"client.http.config.proxy-address", "http://localhost",
64+
"client.http.config.proxy-port", "1080"
65+
);
66+
}
67+
68+
}
69+
70+
@Inject
71+
HttpClientConfiguration configuration;
72+
@Inject
73+
MeterRegistry meterRegistry;
74+
75+
WireMock wireMock;
76+
77+
@AfterEach
78+
void afterEach() {
79+
wireMock.resetToDefaultMappings();
80+
}
81+
82+
@Test
83+
void clientCreatedWithProxyInfoTest() throws IOException {
84+
try (CloseableHttpClient client = configuration.newManagedHttpClient(meterRegistry)) {
85+
wireMock.register(get(urlPathEqualTo("/hello"))
86+
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, "application/json")
87+
.withResponseBody(Body.ofBinaryOrText("hello test".getBytes(),
88+
new ContentTypeHeader("application/json"))).withStatus(HttpStatus.SC_OK)));
89+
HttpUriRequest request = new HttpGet("http://localhost:1080/hello");
90+
try (CloseableHttpResponse response = client.execute(request)) {
91+
Assertions.assertEquals(200, response.getStatusLine().getStatusCode());
92+
String stringResponse = EntityUtils.toString(response.getEntity());
93+
Assertions.assertEquals("hello test", stringResponse);
94+
} catch (IOException ex) {
95+
System.out.println("exception occurred: " + ex.getMessage());
96+
}
97+
}
98+
}
99+
100+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* This file is part of Dependency-Track.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* Copyright (c) OWASP Foundation. All Rights Reserved.
18+
*/
19+
package org.dependencytrack.common;
20+
21+
import com.github.tomakehurst.wiremock.client.WireMock;
22+
import com.github.tomakehurst.wiremock.http.Body;
23+
import com.github.tomakehurst.wiremock.http.ContentTypeHeader;
24+
import io.micrometer.core.instrument.MeterRegistry;
25+
import io.quarkiverse.wiremock.devservice.ConnectWireMock;
26+
import io.quarkus.test.junit.QuarkusTest;
27+
import io.quarkus.test.junit.QuarkusTestProfile;
28+
import io.quarkus.test.junit.TestProfile;
29+
import org.apache.http.HttpHeaders;
30+
import org.apache.http.HttpStatus;
31+
import org.apache.http.client.methods.CloseableHttpResponse;
32+
import org.apache.http.client.methods.HttpGet;
33+
import org.apache.http.client.methods.HttpUriRequest;
34+
import org.apache.http.impl.client.CloseableHttpClient;
35+
import org.apache.http.util.EntityUtils;
36+
import org.junit.jupiter.api.AfterEach;
37+
import org.junit.jupiter.api.Assertions;
38+
import org.junit.jupiter.api.Test;
39+
40+
import jakarta.inject.Inject;
41+
import java.io.IOException;
42+
import java.util.Map;
43+
44+
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
45+
import static com.github.tomakehurst.wiremock.client.WireMock.get;
46+
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
47+
48+
@QuarkusTest
49+
@TestProfile(org.dependencytrack.common.HttpClientConfigWithNoProxyStarTest.TestProfile.class)
50+
@ConnectWireMock
51+
class HttpClientConfigWithNoProxyStarTest {
52+
53+
public static class TestProfile implements QuarkusTestProfile {
54+
55+
@Override
56+
public Map<String, String> getConfigOverrides() {
57+
return Map.of(
58+
"client.http.config.proxy-timeout-connection", "20",
59+
"client.http.config.proxy-timeout-pool", "40",
60+
"client.http.config.proxy-timeout-socket", "20",
61+
"client.http.config.proxy-username", "test",
62+
"client.http.config.proxy-password", "test",
63+
"client.http.config.proxy-address", "http://localhost",
64+
"client.http.config.proxy-port", "1080",
65+
"client.http.config.no-proxy", "*"
66+
);
67+
}
68+
69+
}
70+
71+
@Inject
72+
HttpClientConfiguration configuration;
73+
@Inject
74+
MeterRegistry meterRegistry;
75+
76+
WireMock wireMock;
77+
78+
@AfterEach
79+
void afterEach() {
80+
wireMock.resetToDefaultMappings();
81+
}
82+
83+
@Test
84+
void clientCreatedWithProxyInfoTest() throws IOException {
85+
try (CloseableHttpClient client = configuration.newManagedHttpClient(meterRegistry)) {
86+
wireMock.register(get(urlPathEqualTo("/hello"))
87+
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, "application/json")
88+
.withResponseBody(Body.ofBinaryOrText("hello test".getBytes(),
89+
new ContentTypeHeader("application/json"))).withStatus(HttpStatus.SC_OK)));
90+
HttpUriRequest request = new HttpGet("http://localhost:1080/hello");
91+
try (CloseableHttpResponse response = client.execute(request)) {
92+
Assertions.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
93+
String stringResponse = EntityUtils.toString(response.getEntity());
94+
Assertions.assertEquals("hello test", stringResponse);
95+
} catch (IOException ex) {
96+
System.out.println("exception occurred: " + ex.getMessage());
97+
}
98+
}
99+
}
100+
101+
}

0 commit comments

Comments
 (0)