PasswordConnectionInfoTest.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Tests.Common;
  3. using Renci.SshNet.Tests.Properties;
  4. using System;
  5. using System.Net;
  6. namespace Renci.SshNet.Tests.Classes
  7. {
  8. /// <summary>
  9. /// Provides connection information when password authentication method is used
  10. /// </summary>
  11. [TestClass]
  12. public class PasswordConnectionInfoTest : TestBase
  13. {
  14. [TestMethod]
  15. [TestCategory("PasswordConnectionInfo")]
  16. [ExpectedException(typeof(ArgumentException))]
  17. public void Test_ConnectionInfo()
  18. {
  19. #region ExampleConnectionInfo
  20. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD);
  21. #endregion
  22. Assert.AreEqual(connectionInfo.Host, Resources.HOST);
  23. Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
  24. }
  25. [WorkItem(703), TestMethod]
  26. [TestCategory("PasswordConnectionInfo")]
  27. [ExpectedException(typeof(ArgumentException))]
  28. public void Test_ConnectionInfo_Host_Is_Null()
  29. {
  30. var connectionInfo = new PasswordConnectionInfo(null, Resources.USERNAME, Resources.PASSWORD);
  31. }
  32. [WorkItem(703), TestMethod]
  33. [TestCategory("PasswordConnectionInfo")]
  34. [ExpectedException(typeof(ArgumentException))]
  35. public void Test_ConnectionInfo_Username_Is_Null()
  36. {
  37. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD);
  38. }
  39. [WorkItem(703), TestMethod]
  40. [TestCategory("PasswordConnectionInfo")]
  41. [ExpectedException(typeof(ArgumentNullException))]
  42. public void Test_ConnectionInfo_Password_Is_Null()
  43. {
  44. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, (string)null);
  45. }
  46. [TestMethod]
  47. [TestCategory("PasswordConnectionInfo")]
  48. [Description("Test passing whitespace to host parameter.")]
  49. [ExpectedException(typeof(ArgumentException))]
  50. public void Test_ConnectionInfo_Host_Is_Whitespace()
  51. {
  52. var connectionInfo = new PasswordConnectionInfo(" ", Resources.USERNAME, Resources.PASSWORD);
  53. }
  54. [TestMethod]
  55. [TestCategory("PasswordConnectionInfo")]
  56. [Description("Test passing whitespace to username parameter.")]
  57. [ExpectedException(typeof(ArgumentException))]
  58. public void Test_ConnectionInfo_Username_Is_Whitespace()
  59. {
  60. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD);
  61. }
  62. [WorkItem(703), TestMethod]
  63. [TestCategory("PasswordConnectionInfo")]
  64. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  65. public void Test_ConnectionInfo_SmallPortNumber()
  66. {
  67. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MinPort - 1, Resources.USERNAME, Resources.PASSWORD);
  68. }
  69. [WorkItem(703), TestMethod]
  70. [TestCategory("PasswordConnectionInfo")]
  71. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  72. public void Test_ConnectionInfo_BigPortNumber()
  73. {
  74. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MaxPort + 1, Resources.USERNAME, Resources.PASSWORD);
  75. }
  76. [TestMethod]
  77. [Owner("Kenneth_aa")]
  78. [Description("Test connect to remote server via a SOCKS4 proxy server.")]
  79. [TestCategory("Proxy")]
  80. public void Test_Ssh_Connect_Via_Socks4()
  81. {
  82. var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks4, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
  83. using (var client = new SshClient(connInfo))
  84. {
  85. client.Connect();
  86. var ret = client.RunCommand("ls -la");
  87. client.Disconnect();
  88. }
  89. }
  90. [TestMethod]
  91. [Owner("Kenneth_aa")]
  92. [Description("Test connect to remote server via a TCP SOCKS5 proxy server.")]
  93. [TestCategory("Proxy")]
  94. public void Test_Ssh_Connect_Via_TcpSocks5()
  95. {
  96. var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks5, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
  97. using (var client = new SshClient(connInfo))
  98. {
  99. client.Connect();
  100. var ret = client.RunCommand("ls -la");
  101. client.Disconnect();
  102. }
  103. }
  104. [TestMethod]
  105. [Owner("Kenneth_aa")]
  106. [Description("Test connect to remote server via a HTTP proxy server.")]
  107. [TestCategory("Proxy")]
  108. public void Test_Ssh_Connect_Via_HttpProxy()
  109. {
  110. var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Http, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
  111. using (var client = new SshClient(connInfo))
  112. {
  113. client.Connect();
  114. var ret = client.RunCommand("ls -la");
  115. client.Disconnect();
  116. }
  117. }
  118. /// <summary>
  119. ///A test for Dispose
  120. ///</summary>
  121. [TestMethod()]
  122. public void DisposeTest()
  123. {
  124. string host = string.Empty; // TODO: Initialize to an appropriate value
  125. string username = string.Empty; // TODO: Initialize to an appropriate value
  126. byte[] password = null; // TODO: Initialize to an appropriate value
  127. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password); // TODO: Initialize to an appropriate value
  128. target.Dispose();
  129. Assert.Inconclusive("A method that does not return a value cannot be verified.");
  130. }
  131. /// <summary>
  132. ///A test for PasswordConnectionInfo Constructor
  133. ///</summary>
  134. [TestMethod()]
  135. public void PasswordConnectionInfoConstructorTest()
  136. {
  137. string host = string.Empty; // TODO: Initialize to an appropriate value
  138. int port = 0; // TODO: Initialize to an appropriate value
  139. string username = string.Empty; // TODO: Initialize to an appropriate value
  140. byte[] password = null; // 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. string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
  146. PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword);
  147. Assert.Inconclusive("TODO: Implement code to verify target");
  148. }
  149. /// <summary>
  150. ///A test for PasswordConnectionInfo Constructor
  151. ///</summary>
  152. [TestMethod()]
  153. public void PasswordConnectionInfoConstructorTest1()
  154. {
  155. string host = string.Empty; // TODO: Initialize to an appropriate value
  156. string username = string.Empty; // TODO: Initialize to an appropriate value
  157. byte[] password = null; // 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. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  162. string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
  163. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword);
  164. Assert.Inconclusive("TODO: Implement code to verify target");
  165. }
  166. /// <summary>
  167. ///A test for PasswordConnectionInfo Constructor
  168. ///</summary>
  169. [TestMethod()]
  170. public void PasswordConnectionInfoConstructorTest2()
  171. {
  172. string host = string.Empty; // TODO: Initialize to an appropriate value
  173. string username = string.Empty; // TODO: Initialize to an appropriate value
  174. byte[] password = null; // TODO: Initialize to an appropriate value
  175. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  176. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  177. int proxyPort = 0; // TODO: Initialize to an appropriate value
  178. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  179. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort, proxyUsername);
  180. Assert.Inconclusive("TODO: Implement code to verify target");
  181. }
  182. /// <summary>
  183. ///A test for PasswordConnectionInfo Constructor
  184. ///</summary>
  185. [TestMethod()]
  186. public void PasswordConnectionInfoConstructorTest3()
  187. {
  188. string host = string.Empty; // TODO: Initialize to an appropriate value
  189. string username = string.Empty; // TODO: Initialize to an appropriate value
  190. byte[] password = null; // TODO: Initialize to an appropriate value
  191. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  192. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  193. int proxyPort = 0; // TODO: Initialize to an appropriate value
  194. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort);
  195. Assert.Inconclusive("TODO: Implement code to verify target");
  196. }
  197. /// <summary>
  198. ///A test for PasswordConnectionInfo Constructor
  199. ///</summary>
  200. [TestMethod()]
  201. public void PasswordConnectionInfoConstructorTest4()
  202. {
  203. string host = string.Empty; // TODO: Initialize to an appropriate value
  204. int port = 0; // TODO: Initialize to an appropriate value
  205. string username = string.Empty; // TODO: Initialize to an appropriate value
  206. byte[] password = null; // TODO: Initialize to an appropriate value
  207. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  208. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  209. int proxyPort = 0; // TODO: Initialize to an appropriate value
  210. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  211. PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort, proxyUsername);
  212. Assert.Inconclusive("TODO: Implement code to verify target");
  213. }
  214. /// <summary>
  215. ///A test for PasswordConnectionInfo Constructor
  216. ///</summary>
  217. [TestMethod()]
  218. public void PasswordConnectionInfoConstructorTest5()
  219. {
  220. string host = string.Empty; // TODO: Initialize to an appropriate value
  221. int port = 0; // TODO: Initialize to an appropriate value
  222. string username = string.Empty; // TODO: Initialize to an appropriate value
  223. byte[] password = null; // TODO: Initialize to an appropriate value
  224. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  225. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  226. int proxyPort = 0; // TODO: Initialize to an appropriate value
  227. PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort);
  228. Assert.Inconclusive("TODO: Implement code to verify target");
  229. }
  230. /// <summary>
  231. ///A test for PasswordConnectionInfo Constructor
  232. ///</summary>
  233. [TestMethod()]
  234. public void PasswordConnectionInfoConstructorTest6()
  235. {
  236. string host = string.Empty; // TODO: Initialize to an appropriate value
  237. int port = 0; // TODO: Initialize to an appropriate value
  238. string username = string.Empty; // TODO: Initialize to an appropriate value
  239. byte[] password = null; // TODO: Initialize to an appropriate value
  240. PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password);
  241. Assert.Inconclusive("TODO: Implement code to verify target");
  242. }
  243. /// <summary>
  244. ///A test for PasswordConnectionInfo Constructor
  245. ///</summary>
  246. [TestMethod()]
  247. public void PasswordConnectionInfoConstructorTest7()
  248. {
  249. string host = string.Empty; // TODO: Initialize to an appropriate value
  250. string username = string.Empty; // TODO: Initialize to an appropriate value
  251. byte[] password = null; // TODO: Initialize to an appropriate value
  252. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password);
  253. Assert.Inconclusive("TODO: Implement code to verify target");
  254. }
  255. /// <summary>
  256. ///A test for PasswordConnectionInfo Constructor
  257. ///</summary>
  258. [TestMethod()]
  259. public void PasswordConnectionInfoConstructorTest8()
  260. {
  261. string host = string.Empty; // TODO: Initialize to an appropriate value
  262. string username = string.Empty; // TODO: Initialize to an appropriate value
  263. string password = string.Empty; // TODO: Initialize to an appropriate value
  264. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  265. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  266. int proxyPort = 0; // TODO: Initialize to an appropriate value
  267. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  268. string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
  269. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword);
  270. Assert.Inconclusive("TODO: Implement code to verify target");
  271. }
  272. /// <summary>
  273. ///A test for PasswordConnectionInfo Constructor
  274. ///</summary>
  275. [TestMethod()]
  276. public void PasswordConnectionInfoConstructorTest9()
  277. {
  278. string host = string.Empty; // TODO: Initialize to an appropriate value
  279. string username = string.Empty; // TODO: Initialize to an appropriate value
  280. string password = string.Empty; // TODO: Initialize to an appropriate value
  281. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  282. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  283. int proxyPort = 0; // TODO: Initialize to an appropriate value
  284. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  285. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort, proxyUsername);
  286. Assert.Inconclusive("TODO: Implement code to verify target");
  287. }
  288. /// <summary>
  289. ///A test for PasswordConnectionInfo Constructor
  290. ///</summary>
  291. [TestMethod()]
  292. public void PasswordConnectionInfoConstructorTest10()
  293. {
  294. string host = string.Empty; // TODO: Initialize to an appropriate value
  295. string username = string.Empty; // TODO: Initialize to an appropriate value
  296. string password = string.Empty; // TODO: Initialize to an appropriate value
  297. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  298. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  299. int proxyPort = 0; // TODO: Initialize to an appropriate value
  300. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort);
  301. Assert.Inconclusive("TODO: Implement code to verify target");
  302. }
  303. /// <summary>
  304. ///A test for PasswordConnectionInfo Constructor
  305. ///</summary>
  306. [TestMethod()]
  307. public void PasswordConnectionInfoConstructorTest11()
  308. {
  309. string host = string.Empty; // TODO: Initialize to an appropriate value
  310. int port = 0; // TODO: Initialize to an appropriate value
  311. string username = string.Empty; // TODO: Initialize to an appropriate value
  312. string password = string.Empty; // TODO: Initialize to an appropriate value
  313. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  314. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  315. int proxyPort = 0; // TODO: Initialize to an appropriate value
  316. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  317. PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort, proxyUsername);
  318. Assert.Inconclusive("TODO: Implement code to verify target");
  319. }
  320. /// <summary>
  321. ///A test for PasswordConnectionInfo Constructor
  322. ///</summary>
  323. [TestMethod()]
  324. public void PasswordConnectionInfoConstructorTest12()
  325. {
  326. string host = string.Empty; // TODO: Initialize to an appropriate value
  327. int port = 0; // TODO: Initialize to an appropriate value
  328. string username = string.Empty; // TODO: Initialize to an appropriate value
  329. string password = string.Empty; // TODO: Initialize to an appropriate value
  330. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  331. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  332. int proxyPort = 0; // TODO: Initialize to an appropriate value
  333. PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort);
  334. Assert.Inconclusive("TODO: Implement code to verify target");
  335. }
  336. /// <summary>
  337. ///A test for PasswordConnectionInfo Constructor
  338. ///</summary>
  339. [TestMethod()]
  340. public void PasswordConnectionInfoConstructorTest13()
  341. {
  342. string host = string.Empty; // TODO: Initialize to an appropriate value
  343. int port = 0; // TODO: Initialize to an appropriate value
  344. string username = string.Empty; // TODO: Initialize to an appropriate value
  345. string password = string.Empty; // TODO: Initialize to an appropriate value
  346. PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password);
  347. Assert.Inconclusive("TODO: Implement code to verify target");
  348. }
  349. /// <summary>
  350. ///A test for PasswordConnectionInfo Constructor
  351. ///</summary>
  352. [TestMethod()]
  353. public void PasswordConnectionInfoConstructorTest14()
  354. {
  355. string host = string.Empty; // TODO: Initialize to an appropriate value
  356. string username = string.Empty; // TODO: Initialize to an appropriate value
  357. string password = string.Empty; // TODO: Initialize to an appropriate value
  358. PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password);
  359. Assert.Inconclusive("TODO: Implement code to verify target");
  360. }
  361. }
  362. }