Commit bd414362 bd4143626376adcde3779d438287b4485592661c by Christian Gerdes

New Web Test Plugin: Add Session Cookie

1 parent ce576f2a
......@@ -52,6 +52,35 @@ namespace LIL_VSTT_Plugins
}
}
[DisplayName("Add Session Cookie")]
[Description("Adds a cookie to the webtest cookie collection for this test and all of its requests.")]
public class AddTestSessionCookie : WebTestPlugin
{
[DisplayName("Cookie Name"), DefaultValue(""), Description("Name of the cookie to set.")]
public string CookieName { get; set; }
[DisplayName("Cookie Value"), DefaultValue(""), Description("Value of the cookie to set.")]
public string CookieValue { get; set; }
[DisplayName("Cookie Value Parameter Name"), DefaultValue(""), Description("Parameter for the cookie value. If the parameter is not found, the Cookie Value will be used instead.")]
public string CookieParameter { get; set; }
[DisplayName("Cookie Path"), DefaultValue("/"), Description("Path for the cookie to set. Cookie will only be sent if the URL Path matches.")]
public string CookiePath { get; set; }
[DisplayName("Cookie Domain"), DefaultValue(""), Description("Domain for the cookie to set. Cookie will only be sent if the host name matches.")]
public string CookieDomain { get; set; }
[DisplayName("Skip URL Encode"), DefaultValue(false), Description("By default the cookie value is URL Encoded for transfer. This will turn it off.")]
public bool SkipURLEncode { get; set; }
public override void PreWebTest(object sender, PreWebTestEventArgs e)
{
if (!String.IsNullOrEmpty(CookieParameter) && e.WebTest.Context.ContainsKey(CookieParameter))
CookieValue = e.WebTest.Context[CookieParameter].ToString();
if (!SkipURLEncode)
{
CookieValue = System.Net.WebUtility.UrlEncode(CookieValue);
CookieName = System.Net.WebUtility.UrlEncode(CookieName);
}
e.WebTest.Context.CookieContainer.Add(new System.Net.Cookie(CookieName, CookieValue, CookiePath, CookieDomain));
}
}
[DisplayName("Add Parameter To Reporting Name")]
[Description("This request plugin will add the specified parameter to the end of the reporting name of the request")]
public class AddParameterToReportingName : WebTestRequestPlugin
......