|
32 | 32 | import org.springframework.boot.test.system.CapturedOutput; |
33 | 33 | import org.springframework.boot.test.system.OutputCaptureExtension; |
34 | 34 | import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; |
| 35 | +import org.springframework.cloud.kubernetes.commons.config.Constants; |
35 | 36 | import org.springframework.cloud.kubernetes.commons.config.RetryProperties; |
36 | 37 | import org.springframework.cloud.kubernetes.commons.config.SecretsConfigProperties; |
37 | | -import org.springframework.cloud.kubernetes.commons.config.SourceData; |
38 | 38 | import org.springframework.core.env.CompositePropertySource; |
39 | 39 | import org.springframework.core.env.MapPropertySource; |
40 | 40 | import org.springframework.core.env.PropertySource; |
@@ -85,7 +85,8 @@ void namedSingleSecretFails(CapturedOutput output) { |
85 | 85 | .findAny() |
86 | 86 | .orElseThrow(); |
87 | 87 |
|
88 | | - assertThat(mapPropertySource.getName()).isEqualTo(SourceData.EMPTY_SOURCE_NAME_ON_ERROR); |
| 88 | + assertThat(mapPropertySource.getName()).isEqualTo("secret..spring-k8s"); |
| 89 | + assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true"); |
89 | 90 | assertThat(output).contains("failure in reading named sources"); |
90 | 91 |
|
91 | 92 | } |
@@ -121,7 +122,8 @@ void namedTwoSecretsOneFails() { |
121 | 122 | List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList(); |
122 | 123 |
|
123 | 124 | // two sources are present, one being empty |
124 | | - assertThat(names).containsExactly("secret.two.default", SourceData.EMPTY_SOURCE_NAME_ON_ERROR); |
| 125 | + assertThat(names).containsExactly("secret.two.default", "secret..default"); |
| 126 | + assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true"); |
125 | 127 |
|
126 | 128 | } |
127 | 129 |
|
@@ -153,7 +155,8 @@ void namedTwoSecretsBothFail() { |
153 | 155 | CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment()); |
154 | 156 | List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList(); |
155 | 157 |
|
156 | | - assertThat(names).containsExactly(SourceData.EMPTY_SOURCE_NAME_ON_ERROR); |
| 158 | + assertThat(names).containsExactly("secret..default"); |
| 159 | + assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true"); |
157 | 160 |
|
158 | 161 | } |
159 | 162 |
|
@@ -184,7 +187,8 @@ void labeledSingleSecretFails(CapturedOutput output) { |
184 | 187 | CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment()); |
185 | 188 | List<String> sourceNames = propertySource.getPropertySources().stream().map(PropertySource::getName).toList(); |
186 | 189 |
|
187 | | - assertThat(sourceNames).containsExactly(SourceData.EMPTY_SOURCE_NAME_ON_ERROR); |
| 190 | + assertThat(sourceNames).containsExactly("secret..spring-k8s"); |
| 191 | + assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true"); |
188 | 192 | assertThat(output).contains("failure in reading labeled sources"); |
189 | 193 | assertThat(output).contains("failure in reading named sources"); |
190 | 194 | } |
@@ -230,7 +234,8 @@ void labeledTwoSecretsOneFails(CapturedOutput output) { |
230 | 234 | List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList(); |
231 | 235 |
|
232 | 236 | // two sources are present, one being empty |
233 | | - assertThat(names).containsExactly("secret.two.default", SourceData.EMPTY_SOURCE_NAME_ON_ERROR); |
| 237 | + assertThat(names).containsExactly("secret.two.default", "secret..default"); |
| 238 | + assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true"); |
234 | 239 |
|
235 | 240 | assertThat(output).contains("failure in reading labeled sources"); |
236 | 241 | assertThat(output).contains("failure in reading named sources"); |
@@ -268,8 +273,8 @@ void labeledTwoConfigMapsBothFail(CapturedOutput output) { |
268 | 273 | CompositePropertySource propertySource = (CompositePropertySource) locator.locate(new MockEnvironment()); |
269 | 274 | List<String> names = propertySource.getPropertySources().stream().map(PropertySource::getName).toList(); |
270 | 275 |
|
271 | | - // all 3 sources ('application' named source, and two labeled sources) |
272 | | - assertThat(names).containsExactly(SourceData.EMPTY_SOURCE_NAME_ON_ERROR); |
| 276 | + assertThat(names).containsExactly("secret..default"); |
| 277 | + assertThat(propertySource.getProperty(Constants.ERROR_PROPERTY)).isEqualTo("true"); |
273 | 278 |
|
274 | 279 | assertThat(output).contains("failure in reading labeled sources"); |
275 | 280 | assertThat(output).contains("failure in reading named sources"); |
|
0 commit comments