From 92ae83de6b4f5401a1007bbb26e2f01168e9d6cb Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 5 Oct 2015 07:57:12 -0400 Subject: Revert manual specification of ssh user auth factories --- .../com/gitblit/tests/JschConfigTestSessionFactory.java | 1 - .../com/gitblit/tests/SshKerberosAuthenticationTest.java | 13 ++++++++----- src/test/java/com/gitblit/tests/SshUnitTest.java | 8 -------- 3 files changed, 8 insertions(+), 14 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/com/gitblit/tests/JschConfigTestSessionFactory.java b/src/test/java/com/gitblit/tests/JschConfigTestSessionFactory.java index 421f3366..5d24b401 100644 --- a/src/test/java/com/gitblit/tests/JschConfigTestSessionFactory.java +++ b/src/test/java/com/gitblit/tests/JschConfigTestSessionFactory.java @@ -21,7 +21,6 @@ public class JschConfigTestSessionFactory extends JschConfigSessionFactory { @Override protected void configure(OpenSshConfig.Host host, Session session) { session.setConfig("StrictHostKeyChecking", "no"); - session.setConfig("PreferredAuthentications", "password"); } @Override diff --git a/src/test/java/com/gitblit/tests/SshKerberosAuthenticationTest.java b/src/test/java/com/gitblit/tests/SshKerberosAuthenticationTest.java index 1bebf61e..4ba16b67 100644 --- a/src/test/java/com/gitblit/tests/SshKerberosAuthenticationTest.java +++ b/src/test/java/com/gitblit/tests/SshKerberosAuthenticationTest.java @@ -27,6 +27,7 @@ import com.gitblit.manager.AuthenticationManager; import com.gitblit.manager.IRuntimeManager; import com.gitblit.manager.IUserManager; import com.gitblit.models.UserModel; +import com.gitblit.tests.mock.MemorySettings; import com.gitblit.transport.ssh.SshDaemonClient; import com.gitblit.transport.ssh.SshKrbAuthenticator; @@ -39,20 +40,21 @@ public class SshKerberosAuthenticationTest extends GitblitUnitTest { @Test public void testUserManager() { IRuntimeManager rm = Mockito.mock(IRuntimeManager.class); - + //Build an UserManager that can build a UserModel IUserManager im = Mockito.mock(IUserManager.class); Mockito.doAnswer(new Answer() { + @Override public Object answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); String user = (String) args[0]; return new UserModel(user); - } + } }).when(im).getUserModel(Mockito.anyString()); AuthenticationManager am = new AuthenticationManager(rm, im); - - GSSAuthenticator gssAuthenticator = new SshKrbAuthenticator(am); + + GSSAuthenticator gssAuthenticator = new SshKrbAuthenticator(new MemorySettings(), am); ServerSession session = Mockito.mock(ServerSession.class); @@ -61,12 +63,13 @@ public class SshKerberosAuthenticationTest extends GitblitUnitTest { SshDaemonClient client = Mockito.mock(SshDaemonClient.class); Mockito.when(client.getUser()).thenReturn(umw.um); Mockito.doAnswer(new Answer() { + @Override public Object answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); UserModel um = (UserModel) args[0]; umw.um = um; return null; - } + } }).when(client).setUser(Mockito.any(UserModel.class)); Mockito.when(session.getAttribute(SshDaemonClient.KEY)).thenReturn(client); diff --git a/src/test/java/com/gitblit/tests/SshUnitTest.java b/src/test/java/com/gitblit/tests/SshUnitTest.java index 453f3043..27b4ec73 100644 --- a/src/test/java/com/gitblit/tests/SshUnitTest.java +++ b/src/test/java/com/gitblit/tests/SshUnitTest.java @@ -24,17 +24,12 @@ import java.net.SocketAddress; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.PublicKey; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.sshd.client.ServerKeyVerifier; import org.apache.sshd.client.SshClient; -import org.apache.sshd.client.auth.UserAuth; -import org.apache.sshd.client.auth.UserAuthPublicKeyFactory; import org.apache.sshd.client.channel.ClientChannel; import org.apache.sshd.client.session.ClientSession; -import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.util.SecurityUtils; import org.junit.After; import org.junit.AfterClass; @@ -107,9 +102,6 @@ public abstract class SshUnitTest extends GitblitUnitTest { return true; } }); - List> userAuthFactories = new ArrayList<>(); - userAuthFactories.add(new UserAuthPublicKeyFactory()); - client.setUserAuthFactories(userAuthFactories); client.start(); return client; } -- cgit v1.2.3