AuthenticationMethodDerivativesTest.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.VisualStudio.TestTools.UnitTesting;
  6. using Renci.SshNet.Common;
  7. namespace Renci.SshNet.Tests
  8. {
  9. [TestClass]
  10. public class AuthenticationMethodDerivativesTest
  11. {
  12. [TestMethod]
  13. [TestCategory("AuthenticationMethod")]
  14. [Owner("Kenneth_aa")]
  15. [Description("KeyboardInteractiveAuthenticationMethod: Pass null as username.")]
  16. [ExpectedException(typeof(ArgumentException))]
  17. public void Keyboard_Test_Pass_Null()
  18. {
  19. new KeyboardInteractiveAuthenticationMethod(null);
  20. }
  21. [TestMethod]
  22. [TestCategory("AuthenticationMethod")]
  23. [Owner("Kenneth_aa")]
  24. [Description("KeyboardInteractiveAuthenticationMethod: Pass String.Empty as username.")]
  25. [ExpectedException(typeof(ArgumentException))]
  26. public void Keyboard_Test_Pass_Whitespace()
  27. {
  28. new KeyboardInteractiveAuthenticationMethod(string.Empty);
  29. }
  30. [TestMethod]
  31. [TestCategory("AuthenticationMethod")]
  32. [Owner("Kenneth_aa")]
  33. [Description("NoneAuthenticationMethod: Pass null as username.")]
  34. [ExpectedException(typeof(ArgumentException))]
  35. public void None_Test_Pass_Null()
  36. {
  37. new NoneAuthenticationMethod(null);
  38. }
  39. [TestMethod]
  40. [TestCategory("AuthenticationMethod")]
  41. [Owner("Kenneth_aa")]
  42. [Description("NoneAuthenticationMethod: Pass String.Empty as username.")]
  43. [ExpectedException(typeof(ArgumentException))]
  44. public void None_Test_Pass_Whitespace()
  45. {
  46. new NoneAuthenticationMethod(string.Empty);
  47. }
  48. [TestMethod]
  49. [TestCategory("AuthenticationMethod")]
  50. [Owner("Kenneth_aa")]
  51. [Description("PasswordAuthenticationMethod: Pass null as username, \"valid\" as password.")]
  52. [ExpectedException(typeof(ArgumentException))]
  53. public void Password_Test_Pass_Null_Username()
  54. {
  55. new PasswordAuthenticationMethod(null, "valid");
  56. }
  57. [TestMethod]
  58. [TestCategory("AuthenticationMethod")]
  59. [Owner("Kenneth_aa")]
  60. [Description("PasswordAuthenticationMethod: Pass \"valid\" as username, null as password.")]
  61. [ExpectedException(typeof(ArgumentNullException))]
  62. public void Password_Test_Pass_Null_Password()
  63. {
  64. new PasswordAuthenticationMethod("valid", (string)null);
  65. }
  66. [TestMethod]
  67. [TestCategory("AuthenticationMethod")]
  68. [Owner("Kenneth_aa")]
  69. [Description("PasswordAuthenticationMethod: Pass \"valid\" as username, \"valid\" as password.")]
  70. public void Password_Test_Pass_Valid_Username_And_Password()
  71. {
  72. new PasswordAuthenticationMethod("valid", "valid");
  73. }
  74. [TestMethod]
  75. [TestCategory("AuthenticationMethod")]
  76. [Owner("Kenneth_aa")]
  77. [Description("PasswordAuthenticationMethod: Pass String.Empty as username, \"valid\" as password.")]
  78. [ExpectedException(typeof(ArgumentException))]
  79. public void Password_Test_Pass_Whitespace()
  80. {
  81. new PasswordAuthenticationMethod(string.Empty, "valid");
  82. }
  83. [TestMethod]
  84. [TestCategory("AuthenticationMethod")]
  85. [Owner("Kenneth_aa")]
  86. [Description("PasswordAuthenticationMethod: Pass \"valid\" as username, String.Empty as password.")]
  87. public void Password_Test_Pass_Valid()
  88. {
  89. new PasswordAuthenticationMethod("valid", string.Empty);
  90. }
  91. [TestMethod]
  92. [TestCategory("AuthenticationMethod")]
  93. [Owner("Kenneth_aa")]
  94. [Description("PrivateKeyAuthenticationMethod: Pass null as username, null as password.")]
  95. [ExpectedException(typeof(ArgumentException))]
  96. public void PrivateKey_Test_Pass_Null()
  97. {
  98. new PrivateKeyAuthenticationMethod(null, null);
  99. }
  100. [TestMethod]
  101. [TestCategory("AuthenticationMethod")]
  102. [Owner("Kenneth_aa")]
  103. [Description("PrivateKeyAuthenticationMethod: Pass String.Empty as username, null as password.")]
  104. [ExpectedException(typeof(ArgumentException))]
  105. public void PrivateKey_Test_Pass_Whitespace()
  106. {
  107. new PrivateKeyAuthenticationMethod(string.Empty, null);
  108. }
  109. }
  110. }