Skip to content

Commit

Permalink
Correct tests after fabric8 upgrade (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
wind57 authored Jun 25, 2023
1 parent 8f1ca03 commit 27186ec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
String namespace = "default";
String path = "/api/v1/namespaces/default/configmaps";

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();

ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(),
Map.of(), true, name, namespace, false, true, true, RetryProperties.DEFAULT);
Expand All @@ -57,16 +57,16 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));

assertThatThrownBy(() -> locator.locate(new MockEnvironment())).isInstanceOf(IllegalStateException.class)
.hasMessageContaining("api/v1/namespaces/default/configmaps. Message: Not Found.");
.hasMessageContaining("api/v1/namespaces/default/configmaps. Message: Internal Server Error.");
}

@Test
void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
String name = "my-config";
String namespace = "default";
String path = "/api/v1/namespaces/default/configmaps/my-config";
String path = "/api/v1/namespaces/default/configmaps";

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();

ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(),
Map.of(), true, name, namespace, false, true, false, RetryProperties.DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ void constructorShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
String namespace = "default";
String path = String.format("/api/v1/namespaces/%s/configmaps", namespace);

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();
NormalizedSource source = new NamedConfigMapNormalizedSource(name, namespace, true, DEFAULT, true);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "default", new MockEnvironment());
assertThatThrownBy(() -> new Fabric8ConfigMapPropertySource(context)).isInstanceOf(IllegalStateException.class)
.hasMessageContaining("v1/namespaces/default/configmaps. Message: Not Found.");
.hasMessageContaining("v1/namespaces/default/configmaps. Message: Internal Server Error.");
}

@Test
Expand All @@ -66,7 +66,7 @@ void constructorShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
String namespace = "default";
String path = String.format("/api/v1/namespaces/%s/configmaps/%s", namespace, name);

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();
NormalizedSource source = new NamedConfigMapNormalizedSource(name, namespace, false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());
assertThatNoException().isThrownBy(() -> new Fabric8ConfigMapPropertySource(context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
String namespace = "default";
String path = "/api/v1/namespaces/default/secrets";

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();

SecretsConfigProperties configMapConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(),
List.of(), true, name, namespace, false, true, true, RetryProperties.DEFAULT);
Expand All @@ -57,7 +57,7 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));

assertThatThrownBy(() -> locator.locate(new MockEnvironment())).isInstanceOf(IllegalStateException.class)
.hasMessageContaining("v1/namespaces/default/secrets. Message: Not Found.");
.hasMessageContaining("v1/namespaces/default/secrets. Message: Internal Server Error.");
}

@Test
Expand All @@ -66,7 +66,7 @@ void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
String namespace = "default";
String path = "/api/v1/namespaces/default/secrets/my-secret";

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();

SecretsConfigProperties configMapConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(),
List.of(), true, name, namespace, false, true, false, RetryProperties.DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ class Fabric8SecretsPropertySourceMockTests {

@Test
void namedStrategyShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
final String name = "my-config";
final String name = "my-secret";
final String namespace = "default";
final String path = String.format("/api/v1/namespaces/%s/secrets/%s", namespace, name);
final String path = String.format("/api/v1/namespaces/%s/secrets", namespace);

NamedSecretNormalizedSource named = new NamedSecretNormalizedSource(name, namespace, true, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(client, named, "default", new MockEnvironment());
Fabric8ConfigContext context = new Fabric8ConfigContext(client, named, namespace, new MockEnvironment());

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();
assertThatThrownBy(() -> new Fabric8SecretsPropertySource(context)).isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Failure executing: GET at: https://localhost:")
.hasMessageContaining("api/v1/namespaces/default/secrets. Message: Not Found.");
.hasMessageContaining("api/v1/namespaces/default/secrets. Message: Internal Server Error.");
}

@Test
Expand All @@ -67,34 +67,34 @@ void labeledStrategyShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
LabeledSecretNormalizedSource labeled = new LabeledSecretNormalizedSource(namespace, labels, true, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(client, labeled, "default", new MockEnvironment());

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();
assertThatThrownBy(() -> new Fabric8SecretsPropertySource(context)).isInstanceOf(IllegalStateException.class)
.hasMessageContaining("api/v1/namespaces/default/secrets. Message: Not Found.");
.hasMessageContaining("api/v1/namespaces/default/secrets. Message: Internal Server Error.");
}

@Test
void namedStrategyShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
final String name = "my-config";
final String name = "my-secret";
final String namespace = "default";
final String path = String.format("/api/v1/namespaces/%s/secrets/%s", namespace, name);
final String path = String.format("/api/v1/namespaces/%s/secrets", namespace);

NamedSecretNormalizedSource named = new NamedSecretNormalizedSource(name, namespace, false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(client, named, "default", new MockEnvironment());

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();
assertThatNoException().isThrownBy(() -> new Fabric8SecretsPropertySource(context));
}

@Test
void labeledStrategyShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
final String namespace = "default";
final Map<String, String> labels = Collections.singletonMap("a", "b");
final String path = String.format("/api/v1/namespaces/%s/secrets?labelSelector=", namespace) + "a%3Db";
final String path = String.format("/api/v1/namespaces/%s/secrets", namespace);

LabeledSecretNormalizedSource labeled = new LabeledSecretNormalizedSource(namespace, labels, false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(client, labeled, "default", new MockEnvironment());

mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();
assertThatNoException().isThrownBy(() -> new Fabric8SecretsPropertySource(context));
}

Expand Down

0 comments on commit 27186ec

Please sign in to comment.