Visual Studio Load Test从Siteminder重定向URL

本文关键字:Siteminder 重定向 URL Test Studio Load Visual | 更新日期: 2023-09-27 18:15:29

我有一个叫做Siteminder的安全应用程序。它为每个身份验证创建唯一的url。HTTPS://SITE/idp/**RANDOMURLSTRING**/resumeSAML20/idp/startSSO.ping

如何捕获唯一URL并让测试继续登录。

webtest假定该过程中的下一个URL。它不支持[或者我不知道如何]一个唯一的重定向到一个随机的URL。有人知道怎么处理这个案子吗?

编辑:我的解决方案——将所有url中的SessionID替换为{{SessionID}},并使用此提取规则

 public class ExtractSiteMinderCustomUrl : ExtractionRule
    {
        public string SiteMinderSessionID { get; private set; }
        // The Extract method.  The parameter e contains the web performance test context.
        //---------------------------------------------------------------------
        public override void Extract(object sender, ExtractionEventArgs e)
        {
            //look for anchor tags with URLS
                Regex regex = new Regex("<a''s+(?:[^>]*?''s+)?href='"([^'"]+''?[^'"]+)'"");
            MatchCollection match = regex.Matches(e.Response.BodyString);
            if (match.Count > 0)
            {
                foreach (Match ItemMatch in match)
                {
                    if (ItemMatch.ToString().Contains("/idp/"))
                    {
                        //start and ends string from the sitemindersession is in the link on the page
                        e.WebTest.Context.Add(this.ContextParameterName, GetStringBetween(ItemMatch.ToString(), "/idp/", "/resume"));
                        e.Success = true;
                        return;
                    }
                }
                e.Success = false;
                e.Message = String.Format(CultureInfo.CurrentCulture, "Not Found in Link : /idp/");
            }
            else
            {
                e.Success = false;
                e.Message = String.Format(CultureInfo.CurrentCulture, "No href tags found");
            }
        }
        public static string GetStringBetween(string token, string first, string second)
        {
            if (!token.Contains(first)) return "";
            var afterFirst = token.Split(new[] { first }, StringSplitOptions.None)[1];
            if (!afterFirst.Contains(second)) return "";
            var result = afterFirst.Split(new[] { second }, StringSplitOptions.None)[0];
            return result;
        }
    }

Visual Studio Load Test从Siteminder重定向URL

简单的答案是使用提取规则,获取**RANDOMURLSTRING**,然后将请求中的url更改为,例如,HTTPS://SITE/idp/{{TheRandomString}}/resumeSAML20/idp/startSSO.ping,其中TheRandomString是保存提取值的上下文参数。注意context参数周围的双花括号({{}})。

假设需要捕获第一次重定向返回的值,但正常的web测试将再次重定向,因此提取规则看不到响应。在这种情况下,需要显式处理重定向。将初始请求的Follow redirects属性设置为false,然后添加提取规则来收集所需的值。在初始请求之后添加一个新请求,并根据需要在其中使用提取的值。可以提取整个重定向url,并将Url字段设置为提取的值。