public void TestAbort() { var method = new LoginAuthMethod(); var usernameReset = false; var passwordReset = false; Transaction.SetPropertyStringObjectBoolean = (s, v, p) => { switch (s) { case "Username": usernameReset = v == null && p; break; case "Password": passwordReset = v == null && p; break; default: throw new InvalidOperationException("Invalid name."); } }; method.Abort(Transaction); Assert.True(usernameReset); Assert.True(passwordReset); }
public void TestProcessInitial() { var method = new LoginAuthMethod(); string challenge; var result = method.ProcessResponse(Transaction, null, out challenge); Assert.True(result); Assert.Equal("Username:", challenge); }
public void TestProcessPassword() { const string expectedPassword = "******"; var method = new LoginAuthMethod(); Transaction.HasPropertyString = s => { switch (s) { case "Username": return(true); default: throw new InvalidOperationException("Invalid name."); } }; string password = null; var permanent = false; Transaction.SetPropertyStringObjectBoolean = (s, v, p) => { switch (s) { case "Password": password = (string)v; permanent = p; break; default: throw new InvalidOperationException("Invalid name."); } }; string challenge; var result = method.ProcessResponse(Transaction, expectedPassword, out challenge); Assert.True(result); Assert.Null(challenge); Assert.Equal(expectedPassword, password); Assert.True(permanent); }