KeyHostAlgorithmTest.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Security;
  3. using Renci.SshNet.Tests.Common;
  4. using Renci.SshNet.Tests.Properties;
  5. namespace Renci.SshNet.Tests.Classes.Security
  6. {
  7. /// <summary>
  8. /// Implements key support for host algorithm.
  9. /// </summary>
  10. [TestClass]
  11. public class KeyHostAlgorithmTest : TestBase
  12. {
  13. [TestMethod]
  14. [TestCategory("integration")]
  15. public void Test_HostKey_SshRsa_Connection()
  16. {
  17. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
  18. connectionInfo.HostKeyAlgorithms.Clear();
  19. connectionInfo.HostKeyAlgorithms.Add("ssh-rsa", (data) => { return new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data); });
  20. using (var client = new SshClient(connectionInfo))
  21. {
  22. client.Connect();
  23. client.Disconnect();
  24. }
  25. }
  26. [TestMethod]
  27. [TestCategory("integration")]
  28. public void Test_HostKey_SshDss_Connection()
  29. {
  30. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
  31. connectionInfo.HostKeyAlgorithms.Clear();
  32. connectionInfo.HostKeyAlgorithms.Add("ssh-dss", (data) => { return new KeyHostAlgorithm("ssh-dss", new DsaKey(), data); });
  33. using (var client = new SshClient(connectionInfo))
  34. {
  35. client.Connect();
  36. client.Disconnect();
  37. }
  38. }
  39. /// <summary>
  40. ///A test for KeyHostAlgorithm Constructor
  41. ///</summary>
  42. [TestMethod]
  43. [Ignore] // placeholder for actual test
  44. public void KeyHostAlgorithmConstructorTest()
  45. {
  46. string name = string.Empty; // TODO: Initialize to an appropriate value
  47. Key key = null; // TODO: Initialize to an appropriate value
  48. KeyHostAlgorithm target = new KeyHostAlgorithm(name, key);
  49. Assert.Inconclusive("TODO: Implement code to verify target");
  50. }
  51. /// <summary>
  52. ///A test for KeyHostAlgorithm Constructor
  53. ///</summary>
  54. [TestMethod]
  55. [Ignore] // placeholder for actual test
  56. public void KeyHostAlgorithmConstructorTest1()
  57. {
  58. string name = string.Empty; // TODO: Initialize to an appropriate value
  59. Key key = null; // TODO: Initialize to an appropriate value
  60. byte[] data = null; // TODO: Initialize to an appropriate value
  61. KeyHostAlgorithm target = new KeyHostAlgorithm(name, key, data);
  62. Assert.Inconclusive("TODO: Implement code to verify target");
  63. }
  64. /// <summary>
  65. ///A test for Sign
  66. ///</summary>
  67. [TestMethod]
  68. [Ignore] // placeholder for actual test
  69. public void SignTest()
  70. {
  71. string name = string.Empty; // TODO: Initialize to an appropriate value
  72. Key key = null; // TODO: Initialize to an appropriate value
  73. KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
  74. byte[] data = null; // TODO: Initialize to an appropriate value
  75. byte[] expected = null; // TODO: Initialize to an appropriate value
  76. byte[] actual;
  77. actual = target.Sign(data);
  78. Assert.AreEqual(expected, actual);
  79. Assert.Inconclusive("Verify the correctness of this test method.");
  80. }
  81. /// <summary>
  82. ///A test for VerifySignature
  83. ///</summary>
  84. [TestMethod]
  85. [Ignore] // placeholder for actual test
  86. public void VerifySignatureTest()
  87. {
  88. string name = string.Empty; // TODO: Initialize to an appropriate value
  89. Key key = null; // TODO: Initialize to an appropriate value
  90. KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
  91. byte[] data = null; // TODO: Initialize to an appropriate value
  92. byte[] signature = null; // TODO: Initialize to an appropriate value
  93. bool expected = false; // TODO: Initialize to an appropriate value
  94. bool actual;
  95. actual = target.VerifySignature(data, signature);
  96. Assert.AreEqual(expected, actual);
  97. Assert.Inconclusive("Verify the correctness of this test method.");
  98. }
  99. /// <summary>
  100. ///A test for Data
  101. ///</summary>
  102. [TestMethod]
  103. [Ignore] // placeholder for actual test
  104. public void DataTest()
  105. {
  106. string name = string.Empty; // TODO: Initialize to an appropriate value
  107. Key key = null; // TODO: Initialize to an appropriate value
  108. KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
  109. byte[] actual;
  110. actual = target.Data;
  111. Assert.Inconclusive("Verify the correctness of this test method.");
  112. }
  113. }
  114. }