You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2018/03/18 13:57:12 UTC

[3/3] mina-sshd git commit: [SSHD-805] Added unit tests to ensure that specified default SshConfigFileReader configurations are also known to the code

[SSHD-805] Added unit tests to ensure that specified default SshConfigFileReader configurations are also known to the code


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/9ea83de5
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/9ea83de5
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/9ea83de5

Branch: refs/heads/master
Commit: 9ea83de5eedcdd48df88c9e4112a631a40ead0b1
Parents: 404b9b0
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Sun Mar 18 15:34:17 2018 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Sun Mar 18 15:34:17 2018 +0200

----------------------------------------------------------------------
 .../common/config/SshConfigFileReaderTest.java  | 40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9ea83de5/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
index b57991b..6f39ad7 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
@@ -92,6 +92,12 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
     }
 
     @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;
         Properties props = initNamedResourceProperties(SshConfigFileReader.MACS_CONFIG_PROP, expected);
@@ -100,6 +106,12 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
     }
 
     @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;
         Properties props = initNamedResourceProperties(SshConfigFileReader.HOST_KEY_ALGORITHMS_CONFIG_PROP, expected);
@@ -108,6 +120,11 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
     }
 
     @Test
+    public void testKnownDefaultSignatureFactoriesList() {
+        testKnownDefaultFactoriesList(SshConfigFileReader.DEFAULT_HOST_KEY_ALGORITHMS, BuiltinSignatures::fromFactoryName);
+    }
+
+    @Test
     public void testParseKexFactoriesList() {
         List<? extends NamedResource> expected = BaseBuilder.DEFAULT_KEX_PREFERENCE;
         Properties props = initNamedResourceProperties(SshConfigFileReader.KEX_ALGORITHMS_CONFIG_PROP, expected);
@@ -116,6 +133,29 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
     }
 
     @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();
         for (CompressionConfigValue expected : CompressionConfigValue.VALUES) {