Skip to content

Commit e32a502

Browse files
committed
Use hashed host for known_hosts tests
The `192.168.1.61` is Private Use IP. It is an intranet IP address, which is usually allocated to mobile phones, desktops, laptops, TVs, smart speakers and other devices. The logic is taken from a similar test class in the Apache MINA project
1 parent 4aa2f91 commit e32a502

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/ResourceKnownHostsServerKeyVerifierTests.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.apache.sshd.common.util.net.SshdSocketAddress;
4040
import org.junit.jupiter.api.BeforeAll;
4141
import org.junit.jupiter.api.Test;
42+
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
4243
import org.junit.jupiter.api.condition.EnabledIf;
4344
import org.mockito.Mockito;
4445

@@ -53,6 +54,8 @@
5354
@EnabledIf("isDefaultKnownHostsFilePresent")
5455
public class ResourceKnownHostsServerKeyVerifierTests {
5556

57+
private static final String HASHED_HOST = "192.168.1.61";
58+
5659
private static final Map<SshdSocketAddress, PublicKey> HOST_KEYS = new TreeMap<>(SshdSocketAddress.BY_HOST_AND_PORT);
5760

5861
@BeforeAll
@@ -99,7 +102,7 @@ private static Map<SshdSocketAddress, KnownHostEntry> loadEntries(Path file) thr
99102
int pos = line.indexOf(' ');
100103
String patterns = line.substring(0, pos);
101104
if (entry.getHashedEntry() != null) {
102-
hostsMap.put(new SshdSocketAddress("localhost", 0), entry);
105+
hostsMap.put(new SshdSocketAddress(HASHED_HOST, 0), entry);
103106
}
104107
else {
105108
String[] addrs = GenericUtils.split(patterns, ',');

0 commit comments

Comments
 (0)