Skip to content

Commit 1ab8402

Browse files
committed
2 parents 5654479 + b44e502 commit 1ab8402

File tree

95 files changed

+256
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+256
-189
lines changed

spring-cloud-kubernetes-client-autoconfig/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>spring-cloud-kubernetes-client-autoconfig</artifactId>
13+
<name>${project.artifactId}</name>
1314

1415
<dependencies>
1516
<dependency>
@@ -29,6 +30,11 @@
2930
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
3031
<optional>true</optional>
3132
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-health</artifactId>
36+
<optional>true</optional>
37+
</dependency>
3238
<dependency>
3339
<groupId>org.springframework.boot</groupId>
3440
<artifactId>spring-boot-autoconfigure</artifactId>

spring-cloud-kubernetes-client-autoconfig/src/main/java/org/springframework/cloud/kubernetes/client/KubernetesClientActuatorConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2024 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@
1818

1919
import io.kubernetes.client.openapi.models.V1Pod;
2020

21-
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
2221
import org.springframework.boot.actuate.autoconfigure.info.ConditionalOnEnabledInfoContributor;
22+
import org.springframework.boot.health.autoconfigure.contributor.ConditionalOnEnabledHealthIndicator;
2323
import org.springframework.cloud.kubernetes.commons.PodUtils;
2424
import org.springframework.cloud.kubernetes.commons.autoconfig.ConditionalOnKubernetesHealthIndicatorEnabled;
2525
import org.springframework.context.annotation.Bean;

spring-cloud-kubernetes-client-autoconfig/src/test/java/org/springframework/cloud/kubernetes/client/ActuatorDisabledHealthTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2022 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
2020
import org.junit.jupiter.api.Test;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
23-
import org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry;
23+
import org.springframework.boot.health.registry.ReactiveHealthContributorRegistry;
2424
import org.springframework.boot.test.context.SpringBootTest;
25-
import org.springframework.boot.test.web.server.LocalManagementPort;
25+
import org.springframework.boot.web.server.test.LocalManagementPort;
2626
import org.springframework.cloud.kubernetes.client.example.App;
2727
import org.springframework.http.MediaType;
2828
import org.springframework.test.web.reactive.server.WebTestClient;

spring-cloud-kubernetes-client-autoconfig/src/test/java/org/springframework/cloud/kubernetes/client/ActuatorEnabledFailFastExceptionTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2024 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,8 +30,8 @@
3030
import org.mockito.Mockito;
3131

