Commit d398b451 d398b451d577202020290f871329bde43b86dc5d by Christian Gerdes

Nytt Validation plugin för att validera header värden. Idea by Mårten.

git-tfs-id: [https://tfs.rsv.se/tfs/LoadTestCollection]$/VSTT-Plugins;C1328
1 parent 62c22eb9
......@@ -1502,6 +1502,7 @@
<Compile Include="BouncyCastle_src\x509\X509V2AttributeCertificateGenerator.cs" />
<Compile Include="BouncyCastle_src\x509\X509V2CRLGenerator.cs" />
<Compile Include="BouncyCastle_src\x509\X509V3CertificateGenerator.cs" />
<Compile Include="Skv.cs" />
<Compile Include="ValidationRules.cs" />
<Compile Include="ExtractionRules.cs" />
<Compile Include="Beta.cs" />
......
/* Skatteverkets plugins
(C) Skatteverket Svenska STATEN!!!
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.ComponentModel;
namespace LIL_VSTT_Plugins
{
[DisplayName("Validera Header")]
[Description("(C) Mårten\r\nValiderar att en header har ett visst värde i svaret.")]
public class ValidateHeader : ValidationRule
{
[DisplayName("Header Namn"), DefaultValue(""), Description("Namnet på headern i svaret")]
public string HeaderName { get; set; }
[DisplayName("Värde"), DefaultValue(""), Description("Värdet som headern ska ha")]
public string HeaderValue { get; set; }
public override void Validate(object sender, ValidationEventArgs e)
{
e.IsValid = false;
e.Message = "Default triggades. False! Check the code!!";
if (e.Response.Headers[HeaderName] == HeaderValue)
{
e.IsValid = true;
e.Message = "Hittade header " + HeaderName + " med värde " + HeaderValue;
} else
{
e.IsValid = false;
e.Message = "Hittande ingen header med namnet " + HeaderName + " och värdet " + HeaderValue;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<WebTest Name="WebTest8" Id="bac430ba-6ffc-4989-a29b-d9425412a248" Owner="" Priority="2147483647" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale="">
<Items>
<Request Method="GET" Guid="98c3ac11-a7d8-4267-ad44-075ad706a99b" Version="1.1" Url="http://na28133.rsva.se:8080/SiteScope/servlet/Main" ThinkTime="1" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" />
<Request Method="GET" Guid="98c3ac11-a7d8-4267-ad44-075ad706a99b" Version="1.1" Url="http://www.skatteverket.se/" ThinkTime="1" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<ValidationRules>
<ValidationRule Classname="LIL_VSTT_Plugins.ValidateHeader, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Validera Header" Description="(C) Mårten&#xD;&#xA;Validerar att en header har ett visst värde i svaret." Level="High" ExectuionOrder="BeforeDependents">
<RuleParameters>
<RuleParameter Name="HeaderName" Value="Server" />
<RuleParameter Name="HeaderValue" Value="Apache-Coyote/1.1" />
</RuleParameters>
</ValidationRule>
</ValidationRules>
</Request>
</Items>
</WebTest>
\ No newline at end of file
......