Added unit tests to ensure that specified default SshConfigFileReader configurations are also known to the code
@@ -91,6 +91,12 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories());
}
+ @Test
+ public void testKnownDefaultCipherFactoriesList() {
+ testKnownDefaultFactoriesList(SshConfigFileReader.DEFAULT_CIPHERS, BuiltinCiphers::fromFactoryName,
+ GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER, "cast128-cbc", "arcfour"));
+ }
+
@Test
public void testParseMacsList() {
List<? extends NamedResource> expected = BaseBuilder.DEFAULT_MAC_PREFERENCE;
@@ -99,6 +105,12 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories());
}
+ @Test
+ public void testKnownDefaultMacFactoriesList() {
+ testKnownDefaultFactoriesList(SshConfigFileReader.DEFAULT_MACS, BuiltinMacs::fromFactoryName,
+ GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER, "umac-64@openssh.com", "hmac-ripemd160", "hmac-sha2-256-96", "hmac-sha2-512-96"));
+ }
+
@Test
public void testParseSignaturesList() {
List<? extends NamedResource> expected = BaseBuilder.DEFAULT_SIGNATURE_PREFERENCE;
@@ -107,6 +119,11 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories());
}
+ @Test
+ public void testKnownDefaultSignatureFactoriesList() {
+ testKnownDefaultFactoriesList(SshConfigFileReader.DEFAULT_HOST_KEY_ALGORITHMS, BuiltinSignatures::fromFactoryName);
+ }
+
@Test
public void testParseKexFactoriesList() {
List<? extends NamedResource> expected = BaseBuilder.DEFAULT_KEX_PREFERENCE;
@@ -115,6 +132,29 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories());
}
+ @Test
+ public void testKnownDefaultKexFactoriesList() {
+ testKnownDefaultFactoriesList(SshConfigFileReader.DEFAULT_KEX_ALGORITHMS, BuiltinDHFactories::fromFactoryName);
+ }
+
+ private void testKnownDefaultFactoriesList(String factories, Function<? super String, ? extends NamedResource> resolver) {
+ testKnownDefaultFactoriesList(factories, resolver, Collections.emptySet());
+ }
+
+ private void testKnownDefaultFactoriesList(
+ String factories, Function<? super String, ? extends NamedResource> resolver, Collection<String> excludedNames) {
+ String[] names = GenericUtils.split(factories, ',');
+ assertTrue("No default names", GenericUtils.length(names) > 0);
+ for (String n : names) {
+ NamedResource facInstance = resolver.apply(n);
+ if (excludedNames.contains(n)) {
+ assertNull("Unexpected excluded factory instance: " + n, facInstance);
+ } else {
+ assertNotNull("Unknown factory: " + n, facInstance);
+ }
+ }
+ }
+
@Test
public void testGetCompression() {
Properties props = new Properties();
