public void ValidateSpecificGroup_IsValid() { var group = _testHelper.CreateGroup("TestGroup", null, _testHelper.CreateTenant("TestTenant")); var ace = _testHelper.CreateAceWithSpecificGroup(group); AccessControlEntryValidationResult result = ace.Validate(); Assert.That(result.IsValid, Is.True); }
private Role CreateRole(Tenant tenant) { return(_testHelper.CreateRole( null, _testHelper.CreateGroup(Guid.NewGuid().ToString(), null, tenant), _testHelper.CreatePosition(Guid.NewGuid().ToString()))); }
public void ClearSpecificGroup() { var group = _testHelper.CreateGroup("TestGroup", null, _testHelper.CreateTenant("TestTenant")); var ace = _testHelper.CreateAceWithSpecificGroup(group); using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope()) { ace.GroupCondition = GroupCondition.OwningGroup; Assert.That(ace.SpecificGroup, Is.Not.Null); ClientTransactionScope.CurrentTransaction.Commit(); Assert.That(ace.SpecificGroup, Is.Null); } }
public void DeleteGroup_WithAccessControlEntry() { DatabaseFixtures dbFixtures = new DatabaseFixtures(); AccessControlTestHelper testHelper = new AccessControlTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { dbFixtures.CreateEmptyDomain(); var group = testHelper.CreateGroup("group", null, testHelper.CreateTenant("tenant")); var ace = testHelper.CreateAceWithSpecificGroup(group); ClientTransaction.Current.Commit(); group.Delete(); ClientTransaction.Current.Commit(); Assert.That(ace.State, Is.EqualTo(StateType.Invalid)); } }
public void CascadeToAccessControlEntry() { DatabaseFixtures dbFixtures = new DatabaseFixtures(); AccessControlTestHelper testHelper = new AccessControlTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { dbFixtures.CreateEmptyDomain(); var tenant = testHelper.CreateTenant("TestTenant"); var owningGroup = testHelper.CreateGroup("group", null, tenant); var user = testHelper.CreateUser("user", null, "user", null, owningGroup, tenant); var ace = testHelper.CreateAceWithSpecificUser(user); ClientTransaction.Current.Commit(); user.Delete(); ClientTransaction.Current.Commit(); Assert.That(ace.State, Is.EqualTo(StateType.Invalid)); } }
// Called before each test gets executed. public override void SetUp() { base.SetUp(); TestHelper = new AccessControlTestHelper(); // base class TearDown()-method (by MK) calls ClientTransactionScope.ResetActiveScope(), // discarding the transaction opened by EnterNonDiscardingScope below. TestHelper.Transaction.EnterNonDiscardingScope(); ReadAccessType = TestHelper.CreateReadAccessType(); // read access WriteAccessType = TestHelper.CreateWriteAccessType(); // write access DeleteAccessType = TestHelper.CreateDeleteAccessType(); // delete permission AccessTypeDefinitions = new[] { ReadAccessType, WriteAccessType, DeleteAccessType }; AccessTypeDefinitions2 = new[] { ReadAccessType, DeleteAccessType }; Tenant = TestHelper.CreateTenant("Da Tenant"); Group = TestHelper.CreateGroup("Da Group", null, Tenant); Position = TestHelper.CreatePosition("Supreme Being"); User = TestHelper.CreateUser("DaUs", "Da", "Usa", "Dr.", Group, Tenant); Role = TestHelper.CreateRole(User, Group, Position); Ace = TestHelper.CreateAceWithOwningTenant(); TestHelper.AttachAccessType(Ace, ReadAccessType, null); TestHelper.AttachAccessType(Ace, WriteAccessType, true); TestHelper.AttachAccessType(Ace, DeleteAccessType, null); Group2 = TestHelper.CreateGroup("Anotha Group", null, Tenant); Position2 = TestHelper.CreatePosition("Working Drone"); User2 = TestHelper.CreateUser("mr.smith", "", "Smith", "Mr.", Group2, Tenant); Role2 = TestHelper.CreateRole(User2, Group2, Position2); Ace2 = TestHelper.CreateAceWithSpecificTenant(Tenant); TestHelper.AttachAccessType(Ace2, ReadAccessType, true); TestHelper.AttachAccessType(Ace2, WriteAccessType, null); TestHelper.AttachAccessType(Ace2, DeleteAccessType, true); Group3 = TestHelper.CreateGroup("Da 3rd Group", null, Tenant); Position3 = TestHelper.CreatePosition("Combatant"); User3 = TestHelper.CreateUser("ryan_james", "Ryan", "James", "", Group3, Tenant); Role3 = TestHelper.CreateRole(User3, Group3, Position3); Ace3 = TestHelper.CreateAceWithPositionAndGroupCondition(Position3, GroupCondition.None); TestHelper.AttachAccessType(Ace3, ReadAccessType, true); TestHelper.AttachAccessType(Ace3, WriteAccessType, true); TestHelper.AttachAccessType(Ace3, DeleteAccessType, null); //-------------------------------- // Create ACLs //-------------------------------- SecurableClassDefinition orderClass = SetUpFixture.OrderClassHandle.GetObject(); var aclList = orderClass.StatefulAccessControlLists; Assert.That(aclList.Count, Is.GreaterThanOrEqualTo(2)); Acl = aclList[0]; TestHelper.AttachAces(Acl, Ace, Ace2, Ace3); var ace2_1 = TestHelper.CreateAceWithAbstractRole(); var ace2_2 = TestHelper.CreateAceWithPositionAndGroupCondition(Position2, GroupCondition.OwningGroup); Acl2 = aclList[1]; TestHelper.AttachAces(Acl2, ace2_1, ace2_2, Ace3); // Additional roles for users TestHelper.CreateRole(User2, Group, Position2); TestHelper.CreateRole(User2, Group2, Position); TestHelper.CreateRole(User2, Group3, Position2); TestHelper.CreateRole(User3, Group, Position); TestHelper.CreateRole(User3, Group2, Position2); TestHelper.CreateRole(User3, Group3, Position3); TestHelper.CreateRole(User3, Group, Position3); TestHelper.CreateRole(User3, Group2, Position); }