コード例 #1
0
 public void SetInvalidMembershipPrincipal()
 {
     SilverlightPrincipal.Logout();
     SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("invalidusername", SilverlightPrincipal.VALID_TEST_PWD);
     Assert.IsNotNull(Csla.ApplicationContext.User);
     Assert.AreEqual(false, Csla.ApplicationContext.User.Identity.IsAuthenticated);
     Assert.AreEqual("", Csla.ApplicationContext.User.Identity.Name);
     Assert.AreEqual(false, Csla.ApplicationContext.User.IsInRole(AdminRoleName));
 }
コード例 #2
0
 public void SetMembershipPrincipalDataPortal()
 {
     SilverlightPrincipal.Logout();
     SilverlightPrincipal.LoginUsingMembershipProviderDataPortal(SilverlightPrincipal.VALID_TEST_UID, SilverlightPrincipal.VALID_TEST_PWD);
     Assert.IsNotNull(Csla.ApplicationContext.User);
     Assert.AreEqual(true, Csla.ApplicationContext.User.Identity.IsAuthenticated);
     Assert.AreEqual(SilverlightPrincipal.VALID_TEST_UID, Csla.ApplicationContext.User.Identity.Name);
     Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole("User Role"));
 }
コード例 #3
0
ファイル: RolesTests.cs プロジェクト: RobRobertsCE/MVVM
        public void WebServer_AuthenticatedUserLoginBelongsToUserRole()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderWebServer("user", "1234");

            context.Assert.IsTrue(ApplicationContext.User.IsInRole("User Role"));

            context.Assert.Success();

            context.Complete();
        }
コード例 #4
0
        public void AuthorizedAdmin_CanInstantiateObjectWithCreationRule()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("admin", "12345");

            var item = DataPortal.Create <UserAndAdminCanCreateAndWrite>();

            context.Assert.IsNotNull(item);
            context.Assert.Success();

            context.Complete();
        }
コード例 #5
0
ファイル: RolesTests.cs プロジェクト: RobRobertsCE/MVVM
        public void DataPortal_AuthenticatedAdminLoginBelongsToUserAndAdminRole()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("admin", "12345");

            context.Assert.IsTrue(ApplicationContext.User.IsInRole("User Role"));
            context.Assert.IsTrue(ApplicationContext.User.IsInRole("Admin Role"));

            context.Assert.Success();

            context.Complete();
        }
コード例 #6
0
ファイル: RolesTests.cs プロジェクト: RobRobertsCE/MVVM
        public void DataPortal_UnAuthenticatedUserLoginDoesNotBelongToEitherRole()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("user", "invalid_password");

            context.Assert.IsFalse(ApplicationContext.User.IsInRole("User Role"));
            context.Assert.IsFalse(ApplicationContext.User.IsInRole("Admin Role"));

            context.Assert.Success();

            context.Complete();
        }
コード例 #7
0
        public void AuthorizedUser_CanInstantiateObjectWithCreationRule()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDatPortal("user", "1234", (o, e) =>
                                                                       DataPortal.BeginCreate <UserAndAdminCanCreateAndWrite>((o2, e2) =>
            {
                context.Assert.IsNotNull(e2.Object);
                context.Assert.Success();
            }));

            context.Complete();
        }
コード例 #8
0
        public void DataPortal_AuthenticatedUserLoginBelongsToUserRole()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDatPortal("user", "1234", (o, e2) =>
            {
                context.Assert.IsTrue(ApplicationContext.User.IsInRole("User Role"));

                context.Assert.Success();
            });

            context.Complete();
        }
コード例 #9
0
        public void UnauthorizedUser_CanInstaniateObjectWithoutCreationRules()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("user", "invalid_password");

            //OnlyAdminCanWrite does not have Creation Rules set for it - therefore unauthorized user should be able to create it
            var item = DataPortal.Create <OnlyAdminCanWrite>();

            context.Assert.IsNotNull(item);
            context.Assert.Success();

            context.Complete();
        }
コード例 #10
0
        public void AuthorizedAdmin_CanWriteToObject_AuthorizedForAdminOnlyWrite()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("admin", "12345");

            var item = DataPortal.Create <OnlyAdminCanWrite>();

            item.A = "test";

            context.Assert.Success();

            context.Complete();
        }
コード例 #11
0
        public void AuthorizedUser_CanWriteToObject_AuthorizedForUserWrite()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("user", "1234");

            var item = DataPortal.Create <UserAndAdminCanCreateAndWrite>();

            item.A = "test";

            context.Assert.Success();

            context.Complete();
        }
コード例 #12
0
        public void UnauthorizedUser_CanNotInstaniateObjectWithCreationRules()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDatPortal("user", "invalid_password", (o, e) =>
                                                                       DataPortal.BeginCreate <UserAndAdminCanCreateAndWrite>((o2, e2) =>
            {
                context.Assert.IsTrue(((DataPortalException)e2.Error).ErrorInfo.ExceptionTypeName == "System.Security.SecurityException");
                context.Assert.Success();
            }));


            context.Complete();
        }
