public void TestAuthorizationRulesAfterSerialization() { TestDIContext adminDIContext = TestDIContextFactory.CreateContext(GetPrincipal("Admin")); IDataPortal <Security.PermissionsRoot> dataPortal = _testDIContext.CreateDataPortal <Security.PermissionsRoot>(); Security.PermissionsRoot root = dataPortal.Create(); try { root.FirstName = "something"; Assert.Fail("Exception didn't occur"); } catch (Csla.Security.SecurityException ex) { Assert.AreEqual("Property set not allowed", ex.Message); } dataPortal = adminDIContext.CreateDataPortal <Security.PermissionsRoot>(); root = dataPortal.Create(); try { root.FirstName = "something"; } catch (Csla.Security.SecurityException) { Assert.Fail("exception occurred"); } // TODO: Not sure how to recreate this test now; can't change context under the data portal mid flight //Csla.ApplicationContext.User = new ClaimsPrincipal(); Csla.Test.Security.PermissionsRoot rootClone = root.Clone(); try { rootClone.FirstName = "something else"; Assert.Fail("Exception didn't occur"); } catch (Csla.Security.SecurityException ex) { Assert.AreEqual("Property set not allowed", ex.Message); } // TODO: Not sure how to recreate this test now; can't change context under the data portal mid flight //Csla.ApplicationContext.User = GetPrincipal("Admin"); try { rootClone.FirstName = "something new"; } catch (Csla.Security.SecurityException) { Assert.Fail("exception occurred"); } }
public void TestAuthorizationRulesAfterSerialization() { Csla.Test.Security.PermissionsRoot root = Csla.Test.Security.PermissionsRoot.NewPermissionsRoot(); try { root.FirstName = "something"; Assert.Fail("Exception didn't occur"); } catch (Csla.Security.SecurityException ex) { Assert.AreEqual("Property set not allowed", ex.Message); } Csla.Test.Security.TestPrincipal.SimulateLogin(); try { root.FirstName = "something"; } catch (Csla.Security.SecurityException) { Assert.Fail("exception occurred"); } Csla.Test.Security.TestPrincipal.SimulateLogout(); Csla.Test.Security.PermissionsRoot rootClone = root.Clone(); try { rootClone.FirstName = "something else"; Assert.Fail("Exception didn't occur"); } catch (Csla.Security.SecurityException ex) { Assert.AreEqual("Property set not allowed", ex.Message); } Csla.Test.Security.TestPrincipal.SimulateLogin(); try { rootClone.FirstName = "something new"; } catch (Csla.Security.SecurityException) { Assert.Fail("exception occurred"); } Csla.Test.Security.TestPrincipal.SimulateLogout(); }
public void TestAuthorizationRulesAfterSerialization() { Csla.Test.Security.PermissionsRoot root = Csla.Test.Security.PermissionsRoot.NewPermissionsRoot(); try { root.FirstName = "something"; Assert.Fail("Exception didn't occur"); } catch (Csla.Security.SecurityException ex) { Assert.AreEqual("Property set not allowed", ex.Message); } #pragma warning disable CS0436 // Type conflicts with imported type Csla.Test.Security.TestPrincipal.SimulateLogin(); #pragma warning restore CS0436 // Type conflicts with imported type try { root.FirstName = "something"; } catch (Csla.Security.SecurityException) { Assert.Fail("exception occurred"); } #pragma warning disable CS0436 // Type conflicts with imported type Csla.Test.Security.TestPrincipal.SimulateLogout(); #pragma warning restore CS0436 // Type conflicts with imported type Csla.Test.Security.PermissionsRoot rootClone = root.Clone(); try { rootClone.FirstName = "something else"; Assert.Fail("Exception didn't occur"); } catch (Csla.Security.SecurityException ex) { Assert.AreEqual("Property set not allowed", ex.Message); } #pragma warning disable CS0436 // Type conflicts with imported type Csla.Test.Security.TestPrincipal.SimulateLogin(); #pragma warning restore CS0436 // Type conflicts with imported type try { rootClone.FirstName = "something new"; } catch (Csla.Security.SecurityException) { Assert.Fail("exception occurred"); } #pragma warning disable CS0436 // Type conflicts with imported type Csla.Test.Security.TestPrincipal.SimulateLogout(); #pragma warning restore CS0436 // Type conflicts with imported type }