This is an automated email from the ASF dual-hosted git repository.
twolf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
The following commit(s) were added to refs/heads/master by this push:
new 5c80258b5 Add a test for GH-351
5c80258b5 is described below
commit 5c80258b55581a76aa6b5b6acdc7cd81da4d2f41
Author: Thomas Wolf <[email protected]>
AuthorDate: Sun Apr 9 18:41:27 2023 +0200
Add a test for GH-351
Just a somewhat redundant regression test to make sure GH-351 is fixed
by commit c11bfcca for GH-281.
Bug: https://github.com/apache/mina-sshd/issues/351
---
.../client/config/hosts/HostConfigEntryTest.java | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git
a/sshd-common/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java
b/sshd-common/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java
index 1769a2ac4..4ee7e2c47 100644
---
a/sshd-common/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java
+++
b/sshd-common/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java
@@ -20,6 +20,7 @@
package org.apache.sshd.client.config.hosts;
import java.io.IOException;
+import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@@ -165,6 +166,37 @@ public class HostConfigEntryTest extends JUnitTestSupport {
assertEquals("xFile,dFile",
resolved.getProperty(HostConfigEntry.IDENTITY_FILE_CONFIG_PROP));
}
+ @Test // See GH-351
+ public void testProxyJump() throws Exception {
+ HostConfigEntry bastion = new HostConfigEntry();
+ bastion.setHost("bastion");
+ bastion.setHostName("1.2.3.4");
+ bastion.setUsername("username");
+ bastion.setIdentities(Collections.singleton("yFile"));
+ HostConfigEntry server = new HostConfigEntry();
+ server.setHost("server*");
+ server.setProxyJump("bastion");
+ HostConfigEntryResolver resolver =
HostConfigEntry.toHostConfigEntryResolver(GenericUtils.asList(bastion, server));
+ HostConfigEntry resolved = resolver.resolveEffectiveHost("server1", 0,
null, "someone", null, null);
+ expect("server1", 22, "someone", resolved);
+ Collection<String> identities = resolved.getIdentities();
+ assertTrue("Unexpected configured identities " + identities,
identities == null || identities.isEmpty());
+ String identityProp =
resolved.getProperty(HostConfigEntry.IDENTITY_FILE_CONFIG_PROP);
+ assertNull("Unexpected IdentityFile property", identityProp);
+ // Same handling as in SshClient.parseProxyJumps()
+ String proxy =
resolved.getProperty(HostConfigEntry.PROXY_JUMP_CONFIG_PROP);
+ assertEquals("bastion", proxy);
+ URI uri = URI.create("ssh://" + proxy);
+ resolved = resolver.resolveEffectiveHost(uri.getHost(), uri.getPort(),
null, uri.getUserInfo(), null, null);
+ expect("1.2.3.4", 22, "username", resolved);
+ identities = resolved.getIdentities();
+ assertNotNull("Should have identities", identities);
+ assertEquals("[yFile]", identities.toString());
+ identityProp =
resolved.getProperty(HostConfigEntry.IDENTITY_FILE_CONFIG_PROP);
+ assertNotNull("Should have IdentityFile property", identityProp);
+ assertEquals("yFile", identityProp);
+ }
+
@Test
public void testNegatingPatternOverridesAll() {
String testHost = "37.77.34.7";