Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/10 15:29:38 (14 years ago)
Author:
bfarka
Message:

all needed methods of membershipprovier are implemented and all testes are passing (#1046)

Location:
branches/HeuristicLab.Services.Authentication Prototype
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs

    r4014 r4018  
    3737
    3838    public override bool EnablePasswordReset {
    39       get { return pEnablePasswordReset; }
     39      get { return false; }
    4040    }
    4141
    4242    public override bool EnablePasswordRetrieval {
    43       get { return pEnablePasswordRetrieval; }
     43      get { return false; }
    4444    }
    4545
     
    199199          u.PasswordAnswer = newPasswordAnswer;
    200200          u.PasswordQuestion = newPasswordQuestion;
    201          
     201
    202202          db.SubmitChanges();
    203          
     203
    204204          return true;
    205205        }
     
    327327        return PagedCollection(users, pageIndex, pageSize, out totalRecords);
    328328      }
    329      
     329
    330330    }
    331331
     
    345345        return PagedCollection(users, pageIndex, pageSize, out totalRecords);
    346346      }
    347      
     347
    348348    }
    349349
     
    415415    public override string GetUserNameByEmail(string email) {
    416416      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
    417         HeuristicLabUser u =
    418           db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.Email == email);
    419         if (u != null)
     417
     418        if (db.HeuristicLabUsers.Count(x => x.Email == email) > 0) {
     419
     420          HeuristicLabUser u =
     421            db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.Email == email);
     422
    420423          return u.UserName;
    421         else
    422           return null;
     424        }
     425        return null;
    423426      }
    424427    }
     
    473476
    474477    public override void UpdateUser(MembershipUser user) {
    475       throw new NotImplementedException();
     478      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
     479        if (user != null && user.ProviderUserKey != null && db.HeuristicLabUsers.Count(x => x.ID == (long)user.ProviderUserKey) > 0) {
     480          HeuristicLabUser u = db.HeuristicLabUsers.Single(x => x.ID == (long)user.ProviderUserKey);
     481          u.UserName = user.UserName;
     482          u.Comment = user.Comment;
     483          u.Email = user.Email;
     484          u.Locked = user.IsLockedOut;
     485          db.SubmitChanges();
     486
     487        }
     488      }
    476489    }
    477490    /// <summary>
  • branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs

    r4009 r4018  
    7070      bool actual;
    7171      actual = target.RequiresUniqueEmail;
    72       Assert.Inconclusive("Verify the correctness of this test method.");
     72      Assert.IsTrue(actual);
    7373    }
    7474
     
    9292      string actual;
    9393      actual = target.PasswordStrengthRegularExpression;
    94       Assert.Inconclusive("Verify the correctness of this test method.");
    95     }
    96 
    97     /// <summary>
    98     ///A test for PasswordFormat
    99     ///</summary>
    100     [TestMethod()]
    101     public void PasswordFormatTest() {
    102       MembershipProvider target = Membership.Provider;
    103       MembershipPasswordFormat actual;
    104       actual = target.PasswordFormat;
    105       Assert.Inconclusive("Verify the correctness of this test method.");
    106     }
    107 
    108     /// <summary>
    109     ///A test for PasswordAttemptWindow
    110     ///</summary>
    111     [TestMethod()]
    112     public void PasswordAttemptWindowTest() {
    113       MembershipProvider target = Membership.Provider;  // TODO: Initialize to an appropriate value
    114       int actual;
    115       actual = target.PasswordAttemptWindow;
    116       Assert.Inconclusive("Verify the correctness of this test method.");
    117     }
     94      Assert.AreEqual(actual, String.Empty);
     95    }
     96
     97
     98
     99 
    118100
    119101    /// <summary>
     
    187169      bool actual;
    188170      actual = target.EnablePasswordRetrieval;
    189       Assert.Inconclusive("Verify the correctness of this test method.");
     171      Assert.IsFalse(actual);
    190172    }
    191173
     
    198180      bool actual;
    199181      actual = target.EnablePasswordReset;
    200       Assert.Inconclusive("Verify the correctness of this test method.");
    201     }
    202 
    203     /// <summary>
    204     ///A test for ApplicationName
    205     ///</summary>
    206     [TestMethod()]
    207     public void ApplicationNameTest() {
    208       MembershipProvider target = Membership.Provider;
    209       string expected = string.Empty; // TODO: Initialize to an appropriate value
    210       string actual;
    211       target.ApplicationName = expected;
    212       actual = target.ApplicationName;
    213       Assert.AreEqual(expected, actual);
    214       Assert.Inconclusive("Verify the correctness of this test method.");
     182      Assert.IsFalse(actual);
    215183    }
    216184
     
    255223    [TestMethod()]
    256224    public void UpdateUserTest() {
    257       MembershipProvider target = Membership.Provider; // TODO: Initialize to an appropriate value
    258       MembershipUser user = null; // TODO: Initialize to an appropriate value
     225      MembershipProvider target = Membership.Provider;
     226      MembershipCreateStatus status;
     227      MembershipUser user = null;
     228      target.CreateUser("testUser", "myPassword", "mail", "question", "answer", true, null, out status);
     229      Assert.AreEqual(MembershipCreateStatus.Success, status);
     230      user =target.GetUser("testUser", true);
     231      Assert.IsNotNull(user);
     232      user.Email = "newMail";
    259233      target.UpdateUser(user);
    260       Assert.Inconclusive("A method that does not return a value cannot be verified.");
     234      user = target.GetUser("testUser", true);
     235      Assert.AreEqual(user.Email, "newMail");
    261236    }
    262237
     
    282257    [TestMethod()]
    283258    public void ResetPasswordTest() {
    284       MembershipProvider target = Membership.Provider; // TODO: Initialize to an appropriate value
    285       string username = string.Empty; // TODO: Initialize to an appropriate value
    286       string answer = string.Empty; // TODO: Initialize to an appropriate value
    287       string expected = string.Empty; // TODO: Initialize to an appropriate value
     259      MembershipProvider target = Membership.Provider;
     260      string username = string.Empty;
     261      string answer = string.Empty;
     262      string expected = string.Empty;
    288263      string actual;
    289       actual = target.ResetPassword(username, answer);
    290       Assert.AreEqual(expected, actual);
    291       Assert.Inconclusive("Verify the correctness of this test method.");
     264      try {
     265        target.ResetPassword("foo", "foo");
     266      }
     267      catch (NotSupportedException) {
     268      //should be thrown
     269      }
     270     
    292271    }
    293272
     
    302281      string actual;
    303282      actual = target.GetUserNameByEmail(email);
    304       Assert.AreEqual(expected, actual);
    305       Assert.Inconclusive("Verify the correctness of this test method.");
     283      Assert.IsNull(actual);
     284      MembershipCreateStatus status;
     285      target.CreateUser("testuser", "mySecret", "testmail", "question", "answer", true, null, out status);
     286      Assert.AreEqual(status, MembershipCreateStatus.Success);
     287      Assert.AreEqual(target.GetUserNameByEmail("testmail"), "testuser");
    306288    }
    307289
     
    334316      string expected = string.Empty; // TODO: Initialize to an appropriate value
    335317      string actual;
    336       actual = target.GetPassword(username, answer);
    337       Assert.AreEqual(expected, actual);
    338       Assert.Inconclusive("Verify the correctness of this test method.");
     318      try {
     319        actual = target.GetPassword(username, answer);
     320        Assert.Fail();
     321      }
     322      catch (NotSupportedException) {
     323        //swallow because expected
     324      }
     325     
    339326    }
    340327
Note: See TracChangeset for help on using the changeset viewer.