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)); }
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")); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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); }
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(); }
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(); }
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(); }
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(); }