MembershipProviderTest.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. //
  2. // MembershipProviderTest.cs
  3. // - Unit tests for System.Web.Security.MembershipProvider
  4. //
  5. // Author:
  6. // Sebastien Pouliot <[email protected]>
  7. //
  8. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.Configuration.Provider;
  32. using System.Security.Principal;
  33. using System.Web.Security;
  34. using NUnit.Framework;
  35. namespace MonoTests.System.Web.Security {
  36. class TestMembershipProvider : MembershipProvider {
  37. public override string ApplicationName {
  38. get {
  39. throw new Exception ("The method or operation is not implemented.");
  40. }
  41. set {
  42. throw new Exception ("The method or operation is not implemented.");
  43. }
  44. }
  45. public override bool ChangePassword (string username, string oldPassword, string newPassword)
  46. {
  47. throw new Exception ("The method or operation is not implemented.");
  48. }
  49. public override bool ChangePasswordQuestionAndAnswer (string username, string password, string newPasswordQuestion, string newPasswordAnswer)
  50. {
  51. throw new Exception ("The method or operation is not implemented.");
  52. }
  53. public override MembershipUser CreateUser (string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
  54. {
  55. throw new Exception ("The method or operation is not implemented.");
  56. }
  57. public override bool DeleteUser (string username, bool deleteAllRelatedData)
  58. {
  59. throw new Exception ("The method or operation is not implemented.");
  60. }
  61. public override bool EnablePasswordReset {
  62. get { throw new Exception ("The method or operation is not implemented."); }
  63. }
  64. public override bool EnablePasswordRetrieval {
  65. get { throw new Exception ("The method or operation is not implemented."); }
  66. }
  67. public override MembershipUserCollection FindUsersByEmail (string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
  68. {
  69. throw new Exception ("The method or operation is not implemented.");
  70. }
  71. public override MembershipUserCollection FindUsersByName (string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
  72. {
  73. throw new Exception ("The method or operation is not implemented.");
  74. }
  75. public override MembershipUserCollection GetAllUsers (int pageIndex, int pageSize, out int totalRecords)
  76. {
  77. throw new Exception ("The method or operation is not implemented.");
  78. }
  79. public override int GetNumberOfUsersOnline ()
  80. {
  81. throw new Exception ("The method or operation is not implemented.");
  82. }
  83. public override string GetPassword (string username, string answer)
  84. {
  85. throw new Exception ("The method or operation is not implemented.");
  86. }
  87. public override MembershipUser GetUser (string username, bool userIsOnline)
  88. {
  89. throw new Exception ("The method or operation is not implemented.");
  90. }
  91. public override MembershipUser GetUser (object providerUserKey, bool userIsOnline)
  92. {
  93. throw new Exception ("The method or operation is not implemented.");
  94. }
  95. public override string GetUserNameByEmail (string email)
  96. {
  97. throw new Exception ("The method or operation is not implemented.");
  98. }
  99. public override int MaxInvalidPasswordAttempts
  100. {
  101. get { throw new Exception ("The method or operation is not implemented."); }
  102. }
  103. public override int MinRequiredNonAlphanumericCharacters
  104. {
  105. get { throw new Exception ("The method or operation is not implemented."); }
  106. }
  107. public override int MinRequiredPasswordLength
  108. {
  109. get { throw new Exception ("The method or operation is not implemented."); }
  110. }
  111. public override int PasswordAttemptWindow
  112. {
  113. get { throw new Exception ("The method or operation is not implemented."); }
  114. }
  115. public override MembershipPasswordFormat PasswordFormat
  116. {
  117. get { throw new Exception ("The method or operation is not implemented."); }
  118. }
  119. public override string PasswordStrengthRegularExpression
  120. {
  121. get { throw new Exception ("The method or operation is not implemented."); }
  122. }
  123. public override bool RequiresQuestionAndAnswer
  124. {
  125. get { throw new Exception ("The method or operation is not implemented."); }
  126. }
  127. public override bool RequiresUniqueEmail
  128. {
  129. get { throw new Exception ("The method or operation is not implemented."); }
  130. }
  131. public override string ResetPassword (string username, string answer)
  132. {
  133. throw new Exception ("The method or operation is not implemented.");
  134. }
  135. public override bool UnlockUser (string userName)
  136. {
  137. throw new Exception ("The method or operation is not implemented.");
  138. }
  139. public override void UpdateUser (MembershipUser user)
  140. {
  141. throw new Exception ("The method or operation is not implemented.");
  142. }
  143. public override bool ValidateUser (string username, string password)
  144. {
  145. throw new Exception ("The method or operation is not implemented.");
  146. }
  147. public byte[] Decrypt (byte[] data)
  148. {
  149. return base.DecryptPassword (data);
  150. }
  151. public byte[] Encrypt (byte[] data)
  152. {
  153. return base.EncryptPassword (data);
  154. }
  155. }
  156. [TestFixture]
  157. public class MembershipProviderTest {
  158. [Test]
  159. [Category ("NotWorking")] // Not implemented
  160. [ExpectedException (typeof (ProviderException))]
  161. public void EncryptPassword ()
  162. {
  163. TestMembershipProvider mp = new TestMembershipProvider ();
  164. mp.Encrypt (null);
  165. }
  166. }
  167. }
  168. #endif