You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ApacheSshProtocol2Test.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2020 Thomas Wolf <thomas.wolf@paranor.ch> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.transport.sshd;
  11. import java.io.File;
  12. import java.io.IOException;
  13. import java.io.UncheckedIOException;
  14. import java.nio.file.Files;
  15. import java.util.Arrays;
  16. import org.eclipse.jgit.junit.ssh.SshBasicTestBase;
  17. import org.eclipse.jgit.lib.Constants;
  18. import org.eclipse.jgit.lib.Repository;
  19. import org.eclipse.jgit.lib.StoredConfig;
  20. import org.eclipse.jgit.transport.SshSessionFactory;
  21. import org.eclipse.jgit.util.FS;
  22. public class ApacheSshProtocol2Test extends SshBasicTestBase {
  23. @Override
  24. protected SshSessionFactory createSessionFactory() {
  25. SshdSessionFactory result = new SshdSessionFactory(new JGitKeyCache(),
  26. null);
  27. // The home directory is mocked at this point!
  28. result.setHomeDirectory(FS.DETECTED.userHome());
  29. result.setSshDirectory(sshDir);
  30. return result;
  31. }
  32. @Override
  33. protected void installConfig(String... config) {
  34. File configFile = new File(sshDir, Constants.CONFIG);
  35. if (config != null) {
  36. try {
  37. Files.write(configFile.toPath(), Arrays.asList(config));
  38. } catch (IOException e) {
  39. throw new UncheckedIOException(e);
  40. }
  41. }
  42. }
  43. @Override
  44. public void setUp() throws Exception {
  45. super.setUp();
  46. StoredConfig config = ((Repository) db).getConfig();
  47. config.setInt("protocol", null, "version", 2);
  48. config.save();
  49. }
  50. }