Add (ignored) authorized keys test for specific files
package org.apache.sshd.common.config.keys;
+import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.security.PublicKey;
import java.util.Collection;
@@ -98,14 +100,20 @@ public class AuthorizedKeyEntryTest extends AuthorizedKeysTestSupport {
}
}
- private void runAuthorizedKeysTests(Collection<AuthorizedKeyEntry> entries) throws Exception {
+ @Test
+ @Ignore("Used to test specific files")
+ public void testSpecificFile() throws Exception {
+ Path path = Paths.get("C:" + File.separator + "Temp", "id_ed25519.pub");
+ testReadAuthorizedKeys(AuthorizedKeyEntry.readAuthorizedKeys(path));
+ }
+
+ private <C extends Collection<AuthorizedKeyEntry>> C runAuthorizedKeysTests(C entries) throws Exception {
testReadAuthorizedKeys(entries);
testAuthorizedKeysAuth(entries);
+ return entries;
}
- private static Collection<AuthorizedKeyEntry> testReadAuthorizedKeys(
- Collection<AuthorizedKeyEntry> entries)
- throws Exception {
+ private static <C extends Collection<AuthorizedKeyEntry>> C testReadAuthorizedKeys(C entries) throws Exception {
assertFalse("No entries read", GenericUtils.isEmpty(entries));
Exception err = null;
@@ -138,7 +146,8 @@ public class AuthorizedKeyEntryTest extends AuthorizedKeysTestSupport {
PublickeyAuthenticator.fromAuthorizedEntries(
getCurrentTestName(), null, entries, PublicKeyEntryResolver.FAILING);
for (PublicKey key : keySet) {
- assertTrue("Failed to authenticate with key=" + key.getAlgorithm(), auth.authenticate(getCurrentTestName(), key, null));
+ assertTrue("Failed to authenticate with key=" + key.getAlgorithm(),
+ auth.authenticate(getCurrentTestName(), key, null));
}
return auth;
