public bool Run() { GroupInfo testGroupInfo; var gInfo = new GroupInfo() { Charter = "Charter", Founder = m_Founder, ID = new UGI { ID = m_GroupID, GroupName = "Test Group" }, InsigniaID = m_InsigniaID, IsAllowPublish = true, IsMaturePublish = false, IsOpenEnrollment = true, IsShownInList = false, MembershipFee = 10 }; m_Log.Info("Creating group"); testGroupInfo = m_GroupsService.CreateGroup(m_Founder, gInfo, GroupPowers.DefaultEveryonePowers, GroupPowers.OwnerPowers); m_GroupID = testGroupInfo.ID.ID; m_Log.Info("Checking for group existence"); gInfo = m_GroupsService.Groups[m_Founder, "Test Group"]; GroupInvite invite; UUID inviteID = UUID.Random; m_Log.Info("Testing non-existence of invite 1"); if (m_GroupsService.Invites.ContainsKey(m_Founder, inviteID)) { return(false); } m_Log.Info("Testing non-existence of invite 2"); if (m_GroupsService.Invites.TryGetValue(m_Founder, inviteID, out invite)) { return(false); } m_Log.Info("Testing non-existence of invite 3"); try { invite = m_GroupsService.Invites[m_Founder, inviteID]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Testing non-existence of invite 4"); try { if (m_GroupsService.Invites[m_Founder, new UGI(m_GroupID), gInfo.OwnerRoleID, m_Invitee].Count != 0) { return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } m_Log.Info("Testing non-existence of invite 5"); try { if (m_GroupsService.Invites[m_Founder, m_Invitee].Count != 0) { return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } m_Log.Info("Testing non-existence of invite 6"); try { if (m_GroupsService.Invites.GetByGroup(m_Founder, new UGI(m_GroupID)).Count != 0) { return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } m_Log.Info("Creating invite"); var testinvite = new GroupInvite() { ID = inviteID, Principal = m_Invitee, RoleID = gInfo.OwnerRoleID, Group = new UGI(m_GroupID) }; m_GroupsService.Invites.Add(m_Founder, testinvite); m_Log.Info("Testing existence of invite 1"); if (!m_GroupsService.Invites.ContainsKey(m_Founder, inviteID)) { return(false); } m_Log.Info("Testing existence of invite 2"); if (!m_GroupsService.Invites.TryGetValue(m_Founder, inviteID, out invite)) { return(false); } if (invite.ID != testinvite.ID || invite.Principal != testinvite.Principal || invite.RoleID != testinvite.RoleID || invite.Group != testinvite.Group) { m_Log.Info("Data mismatch"); return(false); } m_Log.Info("Testing existence of invite 3"); invite = m_GroupsService.Invites[m_Founder, inviteID]; if (invite.ID != testinvite.ID || invite.Principal != testinvite.Principal || invite.RoleID != testinvite.RoleID || invite.Group != testinvite.Group) { m_Log.Info("Data mismatch"); return(false); } m_Log.Info("Testing existence of invite 4"); List <GroupInvite> invites; try { if ((invites = m_GroupsService.Invites[m_Founder, new UGI(m_GroupID), gInfo.OwnerRoleID, m_Invitee]).Count != 1) { return(false); } invite = invites[0]; if (invite.ID != testinvite.ID || invite.Principal != testinvite.Principal || invite.RoleID != testinvite.RoleID || invite.Group != testinvite.Group) { m_Log.Info("Data mismatch"); return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } m_Log.Info("Testing existence of invite 5"); try { if ((invites = m_GroupsService.Invites[m_Founder, m_Invitee]).Count != 1) { return(false); } invite = invites[0]; if (invite.ID != testinvite.ID || invite.Principal != testinvite.Principal || invite.RoleID != testinvite.RoleID || invite.Group != testinvite.Group) { m_Log.Info("Data mismatch"); return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } m_Log.Info("Testing non-existence of invite 6"); try { if ((invites = m_GroupsService.Invites.GetByGroup(m_Founder, new UGI(m_GroupID))).Count != 1) { return(false); } invite = invites[0]; if (invite.ID != testinvite.ID || invite.Principal != testinvite.Principal || invite.RoleID != testinvite.RoleID || invite.Group != testinvite.Group) { m_Log.Info("Data mismatch"); return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } m_Log.Info("Deleting invite"); m_GroupsService.Invites.Delete(m_Founder, testinvite.ID); m_Log.Info("Testing non-existence of invite 1"); if (m_GroupsService.Invites.ContainsKey(m_Founder, inviteID)) { return(false); } m_Log.Info("Testing non-existence of invite 2"); if (m_GroupsService.Invites.TryGetValue(m_Founder, inviteID, out invite)) { return(false); } m_Log.Info("Testing non-existence of invite 3"); try { invite = m_GroupsService.Invites[m_Founder, inviteID]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Testing non-existence of invite 4"); try { if (m_GroupsService.Invites[m_Founder, new UGI(m_GroupID), gInfo.OwnerRoleID, m_Invitee].Count != 0) { return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } m_Log.Info("Testing non-existence of invite 5"); try { if (m_GroupsService.Invites[m_Founder, m_Invitee].Count != 0) { return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } m_Log.Info("Testing non-existence of invite 6"); try { if (m_GroupsService.Invites.GetByGroup(m_Founder, new UGI(m_GroupID)).Count != 0) { return(false); } } catch (NotSupportedException) { m_Log.Info("not supported"); } return(true); }
public bool Run() { GroupInfo gInfo; GroupInfo testGroupInfo; UGI ugi; GroupRole role; m_Log.Info("Checking for group non-existence 1"); try { gInfo = m_GroupsService.Groups[m_Founder, "Test Group"]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 2"); try { ugi = m_GroupsService.Groups[m_Founder, m_GroupID]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 3"); try { gInfo = m_GroupsService.Groups[m_Founder, new UGI(m_GroupID)]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 4"); if (m_GroupsService.Groups.TryGetValue(m_Founder, "Test Group", out gInfo)) { return(false); } m_Log.Info("Checking for group non-existence 5"); if (m_GroupsService.Groups.TryGetValue(m_Founder, m_GroupID, out ugi)) { return(false); } m_Log.Info("Checking for group non-existence 6"); if (m_GroupsService.Groups.TryGetValue(m_Founder, new UGI(m_GroupID), out gInfo)) { return(false); } gInfo = new GroupInfo() { Charter = "Charter", Founder = m_Founder, ID = new UGI { ID = m_GroupID, GroupName = "Test Group" }, InsigniaID = m_InsigniaID, IsAllowPublish = true, IsMaturePublish = false, IsOpenEnrollment = true, IsShownInList = false, MembershipFee = 10 }; m_Log.Info("Creating group"); testGroupInfo = m_GroupsService.CreateGroup(m_Founder, gInfo, GroupPowers.DefaultEveryonePowers, GroupPowers.OwnerPowers); m_GroupID = testGroupInfo.ID.ID; m_Log.Info("Checking for group existence 1"); gInfo = m_GroupsService.Groups[m_Founder, "Test Group"]; if (!CheckForEquality(gInfo, testGroupInfo)) { return(false); } m_Log.Info("Checking for group existence 2"); ugi = m_GroupsService.Groups[m_Founder, m_GroupID]; if (ugi != testGroupInfo.ID) { return(false); } m_Log.Info("Checking for group existence 3"); gInfo = m_GroupsService.Groups[m_Founder, new UGI(m_GroupID)]; if (!CheckForEquality(gInfo, testGroupInfo)) { return(false); } m_Log.Info("Checking for group existence 4"); if (!m_GroupsService.Groups.TryGetValue(m_Founder, "Test Group", out gInfo)) { return(false); } if (!CheckForEquality(gInfo, testGroupInfo)) { return(false); } m_Log.Info("Checking for group existence 5"); if (!m_GroupsService.Groups.TryGetValue(m_Founder, m_GroupID, out ugi)) { return(false); } if (ugi != testGroupInfo.ID) { return(false); } m_Log.Info("Checking for group existence 6"); if (!m_GroupsService.Groups.TryGetValue(m_Founder, new UGI(m_GroupID), out gInfo)) { return(false); } if (!CheckForEquality(gInfo, testGroupInfo)) { return(false); } m_Log.Info("Testing role Everyone existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), UUID.Zero, out role)) { return(false); } if (!CheckEveryoneRole(role, testGroupInfo.ID)) { return(false); } m_Log.Info("Testing role Everyone existence 2"); role = m_GroupsService.Roles[m_Founder, new UGI(m_GroupID), UUID.Zero]; if (!CheckEveryoneRole(role, testGroupInfo.ID)) { return(false); } m_Log.Info("Testing role Everyone existence 3"); if (!m_GroupsService.Roles.ContainsKey(m_Founder, new UGI(m_GroupID), UUID.Zero)) { return(false); } m_Log.Info("Testing role Owners existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), testGroupInfo.OwnerRoleID, out role)) { return(false); } if (!CheckOwnersRole(role, testGroupInfo.ID, testGroupInfo.OwnerRoleID)) { return(false); } m_Log.Info("Testing role Owners existence 2"); role = m_GroupsService.Roles[m_Founder, new UGI(m_GroupID), testGroupInfo.OwnerRoleID]; if (!CheckOwnersRole(role, testGroupInfo.ID, testGroupInfo.OwnerRoleID)) { return(false); } m_Log.Info("Testing role Owners existence 3"); if (!m_GroupsService.Roles.ContainsKey(m_Founder, new UGI(m_GroupID), testGroupInfo.OwnerRoleID)) { return(false); } try { m_Log.Info("Delete group"); m_BackendGroupsService.Groups.Delete(m_Founder, testGroupInfo.ID); } catch (NotSupportedException) { return(true); } m_Log.Info("Checking for group non-existence 1"); try { gInfo = m_GroupsService.Groups[m_Founder, "Test Group"]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 2"); try { ugi = m_GroupsService.Groups[m_Founder, m_GroupID]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 3"); try { gInfo = m_GroupsService.Groups[m_Founder, new UGI(m_GroupID)]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 4"); if (m_GroupsService.Groups.TryGetValue(m_Founder, "Test Group", out gInfo)) { return(false); } m_Log.Info("Checking for group non-existence 5"); if (m_GroupsService.Groups.TryGetValue(m_Founder, m_GroupID, out ugi)) { return(false); } m_Log.Info("Checking for group non-existence 6"); if (m_GroupsService.Groups.TryGetValue(m_Founder, new UGI(m_GroupID), out gInfo)) { return(false); } return(true); }
public bool Run() { GroupInfo testGroupInfo; var gInfo = new GroupInfo() { Charter = "Charter", Founder = m_Founder, ID = new UGI { ID = m_GroupID, GroupName = "Test Group" }, InsigniaID = m_InsigniaID, IsAllowPublish = true, IsMaturePublish = false, IsOpenEnrollment = true, IsShownInList = false, MembershipFee = 10 }; m_Log.Info("Creating group"); testGroupInfo = m_GroupsService.CreateGroup(m_Founder, gInfo, GroupPowers.DefaultEveryonePowers, GroupPowers.OwnerPowers); m_GroupID = testGroupInfo.ID.ID; m_Log.Info("Checking for group existence"); gInfo = m_GroupsService.Groups[m_Founder, "Test Group"]; m_Log.Info("Adding new member"); GroupMember newMember = m_GroupsService.Members.Add(m_Founder, new UGI(m_GroupID), m_Invitee, UUID.Zero, UUID.Random.ToString()); m_Log.Info("Testing existence of new member 1"); if (!m_GroupsService.Members.ContainsKey(m_Founder, new UGI(m_GroupID), m_Invitee)) { return(false); } m_Log.Info("Testing existence of new member 2"); GroupMember testMember; if (!m_GroupsService.Members.TryGetValue(m_Founder, new UGI(m_GroupID), m_Invitee, out testMember)) { return(false); } if (!CheckEquality(newMember, testMember)) { return(false); } m_Log.Info("Testing existence of new member 3"); try { testMember = m_GroupsService.Members[m_Founder, new UGI(m_GroupID), m_Invitee]; } catch (KeyNotFoundException) { return(false); } if (!CheckEquality(newMember, testMember)) { return(false); } m_Log.Info("Deleting new member"); m_GroupsService.Members.Delete(m_Founder, new UGI(m_GroupID), m_Invitee); m_Log.Info("Testing non-existence of new member 1"); if (m_GroupsService.Members.ContainsKey(m_Founder, new UGI(m_GroupID), m_Invitee)) { return(false); } m_Log.Info("Testing non-existence of new member 2"); if (m_GroupsService.Members.TryGetValue(m_Founder, new UGI(m_GroupID), m_Invitee, out testMember)) { return(false); } m_Log.Info("Testing existence of new member 3"); try { testMember = m_GroupsService.Members[m_Founder, new UGI(m_GroupID), m_Invitee]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } return(true); }
public bool Run() { GroupInfo gInfo; GroupInfo testGroupInfo; UGI ugi; GroupRole role; m_Log.Info("Checking for group non-existence 1"); try { gInfo = m_GroupsService.Groups[m_Founder, "Test Group"]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 2"); try { ugi = m_GroupsService.Groups[m_Founder, m_GroupID]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 3"); try { gInfo = m_GroupsService.Groups[m_Founder, new UGI(m_GroupID)]; return(false); } catch (KeyNotFoundException) { /* intentionally ignored */ } m_Log.Info("Checking for group non-existence 4"); if (m_GroupsService.Groups.TryGetValue(m_Founder, "Test Group", out gInfo)) { return(false); } m_Log.Info("Checking for group non-existence 5"); if (m_GroupsService.Groups.TryGetValue(m_Founder, m_GroupID, out ugi)) { return(false); } m_Log.Info("Checking for group non-existence 6"); if (m_GroupsService.Groups.TryGetValue(m_Founder, new UGI(m_GroupID), out gInfo)) { return(false); } gInfo = new GroupInfo() { Charter = "Charter", Founder = m_Founder, ID = new UGI { ID = m_GroupID, GroupName = "Test Group" }, InsigniaID = m_InsigniaID, IsAllowPublish = true, IsMaturePublish = false, IsOpenEnrollment = true, IsShownInList = false, MembershipFee = 10 }; m_Log.Info("Creating group"); testGroupInfo = m_GroupsService.CreateGroup(m_Founder, gInfo, GroupPowers.DefaultEveryonePowers, GroupPowers.OwnerPowers); m_GroupID = testGroupInfo.ID.ID; m_Log.Info("Checking for group existence"); gInfo = m_GroupsService.Groups[m_Founder, "Test Group"]; m_Log.Info("Testing role Everyone existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), UUID.Zero, out role)) { return(false); } if (!CheckEveryoneRole(role, testGroupInfo.ID)) { return(false); } m_Log.Info("Testing role Owners existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), testGroupInfo.OwnerRoleID, out role)) { return(false); } if (!CheckOwnersRole(role, testGroupInfo.ID, testGroupInfo.OwnerRoleID)) { return(false); } var testrole = new GroupRole() { Group = testGroupInfo.ID, Name = "Test Role", Description = "Test Description", ID = UUID.Random, Title = "Test", Powers = GroupPowers.DefaultEveryonePowers }; m_Log.Info("Testing role Test non-existence"); if (m_GroupsService.Roles.ContainsKey(m_Founder, new UGI(m_GroupID), testrole.ID)) { return(false); } m_Log.Info("Creating role Test"); m_GroupsService.Roles.Add(m_Founder, testrole); m_Log.Info("Testing role Test existence"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), testrole.ID, out role)) { return(false); } { var unequal = new List <string>(); if (role.Group != testrole.Group) { unequal.Add("Group"); } if (role.ID != testrole.ID) { unequal.Add("ID"); } if (role.Name != testrole.Name) { unequal.Add("Name"); } if (role.Description != testrole.Description) { unequal.Add("Description"); } if (role.Powers != testrole.Powers) { unequal.Add("Powers"); } if (role.Title != testrole.Title) { unequal.Add("Title"); } if (unequal.Count != 0) { m_Log.InfoFormat("Data mismatch: {0}", string.Join(" ", unequal)); return(false); } } m_Log.Info("Testing role Everyone existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), UUID.Zero, out role)) { return(false); } if (!CheckEveryoneRole(role, testGroupInfo.ID)) { return(false); } m_Log.Info("Testing role Owners existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), testGroupInfo.OwnerRoleID, out role)) { return(false); } if (!CheckOwnersRole(role, testGroupInfo.ID, testGroupInfo.OwnerRoleID)) { return(false); } m_Log.Info("Check group for role count"); GroupInfo compareInfo; if (!m_GroupsService.Groups.TryGetValue(m_Founder, new UGI(m_GroupID), out compareInfo)) { return(false); } if (compareInfo.RoleCount != 3) { m_Log.Info("New role test is not seen as part of RoleCount"); return(false); } m_Log.Info("Testing role Test existence"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), testrole.ID, out role)) { return(false); } { var unequal = new List <string>(); if (role.Group != testrole.Group) { unequal.Add("Group"); } if (role.ID != testrole.ID) { unequal.Add("ID"); } if (role.Name != testrole.Name) { unequal.Add("Name"); } if (role.Description != testrole.Description) { unequal.Add("Description"); } if (role.Powers != testrole.Powers) { unequal.Add("Powers"); } if (role.Title != testrole.Title) { unequal.Add("Title"); } if (unequal.Count != 0) { m_Log.InfoFormat("Data mismatch: {0}", string.Join(" ", unequal)); return(false); } } m_Log.Info("Testing role Everyone existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), UUID.Zero, out role)) { return(false); } if (!CheckEveryoneRole(role, testGroupInfo.ID)) { return(false); } m_Log.Info("Testing role Owners existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), testGroupInfo.OwnerRoleID, out role)) { return(false); } if (!CheckOwnersRole(role, testGroupInfo.ID, testGroupInfo.OwnerRoleID)) { return(false); } m_Log.Info("Check group for role count"); if (!m_GroupsService.Groups.TryGetValue(m_Founder, new UGI(m_GroupID), out compareInfo)) { return(false); } if (compareInfo.RoleCount != 3) { m_Log.Info("New role test is not seen as part of RoleCount"); return(false); } m_Log.Info("Updating role Test"); testrole.Name = "Test Role 2"; testrole.Description = "Test Description 2"; testrole.Title = "Test Title 2"; testrole.Powers |= GroupPowers.AssignMember; m_GroupsService.Roles.Update(m_Founder, testrole); m_Log.Info("Deleting role Test"); m_GroupsService.Roles.Delete(m_Founder, new UGI(m_GroupID), testrole.ID); m_Log.Info("Testing role Everyone existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), UUID.Zero, out role)) { return(false); } if (!CheckEveryoneRole(role, testGroupInfo.ID)) { return(false); } m_Log.Info("Testing role Owners existence 1"); if (!m_GroupsService.Roles.TryGetValue(m_Founder, new UGI(m_GroupID), testGroupInfo.OwnerRoleID, out role)) { return(false); } if (!CheckOwnersRole(role, testGroupInfo.ID, testGroupInfo.OwnerRoleID)) { return(false); } m_Log.Info("Check group for role count"); if (!m_GroupsService.Groups.TryGetValue(m_Founder, new UGI(m_GroupID), out compareInfo)) { return(false); } if (compareInfo.RoleCount != 2) { m_Log.Info("Only two roles should be seen after deletion"); return(false); } return(true); }