public void ChangePasswordWithWrongPassword() { ExternalFileSecurityManager manager = new ExternalFileSecurityManager(); string session = InitialiseManagerAndLogin(manager); Assert.That(delegate { manager.ChangePassword(session, "wrong", "whoami"); }, Throws.TypeOf<SecurityException>()); }
public void ResetPasswordForUnknownSession() { ExternalFileSecurityManager manager = new ExternalFileSecurityManager(); string session = InitialiseManagerAndLogin(manager); Assert.That(delegate { manager.ResetPassword("unknown", "johndoe", "whoami"); }, Throws.TypeOf<SessionInvalidException>()); }
public void ResetPasswordWithValidDetails() { ExternalFileSecurityManager manager = new ExternalFileSecurityManager(); string session = InitialiseManagerAndLogin(manager, "janedoe"); manager.ResetPassword(session, "johndoe", "whoami"); string actual = TrimWhitespace(File.ReadAllText(GenerateUsersFileName())); string expected = GenerateUserFileContents("whoami"); Assert.AreEqual(expected, actual, "File contents do not match"); }
public void ManagerLoadsUsers() { ExternalFileSecurityManager manager = new ExternalFileSecurityManager(); manager.Files = new string[] { GenerateUsersFile() }; manager.Initialise(); IAuthentication actualUser = manager.RetrieveUser("johndoe"); Assert.IsNotNull(actualUser, "User not found"); }
public void ResetPasswordWithoutPermission() { ExternalFileSecurityManager manager = new ExternalFileSecurityManager(); string session = InitialiseManagerAndLogin(manager); Assert.That(delegate { manager.ResetPassword(session, "johndoe", "whoami"); }, Throws.TypeOf<PermissionDeniedException>()); }
public void CanLogin() { ExternalFileSecurityManager manager = new ExternalFileSecurityManager(); InitialiseManagerAndLogin(manager); }
private string InitialiseManagerAndLogin(ExternalFileSecurityManager manager, string userName) { manager.Files = new string[] { GenerateUsersFile() }; manager.Initialise(); LoginRequest credentials = new LoginRequest(userName); credentials.AddCredential(LoginRequest.PasswordCredential, "whoareyou"); string session = manager.Login(credentials); Assert.IsFalse(string.IsNullOrEmpty(session), "Session has not been allocated"); return session; }
private string InitialiseManagerAndLogin(ExternalFileSecurityManager manager) { return InitialiseManagerAndLogin(manager, "johndoe"); }