@@ -151,6 +151,36 @@ public void autoConfigWithMasterUrl() throws Exception {
151151 assertEquals ("http://example.com/" , client .getConfiguration ().getMasterUrl ());
152152 }
153153
154+ @ Test
155+ public void autoConfigWithMasterUrlWithoutAuth () throws Exception {
156+ System .setProperty (KUBERNETES_NAMESPACE_FILE , "src/test/resources/kubenamespace" );
157+ KubernetesFactoryAdapter factory = new KubernetesFactoryAdapter ("http://example.com" , null , null , false );
158+ KubernetesClient client = factory .createClient ();
159+ assertEquals ("test-namespace" , client .getNamespace ());
160+ assertEquals (HTTP_PROXY , client .getConfiguration ().getHttpProxy ());
161+ assertEquals (HTTPS_PROXY , client .getConfiguration ().getHttpsProxy ());
162+ assertArrayEquals (new String [] {NO_PROXY }, client .getConfiguration ().getNoProxy ());
163+ assertEquals (PROXY_USERNAME , client .getConfiguration ().getProxyUsername ());
164+ assertEquals (PROXY_PASSWORD , client .getConfiguration ().getProxyPassword ());
165+ assertTrue (client .getConfiguration ().getAutoConfigure ());
166+ assertEquals ("http://example.com/" , client .getConfiguration ().getMasterUrl ());
167+ }
168+
169+ @ Test
170+ public void autoConfigWithKubeconfig () throws Exception {
171+ System .setProperty (KUBERNETES_KUBECONFIG_FILE , "src/test/resources/kubeconfig" );
172+ KubernetesFactoryAdapter factory = new KubernetesFactoryAdapter ("http://example.com" , null , null , false );
173+ KubernetesClient client = factory .createClient ();
174+ assertEquals ("test-namespace" , client .getNamespace ());
175+ assertEquals (HTTP_PROXY , client .getConfiguration ().getHttpProxy ());
176+ assertEquals (HTTPS_PROXY , client .getConfiguration ().getHttpsProxy ());
177+ assertArrayEquals (new String [] {NO_PROXY }, client .getConfiguration ().getNoProxy ());
178+ assertEquals (PROXY_USERNAME , client .getConfiguration ().getProxyUsername ());
179+ assertEquals (PROXY_PASSWORD , client .getConfiguration ().getProxyPassword ());
180+ assertTrue (client .getConfiguration ().getAutoConfigure ());
181+ assertEquals ("http://example.com/" , client .getConfiguration ().getMasterUrl ());
182+ }
183+
154184 @ Test
155185 @ Issue ("JENKINS-70416" )
156186 public void autoConfigWithAuth () throws Exception {
0 commit comments