3232
import org.springframework.beans.factory.annotation.Autowired;
33-
import org.springframework.boot.actuate.health.Health;
34-
import org.springframework.boot.actuate.health.Status;
33+
import org.springframework.boot.health.contributor.Health;
34+
import org.springframework.boot.health.contributor.Status;
3535
import org.springframework.boot.test.context.SpringBootTest;
3636
import org.springframework.boot.test.context.TestConfiguration;
3737
import org.springframework.cloud.kubernetes.client.example.App;
@@ -67,14 +67,14 @@ void afterEach() {
6767

6868
@Test
6969
void test() throws ApiException {
70-
Health health = healthIndicator.getHealth(true);
70+
Health health = healthIndicator.health(true);
7171
Assertions.assertThat(Status.DOWN).isSameAs(health.getStatus());
7272
Mockito.verify(coreV1Api).readNamespacedPod("host", "my-namespace", null);
7373
}
7474

7575
private static void mocks() {
7676
envReaderMockedStatic = Mockito.mockStatic(EnvReader.class);
77-
pathsMockedStatic = Mockito.mockStatic(Paths.class);
77+
pathsMockedStatic = Mockito.mockStatic(Paths.class, Mockito.CALLS_REAL_METHODS);
7878

7979
envReaderMockedStatic.when(() -> EnvReader.getEnv(KubernetesClientPodUtils.KUBERNETES_SERVICE_HOST))
8080
.thenReturn("k8s-host");

spring-cloud-kubernetes-client-autoconfig/src/test/java/org/springframework/cloud/kubernetes/client/ActuatorEnabledHealthTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2022 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
2020
import org.junit.jupiter.api.Test;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
23-
import org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry;
23+
import org.springframework.boot.health.registry.HealthContributorRegistry;
2424
import org.springframework.boot.test.context.SpringBootTest;
25-
import org.springframework.boot.test.web.server.LocalManagementPort;
25+
import org.springframework.boot.web.server.test.LocalManagementPort;
2626
import org.springframework.cloud.kubernetes.client.example.App;
2727
import org.springframework.http.MediaType;
2828
import org.springframework.test.web.reactive.server.WebTestClient;
@@ -37,7 +37,7 @@ class ActuatorEnabledHealthTest {
3737
private WebTestClient webClient;
3838

3939
@Autowired
40-
private ReactiveHealthContributorRegistry registry;
40+
private HealthContributorRegistry registry;
4141

4242
@LocalManagementPort
4343
private int port;

spring-cloud-kubernetes-client-autoconfig/src/test/java/org/springframework/cloud/kubernetes/client/ActuatorEnabledNoFailFastExceptionTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2024 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,8 +30,8 @@
3030
import org.mockito.Mockito;
3131

3232
import org.springframework.beans.factory.annotation.Autowired;
33-
import org.springframework.boot.actuate.health.Health;
34-
import org.springframework.boot.actuate.health.Status;
33+
import org.springframework.boot.health.contributor.Health;
34+
import org.springframework.boot.health.contributor.Status;
3535
import org.springframework.boot.test.context.SpringBootTest;
3636
import org.springframework.boot.test.context.TestConfiguration;
3737
import org.springframework.cloud.kubernetes.client.example.App;
@@ -70,14 +70,14 @@ void afterEach() {
7070
// This is not a real case we have, it just makes sure
7171
@Test
7272
void test() throws ApiException {
73-
Health health = healthIndicator.getHealth(true);
73+
Health health = healthIndicator.health(true);
7474
Assertions.assertThat(Status.UP).isSameAs(health.getStatus());
7575
Mockito.verify(coreV1Api).readNamespacedPod("host", "my-namespace", null);
7676
}
7777

7878
private static void mocks() {
7979
envReaderMockedStatic = Mockito.mockStatic(EnvReader.class);
80-
pathsMockedStatic = Mockito.mockStatic(Paths.class);
80+
pathsMockedStatic = Mockito.mockStatic(Paths.class, Mockito.CALLS_REAL_METHODS);
8181

8282
envReaderMockedStatic.when(() -> EnvReader.getEnv(KubernetesClientPodUtils.KUBERNETES_SERVICE_HOST))
8383
.thenReturn("k8s-host");

spring-cloud-kubernetes-client-config/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>spring-cloud-kubernetes-client-config</artifactId>
13+
<name>${project.artifactId}</name>
1314

1415
<dependencies>
1516
<dependency>
@@ -64,6 +65,11 @@
6465
<optional>true</optional>
6566
</dependency>
6667

68+
<dependency>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-health</artifactId>
71+
<scope>test</scope>
72+
</dependency>
6773
<dependency>
6874
<groupId>org.springframework.boot</groupId>
6975
<artifactId>spring-boot-starter-test</artifactId>

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/bootstrap/stubs/BootstrapKubernetesClientSanitizeEnvEndpointStub.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2023 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.cloud.kubernetes.client.config.boostrap.stubs;
17+
package org.springframework.cloud.kubernetes.client.config.bootstrap.stubs;
1818

1919
import java.util.Map;
2020

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/sanitize_secrets/BootstrapKubernetesClientSanitizeConfigpropsEndpointTests.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2023 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.boot.actuate.endpoint.SanitizableData;
2424
import org.springframework.boot.test.context.SpringBootTest;
25-
import org.springframework.boot.test.web.server.LocalManagementPort;
25+
import org.springframework.boot.web.server.test.LocalManagementPort;
2626
import org.springframework.http.MediaType;
2727
import org.springframework.test.web.reactive.server.WebTestClient;
2828

@@ -34,7 +34,7 @@ class BootstrapKubernetesClientSanitizeConfigpropsEndpointTests {
3434
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SanitizeApp.class,
3535
properties = { "spring.main.cloud-platform=KUBERNETES", "spring.cloud.bootstrap.enabled=true",
3636
"management.endpoints.web.exposure.include=*", "spring.cloud.bootstrap.name=sanitize",
37-
"bootstrap.sanitize=true", "spring.cloud.kubernetes.client.namespace=test" })
37+
"bootstrap.sanitize=true", "spring.cloud.kubernetes.client.namespace=test", "debug=true" })
3838
@Nested
3939
class DefaultSettingsTest {
4040

@@ -47,7 +47,7 @@ class DefaultSettingsTest {
4747
@Test
4848
void test() {
4949
// configmap is sanitized
50-
webClient.get()
50+
this.webClient.get()
5151
.uri("http://localhost:{port}/actuator/configprops", this.port)
5252
.accept(MediaType.APPLICATION_JSON)
5353
.exchange()
@@ -56,7 +56,7 @@ void test() {
5656
.isEqualTo(SanitizableData.SANITIZED_VALUE);
5757

5858
// secret is sanitized
59-
webClient.get()
59+
this.webClient.get()
6060
.uri("http://localhost:{port}/actuator/configprops", this.port)
6161
.accept(MediaType.APPLICATION_JSON)
6262
.exchange()
@@ -65,7 +65,7 @@ void test() {
6565
.isEqualTo(SanitizableData.SANITIZED_VALUE);
6666

6767
// secret is usable from configuration properties
68-
webClient.get()
68+
this.webClient.get()
6969
.uri("http://localhost:{port}/secret", this.port)
7070
.exchange()
7171
.expectStatus()
@@ -75,7 +75,7 @@ void test() {
7575
.isEqualTo("sanitizeSecretValue");
7676

7777
// configmap is usable from configuration properties
78-
webClient.get()
78+
this.webClient.get()
7979
.uri("http://localhost:{port}/configmap", this.port)
8080
.exchange()
8181
.expectStatus()
@@ -105,7 +105,7 @@ class ExplicitNever {
105105
@Test
106106
void test() {
107107
// configmap is sanitized
108-
webClient.get()
108+
this.webClient.get()
109109
.uri("http://localhost:{port}/actuator/configprops", this.port)
110110
.accept(MediaType.APPLICATION_JSON)
111111
.exchange()
@@ -116,7 +116,7 @@ void test() {
116116
.isEqualTo(SanitizableData.SANITIZED_VALUE);
117117

118118
// secret is sanitized
119-
webClient.get()
119+
this.webClient.get()
120120
.uri("http://localhost:{port}/actuator/configprops", this.port)
121121
.accept(MediaType.APPLICATION_JSON)
122122
.exchange()
@@ -127,7 +127,7 @@ void test() {
127127
.isEqualTo(SanitizableData.SANITIZED_VALUE);
128128

129129
// secret is usable from configuration properties
130-
webClient.get()
130+
this.webClient.get()
131131
.uri("http://localhost:{port}/secret", this.port)
132132
.exchange()
133133
.expectStatus()
@@ -137,7 +137,7 @@ void test() {
137137
.isEqualTo("sanitizeSecretValue");
138138

139139
// configmap is usable from configuration properties
140-
webClient.get()
140+
this.webClient.get()
141141
.uri("http://localhost:{port}/configmap", this.port)
142142
.exchange()
143143
.expectStatus()
@@ -177,7 +177,7 @@ class AlwaysWithoutSanitizingFunction {
177177
@Test
178178
void test() {
179179
// configmap is not sanitized
180-
webClient.get()
180+
this.webClient.get()
181181
.uri("http://localhost:{port}/actuator/configprops", this.port)
182182
.accept(MediaType.APPLICATION_JSON)
183183
.exchange()
@@ -188,7 +188,7 @@ void test() {
188188
.isEqualTo("sanitizeConfigMapValue");
189189

190190
// secret is not sanitized
191-
webClient.get()
191+
this.webClient.get()
192192
.uri("http://localhost:{port}/actuator/configprops", this.port)
193193
.accept(MediaType.APPLICATION_JSON)
194194
.exchange()
@@ -199,7 +199,7 @@ void test() {
199199
.isEqualTo("sanitizeSecretValue");
200200

201201
// secret is usable from configuration properties
202-
webClient.get()
202+
this.webClient.get()
203203
.uri("http://localhost:{port}/secret", this.port)
204204
.exchange()
205205
.expectStatus()
@@ -209,7 +209,7 @@ void test() {
209209
.isEqualTo("sanitizeSecretValue");
210210

211211
// configmap is usable from configuration properties
212-
webClient.get()
212+
this.webClient.get()
213213
.uri("http://localhost:{port}/configmap", this.port)
214214
.exchange()
215215
.expectStatus()
@@ -249,7 +249,7 @@ class AlwaysWithSanitizingFunction {
249249
@Test
250250
void test() {
251251
// configmap is not sanitized
252-
webClient.get()
252+
this.webClient.get()
253253
.uri("http://localhost:{port}/actuator/configprops", this.port)
254254
.accept(MediaType.APPLICATION_JSON)
255255
.exchange()
@@ -260,7 +260,7 @@ void test() {
260260
.isEqualTo("sanitizeConfigMapValue");
261261

262262
// first secret is sanitized
263-
webClient.get()
263+
this.webClient.get()
264264
.uri("http://localhost:{port}/actuator/configprops", this.port)
265265
.accept(MediaType.APPLICATION_JSON)
266266
.exchange()
@@ -271,7 +271,7 @@ void test() {
271271
.isEqualTo(SanitizableData.SANITIZED_VALUE);
272272

273273
// second secret is sanitized
274-
webClient.get()
274+
this.webClient.get()
275275
.uri("http://localhost:{port}/actuator/configprops", this.port)
276276
.accept(MediaType.APPLICATION_JSON)
277277
.exchange()
@@ -282,7 +282,7 @@ void test() {
282282
.isEqualTo(SanitizableData.SANITIZED_VALUE);
283283

284284
// secret is usable from configuration properties
285-
webClient.get()
285+
this.webClient.get()
286286
.uri("http://localhost:{port}/secret", this.port)
287287
.exchange()
288288
.expectStatus()
@@ -292,7 +292,7 @@ void test() {
292292
.isEqualTo("sanitizeSecretValue");
293293

294294
// configmap is usable from configuration properties
295-
webClient.get()
295+
this.webClient.get()
296296
.uri("http://localhost:{port}/configmap", this.port)
297297
.exchange()
298298
.expectStatus()

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/sanitize_secrets/BootstrapKubernetesClientSanitizeEnvEndpointTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2023 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.boot.actuate.endpoint.SanitizableData;
2424
import org.springframework.boot.test.context.SpringBootTest;
25-
import org.springframework.boot.test.web.server.LocalManagementPort;
25+
import org.springframework.boot.web.server.test.LocalManagementPort;
2626
import org.springframework.http.MediaType;
2727
import org.springframework.test.web.reactive.server.WebTestClient;
2828

0 commit comments

Comments
 (0)