PrivateKeyConnectionInfoTest.cs 11 KB

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