GitSSHService { public void setup(final File certDir, final InetSocketAddress inetSocketAddress, final String sshIdleTimeout, final String algorithm, final ReceivePackFactory receivePackFactory, final UploadPackFactory uploadPackFactory, final JGitFileSystemProvider.RepositoryResolverImpl<BaseGitCommand> repositoryResolver, final ExecutorService executorService) { setup(certDir, inetSocketAddress, sshIdleTimeout, algorithm, receivePackFactory, uploadPackFactory, repositoryResolver, executorService, null, null); }  void setup(final File certDir,
                      final InetSocketAddress inetSocketAddress,
                      final String sshIdleTimeout,
                      final String algorithm,
                      final ReceivePackFactory receivePackFactory,
                      final UploadPackFactory uploadPackFactory,
                      final JGitFileSystemProvider.RepositoryResolverImpl<BaseGitCommand> repositoryResolver,
                      final ExecutorService executorService); void setup(final File certDir,
                      final InetSocketAddress inetSocketAddress,
                      final String sshIdleTimeout,
                      final String algorithm,
                      final ReceivePackFactory receivePackFactory,
                      final UploadPackFactory uploadPackFactory,
                      final JGitFileSystemProvider.RepositoryResolverImpl<BaseGitCommand> repositoryResolver,
                      final ExecutorService executorService,
                      final String gitSshCiphers,
                      final String gitSshMacs); void stop(); void start(); boolean isRunning(); Map<String, Object> getProperties(); AuthenticationService getUserPassAuthenticator(); void setUserPassAuthenticator(AuthenticationService authenticationService); SSHAuthenticator getSshAuthenticator(); void setSshAuthenticator(SSHAuthenticator sshAuthenticator); List<BuiltinCiphers> getManagedCiphers(); List<BuiltinMacs> getManagedMACs();  }
@Test public void testCheckAlgo() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); try { sshService.setup(certDir, null, "10000", "xxxx", mock(ReceivePackFactory.class), mock(UploadPackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); fail("has to fail"); } catch (final Exception ex) { assertThat(ex.getMessage()).contains("'xxxx'"); } }
@Test public void testCheckSetupParameters() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); try { sshService.setup(null, null, "10000", "RSA", mock(ReceivePackFactory.class), mock(UploadPackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); fail("has to fail"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("'certDir'"); } try { sshService.setup(certDir, null, null, "RSA", mock(ReceivePackFactory.class), mock(UploadPackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); fail("has to fail"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("'sshIdleTimeout'"); } try { sshService.setup(certDir, null, "", "RSA", mock(ReceivePackFactory.class), mock(UploadPackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); fail("has to fail"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("'sshIdleTimeout'"); } try { sshService.setup(certDir, null, "1000", null, mock(ReceivePackFactory.class), mock(UploadPackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); fail("has to fail"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("'algorithm'"); } try { sshService.setup(certDir, null, "1000", "", mock(ReceivePackFactory.class), mock(UploadPackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); fail("has to fail"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("'algorithm'"); } try { sshService.setup(certDir, null, "100", "RSA", null, null, mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); fail("has to fail"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("'receivePackFactory'"); } try { sshService.setup(certDir, null, "100", "RSA", mock(ReceivePackFactory.class), mock(UploadPackFactory.class), null, executorService); fail("has to fail"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("'repositoryResolver'"); } try { sshService.setup(certDir, null, "10000", "RSA", mock(ReceivePackFactory.class), mock(UploadPackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); } catch (IllegalArgumentException ex) { fail("should not fail"); } }