Skip to content

Commit dc6719e

Browse files
committed
Remove test calls to isKubernetesCI()
No benefit to calling a method that always returns false. The tests now require a docker environment, so they cannot be run on a Kubernetes agent. (cherry picked from commit 2ac8d07)
1 parent d24fabf commit dc6719e

File tree

4 files changed

+0
-36
lines changed

4 files changed

+0
-36
lines changed

src/test/java/org/jenkinsci/plugins/gitclient/verifier/AcceptFirstConnectionVerifierTest.java

-19
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import static org.hamcrest.Matchers.hasItem;
66
import static org.hamcrest.Matchers.is;
77
import static org.hamcrest.io.FileMatchers.anExistingFile;
8-
import static org.jenkinsci.plugins.gitclient.verifier.KnownHostsTestUtil.isKubernetesCI;
98
import static org.mockito.Mockito.spy;
109
import static org.mockito.Mockito.when;
1110

@@ -54,9 +53,6 @@ public void testVerifyHostKeyOption() throws IOException {
5453

5554
@Test
5655
public void testVerifyServerHostKeyWhenFirstConnection() throws Exception {
57-
if (isKubernetesCI()) {
58-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
59-
}
6056
File file = new File(testFolder.getRoot() + "path/to/file");
6157
AcceptFirstConnectionVerifier acceptFirstConnectionVerifier = spy(new AcceptFirstConnectionVerifier());
6258
when(acceptFirstConnectionVerifier.getKnownHostsFile()).thenReturn(file);
@@ -81,9 +77,6 @@ public void testVerifyServerHostKeyWhenFirstConnection() throws Exception {
8177

8278
@Test
8379
public void testVerifyServerHostKeyWhenSecondConnectionWithEqualKeys() throws Exception {
84-
if (isKubernetesCI()) {
85-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
86-
}
8780
String hostKeyEntry =
8881
"|1|FJGXVAi7jMQIsl1J6uE6KnCiteM=|xlH92KQ91GuBgRxvRbU/sBo60Bo= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=";
8982

@@ -112,9 +105,6 @@ public void testVerifyServerHostKeyWhenSecondConnectionWithEqualKeys() throws Ex
112105

113106
@Test
114107
public void testVerifyServerHostKeyWhenHostnameWithoutPort() throws Exception {
115-
if (isKubernetesCI()) {
116-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
117-
}
118108
String hostKeyEntry =
119109
"github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=";
120110
File mockedKnownHosts = knownHostsTestUtil.createFakeKnownHosts(hostKeyEntry);
@@ -138,9 +128,6 @@ public void testVerifyServerHostKeyWhenHostnameWithoutPort() throws Exception {
138128

139129
@Test
140130
public void testVerifyServerHostKeyWhenSecondConnectionWhenNotDefaultAlgorithm() throws Exception {
141-
if (isKubernetesCI()) {
142-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
143-
}
144131
String fileContent =
145132
"""
146133
github.com,140.82.121.4\
@@ -201,9 +188,6 @@ public void testVerifyServerHostKeyWhenSecondConnectionWithNonEqualKeys() throws
201188

202189
@Test
203190
public void testVerifyServerHostKeyWhenConnectionWithAnotherHost() throws Exception {
204-
if (isKubernetesCI()) {
205-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
206-
}
207191
String bitbucketFileContent =
208192
"""
209193
|1|HnmPCP38pBhCY0NUtBXSraOg9pM=|L6YZ9asEeb2xplTDEThGOxRq7ZY=\
@@ -236,9 +220,6 @@ public void testVerifyServerHostKeyWhenConnectionWithAnotherHost() throws Except
236220

237221
@Test
238222
public void testVerifyServerHostKeyWhenHostnamePortProvided() throws Exception {
239-
if (isKubernetesCI()) {
240-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
241-
}
242223
String fileContent =
243224
"""
244225
|1|6uMj3M7sLgZpn54vQbGqgPNTCVM=|OkV9Lu9REJZR5QCVrITAIY34I1M=\

src/test/java/org/jenkinsci/plugins/gitclient/verifier/KnownHostsFileVerifierTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ public void connectWhenHostKeyNotInKnownHostsFileForOtherHostNameThenShouldFail(
6868

6969
@Test
7070
public void connectWhenHostKeyProvidedThenShouldNotFail() throws IOException {
71-
if (isKubernetesCI()) {
72-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
73-
}
7471
KnownHostsFileVerifier knownHostsFileVerifier = spy(new KnownHostsFileVerifier());
7572
when(knownHostsFileVerifier.getKnownHostsFile()).thenReturn(fakeKnownHosts);
7673

@@ -91,9 +88,6 @@ public void connectWhenHostKeyProvidedThenShouldNotFail() throws IOException {
9188

9289
@Test
9390
public void connectWhenHostKeyInKnownHostsFileWithNotDefaultAlgorithmThenShouldNotFail() throws IOException {
94-
if (isKubernetesCI()) {
95-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
96-
}
9791
fakeKnownHosts = knownHostsTestUtil.createFakeKnownHosts(
9892
"fake2.ssh",
9993
"known_hosts_fake2",

src/test/java/org/jenkinsci/plugins/gitclient/verifier/ManuallyProvidedKeyVerifierTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ public void connectWhenHostKeyProvidedForOtherHostNameThenShouldFail() throws Ex
6060

6161
@Test
6262
public void connectWhenHostKeyProvidedThenShouldNotFail() throws Exception {
63-
if (isKubernetesCI()) {
64-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
65-
}
6663
ManuallyProvidedKeyVerifier verifier = new ManuallyProvidedKeyVerifier(hostKey);
6764
ManuallyProvidedKeyVerifier.ManuallyProvidedKeyJGitHostKeyVerifier jGitHostKeyVerifier =
6865
(ManuallyProvidedKeyVerifier.ManuallyProvidedKeyJGitHostKeyVerifier)
@@ -100,9 +97,6 @@ public void connectWhenWrongHostKeyProvidedThenShouldFail() throws Exception {
10097

10198
@Test
10299
public void connectWhenHostKeyProvidedWithPortThenShouldNotFail() throws Exception {
103-
if (isKubernetesCI()) {
104-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
105-
}
106100
String key =
107101
"github.com:22 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=";
108102
HostKeyVerifierFactory verifier = new ManuallyProvidedKeyVerifier(key);

src/test/java/org/jenkinsci/plugins/gitclient/verifier/NoHostKeyVerifierTest.java

-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static org.hamcrest.MatcherAssert.assertThat;
44
import static org.hamcrest.Matchers.is;
5-
import static org.jenkinsci.plugins.gitclient.verifier.KnownHostsTestUtil.isKubernetesCI;
65

76
import hudson.model.StreamBuildListener;
87
import hudson.model.TaskListener;
@@ -24,10 +23,6 @@ public void assignVerifier() {
2423

2524
@Test
2625
public void verifyServerHostKey() throws IOException {
27-
if (isKubernetesCI()) {
28-
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
29-
}
30-
3126
NoHostKeyVerifier acceptFirstConnectionVerifier = new NoHostKeyVerifier();
3227

3328
KnownHostsTestUtil.connectToHost(

0 commit comments

Comments
 (0)