SshClientTest.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Common;
  3. using Renci.SshNet.Tests.Common;
  4. using Renci.SshNet.Tests.Properties;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Text;
  9. using System.Linq;
  10. namespace Renci.SshNet.Tests.Classes
  11. {
  12. /// <summary>
  13. /// Provides client connection to SSH server.
  14. /// </summary>
  15. [TestClass]
  16. public class SshClientTest : TestBase
  17. {
  18. [TestMethod]
  19. [TestCategory("Authentication")]
  20. [TestCategory("integration")]
  21. public void Test_Connect_Using_Correct_Password()
  22. {
  23. var host = Resources.HOST;
  24. var username = Resources.USERNAME;
  25. var password = Resources.PASSWORD;
  26. #region Example SshClient(host, username) Connect
  27. using (var client = new SshClient(host, username, password))
  28. {
  29. client.Connect();
  30. // Do something here
  31. client.Disconnect();
  32. }
  33. #endregion
  34. }
  35. [TestMethod]
  36. [TestCategory("Authentication")]
  37. [TestCategory("integration")]
  38. public void Test_Connect_Handle_HostKeyReceived()
  39. {
  40. var host = Resources.HOST;
  41. var username = Resources.USERNAME;
  42. var password = Resources.PASSWORD;
  43. var hostKeyValidated = false;
  44. #region Example SshClient Connect HostKeyReceived
  45. using (var client = new SshClient(host, username, password))
  46. {
  47. client.HostKeyReceived += delegate(object sender, HostKeyEventArgs e)
  48. {
  49. hostKeyValidated = true;
  50. if (e.FingerPrint.SequenceEqual(new byte[] { 0x00, 0x01, 0x02, 0x03 }))
  51. {
  52. e.CanTrust = true;
  53. }
  54. else
  55. {
  56. e.CanTrust = false;
  57. }
  58. };
  59. client.Connect();
  60. // Do something here
  61. client.Disconnect();
  62. }
  63. #endregion
  64. Assert.IsTrue(hostKeyValidated);
  65. }
  66. [TestMethod]
  67. [TestCategory("Authentication")]
  68. [TestCategory("integration")]
  69. public void Test_Connect_Timeout()
  70. {
  71. var host = Resources.HOST;
  72. var username = Resources.USERNAME;
  73. var password = Resources.PASSWORD;
  74. #region Example SshClient Connect Timeout
  75. var connectionInfo = new PasswordConnectionInfo(host, username, password);
  76. connectionInfo.Timeout = TimeSpan.FromSeconds(30);
  77. using (var client = new SshClient(connectionInfo))
  78. {
  79. client.Connect();
  80. // Do something here
  81. client.Disconnect();
  82. }
  83. #endregion
  84. Assert.Inconclusive();
  85. }
  86. [TestMethod]
  87. [TestCategory("Authentication")]
  88. [TestCategory("integration")]
  89. public void Test_Connect_Handle_ErrorOccurred()
  90. {
  91. var host = Resources.HOST;
  92. var username = Resources.USERNAME;
  93. var password = Resources.PASSWORD;
  94. var exceptionOccured = false;
  95. #region Example SshClient Connect ErrorOccurred
  96. using (var client = new SshClient(host, username, password))
  97. {
  98. client.ErrorOccurred += delegate(object sender, ExceptionEventArgs e)
  99. {
  100. Console.WriteLine("Error occured: " + e.Exception.ToString());
  101. exceptionOccured = true;
  102. };
  103. client.Connect();
  104. // Do something here
  105. client.Disconnect();
  106. }
  107. #endregion
  108. Assert.IsTrue(exceptionOccured);
  109. }
  110. [TestMethod]
  111. [TestCategory("Authentication")]
  112. [TestCategory("integration")]
  113. [ExpectedException(typeof(SshAuthenticationException))]
  114. public void Test_Connect_Using_Invalid_Password()
  115. {
  116. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  117. {
  118. client.Connect();
  119. client.Disconnect();
  120. }
  121. }
  122. [TestMethod]
  123. [TestCategory("Authentication")]
  124. [TestCategory("integration")]
  125. public void Test_Connect_Using_Rsa_Key_Without_PassPhrase()
  126. {
  127. var host = Resources.HOST;
  128. var username = Resources.USERNAME;
  129. MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS));
  130. #region Example SshClient(host, username) Connect PrivateKeyFile
  131. using (var client = new SshClient(host, username, new PrivateKeyFile(keyFileStream)))
  132. {
  133. client.Connect();
  134. client.Disconnect();
  135. }
  136. #endregion
  137. }
  138. [TestMethod]
  139. [TestCategory("Authentication")]
  140. [TestCategory("integration")]
  141. public void Test_Connect_Using_RsaKey_With_PassPhrase()
  142. {
  143. var host = Resources.HOST;
  144. var username = Resources.USERNAME;
  145. var passphrase = Resources.PASSWORD;
  146. MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITH_PASS));
  147. #region Example SshClient(host, username) Connect PrivateKeyFile PassPhrase
  148. using (var client = new SshClient(host, username, new PrivateKeyFile(keyFileStream, passphrase)))
  149. {
  150. client.Connect();
  151. client.Disconnect();
  152. }
  153. #endregion
  154. }
  155. [TestMethod]
  156. [TestCategory("Authentication")]
  157. [TestCategory("integration")]
  158. [ExpectedException(typeof(SshPassPhraseNullOrEmptyException))]
  159. public void Test_Connect_Using_Key_With_Empty_PassPhrase()
  160. {
  161. MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITH_PASS));
  162. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, new PrivateKeyFile(keyFileStream, null)))
  163. {
  164. client.Connect();
  165. client.Disconnect();
  166. }
  167. }
  168. [TestMethod]
  169. [TestCategory("Authentication")]
  170. [TestCategory("integration")]
  171. public void Test_Connect_Using_DsaKey_Without_PassPhrase()
  172. {
  173. MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.DSA_KEY_WITHOUT_PASS));
  174. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, new PrivateKeyFile(keyFileStream)))
  175. {
  176. client.Connect();
  177. client.Disconnect();
  178. }
  179. }
  180. [TestMethod]
  181. [TestCategory("Authentication")]
  182. [TestCategory("integration")]
  183. public void Test_Connect_Using_DsaKey_With_PassPhrase()
  184. {
  185. MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.DSA_KEY_WITH_PASS));
  186. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, new PrivateKeyFile(keyFileStream, Resources.PASSWORD)))
  187. {
  188. client.Connect();
  189. client.Disconnect();
  190. }
  191. }
  192. [TestMethod]
  193. [TestCategory("Authentication")]
  194. [TestCategory("integration")]
  195. [ExpectedException(typeof(SshAuthenticationException))]
  196. public void Test_Connect_Using_Invalid_PrivateKey()
  197. {
  198. MemoryStream keyFileStream = new MemoryStream(Encoding.ASCII.GetBytes(Resources.INVALID_KEY));
  199. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, new PrivateKeyFile(keyFileStream)))
  200. {
  201. client.Connect();
  202. client.Disconnect();
  203. }
  204. }
  205. [TestMethod]
  206. [TestCategory("Authentication")]
  207. [TestCategory("integration")]
  208. public void Test_Connect_Using_Multiple_PrivateKeys()
  209. {
  210. using (var client = new SshClient(Resources.HOST, Resources.USERNAME,
  211. new PrivateKeyFile(new MemoryStream(Encoding.ASCII.GetBytes(Resources.INVALID_KEY))),
  212. new PrivateKeyFile(new MemoryStream(Encoding.ASCII.GetBytes(Resources.DSA_KEY_WITH_PASS)), Resources.PASSWORD),
  213. new PrivateKeyFile(new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITH_PASS)), Resources.PASSWORD),
  214. new PrivateKeyFile(new MemoryStream(Encoding.ASCII.GetBytes(Resources.RSA_KEY_WITHOUT_PASS))),
  215. new PrivateKeyFile(new MemoryStream(Encoding.ASCII.GetBytes(Resources.DSA_KEY_WITHOUT_PASS)))
  216. ))
  217. {
  218. client.Connect();
  219. client.Disconnect();
  220. }
  221. }
  222. [TestMethod]
  223. [TestCategory("Authentication")]
  224. [TestCategory("integration")]
  225. public void Test_Connect_Then_Reconnect()
  226. {
  227. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
  228. {
  229. client.Connect();
  230. client.Disconnect();
  231. client.Connect();
  232. client.Disconnect();
  233. }
  234. }
  235. [TestMethod]
  236. public void CreateShellStream1_NeverConnected()
  237. {
  238. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  239. {
  240. const string terminalName = "vt100";
  241. const uint columns = 80;
  242. const uint rows = 25;
  243. const uint width = 640;
  244. const uint height = 480;
  245. const int bufferSize = 4096;
  246. try
  247. {
  248. client.CreateShellStream(terminalName, columns, rows, width, height, bufferSize);
  249. Assert.Fail();
  250. }
  251. catch (SshConnectionException ex)
  252. {
  253. Assert.IsNull(ex.InnerException);
  254. Assert.AreEqual("Client not connected.", ex.Message);
  255. }
  256. }
  257. }
  258. [TestMethod]
  259. public void CreateShellStream2_NeverConnected()
  260. {
  261. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  262. {
  263. const string terminalName = "vt100";
  264. const uint columns = 80;
  265. const uint rows = 25;
  266. const uint width = 640;
  267. const uint height = 480;
  268. var terminalModes = new Dictionary<TerminalModes, uint>();
  269. const int bufferSize = 4096;
  270. try
  271. {
  272. client.CreateShellStream(terminalName, columns, rows, width, height, bufferSize, terminalModes);
  273. Assert.Fail();
  274. }
  275. catch (SshConnectionException ex)
  276. {
  277. Assert.IsNull(ex.InnerException);
  278. Assert.AreEqual("Client not connected.", ex.Message);
  279. }
  280. }
  281. }
  282. /// <summary>
  283. ///A test for CreateShellStream
  284. ///</summary>
  285. [TestMethod]
  286. [Ignore] // placeholder for actual test
  287. public void CreateShellStreamTest()
  288. {
  289. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  290. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  291. string terminalName = string.Empty; // TODO: Initialize to an appropriate value
  292. uint columns = 0; // TODO: Initialize to an appropriate value
  293. uint rows = 0; // TODO: Initialize to an appropriate value
  294. uint width = 0; // TODO: Initialize to an appropriate value
  295. uint height = 0; // TODO: Initialize to an appropriate value
  296. int bufferSize = 0; // TODO: Initialize to an appropriate value
  297. IDictionary<TerminalModes, uint> terminalModeValues = null; // TODO: Initialize to an appropriate value
  298. ShellStream expected = null; // TODO: Initialize to an appropriate value
  299. ShellStream actual;
  300. actual = target.CreateShellStream(terminalName, columns, rows, width, height, bufferSize, terminalModeValues);
  301. Assert.AreEqual(expected, actual);
  302. Assert.Inconclusive("Verify the correctness of this test method.");
  303. }
  304. /// <summary>
  305. ///A test for CreateShellStream
  306. ///</summary>
  307. [TestMethod]
  308. [Ignore] // placeholder for actual test
  309. public void CreateShellStreamTest1()
  310. {
  311. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  312. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  313. string terminalName = string.Empty; // TODO: Initialize to an appropriate value
  314. uint columns = 0; // TODO: Initialize to an appropriate value
  315. uint rows = 0; // TODO: Initialize to an appropriate value
  316. uint width = 0; // TODO: Initialize to an appropriate value
  317. uint height = 0; // TODO: Initialize to an appropriate value
  318. int bufferSize = 0; // TODO: Initialize to an appropriate value
  319. ShellStream expected = null; // TODO: Initialize to an appropriate value
  320. ShellStream actual;
  321. actual = target.CreateShellStream(terminalName, columns, rows, width, height, bufferSize);
  322. Assert.AreEqual(expected, actual);
  323. Assert.Inconclusive("Verify the correctness of this test method.");
  324. }
  325. [TestMethod]
  326. public void CreateShell1_NeverConnected()
  327. {
  328. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  329. {
  330. var encoding = Encoding.UTF8;
  331. const string input = "INPUT";
  332. var output = new MemoryStream();
  333. var extendedOutput = new MemoryStream();
  334. try
  335. {
  336. client.CreateShell(encoding, input, output, extendedOutput);
  337. Assert.Fail();
  338. }
  339. catch (SshConnectionException ex)
  340. {
  341. Assert.IsNull(ex.InnerException);
  342. Assert.AreEqual("Client not connected.", ex.Message);
  343. }
  344. }
  345. }
  346. [TestMethod]
  347. public void CreateShell2_NeverConnected()
  348. {
  349. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  350. {
  351. var encoding = Encoding.UTF8;
  352. const string input = "INPUT";
  353. var output = new MemoryStream();
  354. var extendedOutput = new MemoryStream();
  355. const string terminalName = "vt100";
  356. const uint columns = 80;
  357. const uint rows = 25;
  358. const uint width = 640;
  359. const uint height = 480;
  360. var terminalModes = new Dictionary<TerminalModes, uint>();
  361. try
  362. {
  363. client.CreateShell(
  364. encoding,
  365. input,
  366. output,
  367. extendedOutput,
  368. terminalName,
  369. columns,
  370. rows,
  371. width,
  372. height,
  373. terminalModes);
  374. Assert.Fail();
  375. }
  376. catch (SshConnectionException ex)
  377. {
  378. Assert.IsNull(ex.InnerException);
  379. Assert.AreEqual("Client not connected.", ex.Message);
  380. }
  381. }
  382. }
  383. [TestMethod]
  384. public void CreateShell3_NeverConnected()
  385. {
  386. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  387. {
  388. var encoding = Encoding.UTF8;
  389. const string input = "INPUT";
  390. var output = new MemoryStream();
  391. var extendedOutput = new MemoryStream();
  392. const string terminalName = "vt100";
  393. const uint columns = 80;
  394. const uint rows = 25;
  395. const uint width = 640;
  396. const uint height = 480;
  397. var terminalModes = new Dictionary<TerminalModes, uint>();
  398. const int bufferSize = 4096;
  399. try
  400. {
  401. client.CreateShell(
  402. encoding,
  403. input,
  404. output,
  405. extendedOutput,
  406. terminalName,
  407. columns,
  408. rows,
  409. width,
  410. height,
  411. terminalModes,
  412. bufferSize);
  413. Assert.Fail();
  414. }
  415. catch (SshConnectionException ex)
  416. {
  417. Assert.IsNull(ex.InnerException);
  418. Assert.AreEqual("Client not connected.", ex.Message);
  419. }
  420. }
  421. }
  422. [TestMethod]
  423. public void CreateShell4_NeverConnected()
  424. {
  425. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  426. {
  427. var input = new MemoryStream();
  428. var output = new MemoryStream();
  429. var extendedOutput = new MemoryStream();
  430. try
  431. {
  432. client.CreateShell(input, output, extendedOutput);
  433. Assert.Fail();
  434. }
  435. catch (SshConnectionException ex)
  436. {
  437. Assert.IsNull(ex.InnerException);
  438. Assert.AreEqual("Client not connected.", ex.Message);
  439. }
  440. }
  441. }
  442. [TestMethod]
  443. public void CreateShell5_NeverConnected()
  444. {
  445. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  446. {
  447. var input = new MemoryStream();
  448. var output = new MemoryStream();
  449. var extendedOutput = new MemoryStream();
  450. const string terminalName = "vt100";
  451. const uint columns = 80;
  452. const uint rows = 25;
  453. const uint width = 640;
  454. const uint height = 480;
  455. var terminalModes = new Dictionary<TerminalModes, uint>();
  456. try
  457. {
  458. client.CreateShell(
  459. input,
  460. output,
  461. extendedOutput,
  462. terminalName,
  463. columns,
  464. rows,
  465. width,
  466. height,
  467. terminalModes);
  468. Assert.Fail();
  469. }
  470. catch (SshConnectionException ex)
  471. {
  472. Assert.IsNull(ex.InnerException);
  473. Assert.AreEqual("Client not connected.", ex.Message);
  474. }
  475. }
  476. }
  477. [TestMethod]
  478. public void CreateShell6_NeverConnected()
  479. {
  480. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  481. {
  482. var input = new MemoryStream();
  483. var output = new MemoryStream();
  484. var extendedOutput = new MemoryStream();
  485. const string terminalName = "vt100";
  486. const uint columns = 80;
  487. const uint rows = 25;
  488. const uint width = 640;
  489. const uint height = 480;
  490. var terminalModes = new Dictionary<TerminalModes, uint>();
  491. const int bufferSize = 4096;
  492. try
  493. {
  494. client.CreateShell(
  495. input,
  496. output,
  497. extendedOutput,
  498. terminalName,
  499. columns,
  500. rows,
  501. width,
  502. height,
  503. terminalModes,
  504. bufferSize);
  505. Assert.Fail();
  506. }
  507. catch (SshConnectionException ex)
  508. {
  509. Assert.IsNull(ex.InnerException);
  510. Assert.AreEqual("Client not connected.", ex.Message);
  511. }
  512. }
  513. }
  514. /// <summary>
  515. ///A test for CreateShell
  516. ///</summary>
  517. [TestMethod]
  518. [Ignore] // placeholder for actual test
  519. public void CreateShellTest()
  520. {
  521. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  522. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  523. Encoding encoding = null; // TODO: Initialize to an appropriate value
  524. string input = string.Empty; // TODO: Initialize to an appropriate value
  525. Stream output = null; // TODO: Initialize to an appropriate value
  526. Stream extendedOutput = null; // TODO: Initialize to an appropriate value
  527. Shell expected = null; // TODO: Initialize to an appropriate value
  528. Shell actual;
  529. actual = target.CreateShell(encoding, input, output, extendedOutput);
  530. Assert.AreEqual(expected, actual);
  531. Assert.Inconclusive("Verify the correctness of this test method.");
  532. }
  533. /// <summary>
  534. ///A test for CreateShell
  535. ///</summary>
  536. [TestMethod]
  537. [Ignore] // placeholder for actual test
  538. public void CreateShellTest1()
  539. {
  540. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  541. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  542. Encoding encoding = null; // TODO: Initialize to an appropriate value
  543. string input = string.Empty; // TODO: Initialize to an appropriate value
  544. Stream output = null; // TODO: Initialize to an appropriate value
  545. Stream extendedOutput = null; // TODO: Initialize to an appropriate value
  546. string terminalName = string.Empty; // TODO: Initialize to an appropriate value
  547. uint columns = 0; // TODO: Initialize to an appropriate value
  548. uint rows = 0; // TODO: Initialize to an appropriate value
  549. uint width = 0; // TODO: Initialize to an appropriate value
  550. uint height = 0; // TODO: Initialize to an appropriate value
  551. IDictionary<TerminalModes, uint> terminalModes = null; // TODO: Initialize to an appropriate value
  552. Shell expected = null; // TODO: Initialize to an appropriate value
  553. Shell actual;
  554. actual = target.CreateShell(encoding, input, output, extendedOutput, terminalName, columns, rows, width, height, terminalModes);
  555. Assert.AreEqual(expected, actual);
  556. Assert.Inconclusive("Verify the correctness of this test method.");
  557. }
  558. /// <summary>
  559. ///A test for CreateShell
  560. ///</summary>
  561. [TestMethod]
  562. [Ignore] // placeholder for actual test
  563. public void CreateShellTest2()
  564. {
  565. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  566. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  567. Encoding encoding = null; // TODO: Initialize to an appropriate value
  568. string input = string.Empty; // TODO: Initialize to an appropriate value
  569. Stream output = null; // TODO: Initialize to an appropriate value
  570. Stream extendedOutput = null; // TODO: Initialize to an appropriate value
  571. string terminalName = string.Empty; // TODO: Initialize to an appropriate value
  572. uint columns = 0; // TODO: Initialize to an appropriate value
  573. uint rows = 0; // TODO: Initialize to an appropriate value
  574. uint width = 0; // TODO: Initialize to an appropriate value
  575. uint height = 0; // TODO: Initialize to an appropriate value
  576. IDictionary<TerminalModes, uint> terminalModes = null; // TODO: Initialize to an appropriate value
  577. int bufferSize = 0; // TODO: Initialize to an appropriate value
  578. Shell expected = null; // TODO: Initialize to an appropriate value
  579. Shell actual;
  580. actual = target.CreateShell(encoding, input, output, extendedOutput, terminalName, columns, rows, width, height, terminalModes, bufferSize);
  581. Assert.AreEqual(expected, actual);
  582. Assert.Inconclusive("Verify the correctness of this test method.");
  583. }
  584. /// <summary>
  585. ///A test for CreateShell
  586. ///</summary>
  587. [TestMethod]
  588. [Ignore] // placeholder for actual test
  589. public void CreateShellTest3()
  590. {
  591. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  592. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  593. Stream input = null; // TODO: Initialize to an appropriate value
  594. Stream output = null; // TODO: Initialize to an appropriate value
  595. Stream extendedOutput = null; // TODO: Initialize to an appropriate value
  596. Shell expected = null; // TODO: Initialize to an appropriate value
  597. Shell actual;
  598. actual = target.CreateShell(input, output, extendedOutput);
  599. Assert.AreEqual(expected, actual);
  600. Assert.Inconclusive("Verify the correctness of this test method.");
  601. }
  602. /// <summary>
  603. ///A test for CreateShell
  604. ///</summary>
  605. [TestMethod]
  606. [Ignore] // placeholder for actual test
  607. public void CreateShellTest4()
  608. {
  609. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  610. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  611. Stream input = null; // TODO: Initialize to an appropriate value
  612. Stream output = null; // TODO: Initialize to an appropriate value
  613. Stream extendedOutput = null; // TODO: Initialize to an appropriate value
  614. string terminalName = string.Empty; // TODO: Initialize to an appropriate value
  615. uint columns = 0; // TODO: Initialize to an appropriate value
  616. uint rows = 0; // TODO: Initialize to an appropriate value
  617. uint width = 0; // TODO: Initialize to an appropriate value
  618. uint height = 0; // TODO: Initialize to an appropriate value
  619. IDictionary<TerminalModes, uint> terminalModes = null; // TODO: Initialize to an appropriate value
  620. Shell expected = null; // TODO: Initialize to an appropriate value
  621. Shell actual;
  622. actual = target.CreateShell(input, output, extendedOutput, terminalName, columns, rows, width, height, terminalModes);
  623. Assert.AreEqual(expected, actual);
  624. Assert.Inconclusive("Verify the correctness of this test method.");
  625. }
  626. /// <summary>
  627. ///A test for CreateShell
  628. ///</summary>
  629. [TestMethod]
  630. [Ignore] // placeholder for actual test
  631. public void CreateShellTest5()
  632. {
  633. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  634. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  635. Stream input = null; // TODO: Initialize to an appropriate value
  636. Stream output = null; // TODO: Initialize to an appropriate value
  637. Stream extendedOutput = null; // TODO: Initialize to an appropriate value
  638. string terminalName = string.Empty; // TODO: Initialize to an appropriate value
  639. uint columns = 0; // TODO: Initialize to an appropriate value
  640. uint rows = 0; // TODO: Initialize to an appropriate value
  641. uint width = 0; // TODO: Initialize to an appropriate value
  642. uint height = 0; // TODO: Initialize to an appropriate value
  643. IDictionary<TerminalModes, uint> terminalModes = null; // TODO: Initialize to an appropriate value
  644. int bufferSize = 0; // TODO: Initialize to an appropriate value
  645. Shell expected = null; // TODO: Initialize to an appropriate value
  646. Shell actual;
  647. actual = target.CreateShell(input, output, extendedOutput, terminalName, columns, rows, width, height, terminalModes, bufferSize);
  648. Assert.AreEqual(expected, actual);
  649. Assert.Inconclusive("Verify the correctness of this test method.");
  650. }
  651. [TestMethod]
  652. public void CreateCommand_CommandText_NeverConnected()
  653. {
  654. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  655. {
  656. try
  657. {
  658. client.CreateCommand("ls");
  659. Assert.Fail();
  660. }
  661. catch (SshConnectionException ex)
  662. {
  663. Assert.IsNull(ex.InnerException);
  664. Assert.AreEqual("Client not connected.", ex.Message);
  665. }
  666. }
  667. }
  668. [TestMethod]
  669. public void CreateCommand_CommandTextAndEncoding_NeverConnected()
  670. {
  671. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  672. {
  673. try
  674. {
  675. client.CreateCommand("ls", Encoding.UTF8);
  676. Assert.Fail();
  677. }
  678. catch (SshConnectionException ex)
  679. {
  680. Assert.IsNull(ex.InnerException);
  681. Assert.AreEqual("Client not connected.", ex.Message);
  682. }
  683. }
  684. }
  685. /// <summary>
  686. ///A test for CreateCommand
  687. ///</summary>
  688. [TestMethod]
  689. [Ignore] // placeholder for actual test
  690. public void CreateCommandTest()
  691. {
  692. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  693. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  694. string commandText = string.Empty; // TODO: Initialize to an appropriate value
  695. Encoding encoding = null; // TODO: Initialize to an appropriate value
  696. SshCommand expected = null; // TODO: Initialize to an appropriate value
  697. SshCommand actual;
  698. actual = target.CreateCommand(commandText, encoding);
  699. Assert.AreEqual(expected, actual);
  700. Assert.Inconclusive("Verify the correctness of this test method.");
  701. }
  702. /// <summary>
  703. ///A test for CreateCommand
  704. ///</summary>
  705. [TestMethod]
  706. [Ignore] // placeholder for actual test
  707. public void CreateCommandTest1()
  708. {
  709. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  710. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  711. string commandText = string.Empty; // TODO: Initialize to an appropriate value
  712. SshCommand expected = null; // TODO: Initialize to an appropriate value
  713. SshCommand actual;
  714. actual = target.CreateCommand(commandText);
  715. Assert.AreEqual(expected, actual);
  716. Assert.Inconclusive("Verify the correctness of this test method.");
  717. }
  718. [TestMethod]
  719. public void AddForwardedPort_NeverConnected()
  720. {
  721. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  722. {
  723. var port = new ForwardedPortLocal(50, "host", 8080);
  724. try
  725. {
  726. client.AddForwardedPort(port);
  727. Assert.Fail();
  728. }
  729. catch (SshConnectionException ex)
  730. {
  731. Assert.IsNull(ex.InnerException);
  732. Assert.AreEqual("Client not connected.", ex.Message);
  733. }
  734. }
  735. }
  736. /// <summary>
  737. ///A test for AddForwardedPort
  738. ///</summary>
  739. [TestMethod]
  740. [Ignore] // placeholder for actual test
  741. public void AddForwardedPortTest()
  742. {
  743. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  744. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  745. ForwardedPort port = null; // TODO: Initialize to an appropriate value
  746. target.AddForwardedPort(port);
  747. Assert.Inconclusive("A method that does not return a value cannot be verified.");
  748. }
  749. /// <summary>
  750. ///A test for SshClient Constructor
  751. ///</summary>
  752. [TestMethod]
  753. [Ignore] // placeholder for actual test
  754. public void SshClientConstructorTest()
  755. {
  756. string host = string.Empty; // TODO: Initialize to an appropriate value
  757. string username = string.Empty; // TODO: Initialize to an appropriate value
  758. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  759. SshClient target = new SshClient(host, username, keyFiles);
  760. Assert.Inconclusive("TODO: Implement code to verify target");
  761. }
  762. /// <summary>
  763. ///A test for SshClient Constructor
  764. ///</summary>
  765. [TestMethod]
  766. [Ignore] // placeholder for actual test
  767. public void SshClientConstructorTest1()
  768. {
  769. string host = string.Empty; // TODO: Initialize to an appropriate value
  770. int port = 0; // TODO: Initialize to an appropriate value
  771. string username = string.Empty; // TODO: Initialize to an appropriate value
  772. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  773. SshClient target = new SshClient(host, port, username, keyFiles);
  774. Assert.Inconclusive("TODO: Implement code to verify target");
  775. }
  776. /// <summary>
  777. ///A test for SshClient Constructor
  778. ///</summary>
  779. [TestMethod]
  780. [Ignore] // placeholder for actual test
  781. public void SshClientConstructorTest2()
  782. {
  783. string host = string.Empty; // TODO: Initialize to an appropriate value
  784. string username = string.Empty; // TODO: Initialize to an appropriate value
  785. string password = string.Empty; // TODO: Initialize to an appropriate value
  786. SshClient target = new SshClient(host, username, password);
  787. Assert.Inconclusive("TODO: Implement code to verify target");
  788. }
  789. /// <summary>
  790. ///A test for SshClient Constructor
  791. ///</summary>
  792. [TestMethod]
  793. [Ignore] // placeholder for actual test
  794. public void SshClientConstructorTest3()
  795. {
  796. string host = string.Empty; // TODO: Initialize to an appropriate value
  797. int port = 0; // TODO: Initialize to an appropriate value
  798. string username = string.Empty; // TODO: Initialize to an appropriate value
  799. string password = string.Empty; // TODO: Initialize to an appropriate value
  800. SshClient target = new SshClient(host, port, username, password);
  801. Assert.Inconclusive("TODO: Implement code to verify target");
  802. }
  803. /// <summary>
  804. ///A test for SshClient Constructor
  805. ///</summary>
  806. [TestMethod]
  807. [Ignore] // placeholder for actual test
  808. public void SshClientConstructorTest4()
  809. {
  810. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  811. SshClient target = new SshClient(connectionInfo);
  812. Assert.Inconclusive("TODO: Implement code to verify target");
  813. }
  814. /// <summary>
  815. ///A test for RemoveForwardedPort
  816. ///</summary>
  817. [TestMethod]
  818. [Ignore] // placeholder for actual test
  819. public void RemoveForwardedPortTest()
  820. {
  821. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  822. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  823. ForwardedPort port = null; // TODO: Initialize to an appropriate value
  824. target.RemoveForwardedPort(port);
  825. Assert.Inconclusive("A method that does not return a value cannot be verified.");
  826. }
  827. [TestMethod]
  828. public void RunCommand_CommandText_NeverConnected()
  829. {
  830. using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
  831. {
  832. try
  833. {
  834. client.RunCommand("ls");
  835. Assert.Fail();
  836. }
  837. catch (SshConnectionException ex)
  838. {
  839. Assert.IsNull(ex.InnerException);
  840. Assert.AreEqual("Client not connected.", ex.Message);
  841. }
  842. }
  843. }
  844. /// <summary>
  845. ///A test for RunCommand
  846. ///</summary>
  847. [TestMethod]
  848. [Ignore] // placeholder for actual test
  849. public void RunCommandTest()
  850. {
  851. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  852. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  853. string commandText = string.Empty; // TODO: Initialize to an appropriate value
  854. SshCommand expected = null; // TODO: Initialize to an appropriate value
  855. SshCommand actual;
  856. actual = target.RunCommand(commandText);
  857. Assert.AreEqual(expected, actual);
  858. Assert.Inconclusive("Verify the correctness of this test method.");
  859. }
  860. /// <summary>
  861. ///A test for ForwardedPorts
  862. ///</summary>
  863. [TestMethod]
  864. [Ignore] // placeholder for actual test
  865. public void ForwardedPortsTest()
  866. {
  867. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  868. SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
  869. IEnumerable<ForwardedPort> actual;
  870. actual = target.ForwardedPorts;
  871. Assert.Inconclusive("Verify the correctness of this test method.");
  872. }
  873. }
  874. }