Commit a24fe3a2 a24fe3a2498fab44732dc7e8e9aff16c5fa7ee5a by Christian Gerdes

Added Report Name Automator (needs more testing though)

1 parent 8dfa4d7d
......@@ -323,6 +323,72 @@ namespace LIL_VSTT_Plugins
}
/// <summary>
/// Sätter Reporting name
/// </summary>
[DisplayName("Report Name Automator")]
[Description("(C) Copyright 2017 LIGHTS IN LINE AB\r\nSätter automatiskt Reporting Name på requests")]
public class WebTestReportingNameAutomator : WebTestPlugin
{
[DisplayName("Use RegEx with group")]
[Description("Will use the Set To Name as a regular expression with a group and use the matching group result as the Reporting Name. If no match, reporting name will not be set to \"no-match\"")]
[DefaultValue(false)]
public bool useRegGroup { get; set; }
[DisplayName("Run on Dependents")]
[Description("If set to true will run on dependents")]
[DefaultValue(false)]
public bool runOnDependents { get; set; }
[DisplayName("Run on Requests")]
[Description("If set to true will run on requests (default)")]
[DefaultValue(true)]
public bool runOnRequests { get; set; }
[DisplayName("Set to Name")]
[Description("The name to be set or the regular expression to be used. Groups are specified within () like (.+?) would match the shortest possible string")]
[DefaultValue(false)]
public string reportingName { get; set; }
private Regex regex = null;
public override void PostRequest(object sender, PostRequestEventArgs e)
{
if(runOnDependents)
foreach (WebTestRequest r in e.Request.DependentRequests)
{
r.ReportingName = getNameToSet(r.Url);
}
}
public override void PreRequest(object sender, PreRequestEventArgs e)
{
if (runOnRequests)
e.Request.ReportingName = getNameToSet(e.Request.Url);
}
private void createRegExOnce() {
if(regex == null) {
regex = new Regex(reportingName);
}
}
private string getNameToSet(string input) {
string result = "no-match";
if (useRegGroup == false)
result = reportingName;
else
{
createRegExOnce();
Match m = regex.Match(input);
if (m.Success && m.Groups.Count > 0)
{
result = m.Groups[0].Value;
}
}
return result;
}
}
/// <summary>
/// Service Manager Plugin
/// </summary>
[DisplayName("Service Manager Config")]
......
......@@ -33,5 +33,11 @@
<RuleParameter Name="PreRequestVal" Value="False" />
</RuleParameters>
</WebTestPlugin>
<WebTestPlugin Classname="LIL_VSTT_Plugins.WebTestDependentRegexFilter, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Dynamisk URL Regex filter" Description="(C) Copyright 2011 LIGHTS IN LINE AB&#xD;&#xA;Filter för att ignorera vissa objekt på websidor så de inte laddas ner automatiskt.">
<RuleParameters>
<RuleParameter Name="FilterString" Value="stat.swedbank.se" />
<RuleParameter Name="Exclude" Value="True" />
</RuleParameters>
</WebTestPlugin>
</WebTestPlugins>
</WebTest>
\ No newline at end of file
......