public void LoginWithAsSystemUserWithWrongPasswordShouldReturnFalse() { var user = (LoginCriteria)CreateSystemUser(); user.Password = "******"; GenFormPrincipal.Login(user); Assert.IsFalse(GenFormPrincipal.GetPrincipal().IsLoggedIn(), "System user should not be able to login with password bar"); }
public void LoginSystemUserResultsInPricipalIdentityBeingSet() { ILoginCriteria user = CreateSystemUser(); IsolateGetIdentity(); GenFormPrincipal.Login(user); Assert.IsNotNull(GenFormPrincipal.GetPrincipal().Identity, "Principal identity should be set"); }
public JObject GenFormLogOut(string user) { Session.Remove("user"); GenFormPrincipal.Logout(); var ser = new JsonSerializer(); JObject json = JObject.FromObject(new { success = true }, ser); return(json); }
public static void Login(UserLoginDto dto) { EnvironmentServices.SetEnvironment(dto.Environment); var criteria = new LoginCriteria { UserName = dto.UserName, Password = dto.Password }; GenFormPrincipal.Login(criteria); }
public void Init() { _principal = Isolate.Fake.Instance <GenFormPrincipal>(); _identity = Isolate.Fake.Instance <IGenFormIdentity>(); Isolate.WhenCalled(() => _principal.Identity).WillReturn(_identity); Isolate.WhenCalled(() => GenFormPrincipal.GetPrincipal()).WillReturn(_principal); Isolate.WhenCalled(() => GenFormPrincipal.Login(_criteria)).IgnoreCall(); Isolate.WhenCalled(() => EnvironmentServices.SetEnvironment(string.Empty)).IgnoreCall(); _dto = GetAdminUserDto(); }
public void UseGenFormPrincipalToLogin() { try { LoginServices.Login(_dto); _criteria = new LoginCriteria { UserName = _dto.UserName, Password = _dto.Password }; Isolate.Verify.WasCalledWithAnyArguments(() => GenFormPrincipal.Login(_criteria)); } catch (Exception e) { Assert.Fail(e.ToString()); } }
public void LoginCallsSetPrincipalWithIdentity() { var user = CreateSystemUser(); var identity = CreateFakeGenFormIdentity(); Isolate.WhenCalled(() => GenFormIdentity.GetIdentity(user)).WillReturn(identity); Isolate.NonPublic.WhenCalled(typeof(GenFormPrincipal), "SetPrincipal").CallOriginal(); try { GenFormPrincipal.Login(user); Isolate.Verify.NonPublic.WasCalled(typeof(GenFormPrincipal), "SetPrincipal").WithArguments(identity); } catch (VerifyException e) { Assert.Fail("SetPrincipal was not called using a fake identity: " + e); } }
public static bool IsLoggedIn(string userName) { return(GenFormPrincipal.GetPrincipal().Identity.Name == userName && GenFormPrincipal.GetPrincipal().IsLoggedIn()); }
public void IsLoggedInReturnsFalseForAnonymousUser() { var principal = GenFormPrincipal.GetPrincipal(); Assert.IsFalse(principal.IsLoggedIn(), "Principal that is not logged in should return false"); }