コード例 #1
0
        public void LoginSystemUserResultsInPricipalIdentityBeingSet()
        {
            ILoginCriteria user = CreateSystemUser();

            IsolateGetIdentity();
            GenFormPrincipal.Login(user);

            Assert.IsNotNull(GenFormPrincipal.GetPrincipal().Identity, "Principal identity should be set");
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        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();
        }
コード例 #4
0
 public static bool IsLoggedIn(string userName)
 {
     return(GenFormPrincipal.GetPrincipal().Identity.Name == userName &&
            GenFormPrincipal.GetPrincipal().IsLoggedIn());
 }
コード例 #5
0
        public void IsLoggedInReturnsFalseForAnonymousUser()
        {
            var principal = GenFormPrincipal.GetPrincipal();

            Assert.IsFalse(principal.IsLoggedIn(), "Principal that is not logged in should return false");
        }