From 8ec06317276abd624630c37675d8d563a1fcb754 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 10 Apr 2014 19:00:52 -0400 Subject: [PATCH] Documentation --- src/test/java/com/gitblit/tests/SshDaemonTest.java | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/src/test/java/com/gitblit/tests/SshDaemonTest.java b/src/test/java/com/gitblit/tests/SshDaemonTest.java index 5294f69..dbd1d86 100644 --- a/src/test/java/com/gitblit/tests/SshDaemonTest.java +++ b/src/test/java/com/gitblit/tests/SshDaemonTest.java @@ -26,11 +26,16 @@ import org.apache.sshd.ClientSession; import org.apache.sshd.SshClient; import org.apache.sshd.common.KeyPairProvider; +import org.junit.After; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.gitblit.Constants; +import com.gitblit.transport.ssh.IPublicKeyManager; +import com.gitblit.transport.ssh.MemoryKeyManager; +import com.gitblit.transport.ssh.SshKey; public class SshDaemonTest extends GitblitUnitTest { @@ -50,6 +55,27 @@ } } + protected MemoryKeyManager getKeyManager() { + IPublicKeyManager mgr = gitblit().getPublicKeyManager(); + if (mgr instanceof MemoryKeyManager) { + return (MemoryKeyManager) gitblit().getPublicKeyManager(); + } else { + throw new RuntimeException("unexpected key manager type " + mgr.getClass().getName()); + } + } + + @Before + public void prepare() { + MemoryKeyManager keyMgr = getKeyManager(); + keyMgr.addKey("admin", new SshKey(pair.getPublic())); + } + + @After + public void tearDown() { + MemoryKeyManager keyMgr = getKeyManager(); + keyMgr.removeAllKeys("admin"); + } + @Test public void testPublicKeyAuthentication() throws Exception { SshClient client = SshClient.setUpDefaultClient(); -- Gitblit v1.9.1