Skip to content

Commit

Permalink
Remove test calls to isKubernetesCI()
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
MarkEWaite committed Jan 15, 2025
1 parent d24fabf commit dc6719e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.io.FileMatchers.anExistingFile;
import static org.jenkinsci.plugins.gitclient.verifier.KnownHostsTestUtil.isKubernetesCI;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

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

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

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

Expand Down Expand Up @@ -112,9 +105,6 @@ public void testVerifyServerHostKeyWhenSecondConnectionWithEqualKeys() throws Ex

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

@Test
public void testVerifyServerHostKeyWhenSecondConnectionWhenNotDefaultAlgorithm() throws Exception {
if (isKubernetesCI()) {
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
}
String fileContent =
"""
github.com,140.82.121.4\
Expand Down Expand Up @@ -201,9 +188,6 @@ public void testVerifyServerHostKeyWhenSecondConnectionWithNonEqualKeys() throws

@Test
public void testVerifyServerHostKeyWhenConnectionWithAnotherHost() throws Exception {
if (isKubernetesCI()) {
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
}
String bitbucketFileContent =
"""
|1|HnmPCP38pBhCY0NUtBXSraOg9pM=|L6YZ9asEeb2xplTDEThGOxRq7ZY=\
Expand Down Expand Up @@ -236,9 +220,6 @@ public void testVerifyServerHostKeyWhenConnectionWithAnotherHost() throws Except

@Test
public void testVerifyServerHostKeyWhenHostnamePortProvided() throws Exception {
if (isKubernetesCI()) {
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
}
String fileContent =
"""
|1|6uMj3M7sLgZpn54vQbGqgPNTCVM=|OkV9Lu9REJZR5QCVrITAIY34I1M=\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ public void connectWhenHostKeyNotInKnownHostsFileForOtherHostNameThenShouldFail(

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

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

@Test
public void connectWhenHostKeyInKnownHostsFileWithNotDefaultAlgorithmThenShouldNotFail() throws IOException {
if (isKubernetesCI()) {
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
}
fakeKnownHosts = knownHostsTestUtil.createFakeKnownHosts(
"fake2.ssh",
"known_hosts_fake2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public void connectWhenHostKeyProvidedForOtherHostNameThenShouldFail() throws Ex

@Test
public void connectWhenHostKeyProvidedThenShouldNotFail() throws Exception {
if (isKubernetesCI()) {
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
}
ManuallyProvidedKeyVerifier verifier = new ManuallyProvidedKeyVerifier(hostKey);
ManuallyProvidedKeyVerifier.ManuallyProvidedKeyJGitHostKeyVerifier jGitHostKeyVerifier =
(ManuallyProvidedKeyVerifier.ManuallyProvidedKeyJGitHostKeyVerifier)
Expand Down Expand Up @@ -100,9 +97,6 @@ public void connectWhenWrongHostKeyProvidedThenShouldFail() throws Exception {

@Test
public void connectWhenHostKeyProvidedWithPortThenShouldNotFail() throws Exception {
if (isKubernetesCI()) {
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
}
String key =
"github.com:22 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=";
HostKeyVerifierFactory verifier = new ManuallyProvidedKeyVerifier(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.jenkinsci.plugins.gitclient.verifier.KnownHostsTestUtil.isKubernetesCI;

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

@Test
public void verifyServerHostKey() throws IOException {
if (isKubernetesCI()) {
return; // Test fails with connection timeout on ci.jenkins.io kubernetes agents
}

NoHostKeyVerifier acceptFirstConnectionVerifier = new NoHostKeyVerifier();

KnownHostsTestUtil.connectToHost(
Expand Down

0 comments on commit dc6719e

Please sign in to comment.