コード例 #13
0
        public void AuthorizedAdmin_CanWriteToObject_AuthorizedForAdminOnlyWrite()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDatPortal("admin", "12345", (o, e) =>
            {
                var item = new OnlyAdminCanWrite();

                item.A = "test";//no SecurityException

                context.Assert.Success();
            });

            context.Complete();
        }
コード例 #14
0
        public void AuthorizedUser_CanWriteToObject_AuthorizedForUserWrite()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDatPortal("user", "1234", (o, e) =>
            {
                var item = new UserAndAdminCanCreateAndWrite();

                item.A = "test";//no SecurityException

                context.Assert.Success();
            });

            context.Complete();
        }
コード例 #15
0
        public void UnauthorizedUser_CanNotInstaniateObjectWithCreationRules()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("user", "invalid_password");

            context.Assert.Try(() =>
            {
                var item = DataPortal.Create <UserAndAdminCanCreateAndWrite>();
            });
            context.Assert.Fail();
            context.Assert.Success();

            context.Complete();
        }
コード例 #16
0
        public void DataPortal_InvalidMembershipId_ResultsInFailedLogin()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("invalid", "1234");
            var identity = ApplicationContext.User.Identity;

            context.Assert.IsNotNull(identity);
            context.Assert.IsTrue(identity.Name == "");
            context.Assert.IsFalse(identity.IsAuthenticated);
            context.Assert.IsFalse(ApplicationContext.User.IsInRole("User Role"));

            context.Assert.Success();

            context.Complete();
        }
コード例 #17
0
        public void SetCSLAPrincipalLocal()
        {
            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingCSLA(SilverlightPrincipal.VALID_TEST_UID, SilverlightPrincipal.VALID_TEST_PWD);
            Assert.IsNotNull(Csla.ApplicationContext.User);
            Assert.AreEqual(true, Csla.ApplicationContext.User.Identity.IsAuthenticated);
            Assert.AreEqual("SilverlightIdentity", Csla.ApplicationContext.User.Identity.Name);
            Assert.AreEqual("SilverLight", Csla.ApplicationContext.User.Identity.AuthenticationType);
            Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole(AdminRoleName));

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingCSLA("invalidusername", SilverlightPrincipal.VALID_TEST_PWD);
            Assert.IsNotNull(Csla.ApplicationContext.User);
            Assert.AreEqual(false, Csla.ApplicationContext.User.Identity.IsAuthenticated);
            Assert.AreEqual("", Csla.ApplicationContext.User.Identity.Name);
            Assert.AreEqual(false, Csla.ApplicationContext.User.IsInRole(AdminRoleName));
            Assert.AreEqual("Csla", Csla.ApplicationContext.User.Identity.AuthenticationType);
        }
コード例 #18
0
        public void WebServer_ValidMembershipIdAndPwd_ResultInSucessfullLogin()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderWebServer("user", "1234");

            var identity = ApplicationContext.User.Identity;

            context.Assert.IsNotNull(identity);
            context.Assert.IsTrue(identity.Name == "user");
            context.Assert.IsTrue(identity.IsAuthenticated);
            context.Assert.IsTrue(ApplicationContext.User.IsInRole("User Role"));

            context.Assert.Success();

            context.Complete();
        }
コード例 #19
0
        public void AuthorizedUser_CanNotWriteToObject_AuthorizedForAdminOnlyWrite()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDataPortal("user", "1234");

            var item = DataPortal.Create <OnlyAdminCanWrite>();

            context.Assert.Try(() =>
            {
                item.A = "test";
            });

            context.Assert.Fail();
            context.Assert.Success();

            context.Complete();
        }
コード例 #20
0
        public void AuthorizedUser_CanNotWriteToObject_AuthorizedForAdminOnlyWrite()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderDatPortal("user", "1234", (o, e) =>
            {
                var item = new OnlyAdminCanWrite();

                context.Assert.Try(() =>
                {
                    item.A = "test";
                });
                context.Assert.Fail();//assure that exception was thrown for Assert.Try
                context.Assert.Success();
            });

            context.Complete();
        }
コード例 #21
0
        public void WebServer_InvalidPassword_ResultsInFailedLogin()
        {
            var context = GetContext();

            SilverlightPrincipal.Logout();
            SilverlightPrincipal.LoginUsingMembershipProviderWebServer("user", "invalid", (o, e2) =>
            {
                var identity = ApplicationContext.User.Identity;

                context.Assert.IsNotNull(identity);
                context.Assert.IsTrue(identity.Name == "");
                context.Assert.IsFalse(identity.IsAuthenticated);
                context.Assert.IsFalse(ApplicationContext.User.IsInRole("User Role"));

                context.Assert.Success();
            });

            context.Complete();
        }