/// <summary> /// Get group users (email or deployment identifiers) /// </summary> /// <param name="groupName">Group name</param> /// <returns>List of user group emails or deployment ids</returns> public IEnumerable <string> GetGroupUsers(string groupName) { List <string> emptyList = new List <string>(); if (string.IsNullOrWhiteSpace(groupName)) { ULSLogging.LogCodeErrorTag(0x23821092 /* tag_967cs */, Categories.TestGroupsDataSet, false, false, "Null or empty group passed to TestGroupsDataSet.GetGroupUsers"); return(emptyList); } if (m_groupUsers == null) { ULSLogging.LogCodeErrorTag(0x23821093 /* tag_967ct */, Categories.TestGroupsDataSet, false, false, "TestGroupsDataSet is not loaded."); return(emptyList); } string group = groupName.Trim(); if (DefaultGroups.Contains(group)) { return(m_userGroups.Keys.ToList()); } if (m_groupUsers.TryGetValue(group, out List <string> groupUsers)) { return(groupUsers); } return(emptyList); }
/// <summary> /// Load the Test Groups Data /// </summary> /// <param name="testGroupsRaw">Raw test groups data</param> /// <param name="userGroups">User groups</param> /// <param name="groupUsers">Group users</param> private void LoadGroupsData(Configuration.TestGroups testGroupsRaw, out Dictionary <string, List <string> > userGroups, out Dictionary <string, List <string> > groupUsers) { if (testGroupsRaw == null || testGroupsRaw.TestGroup == null) { ULSLogging.LogCodeErrorTag(0x23821095 /* tag_967cv */, Categories.TestGroupsDataSet, false, true, "Null raw data has been passed to TestGroupsDataSet.LoadGroupsData."); userGroups = null; groupUsers = null; return; } userGroups = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase); groupUsers = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase); foreach (Configuration.TestGroupsTestGroup testGroup in testGroupsRaw.TestGroup) { string testGroupName = testGroup.name.Trim(); if (string.IsNullOrWhiteSpace(testGroupName)) { ULSLogging.LogCodeErrorTag(0x23821096 /* tag_967cw */, Categories.TestGroupsDataSet, false, true, "A test user with empty name found, skipping."); continue; } if (testGroupName.Contains(ListSeparator)) { ULSLogging.LogCodeErrorTag(0x23821097 /* tag_967cx */, Categories.TestGroupsDataSet, false, true, "Test user name '{0}' contains a semicolon. This name cannot be used as the semicolon is used to delimit groups within the asset field. Skipping.", testGroupName); continue; } if (DefaultGroups.Contains(testGroupName)) { ULSLogging.LogCodeErrorTag(0x23821098 /* tag_967cy */, Categories.TestGroupsDataSet, false, true, "Test user name '{0}' is a restricted user name and cannot be manually specified. Skipping.", testGroupName); continue; } if (testGroup.Member == null) { ULSLogging.LogCodeErrorTag(0x23821099 /* tag_967cz */, Categories.TestGroupsDataSet, false, true, "Skipping test user '{0}' : the user has no members", testGroupName); continue; } if (!groupUsers.ContainsKey(testGroupName)) { groupUsers.Add(testGroupName, new List <string>()); } foreach (Configuration.TestGroupsTestGroupMember member in testGroup.Member) { if (member.email != null) { UpdateGroups(userGroups, groupUsers, member.email, testGroupName); } if (member.deploymentId != null) { UpdateGroups(userGroups, groupUsers, member.deploymentId, testGroupName); } } } }