protected List <AclExpansionEntry> GetAclExpansionEntryList(List <User> userList, List <AccessControlList> aclList, bool sortedAndDistinct) { var userFinderStub = MockRepository.GenerateStub <IAclExpanderUserFinder> (); userFinderStub.Expect(mock => mock.FindUsers()).Return(userList); var aclFinderStub = MockRepository.GenerateStub <IAclExpanderAclFinder> (); aclFinderStub.Expect(mock => mock.FindAccessControlLists()).Return(aclList); var aclExpander = new AclExpander(userFinderStub, aclFinderStub); List <AclExpansionEntry> aclExpansionEntryList; if (sortedAndDistinct) { aclExpansionEntryList = aclExpander.GetAclExpansionEntryListSortedAndDistinct(); } else { aclExpansionEntryList = aclExpander.GetAclExpansionEntryList(); } return(aclExpansionEntryList); }
// Returns a list of AclExpansionEntry for the passed User, ACE with the passed Positon and passed GroupSelection private List <AclExpansionEntry> GetAclExpansionEntryList_UserPositionGroupSelection( User user, Position position, GroupCondition groupCondition, GroupHierarchyCondition groupHierarchyCondition) { List <User> userList = new List <User> (); userList.Add(user); var userFinderStub = MockRepository.GenerateStub <IAclExpanderUserFinder> (); userFinderStub.Expect(mock => mock.FindUsers()).Return(userList); List <AccessControlList> aclList = new List <AccessControlList>(); var ace = TestHelper.CreateAceWithPositionAndGroupCondition(position, groupCondition); ace.GroupHierarchyCondition = groupHierarchyCondition; AttachAccessTypeReadWriteDelete(ace, true, null, true); Assert.That(ace.Validate().IsValid); var acl = TestHelper.CreateStatefulAcl(ace); aclList.Add(acl); var aclFinderStub = MockRepository.GenerateStub <IAclExpanderAclFinder> (); aclFinderStub.Expect(mock => mock.FindAccessControlLists()).Return(aclList); var aclExpander = new AclExpander(userFinderStub, aclFinderStub); // Retrieve the resulting list of AclExpansionEntry|s var aclExpansionEntryList = aclExpander.GetAclExpansionEntryList(); return(aclExpansionEntryList); }
public void WriteAclExpansionAsHtmlTest() { using (new CultureScope("de-AT", "de-AT")) { var aclExpander = new AclExpander(); var aclExpansion = aclExpander.GetAclExpansionEntryList(); var stringWriter = new StringWriter(); var aclExpansionHtmlWriter = new AclExpansionHtmlWriter(stringWriter, true, new AclExpansionHtmlWriterSettings()); aclExpansionHtmlWriter.WriteAclExpansion(aclExpansion); } }
public void GetAclExpansionEntryList_UserList_IUserRoleAclAceCombinations2() { var userRoleAclAceCombinationsMock = MockRepository.GenerateMock <IUserRoleAclAceCombinationFinder> (); var myValues = ListObjectMother.New(new UserRoleAclAceCombination(Role, Ace)); userRoleAclAceCombinationsMock.Expect(mock => mock.GetEnumerator()).Return(myValues.GetEnumerator()); var aclExpander = new AclExpander(userRoleAclAceCombinationsMock); aclExpander.GetAclExpansionEntryList(); userRoleAclAceCombinationsMock.VerifyAllExpectations(); }
// Returns a list of AclExpansionEntry for the passed users and ACLs private List <AclExpansionEntry> GetAclExpansionEntryList(List <User> userList, List <AccessControlList> aclList) { var userFinderStub = MockRepository.GenerateStub <IAclExpanderUserFinder> (); userFinderStub.Expect(mock => mock.FindUsers()).Return(userList); var aclFinderStub = MockRepository.GenerateStub <IAclExpanderAclFinder> (); aclFinderStub.Expect(mock => mock.FindAccessControlLists()).Return(aclList); var aclExpander = new AclExpander(userFinderStub, aclFinderStub); // Retrieve the resulting list of AclExpansionEntry|s var aclExpansionEntryList = aclExpander.GetAclExpansionEntryList(); userFinderStub.VerifyAllExpectations(); aclFinderStub.VerifyAllExpectations(); return(aclExpansionEntryList); }
public void TextWriterFactoryResultTest() { using (new CultureScope("en-US")) { var aclExpander = new AclExpander(); var aclExpansionEntryList = aclExpander.GetAclExpansionEntryList(); var stringWriterFactory = new StringWriterFactory(); stringWriterFactory.Directory = ""; stringWriterFactory.Extension = "xYz"; var aclExpansionMultiFileHtmlWriter = new AclExpansionMultiFileHtmlWriter(stringWriterFactory, false); aclExpansionMultiFileHtmlWriter.WriteAclExpansion(aclExpansionEntryList); Assert.That(stringWriterFactory.Count, Is.EqualTo(7)); AssertTextWriterFactoryMemberEquals(stringWriterFactory, "_AclExpansionMain_", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\"><html><head><title>re-motion ACL Expansion - User Master Table</title><style>@import \"AclExpansion.css\";</style><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><table style=\"width: 100%;\" class=\"aclExpansionTable\" id=\"remotion-user-table\"><tr><th class=\"header\">User</th><th class=\"header\">First Name</th><th class=\"header\">Last Name</th><th class=\"header\">Access Rights</th></tr><tr><td>substituting.user</td><td></td><td>substitute</td><td><a href=\".\\substituting.user.xYz\" target=\"_blank\">.\\substituting.user.xYz</a></td></tr><tr><td>test.user</td><td>test</td><td>user</td><td><a href=\".\\test.user.xYz\" target=\"_blank\">.\\test.user.xYz</a></td></tr><tr><td>group0/user1</td><td></td><td>user1</td><td><a href=\".\\group0_user1.xYz\" target=\"_blank\">.\\group0_user1.xYz</a></td></tr><tr><td>group1/user1</td><td></td><td>user1</td><td><a href=\".\\group1_user1.xYz\" target=\"_blank\">.\\group1_user1.xYz</a></td></tr><tr><td>group0/user2</td><td></td><td>user2</td><td><a href=\".\\group0_user2.xYz\" target=\"_blank\">.\\group0_user2.xYz</a></td></tr><tr><td>group1/user2</td><td></td><td>user2</td><td><a href=\".\\group1_user2.xYz\" target=\"_blank\">.\\group1_user2.xYz</a></td></tr></table></body></html>"); AssertTextWriterFactoryMemberEquals(stringWriterFactory, "test.user", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\"><html><head><title>re-motion ACL Expansion</title><style>@import \"AclExpansion.css\";</style><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><table style=\"width: 100%;\" class=\"aclExpansionTable\" id=\"remotion-ACL-expansion-table\"><tr><th class=\"header\">User</th><th class=\"header\">Role</th><th class=\"header\">Class</th><th class=\"header\">States</th><th class=\"header\">User Must Own</th><th class=\"header\">Owning Group Equals</th><th class=\"header\">Owning Tenant Equals</th><th class=\"header\">User Must Have Abstract Role</th><th class=\"header\">Access Rights</th></tr><tr><td rowspan=\"8\">user test, Dipl.Ing.(FH)</td><td rowspan=\"2\">testGroup, Manager</td><td rowspan=\"2\">Order</td><td>DHL, None, Received</td><td></td><td></td><td></td><td></td><td>FirstAccessType</td></tr><tr><td>DHL, None, Received</td><td></td><td></td><td>TestTenant</td><td></td><td>FirstAccessType, Write</td></tr><tr><td rowspan=\"2\">testGroup, Official</td><td rowspan=\"2\">Order</td><td>DHL, None, Received</td><td></td><td></td><td></td><td></td><td>FirstAccessType</td></tr><tr><td>DHL, None, Received</td><td></td><td></td><td>TestTenant</td><td></td><td>FirstAccessType, Write</td></tr><tr><td rowspan=\"2\">testOwningGroup, Manager</td><td rowspan=\"2\">Order</td><td>DHL, None, Received</td><td></td><td></td><td></td><td></td><td>FirstAccessType</td></tr><tr><td>DHL, None, Received</td><td></td><td></td><td>TestTenant</td><td></td><td>FirstAccessType, Write</td></tr><tr><td rowspan=\"2\">testRootGroup, Official</td><td rowspan=\"2\">Order</td><td>DHL, None, Received</td><td></td><td></td><td></td><td></td><td>FirstAccessType</td></tr><tr><td>DHL, None, Received</td><td></td><td></td><td>TestTenant</td><td></td><td>FirstAccessType, Write</td></tr></table></body></html>"); AssertTextWriterFactoryMemberEquals(stringWriterFactory, "group0_user1", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\"><html><head><title>re-motion ACL Expansion</title><style>@import \"AclExpansion.css\";</style><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><table style=\"width: 100%;\" class=\"aclExpansionTable\" id=\"remotion-ACL-expansion-table\"><tr><th class=\"header\">User</th><th class=\"header\">Role</th><th class=\"header\">Class</th><th class=\"header\">States</th><th class=\"header\">User Must Own</th><th class=\"header\">Owning Group Equals</th><th class=\"header\">Owning Tenant Equals</th><th class=\"header\">User Must Have Abstract Role</th><th class=\"header\">Access Rights</th></tr><tr><td rowspan=\"2\">user1</td><td rowspan=\"2\">PG0 (parentGroup0), Manager</td><td rowspan=\"2\">Order</td><td>DHL, None, Received</td><td></td><td></td><td></td><td></td><td>FirstAccessType</td></tr><tr><td>DHL, None, Received</td><td></td><td></td><td>TestTenant</td><td></td><td>FirstAccessType, Write</td></tr></table></body></html>"); AssertTextWriterFactoryMemberEquals(stringWriterFactory, "group1_user1", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\"><html><head><title>re-motion ACL Expansion</title><style>@import \"AclExpansion.css\";</style><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><table style=\"width: 100%;\" class=\"aclExpansionTable\" id=\"remotion-ACL-expansion-table\"><tr><th class=\"header\">User</th><th class=\"header\">Role</th><th class=\"header\">Class</th><th class=\"header\">States</th><th class=\"header\">User Must Own</th><th class=\"header\">Owning Group Equals</th><th class=\"header\">Owning Tenant Equals</th><th class=\"header\">User Must Have Abstract Role</th><th class=\"header\">Access Rights</th></tr><tr><td rowspan=\"2\">user1</td><td rowspan=\"2\">PG1 (parentGroup1), Manager</td><td rowspan=\"2\">Order</td><td>DHL, None, Received</td><td></td><td></td><td></td><td></td><td>FirstAccessType</td></tr><tr><td>DHL, None, Received</td><td></td><td></td><td>TestTenant</td><td></td><td>FirstAccessType, Write</td></tr></table></body></html>"); AssertTextWriterFactoryMemberEquals(stringWriterFactory, "group0_user2", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\"><html><head><title>re-motion ACL Expansion</title><style>@import \"AclExpansion.css\";</style><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><table style=\"width: 100%;\" class=\"aclExpansionTable\" id=\"remotion-ACL-expansion-table\"><tr><th class=\"header\">User</th><th class=\"header\">Role</th><th class=\"header\">Class</th><th class=\"header\">States</th><th class=\"header\">User Must Own</th><th class=\"header\">Owning Group Equals</th><th class=\"header\">Owning Tenant Equals</th><th class=\"header\">User Must Have Abstract Role</th><th class=\"header\">Access Rights</th></tr><tr><td rowspan=\"2\">user2</td><td rowspan=\"2\">PG0 (parentGroup0), Official</td><td rowspan=\"2\">Order</td><td>DHL, None, Received</td><td></td><td></td><td></td><td></td><td>FirstAccessType</td></tr><tr><td>DHL, None, Received</td><td></td><td></td><td>TestTenant</td><td></td><td>FirstAccessType, Write</td></tr></table></body></html>"); AssertTextWriterFactoryMemberEquals(stringWriterFactory, "group1_user2", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\"><html><head><title>re-motion ACL Expansion</title><style>@import \"AclExpansion.css\";</style><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><table style=\"width: 100%;\" class=\"aclExpansionTable\" id=\"remotion-ACL-expansion-table\"><tr><th class=\"header\">User</th><th class=\"header\">Role</th><th class=\"header\">Class</th><th class=\"header\">States</th><th class=\"header\">User Must Own</th><th class=\"header\">Owning Group Equals</th><th class=\"header\">Owning Tenant Equals</th><th class=\"header\">User Must Have Abstract Role</th><th class=\"header\">Access Rights</th></tr><tr><td rowspan=\"2\">user2</td><td rowspan=\"2\">PG1 (parentGroup1), Official</td><td rowspan=\"2\">Order</td><td>DHL, None, Received</td><td></td><td></td><td></td><td></td><td>FirstAccessType</td></tr><tr><td>DHL, None, Received</td><td></td><td></td><td>TestTenant</td><td></td><td>FirstAccessType, Write</td></tr></table></body></html>"); } }