来自Siteminder的Visual Studio负载测试重定向URL [英] Visual Studio Load Test redirect URL from Siteminder

查看:101
本文介绍了来自Siteminder的Visual Studio负载测试重定向URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a security application called Siteminder. It creates unique URLS for every authentication. HTTPS://SITE/idp/**RANDOMURLSTRING**/resumeSAML20/idp/startSSO.ping

我如何捕获唯一URL并使测试继续登录.

How can i capture the Unique URL and have the test continue to login.

Webtest假定过程中的下一个URL.它不支持[或者我不知道如何]唯一重定向到随机URL.有人知道处理这种情况的方法吗?

A webtest assumes the next URL in the process. It does not support[Or I don't know how] a unique redirect to a random URL. Does anyone know of a way to handle this case?

我的解决方案-在所有网址中都用{{SessionID}}替换SessionID并使用此提取规则

My Solution -- Replace the SessionID with {{SessionID}} in all the URLS and use this extraction rule

 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;
        }

    }

推荐答案

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

The simple answer is to have use extraction rule that gets the **RANDOMURLSTRING** then change the URLs in the requests to be, for example, HTTPS://SITE/idp/{{TheRandomString}}/resumeSAML20/idp/startSSO.ping where TheRandomString is the context parameter that holds the extracted value. Note the doubled curly braces ({{ and }}) around the context parameter.

假定需要捕获由第一次重定向返回的值,但是普通的Web测试将再次重定向,因此提取规则看不到响应.在这种情况下,需要显式处理重定向.将初始请求的Follow redirects属性设置为false,然后添加提取规则以收集所需的值.在初始请求之后添加一个新请求,并在必要时使用提取的值.可以提取整个重定向的URL,并将Url字段设置为提取的值.

Suppose a value returned by the first redirection needs to be captured but a normal web test would redirect again and so the response is not seen by the extraction rules. In this case need to handle the redirect explicitly. Set the Follow redirects property of the initial request to false then add extraction rule(s) to gather the wanted values. Add a new request after the initial request and use the extracted values in it as necessary. It is possible to extract the entire redirected url and set the Url field to the extracted value.

这篇关于来自Siteminder的Visual Studio负载测试重定向URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