diff --git a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlApplyTest.java b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlApplyTest.java index 32408b72c1..a47010eff2 100644 --- a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlApplyTest.java +++ b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlApplyTest.java @@ -38,13 +38,22 @@ public class KubectlApplyTest { private static final String DISCOVERY_API = - KubectlApplyTest.class.getClassLoader().getResource("discovery-api.json").getPath(); + new java.io.File( + KubectlApplyTest.class.getClassLoader().getResource("discovery-api.json").getPath()) + .toString(); private static final String DISCOVERY_APIV1 = - KubectlApplyTest.class.getClassLoader().getResource("discovery-api-v1.json").getPath(); + new java.io.File( + KubectlApplyTest.class + .getClassLoader() + .getResource("discovery-api-v1.json") + .getPath()) + .toString(); private static final String DISCOVERY_APIS = - KubectlApplyTest.class.getClassLoader().getResource("discovery-apis.json").getPath(); + new java.io.File( + KubectlApplyTest.class.getClassLoader().getResource("discovery-apis.json").getPath()) + .toString(); private ApiClient apiClient; diff --git a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlCreateTest.java b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlCreateTest.java index 860d986b36..0011b3b21a 100644 --- a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlCreateTest.java +++ b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlCreateTest.java @@ -21,6 +21,7 @@ import io.kubernetes.client.openapi.models.V1ConfigMap; import io.kubernetes.client.openapi.models.V1ObjectMeta; import io.kubernetes.client.util.ClientBuilder; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -32,13 +33,21 @@ public class KubectlCreateTest { private static final String DISCOVERY_API = - KubectlCreateTest.class.getClassLoader().getResource("discovery-api.json").getPath(); + new File(KubectlCreateTest.class.getClassLoader().getResource("discovery-api.json").getPath()) + .toString(); private static final String DISCOVERY_APIV1 = - KubectlCreateTest.class.getClassLoader().getResource("discovery-api-v1.json").getPath(); + new File( + KubectlCreateTest.class + .getClassLoader() + .getResource("discovery-api-v1.json") + .getPath()) + .toString(); private static final String DISCOVERY_APIS = - KubectlCreateTest.class.getClassLoader().getResource("discovery-apis.json").getPath(); + new File( + KubectlCreateTest.class.getClassLoader().getResource("discovery-apis.json").getPath()) + .toString(); private ApiClient apiClient; diff --git a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlDrainTest.java b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlDrainTest.java index b147a3ba6a..aece9ee852 100644 --- a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlDrainTest.java +++ b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlDrainTest.java @@ -31,6 +31,7 @@ import io.kubernetes.client.openapi.models.V1Pod; import io.kubernetes.client.util.ClientBuilder; import io.kubernetes.client.util.ModelMapper; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -41,7 +42,8 @@ public class KubectlDrainTest { private static final String POD_LIST_API = - KubectlDrainTest.class.getClassLoader().getResource("pod-list.json").getPath(); + new File(KubectlDrainTest.class.getClassLoader().getResource("pod-list.json").getPath()) + .toString(); private ApiClient apiClient; diff --git a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlPatchTest.java b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlPatchTest.java index 13e4182223..f7a9cf778e 100644 --- a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlPatchTest.java +++ b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlPatchTest.java @@ -27,6 +27,7 @@ import io.kubernetes.client.openapi.ApiClient; import io.kubernetes.client.openapi.models.V1ConfigMap; import io.kubernetes.client.util.ClientBuilder; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -37,13 +38,20 @@ public class KubectlPatchTest { private static final String DISCOVERY_API = - KubectlPatchTest.class.getClassLoader().getResource("discovery-api.json").getPath(); + new File(KubectlPatchTest.class.getClassLoader().getResource("discovery-api.json").getPath()) + .toString(); private static final String DISCOVERY_APIV1 = - KubectlPatchTest.class.getClassLoader().getResource("discovery-api-v1.json").getPath(); + new File( + KubectlPatchTest.class + .getClassLoader() + .getResource("discovery-api-v1.json") + .getPath()) + .toString(); private static final String DISCOVERY_APIS = - KubectlPatchTest.class.getClassLoader().getResource("discovery-apis.json").getPath(); + new File(KubectlPatchTest.class.getClassLoader().getResource("discovery-apis.json").getPath()) + .toString(); private ApiClient apiClient; diff --git a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlRolloutTest.java b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlRolloutTest.java index b6239a3e25..0d95c3a6b6 100644 --- a/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlRolloutTest.java +++ b/extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlRolloutTest.java @@ -34,6 +34,7 @@ import io.kubernetes.client.openapi.models.V1StatefulSetList; import io.kubernetes.client.util.ClientBuilder; import io.kubernetes.client.util.ModelMapper; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -50,34 +51,56 @@ public class KubectlRolloutTest { @Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); private static final String DEPLOYMENT = - KubectlRolloutTest.class.getClassLoader().getResource("deployment.json").getPath(); + new File(KubectlRolloutTest.class.getClassLoader().getResource("deployment.json").getPath()) + .toString(); private static final String REPLICASET_LIST = - KubectlRolloutTest.class.getClassLoader().getResource("replicaset-list.json").getPath(); + new File( + KubectlRolloutTest.class + .getClassLoader() + .getResource("replicaset-list.json") + .getPath()) + .toString(); private static final String DAEMON_SET = - KubectlRolloutTest.class.getClassLoader().getResource("daemonset.json").getPath(); + new File(KubectlRolloutTest.class.getClassLoader().getResource("daemonset.json").getPath()) + .toString(); private static final String PATCHED_DAEMON_SET = - KubectlRolloutTest.class.getClassLoader().getResource("patched-daemonset.json").getPath(); + new File( + KubectlRolloutTest.class + .getClassLoader() + .getResource("patched-daemonset.json") + .getPath()) + .toString(); private static final String DAEMON_SET_CONTROLLER_REVISION_LIST = - KubectlRolloutTest.class - .getClassLoader() - .getResource("daemonset-controllerrevision-list.json") - .getPath(); + new File( + KubectlRolloutTest.class + .getClassLoader() + .getResource("daemonset-controllerrevision-list.json") + .getPath()) + .toString(); private static final String STATEFUL_SET = - KubectlRolloutTest.class.getClassLoader().getResource("statefulset.json").getPath(); + new File(KubectlRolloutTest.class.getClassLoader().getResource("statefulset.json").getPath()) + .toString(); private static final String PATCHED_STATEFUL_SET = - KubectlRolloutTest.class.getClassLoader().getResource("patched-statefulset.json").getPath(); + new File( + KubectlRolloutTest.class + .getClassLoader() + .getResource("patched-statefulset.json") + .getPath()) + .toString(); private static final String STATEFUL_SET_CONTROLLER_REVISION_LIST = - KubectlRolloutTest.class - .getClassLoader() - .getResource("statefulset-controllerrevision-list.json") - .getPath(); + new File( + KubectlRolloutTest.class + .getClassLoader() + .getResource("statefulset-controllerrevision-list.json") + .getPath()) + .toString(); @Before public void setup() throws IOException { diff --git a/extended/src/test/java/io/kubernetes/client/extended/kubectl/util/deployment/DeploymentHelperTest.java b/extended/src/test/java/io/kubernetes/client/extended/kubectl/util/deployment/DeploymentHelperTest.java index 773d1a2e9b..efa62a20af 100644 --- a/extended/src/test/java/io/kubernetes/client/extended/kubectl/util/deployment/DeploymentHelperTest.java +++ b/extended/src/test/java/io/kubernetes/client/extended/kubectl/util/deployment/DeploymentHelperTest.java @@ -28,6 +28,7 @@ import io.kubernetes.client.openapi.models.V1ReplicaSet; import io.kubernetes.client.openapi.models.V1ReplicaSetList; import io.kubernetes.client.util.ClientBuilder; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -46,10 +47,16 @@ public class DeploymentHelperTest { @Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort(), false); private static final String DEPLOYMENT = - DeploymentHelperTest.class.getClassLoader().getResource("deployment.json").getPath(); + new File(DeploymentHelperTest.class.getClassLoader().getResource("deployment.json").getPath()) + .toString(); private static final String REPLICASET_LIST = - DeploymentHelperTest.class.getClassLoader().getResource("replicaset-list.json").getPath(); + new File( + DeploymentHelperTest.class + .getClassLoader() + .getResource("replicaset-list.json") + .getPath()) + .toString(); @Before public void setup() throws IOException { diff --git a/extended/src/test/java/io/kubernetes/client/extended/pager/PagerTest.java b/extended/src/test/java/io/kubernetes/client/extended/pager/PagerTest.java index 36ded23a48..0ae56452f6 100644 --- a/extended/src/test/java/io/kubernetes/client/extended/pager/PagerTest.java +++ b/extended/src/test/java/io/kubernetes/client/extended/pager/PagerTest.java @@ -30,6 +30,7 @@ import io.kubernetes.client.openapi.models.V1Namespace; import io.kubernetes.client.openapi.models.V1NamespaceList; import io.kubernetes.client.util.ClientBuilder; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -46,15 +47,20 @@ public class PagerTest { private ApiClient client; private static final String LIST_PAGE0_FILE_PATH = - PagerTest.class.getClassLoader().getResource("namespace-list-pager0.json").getPath(); + new File(PagerTest.class.getClassLoader().getResource("namespace-list-pager0.json").getPath()) + .toString(); private static final String LIST_PAGE1_FILE_PATH = - PagerTest.class.getClassLoader().getResource("namespace-list-pager1.json").getPath(); + new File(PagerTest.class.getClassLoader().getResource("namespace-list-pager1.json").getPath()) + .toString(); private static final String LIST_PAGE2_FILE_PATH = - PagerTest.class.getClassLoader().getResource("namespace-list-pager2.json").getPath(); + new File(PagerTest.class.getClassLoader().getResource("namespace-list-pager2.json").getPath()) + .toString(); private static final String LIST_STATUS_FILE_PATH = - PagerTest.class.getClassLoader().getResource("status-400.json").getPath(); + new File(PagerTest.class.getClassLoader().getResource("status-400.json").getPath()) + .toString(); private static final String STATUS_BAD_TOKEN_FILE_PATH = - PagerTest.class.getClassLoader().getResource("bad-token-status.json").getPath(); + new File(PagerTest.class.getClassLoader().getResource("bad-token-status.json").getPath()) + .toString(); @Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); @Before diff --git a/spring/src/main/java/io/kubernetes/client/spring/extended/manifests/KubernetesFromYamlProcessor.java b/spring/src/main/java/io/kubernetes/client/spring/extended/manifests/KubernetesFromYamlProcessor.java index 42922d61f4..a11da9bd38 100644 --- a/spring/src/main/java/io/kubernetes/client/spring/extended/manifests/KubernetesFromYamlProcessor.java +++ b/spring/src/main/java/io/kubernetes/client/spring/extended/manifests/KubernetesFromYamlProcessor.java @@ -14,6 +14,7 @@ import io.kubernetes.client.spring.extended.manifests.annotation.FromYaml; import io.kubernetes.client.util.Yaml; +import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.nio.file.Files; @@ -91,7 +92,8 @@ private Object loadFromYaml(String targetFilePath) { Path targetPath = Paths.get(targetFilePath); if (!Files.exists(Paths.get(targetFilePath))) { // checks if it exists on the machine // otherwise use load from classpath resources - Path classPath = Paths.get(getClass().getClassLoader().getResource(targetFilePath).getPath()); + Path classPath = + new File(getClass().getClassLoader().getResource(targetFilePath).getFile()).toPath(); if (Files.exists(classPath)) { // use classpath it works targetPath = classPath; } else { diff --git a/util/src/main/java/io/kubernetes/client/Copy.java b/util/src/main/java/io/kubernetes/client/Copy.java index a4f90b46fb..66d5acf3e0 100644 --- a/util/src/main/java/io/kubernetes/client/Copy.java +++ b/util/src/main/java/io/kubernetes/client/Copy.java @@ -411,6 +411,7 @@ public Future copyFileToPodAsync( private Process execCopyToPod(String namespace, String pod, String container, Path destPath) throws ApiException, IOException { + // TODO: This assumes Linux and won't work on Windows Containers (for many reasons...) String parentPath = destPath.getParent() != null ? destPath.getParent().toString() : "."; parentPath = parentPath.replace("\\", "/"); return this.exec( diff --git a/util/src/main/java/io/kubernetes/client/util/ClientBuilder.java b/util/src/main/java/io/kubernetes/client/util/ClientBuilder.java index 181b6c4a90..024d428376 100644 --- a/util/src/main/java/io/kubernetes/client/util/ClientBuilder.java +++ b/util/src/main/java/io/kubernetes/client/util/ClientBuilder.java @@ -140,7 +140,6 @@ private static File findConfigFromEnv() { if (kubeConfigPath == null) { return null; } - final File kubeConfig = new File(kubeConfigPath); if (kubeConfig.exists()) { return kubeConfig; diff --git a/util/src/test/java/io/kubernetes/client/util/ClientBuilderTest.java b/util/src/test/java/io/kubernetes/client/util/ClientBuilderTest.java index 29614ed836..8d031dd475 100644 --- a/util/src/test/java/io/kubernetes/client/util/ClientBuilderTest.java +++ b/util/src/test/java/io/kubernetes/client/util/ClientBuilderTest.java @@ -46,9 +46,10 @@ public class ClientBuilderTest { Resources.getResource("kubeconfig-https").getPath(); private static final String KUBECONFIG_HTTPS_X509_FILE_PATH = Resources.getResource("kubeconfig-https-x509").getPath(); - private static final String SSL_CA_CERT_PATH = Resources.getResource("ca-cert.pem").getPath(); + private static final String SSL_CA_CERT_PATH = + new File(Resources.getResource("ca-cert.pem").getPath()).toString(); private static final String INVALID_SSL_CA_CERT_PATH = - Resources.getResource("ca-cert-invalid.pem").getPath(); + new File(Resources.getResource("ca-cert-invalid.pem").getPath()).toString(); private String basePath = "http://localhost"; private String apiKey = "ABCD"; @@ -62,6 +63,8 @@ public class ClientBuilderTest { public void testDefaultClientWithNoFiles() throws Exception { String path = withEnvironmentVariable("HOME", "/non-existent") + .and("HOMEDRIVE", null) + .and("USERPROFILE", null) .and("KUBECONFIG", null) .execute( () -> { @@ -139,6 +142,8 @@ public void testInvalidKubeconfig() throws Exception { String path = withEnvironmentVariable("KUBECONFIG", "/non-existent") .and("HOME", "/none-existent") + .and("HOMEDRIVE", null) + .and("USERPROFILE", null) .execute( () -> { final ApiClient client = ClientBuilder.standard().build(); diff --git a/util/src/test/java/io/kubernetes/client/util/ConfigTest.java b/util/src/test/java/io/kubernetes/client/util/ConfigTest.java index c0ab7ff55c..1934ad3fdd 100644 --- a/util/src/test/java/io/kubernetes/client/util/ConfigTest.java +++ b/util/src/test/java/io/kubernetes/client/util/ConfigTest.java @@ -33,6 +33,8 @@ public void testDefaultClientNothingPresent() { try { String path = withEnvironmentVariable("HOME", "/non-existent") + .and("HOMEDRIVE", null) + .and("USERPROFILE", null) .execute( () -> { ApiClient client = Config.defaultClient(); diff --git a/util/src/test/java/io/kubernetes/client/util/KubeConfigTest.java b/util/src/test/java/io/kubernetes/client/util/KubeConfigTest.java index 53c0c51fcc..1dbf180bd8 100644 --- a/util/src/test/java/io/kubernetes/client/util/KubeConfigTest.java +++ b/util/src/test/java/io/kubernetes/client/util/KubeConfigTest.java @@ -315,6 +315,10 @@ public void testRefreshToken() { @Test public void testExecCredentials() throws Exception { + // TODO: test exec on Windows + if (System.getProperty("os.name").contains("Windows")) { + return; + } KubeConfig kc = KubeConfig.loadKubeConfig(new StringReader(KUBECONFIG_EXEC)); kc.setFile(folder.newFile()); // just making sure it is ignored assertEquals("abc123", kc.getAccessToken()); @@ -322,6 +326,10 @@ public void testExecCredentials() throws Exception { @Test public void testExecCredentialsAlpha1() throws Exception { + // TODO: test exec on Windows + if (System.getProperty("os.name").contains("Windows")) { + return; + } KubeConfig kc = KubeConfig.loadKubeConfig(new StringReader(KUBECONFIG_EXEC.replace("v1beta1", "v1alpha1"))); assertEquals("abc123", kc.getAccessToken()); @@ -350,6 +358,11 @@ public void testExecCredentialsAlpha1() throws Exception { @Test public void testExecCredentialsEnv() throws Exception { + // TODO: test exec on Windows + if (System.getProperty("os.name").contains("Windows")) { + return; + } + KubeConfig kc = KubeConfig.loadKubeConfig(new StringReader(KUBECONFIG_EXEC_ENV)); assertEquals("abc123", kc.getAccessToken()); } @@ -374,6 +387,11 @@ public void testExecCredentialsEnv() throws Exception { @Test public void testExecCredentialsBasedir() throws Exception { + // TODO: test exec on Windows + if (System.getProperty("os.name").contains("Windows")) { + return; + } + File basedir = folder.newFolder(); File config = new File(basedir, ".kubeconfig"); try (FileWriter writer = new FileWriter(config)) { diff --git a/util/src/test/java/io/kubernetes/client/util/SSLUtilsTest.java b/util/src/test/java/io/kubernetes/client/util/SSLUtilsTest.java index 2a58739b3b..bb9b0ad9fb 100644 --- a/util/src/test/java/io/kubernetes/client/util/SSLUtilsTest.java +++ b/util/src/test/java/io/kubernetes/client/util/SSLUtilsTest.java @@ -13,6 +13,7 @@ package io.kubernetes.client.util; import io.kubernetes.client.Resources; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -23,15 +24,16 @@ public class SSLUtilsTest extends TestCase { - private static final String CLIENT_KEY_PATH = Resources.getResource("clientauth.key").getPath(); + private static final String CLIENT_KEY_PATH = + new File(Resources.getResource("clientauth.key").getPath()).toString(); private static final String CLIENT_KEY_RSA_PATH = - Resources.getResource("clientauth-rsa.key").getPath(); + new File(Resources.getResource("clientauth-rsa.key").getPath()).toString(); private static final String CLIENT_KEY_EC_PATH = - Resources.getResource("clientauth-ec.key").getPath(); + new File(Resources.getResource("clientauth-ec.key").getPath()).toString(); public void testPKCS8KeyLoadDump() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException { - byte[] loaded = Files.readAllBytes(Paths.get(CLIENT_KEY_PATH)); + byte[] loaded = Files.readAllBytes(Paths.get(CLIENT_KEY_PATH.replace("C:/", ""))); PrivateKey privateKey = SSLUtils.loadKey(loaded); byte[] dumped = SSLUtils.dumpKey(privateKey); PrivateKey reloaded = SSLUtils.loadKey(dumped); diff --git a/util/src/test/java/io/kubernetes/client/util/YamlTest.java b/util/src/test/java/io/kubernetes/client/util/YamlTest.java index e62efa28ab..a27ccf2969 100644 --- a/util/src/test/java/io/kubernetes/client/util/YamlTest.java +++ b/util/src/test/java/io/kubernetes/client/util/YamlTest.java @@ -43,7 +43,7 @@ public class YamlTest { private static final URL TEST_YAML_FILE = Resources.getResource("test.yaml"); - private static final String TEST_YAML_FILE_PATH = TEST_YAML_FILE.getPath(); + private static final String TEST_YAML_FILE_PATH = new File(TEST_YAML_FILE.getPath()).toString(); private static final URL EXPECTED_YAML_FILE = Resources.getResource("expected.yaml"); @@ -160,7 +160,7 @@ public void testLoadAllFile() throws Exception { } } String result = Yaml.dumpAll(k8ObjectList.iterator()); - String expected = Resources.toString(EXPECTED_YAML_FILE, UTF_8); + String expected = Resources.toString(EXPECTED_YAML_FILE, UTF_8).replace("\r\n", "\n"); assertThat(result, equalTo(expected)); } @@ -287,7 +287,7 @@ public void testLoadAsYamlCantConstructObjects() { @Test public void testLoadDumpCRDWithIntOrStringExtension() { - String data = Resources.toString(CRD_INT_OR_STRING_FILE, UTF_8); + String data = Resources.toString(CRD_INT_OR_STRING_FILE, UTF_8).replace("\r\n", "\n"); V1CustomResourceDefinition crd = Yaml.loadAs(data, V1CustomResourceDefinition.class); assertNotNull(crd); assertTrue( diff --git a/util/src/test/java/io/kubernetes/client/util/credentials/ClientCertificateAuthenticationTest.java b/util/src/test/java/io/kubernetes/client/util/credentials/ClientCertificateAuthenticationTest.java index 78f5b6c0de..8f87a2490e 100644 --- a/util/src/test/java/io/kubernetes/client/util/credentials/ClientCertificateAuthenticationTest.java +++ b/util/src/test/java/io/kubernetes/client/util/credentials/ClientCertificateAuthenticationTest.java @@ -14,31 +14,34 @@ import io.kubernetes.client.Resources; import io.kubernetes.client.openapi.ApiClient; +import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; import org.junit.Test; public class ClientCertificateAuthenticationTest { - private static final String CLIENT_CERT_PATH = Resources.getResource("clientauth.cert").getPath(); + private static final String CLIENT_CERT_PATH = + new File(Resources.getResource("clientauth.cert").getPath()).toString(); private static final String CLIENT_EC_CERT_PATH = - Resources.getResource("clientauth-ec.cert").getPath(); + new File(Resources.getResource("clientauth-ec.cert").getPath()).toString(); // RSA key in PKCS8 format - private static final String CLIENT_KEY_PATH = Resources.getResource("clientauth.key").getPath(); + private static final String CLIENT_KEY_PATH = + new File(Resources.getResource("clientauth.key").getPath()).toString(); // EC key in PKCS8 format private static final String CLIENT_EC_KEY_PATH = - Resources.getResource("clientauth-ec-fixed.key").getPath(); + new File(Resources.getResource("clientauth-ec-fixed.key").getPath()).toString(); // RSA key in PKCS1 format private static final String CLIENT_KEY_OLD_PATH = - Resources.getResource("clientauth-rsa.key").getPath(); + new File(Resources.getResource("clientauth-rsa.key").getPath()).toString(); // EC key in PKCS7 format private static final String CLIENT_EC_KEY_OLD_PATH = - Resources.getResource("clientauth-ec.key").getPath(); + new File(Resources.getResource("clientauth-ec.key").getPath()).toString(); private static final String CLIENT_CERT_CHAIN_PATH = - Resources.getResource("clientauth-chain.cert").getPath(); + new File(Resources.getResource("clientauth-chain.cert").getPath()).toString(); private static final String CLIENT_CERT_CHAIN_KEY_PATH = - Resources.getResource("clientauth-chain.key").getPath(); + new File(Resources.getResource("clientauth-chain.key").getPath()).toString(); @Test public void testValidCertificates() throws Exception { diff --git a/util/src/test/java/io/kubernetes/client/util/credentials/TokenFileAuthenticationTest.java b/util/src/test/java/io/kubernetes/client/util/credentials/TokenFileAuthenticationTest.java index d920ecaf78..0ff3c7e05b 100644 --- a/util/src/test/java/io/kubernetes/client/util/credentials/TokenFileAuthenticationTest.java +++ b/util/src/test/java/io/kubernetes/client/util/credentials/TokenFileAuthenticationTest.java @@ -27,6 +27,7 @@ import io.kubernetes.client.openapi.ApiException; import io.kubernetes.client.openapi.Configuration; import io.kubernetes.client.openapi.apis.CoreV1Api; +import java.io.File; import java.io.IOException; import java.time.Instant; import org.junit.Before; @@ -35,9 +36,9 @@ public class TokenFileAuthenticationTest { private static final String SERVICEACCOUNT_TOKEN1_PATH = - Resources.getResource("token1").getPath(); + new File(Resources.getResource("token1").getPath()).toString(); private static final String SERVICEACCOUNT_TOKEN2_PATH = - Resources.getResource("token2").getPath(); + new File(Resources.getResource("token2").getPath()).toString(); private static final int PORT = 8089; private TokenFileAuthentication auth; diff --git a/util/src/test/java/io/kubernetes/client/util/generic/dynamic/DynamicsTest.java b/util/src/test/java/io/kubernetes/client/util/generic/dynamic/DynamicsTest.java index b98959eb40..c56d006e70 100644 --- a/util/src/test/java/io/kubernetes/client/util/generic/dynamic/DynamicsTest.java +++ b/util/src/test/java/io/kubernetes/client/util/generic/dynamic/DynamicsTest.java @@ -18,6 +18,7 @@ import io.kubernetes.client.Resources; import io.kubernetes.client.openapi.JSON; import io.kubernetes.client.util.Yaml; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -25,9 +26,11 @@ public class DynamicsTest { - private static final String TEST_POD_YAML_FILE = Resources.getResource("test-pod.yaml").getPath(); + private static final String TEST_POD_YAML_FILE = + new File(Resources.getResource("test-pod.yaml").getPath()).toString(); - private static final String TEST_POD_JSON_FILE = Resources.getResource("test-pod.json").getPath(); + private static final String TEST_POD_JSON_FILE = + new File(Resources.getResource("test-pod.json").getPath()).toString(); private JSON json = new JSON();