예제 #1
0
        public static string GetAdGroupFromTestContext(string mockName)
        {
            string retValue = string.Empty;

            if (HttpMockServer.Mode != HttpRecorderMode.Playback)
            {
                var aadClient   = new AADClientHelper();
                var adGroups    = aadClient.GetUserGroups().GetAwaiter().GetResult();
                var adGroupList = adGroups.Where(x => x.Keys.Contains("ID")).Select(x => x["ID"]).ToList();
                if (adGroupList.Count >= 1)
                {
                    retValue = HttpMockServer.Variables[mockName] = adGroupList.ElementAt(0);
                }
                else
                {
                    throw new Exception(string.Format("Unexpected number of Groups. Expected: adGroupList.Count >= 1 but actual = {0}", adGroupList.Count));
                }
            }
            else
            {
                if (HttpMockServer.Variables.ContainsKey(mockName))
                {
                    retValue = HttpMockServer.Variables[mockName];
                }
                else
                {
                    throw new Exception(string.Format("HttpMockServer.Variables does not have a value to retrieve for mockName={0}", mockName));
                }
            }

            return(retValue);
        }
예제 #2
0
        public static string GetAdUserFromTestContext(string mockName)
        {
            string retValue = string.Empty;

            if (HttpMockServer.Mode != HttpRecorderMode.Playback)
            {
                var aadClient = new AADClientHelper();
                retValue = HttpMockServer.Variables[mockName] = aadClient.UserId;
            }
            else
            {
                if (HttpMockServer.Variables.ContainsKey(mockName))
                {
                    retValue = HttpMockServer.Variables[mockName];
                }
                else
                {
                    throw new Exception(string.Format("HttpMockServer.Variables does not have a value to retrieve for mockName={0}", mockName));
                }
            }

            return(retValue);
        }