LinuxVMConnectionFactory.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. namespace Renci.SshNet.IntegrationTests
  2. {
  3. public class LinuxVMConnectionFactory : IConnectionInfoFactory
  4. {
  5. private const string ProxyHost = "127.0.0.1";
  6. private const int ProxyPort = 1234;
  7. private const string ProxyUserName = "test";
  8. private const string ProxyPassword = "123";
  9. private readonly string _host;
  10. private readonly int _port;
  11. private readonly AuthenticationMethodFactory _authenticationMethodFactory;
  12. public LinuxVMConnectionFactory(string sshServerHostName, ushort sshServerPort)
  13. {
  14. _host = sshServerHostName;
  15. _port = sshServerPort;
  16. _authenticationMethodFactory = new AuthenticationMethodFactory();
  17. }
  18. public LinuxVMConnectionFactory(string sshServerHostName, ushort sshServerPort, AuthenticationMethodFactory authenticationMethodFactory)
  19. {
  20. _host = sshServerHostName;
  21. _port = sshServerPort;
  22. _authenticationMethodFactory = authenticationMethodFactory;
  23. }
  24. public ConnectionInfo Create()
  25. {
  26. return Create(_authenticationMethodFactory.CreateRegularUserPrivateKeyAuthenticationMethod());
  27. }
  28. public ConnectionInfo Create(params AuthenticationMethod[] authenticationMethods)
  29. {
  30. return new ConnectionInfo(_host, _port, Users.Regular.UserName, authenticationMethods);
  31. }
  32. public ConnectionInfo CreateWithProxy()
  33. {
  34. return CreateWithProxy(_authenticationMethodFactory.CreateRegularUserPrivateKeyAuthenticationMethod());
  35. }
  36. public ConnectionInfo CreateWithProxy(params AuthenticationMethod[] authenticationMethods)
  37. {
  38. return new ConnectionInfo(
  39. _host,
  40. _port,
  41. Users.Regular.UserName,
  42. ProxyTypes.Socks4,
  43. ProxyHost,
  44. ProxyPort,
  45. ProxyUserName,
  46. ProxyPassword,
  47. authenticationMethods);
  48. }
  49. }
  50. }