internal static IUserBasic CreateUser(IApplicationSettings applicationSettings, IApplication application , DummyDataManager dummyDataManager, WorkmateRoleProvider roleProvider , WorkmateMembershipProvider membershipProvider, string password, AccountStatus accountStatus) { DummyUser user = dummyDataManager.GetDummy(); string firstName = user.Firstname; string lastName = user.Surname; TimeZoneInfo timeZoneInfo = TimeZoneUtility.GetGMTStandardTimeZone(); IUserBasic userBasic = new UserBasic(user.Email, user.Email, 1) { AccountStatus = accountStatus, TimeZoneInfo = timeZoneInfo }; Guid uniqueId; List <UserRole> userRoles = new List <UserRole>() { UserRole.SystemAdministrator, UserRole.Registered }; UserCreateStatus userCreateStatus = membershipProvider.CreateUser(ref userBasic, password, userRoles, UserNameDisplayMode.FullName , firstName, lastName , Workmate.Components.Contracts.Membership.Gender.Male , out uniqueId, application.ApplicationId).Status; Assert.AreEqual(UserCreateStatus.Success, userCreateStatus); Assert.Greater(userBasic.UserId, 0); return(membershipProvider.GetUserBasic(userBasic.UserId, false)); }
private void Test_UserLocking_Valid(AccountStatus accountStatus) { IMembershipSettings membershipSettings = Workmate.Components.InstanceContainer.MembershipSettings; membershipSettings.MaxInvalidPasswordAttempts = 3; IApplicationSettings applicationSettings = Workmate.Components.InstanceContainer.ApplicationSettings; WorkmateRoleProvider roleProvider = new WorkmateRoleProvider(); WorkmateMembershipProvider membershipProvider = new WorkmateMembershipProvider(); string password = "******"; IUserBasic userBasic = CreateUser(applicationSettings, this.Application, this.DummyDataManager, roleProvider, membershipProvider, password, accountStatus); IUserBasic validatedUser; ValidateUserStatus validateUserStatus; for (int i = 0; i < membershipSettings.MaxInvalidPasswordAttempts; i++) { validateUserStatus = membershipProvider.ValidateUser(this.Application.ApplicationId, userBasic.UserName, "465", out validatedUser); Assert.AreEqual(ValidateUserStatus.WrongPassword, validateUserStatus); } // by the next attempt we expect the user to be locked validateUserStatus = membershipProvider.ValidateUser(this.Application.ApplicationId, userBasic.UserName, "123", out validatedUser); Assert.AreEqual(ValidateUserStatus.UserIsLockedOut, validateUserStatus); // test unlock Assert.IsTrue(membershipProvider.UnlockUser(userBasic.UserId)); userBasic = membershipProvider.GetUserBasic(userBasic.UserId, false); Assert.AreEqual(accountStatus, userBasic.AccountStatus); }
public void Test_CreateUser() { IApplicationSettings applicationSettings = Workmate.Components.InstanceContainer.ApplicationSettings; WorkmateRoleProvider roleProvider = new WorkmateRoleProvider(); WorkmateMembershipProvider membershipProvider = new WorkmateMembershipProvider(); DummyUser user = this.DummyDataManager.GetDummy(); string firstName = user.Firstname; string lastName = user.Surname; string password = "******"; AccountStatus accountStatus = AccountStatus.Valid; TimeZoneInfo timeZoneInfo = TimeZoneUtility.GetGMTStandardTimeZone(); IUserBasic userBasic = new UserBasic(user.Email, user.Email, 1) { AccountStatus = accountStatus, TimeZoneInfo = timeZoneInfo }; Guid uniqueId; List <UserRole> userRoles = new List <UserRole>() { UserRole.SystemAdministrator, UserRole.Registered }; UserCreateStatus userCreateStatus = membershipProvider.CreateUser(ref userBasic, password, userRoles, UserNameDisplayMode.FullName , firstName, lastName , DebugUtility.GetRandomEnum <Workmate.Components.Contracts.Membership.Gender>(this.Random) , out uniqueId, this.Application.ApplicationId).Status; Assert.AreEqual(UserCreateStatus.Success, userCreateStatus); Assert.Greater(userBasic.UserId, 0); userBasic = membershipProvider.GetUserBasic(userBasic.UserId, false); Assert.AreEqual(user.Email, userBasic.UserName); Assert.AreEqual(user.Email, userBasic.Email); Assert.AreEqual(accountStatus, userBasic.AccountStatus); Assert.AreEqual(timeZoneInfo.Id, userBasic.TimeZoneInfoId); }
internal static ProfileImage CreateProfileImage(IDataStore dataStore, int applicationId, IUserBasic fileOwner, Random random) { ProfileImageManager manager = new ProfileImageManager(dataStore); ProfileImage file = new ProfileImage(applicationId, fileOwner); ASCIIEncoding encoding = new ASCIIEncoding(); string contentString = "Some String " + random.Next(1000000, 10000000); file.Height = random.Next(10, 1000); file.Width = random.Next(10, 1000); file.Content = encoding.GetBytes(contentString); file.ContentSize = file.Content.Length; file.ContentType = "TEXT " + random.Next(1000, 10000); file.FriendlyFileName = "Some Name " + random.Next(1000000, 10000000); file.IsTemporary = false; BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.CreateTemporaryImage(file); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); int newFileId; Assert.IsTrue(manager.AssignTemporaryProfileImageToUser(file.ImageId, out newFileId)); ProfileImage dsFile = manager.GetProfileImage(newFileId); Assert.IsNotNull(dsFile); Assert.AreEqual(contentString, encoding.GetString(dsFile.Content)); WorkmateMembershipProvider membershipProvider = new WorkmateMembershipProvider(); fileOwner = membershipProvider.GetUserBasic(fileOwner.UserId, false); Assert.AreEqual(fileOwner.ProfileImageId, newFileId); return(dsFile); }