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 17, 2025
1 parent ed6a076 commit 3e35223
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 @@ -49,9 +48,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 @@ -76,9 +72,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 @@ -107,9 +100,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 @@ -133,9 +123,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"
+ " ecdsa-sha2-nistp256"
+ " AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=";
Expand Down Expand Up @@ -190,9 +177,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="
+ " ssh-rsa"
+ " AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==";
Expand Down Expand Up @@ -222,9 +206,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=" // github.com:59666
+ " ssh-ed25519"
+ " AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,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 @@ -88,9 +85,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 3e35223

Please sign in to comment.