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
Showing
3 changed files
with
51 additions
and
1 deletions
... | @@ -1502,6 +1502,7 @@ | ... | @@ -1502,6 +1502,7 @@ |
1502 | <Compile Include="BouncyCastle_src\x509\X509V2AttributeCertificateGenerator.cs" /> | 1502 | <Compile Include="BouncyCastle_src\x509\X509V2AttributeCertificateGenerator.cs" /> |
1503 | <Compile Include="BouncyCastle_src\x509\X509V2CRLGenerator.cs" /> | 1503 | <Compile Include="BouncyCastle_src\x509\X509V2CRLGenerator.cs" /> |
1504 | <Compile Include="BouncyCastle_src\x509\X509V3CertificateGenerator.cs" /> | 1504 | <Compile Include="BouncyCastle_src\x509\X509V3CertificateGenerator.cs" /> |
1505 | <Compile Include="Skv.cs" /> | ||
1505 | <Compile Include="ValidationRules.cs" /> | 1506 | <Compile Include="ValidationRules.cs" /> |
1506 | <Compile Include="ExtractionRules.cs" /> | 1507 | <Compile Include="ExtractionRules.cs" /> |
1507 | <Compile Include="Beta.cs" /> | 1508 | <Compile Include="Beta.cs" /> | ... | ... |
LIL_VSTT_Plugins/Skv.cs
0 → 100644
1 | /* Skatteverkets plugins | ||
2 | (C) Skatteverket Svenska STATEN!!! | ||
3 | */ | ||
4 | |||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using System.Linq; | ||
8 | using System.Text; | ||
9 | using System.Threading.Tasks; | ||
10 | using Microsoft.VisualStudio.TestTools.WebTesting; | ||
11 | using System.ComponentModel; | ||
12 | |||
13 | namespace LIL_VSTT_Plugins | ||
14 | { | ||
15 | [DisplayName("Validera Header")] | ||
16 | [Description("(C) Mårten\r\nValiderar att en header har ett visst värde i svaret.")] | ||
17 | public class ValidateHeader : ValidationRule | ||
18 | { | ||
19 | [DisplayName("Header Namn"), DefaultValue(""), Description("Namnet på headern i svaret")] | ||
20 | public string HeaderName { get; set; } | ||
21 | |||
22 | [DisplayName("Värde"), DefaultValue(""), Description("Värdet som headern ska ha")] | ||
23 | public string HeaderValue { get; set; } | ||
24 | |||
25 | public override void Validate(object sender, ValidationEventArgs e) | ||
26 | { | ||
27 | e.IsValid = false; | ||
28 | e.Message = "Default triggades. False! Check the code!!"; | ||
29 | if (e.Response.Headers[HeaderName] == HeaderValue) | ||
30 | { | ||
31 | e.IsValid = true; | ||
32 | e.Message = "Hittade header " + HeaderName + " med värde " + HeaderValue; | ||
33 | } else | ||
34 | { | ||
35 | e.IsValid = false; | ||
36 | e.Message = "Hittande ingen header med namnet " + HeaderName + " och värdet " + HeaderValue; | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | } |
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <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=""> | 2 | <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=""> |
3 | <Items> | 3 | <Items> |
4 | <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" /> | 4 | <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"> |
5 | <ValidationRules> | ||
6 | <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
Validerar att en header har ett visst värde i svaret." Level="High" ExectuionOrder="BeforeDependents"> | ||
7 | <RuleParameters> | ||
8 | <RuleParameter Name="HeaderName" Value="Server" /> | ||
9 | <RuleParameter Name="HeaderValue" Value="Apache-Coyote/1.1" /> | ||
10 | </RuleParameters> | ||
11 | </ValidationRule> | ||
12 | </ValidationRules> | ||
13 | </Request> | ||
5 | </Items> | 14 | </Items> |
6 | </WebTest> | 15 | </WebTest> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment