diff --git a/CHANGELOG.md b/CHANGELOG.md index f66f57f474..b784f0b989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 5.1-SNAPSHOT #### Bugs +* Fix #2687: RawCustomResourceOperationsImpl ignores config #### Improvements diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java index 8356cef89e..2c3035070e 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java @@ -60,16 +60,13 @@ public class RawCustomResourceOperationsImpl extends OperationSupport { private static final String METADATA = "metadata"; private static final String RESOURCE_VERSION = "resourceVersion"; - private OkHttpClient client; - private Config config; - private CustomResourceDefinitionContext customResourceDefinition; - private ObjectMapper objectMapper; + private final CustomResourceDefinitionContext customResourceDefinition; + private final ObjectMapper objectMapper; - private enum HttpCallMethod { GET, POST, PUT, DELETE }; + private enum HttpCallMethod { GET, POST, PUT, DELETE } public RawCustomResourceOperationsImpl(OkHttpClient client, Config config, CustomResourceDefinitionContext customResourceDefinition) { - this.client = client; - this.config = config; + super(client, config); this.customResourceDefinition = customResourceDefinition; this.objectMapper = Serialization.jsonMapper(); } diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java index 7e6cc3eba6..06cca79f92 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java @@ -45,6 +45,8 @@ import okhttp3.Response; import okhttp3.ResponseBody; +import static org.assertj.core.api.Assertions.assertThat; + public class RawCustomResourceOperationsImplTest { private OkHttpClient mockClient; private Config config; @@ -146,7 +148,7 @@ void testDeleteUrl() throws IOException { } @Test - public void testFetchWatchUrlWithNamespace() throws MalformedURLException { + void testFetchWatchUrlWithNamespace() throws MalformedURLException { // Given RawCustomResourceOperationsImpl rawCustomResourceOperations = new RawCustomResourceOperationsImpl(mockClient, config, customResourceDefinitionContext); @@ -158,7 +160,7 @@ public void testFetchWatchUrlWithNamespace() throws MalformedURLException { } @Test - public void testFetchWatchUrlWithNamespaceAndName() throws MalformedURLException { + void testFetchWatchUrlWithNamespaceAndName() throws MalformedURLException { // Given RawCustomResourceOperationsImpl rawCustomResourceOperations = new RawCustomResourceOperationsImpl(mockClient, config, customResourceDefinitionContext); @@ -170,7 +172,7 @@ public void testFetchWatchUrlWithNamespaceAndName() throws MalformedURLException } @Test - public void testFetchWatchUrlWithNamespaceAndNameAndResourceVersion() throws MalformedURLException { + void testFetchWatchUrlWithNamespaceAndNameAndResourceVersion() throws MalformedURLException { // Given RawCustomResourceOperationsImpl rawCustomResourceOperations = new RawCustomResourceOperationsImpl(mockClient, config, customResourceDefinitionContext); @@ -182,7 +184,7 @@ public void testFetchWatchUrlWithNamespaceAndNameAndResourceVersion() throws Mal } @Test - public void testFetchWatchUrlWithoutAnything() throws MalformedURLException { + void testFetchWatchUrlWithoutAnything() throws MalformedURLException { // Given RawCustomResourceOperationsImpl rawCustomResourceOperations = new RawCustomResourceOperationsImpl(mockClient, config, customResourceDefinitionContext); @@ -194,7 +196,7 @@ public void testFetchWatchUrlWithoutAnything() throws MalformedURLException { } @Test - public void testFetchWatchUrlWithLabels() throws MalformedURLException { + void testFetchWatchUrlWithLabels() throws MalformedURLException { // Given RawCustomResourceOperationsImpl rawCustomResourceOperations = new RawCustomResourceOperationsImpl(mockClient, config, customResourceDefinitionContext); @@ -210,7 +212,7 @@ public void testFetchWatchUrlWithLabels() throws MalformedURLException { } @Test - public void testFetchWatchUrlWithLabelsWithNamespace() throws MalformedURLException { + void testFetchWatchUrlWithLabelsWithNamespace() throws MalformedURLException { // Given RawCustomResourceOperationsImpl rawCustomResourceOperations = new RawCustomResourceOperationsImpl(mockClient, config, customResourceDefinitionContext); @@ -224,4 +226,30 @@ public void testFetchWatchUrlWithLabelsWithNamespace() throws MalformedURLExcept // Then assertEquals("https://localhost:8443/apis/test.fabric8.io/v1alpha1/namespaces/test/hellos?labelSelector=" + Utils.toUrlEncoded("foo=bar") + "," + Utils.toUrlEncoded("foo1=bar1") + "&watch=true", url.url().toString()); } + + @Test + void testGetConfigShouldNotReturnNull() { + // Given + Config config = new ConfigBuilder() + .withRequestTimeout(5) + .withWebsocketTimeout(10L) + .withWebsocketPingInterval(10L) + .withConnectionTimeout(10) + .withWatchReconnectLimit(1) + .withWatchReconnectInterval(10) + .build(); + RawCustomResourceOperationsImpl rawOp = new RawCustomResourceOperationsImpl(mockClient, config, customResourceDefinitionContext); + + // When + Config configFromRawOp = rawOp.getConfig(); + + // Then + assertThat(configFromRawOp).isNotNull(); + assertThat(configFromRawOp.getRequestTimeout()).isEqualTo(5); + assertThat(configFromRawOp.getWebsocketTimeout()).isEqualTo(10L); + assertThat(configFromRawOp.getWebsocketPingInterval()).isEqualTo(10L); + assertThat(configFromRawOp.getConnectionTimeout()).isEqualTo(10L); + assertThat(configFromRawOp.getWatchReconnectInterval()).isEqualTo(10); + assertThat(configFromRawOp.getWatchReconnectLimit()).isEqualTo(1); + } }