PrivateKeyConnectionInfoTest.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Tests.Common;
  3. using Renci.SshNet.Tests.Properties;
  4. using System.IO;
  5. using System.Text;
  6. namespace Renci.SshNet.Tests.Classes
  7. {
  8. /// <summary>
  9. /// Provides connection information when private key authentication method is used
  10. /// </summary>
  11. [TestClass]
  12. public class PrivateKeyConnectionInfoTest : TestBase
  13. {
  14. [TestMethod]
  15. [TestCategory("PrivateKeyConnectionInfo")]
  16. public void Test_PrivateKeyConnectionInfo()
  17. {
  18. var host = Resources.HOST;
  19. var username = Resources.USERNAME;
  20. MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
  21. #region Example PrivateKeyConnectionInfo PrivateKeyFile
  22. var connectionInfo = new PrivateKeyConnectionInfo(host, username, new PrivateKeyFile(keyFileStream));
  23. using (var client = new SshClient(connectionInfo))
  24. {
  25. client.Connect();
  26. client.Disconnect();
  27. }
  28. #endregion
  29. Assert.AreEqual(connectionInfo.Host, Resources.HOST);
  30. Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
  31. }
  32. [TestMethod]
  33. [TestCategory("PrivateKeyConnectionInfo")]
  34. public void Test_PrivateKeyConnectionInfo_MultiplePrivateKey()
  35. {
  36. var host = Resources.HOST;
  37. var username = Resources.USERNAME;
  38. MemoryStream keyFileStream1 = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
  39. MemoryStream keyFileStream2 = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
  40. #region Example PrivateKeyConnectionInfo PrivateKeyFile Multiple
  41. var connectionInfo = new PrivateKeyConnectionInfo(host, username,
  42. new PrivateKeyFile(keyFileStream1),
  43. new PrivateKeyFile(keyFileStream2));
  44. using (var client = new SshClient(connectionInfo))
  45. {
  46. client.Connect();
  47. client.Disconnect();
  48. }
  49. #endregion
  50. Assert.AreEqual(connectionInfo.Host, Resources.HOST);
  51. Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
  52. }
  53. /// <summary>
  54. ///A test for Dispose
  55. ///</summary>
  56. [TestMethod()]
  57. public void DisposeTest()
  58. {
  59. string host = string.Empty; // TODO: Initialize to an appropriate value
  60. string username = string.Empty; // TODO: Initialize to an appropriate value
  61. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  62. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, keyFiles); // TODO: Initialize to an appropriate value
  63. target.Dispose();
  64. Assert.Inconclusive("A method that does not return a value cannot be verified.");
  65. }
  66. /// <summary>
  67. ///A test for PrivateKeyConnectionInfo Constructor
  68. ///</summary>
  69. [TestMethod()]
  70. public void PrivateKeyConnectionInfoConstructorTest()
  71. {
  72. string host = string.Empty; // TODO: Initialize to an appropriate value
  73. int port = 0; // TODO: Initialize to an appropriate value
  74. string username = string.Empty; // TODO: Initialize to an appropriate value
  75. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  76. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  77. int proxyPort = 0; // TODO: Initialize to an appropriate value
  78. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  79. string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
  80. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  81. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles);
  82. Assert.Inconclusive("TODO: Implement code to verify target");
  83. }
  84. /// <summary>
  85. ///A test for PrivateKeyConnectionInfo Constructor
  86. ///</summary>
  87. [TestMethod()]
  88. public void PrivateKeyConnectionInfoConstructorTest1()
  89. {
  90. string host = string.Empty; // TODO: Initialize to an appropriate value
  91. string username = string.Empty; // TODO: Initialize to an appropriate value
  92. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  93. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  94. int proxyPort = 0; // TODO: Initialize to an appropriate value
  95. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  96. string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
  97. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  98. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles);
  99. Assert.Inconclusive("TODO: Implement code to verify target");
  100. }
  101. /// <summary>
  102. ///A test for PrivateKeyConnectionInfo Constructor
  103. ///</summary>
  104. [TestMethod()]
  105. public void PrivateKeyConnectionInfoConstructorTest2()
  106. {
  107. string host = string.Empty; // TODO: Initialize to an appropriate value
  108. string username = string.Empty; // TODO: Initialize to an appropriate value
  109. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  110. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  111. int proxyPort = 0; // TODO: Initialize to an appropriate value
  112. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  113. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  114. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, proxyUsername, keyFiles);
  115. Assert.Inconclusive("TODO: Implement code to verify target");
  116. }
  117. /// <summary>
  118. ///A test for PrivateKeyConnectionInfo Constructor
  119. ///</summary>
  120. [TestMethod()]
  121. public void PrivateKeyConnectionInfoConstructorTest3()
  122. {
  123. string host = string.Empty; // TODO: Initialize to an appropriate value
  124. string username = string.Empty; // TODO: Initialize to an appropriate value
  125. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  126. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  127. int proxyPort = 0; // TODO: Initialize to an appropriate value
  128. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  129. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, proxyType, proxyHost, proxyPort, keyFiles);
  130. Assert.Inconclusive("TODO: Implement code to verify target");
  131. }
  132. /// <summary>
  133. ///A test for PrivateKeyConnectionInfo Constructor
  134. ///</summary>
  135. [TestMethod()]
  136. public void PrivateKeyConnectionInfoConstructorTest4()
  137. {
  138. string host = string.Empty; // TODO: Initialize to an appropriate value
  139. int port = 0; // TODO: Initialize to an appropriate value
  140. string username = string.Empty; // TODO: Initialize to an appropriate value
  141. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  142. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  143. int proxyPort = 0; // TODO: Initialize to an appropriate value
  144. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  145. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  146. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, keyFiles);
  147. Assert.Inconclusive("TODO: Implement code to verify target");
  148. }
  149. /// <summary>
  150. ///A test for PrivateKeyConnectionInfo Constructor
  151. ///</summary>
  152. [TestMethod()]
  153. public void PrivateKeyConnectionInfoConstructorTest5()
  154. {
  155. string host = string.Empty; // TODO: Initialize to an appropriate value
  156. int port = 0; // TODO: Initialize to an appropriate value
  157. string username = string.Empty; // TODO: Initialize to an appropriate value
  158. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  159. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  160. int proxyPort = 0; // TODO: Initialize to an appropriate value
  161. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  162. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, keyFiles);
  163. Assert.Inconclusive("TODO: Implement code to verify target");
  164. }
  165. /// <summary>
  166. ///A test for PrivateKeyConnectionInfo Constructor
  167. ///</summary>
  168. [TestMethod()]
  169. public void PrivateKeyConnectionInfoConstructorTest6()
  170. {
  171. string host = string.Empty; // TODO: Initialize to an appropriate value
  172. int port = 0; // TODO: Initialize to an appropriate value
  173. string username = string.Empty; // TODO: Initialize to an appropriate value
  174. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  175. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, port, username, keyFiles);
  176. Assert.Inconclusive("TODO: Implement code to verify target");
  177. }
  178. /// <summary>
  179. ///A test for PrivateKeyConnectionInfo Constructor
  180. ///</summary>
  181. [TestMethod()]
  182. public void PrivateKeyConnectionInfoConstructorTest7()
  183. {
  184. string host = string.Empty; // TODO: Initialize to an appropriate value
  185. string username = string.Empty; // TODO: Initialize to an appropriate value
  186. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  187. PrivateKeyConnectionInfo target = new PrivateKeyConnectionInfo(host, username, keyFiles);
  188. Assert.Inconclusive("TODO: Implement code to verify target");
  189. }
  190. }
  191. }