Ny funktionalitet i ServiceManagerCondig WebTest Plugin som anger avancerade proxy inställningar
Showing
6 changed files
with
112 additions
and
7 deletions
| ... | @@ -52,6 +52,31 @@ namespace LIL_VSTT_Plugins | ... | @@ -52,6 +52,31 @@ namespace LIL_VSTT_Plugins |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | /// <summary> | 54 | /// <summary> |
| 55 | /// LoadTest Context Copy | ||
| 56 | /// </summary> | ||
| 57 | [DisplayName("Personnummer Generator")] | ||
| 58 | [Description("(C) Copyright 2017 LIGHTS IN LINE AB\r\nGenererar personnummer och sätter dem som parameter till testernas context.")] | ||
| 59 | public class LoadTestPnumGen : ILoadTestPlugin | ||
| 60 | { | ||
| 61 | //store the load test object. | ||
| 62 | LoadTest mLoadTest; | ||
| 63 | |||
| 64 | public void Initialize(LoadTest loadTest) | ||
| 65 | { | ||
| 66 | mLoadTest = loadTest; | ||
| 67 | |||
| 68 | //connect to the TestStarting event. | ||
| 69 | mLoadTest.TestStarting += new EventHandler<TestStartingEventArgs>(mLoadTest_TestStarting); | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | void mLoadTest_TestStarting(object sender, TestStartingEventArgs e) | ||
| 74 | { | ||
| 75 | //TODO | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | /// <summary> | ||
| 55 | /// Service Manager Plugin | 80 | /// Service Manager Plugin |
| 56 | /// </summary> | 81 | /// </summary> |
| 57 | [DisplayName("Service Manager Config")] | 82 | [DisplayName("Service Manager Config")] | ... | ... |
| ... | @@ -355,16 +355,70 @@ namespace LIL_VSTT_Plugins | ... | @@ -355,16 +355,70 @@ namespace LIL_VSTT_Plugins |
| 355 | [Description("Default inte påslaget. Om servern inte stödjer TLS1.2 kommer SSL handskakningen att avbrytas och requestet failar. Kräver .NET 4.5 samt att TLS1.2 är aktiverat i SChannel (använd bifogad schannel_high.reg om det inte är påslaget på äldre windows versioner)")] | 355 | [Description("Default inte påslaget. Om servern inte stödjer TLS1.2 kommer SSL handskakningen att avbrytas och requestet failar. Kräver .NET 4.5 samt att TLS1.2 är aktiverat i SChannel (använd bifogad schannel_high.reg om det inte är påslaget på äldre windows versioner)")] |
| 356 | public bool useTls12 { get; set; } | 356 | public bool useTls12 { get; set; } |
| 357 | 357 | ||
| 358 | [DisplayName("Apply Override"), DefaultValue(false)] | ||
| 359 | [Description("Ändrar proxy inställningarna för detta webtest enligt detta plugin")] | ||
| 360 | [Category("Web Proxy")] | ||
| 361 | public bool proxyOverride { get; set; } | ||
| 362 | |||
| 363 | [DisplayName("Proxy URI"), DefaultValue("http://host:port")] | ||
| 364 | [Description("Anger proxyserverns URI (http://host:port)")] | ||
| 365 | [Category("Web Proxy")] | ||
| 366 | public string proxyURI { get; set; } | ||
| 367 | |||
| 368 | [DisplayName("Bypass Local"), DefaultValue(false)] | ||
| 369 | [Description("True för att inte använda proxy på lokala hostnamn, i.e. utan domännamn")] | ||
| 370 | [Category("Web Proxy")] | ||
| 371 | public bool proxyBypassLocal { get; set; } | ||
| 372 | |||
| 373 | [DisplayName("Bypass RegExp"), DefaultValue("")] | ||
| 374 | [Description("Sätter ett reguljärt uttryck för URI (hostnamn) som INTE ska gå via proxyn")] | ||
| 375 | [Category("Web Proxy")] | ||
| 376 | public string proxyBypass { get; set; } | ||
| 377 | |||
| 378 | [DisplayName("User Name"), DefaultValue("")] | ||
| 379 | [Description("Sätter användarnamn för proxyn")] | ||
| 380 | [Category("Web Proxy")] | ||
| 381 | public string proxyUser { get; set; } | ||
| 382 | |||
| 383 | [DisplayName("User Password"), DefaultValue("")] | ||
| 384 | [Description("Sätter swedbanks proxy (temp lösning)")] | ||
| 385 | [Category("Web Proxy")] | ||
| 386 | public string proxyPass { get; set; } | ||
| 387 | |||
| 388 | System.Net.WebProxy myProxy = null; | ||
| 389 | |||
| 358 | public override void PreWebTest(object sender, PreWebTestEventArgs e) | 390 | public override void PreWebTest(object sender, PreWebTestEventArgs e) |
| 359 | { | 391 | { |
| 360 | base.PreWebTest(sender, e); | 392 | base.PreWebTest(sender, e); |
| 393 | |||
| 394 | if (proxyOverride) | ||
| 395 | { | ||
| 396 | if (myProxy == null) | ||
| 397 | { | ||
| 398 | myProxy = new System.Net.WebProxy(); | ||
| 399 | if(!String.IsNullOrWhiteSpace(proxyURI)) myProxy.Address = new Uri(proxyURI); | ||
| 400 | myProxy.BypassProxyOnLocal = proxyBypassLocal; | ||
| 401 | if (!String.IsNullOrWhiteSpace(proxyBypass)) myProxy.BypassList = new string[] { proxyBypass }; | ||
| 402 | if (!String.IsNullOrWhiteSpace(proxyUser)) myProxy.Credentials = new System.Net.NetworkCredential(proxyUser, proxyPass); | ||
| 403 | } | ||
| 404 | // Change the webtests proxy setting | ||
| 405 | e.WebTest.Proxy = "lil"; | ||
| 406 | e.WebTest.WebProxy = myProxy; | ||
| 407 | // Set context parameters | ||
| 408 | e.WebTest.Context["proxyOverride"] = proxyOverride; | ||
| 409 | e.WebTest.Context["proxyURI"] = proxyURI; | ||
| 410 | e.WebTest.Context["proxyBypassLocal"] = proxyBypassLocal; | ||
| 411 | e.WebTest.Context["proxyBypass"] = proxyBypass; | ||
| 412 | e.WebTest.Context["proxyUser"] = proxyUser; | ||
| 413 | e.WebTest.Context["proxyPass"] = proxyPass; | ||
| 414 | } | ||
| 415 | |||
| 361 | System.Net.ServicePointManager.Expect100Continue = exp100; | 416 | System.Net.ServicePointManager.Expect100Continue = exp100; |
| 362 | System.Net.ServicePointManager.MaxServicePointIdleTime = maxIdle; | 417 | System.Net.ServicePointManager.MaxServicePointIdleTime = maxIdle; |
| 363 | System.Net.ServicePointManager.SetTcpKeepAlive(keepAlive, timeOut, interVal); | 418 | System.Net.ServicePointManager.SetTcpKeepAlive(keepAlive, timeOut, interVal); |
| 364 | System.Net.ServicePointManager.UseNagleAlgorithm = useNagle; | 419 | System.Net.ServicePointManager.UseNagleAlgorithm = useNagle; |
| 365 | if(useTls12) System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; | 420 | if(useTls12) System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; |
| 366 | } | 421 | } |
| 367 | |||
| 368 | } | 422 | } |
| 369 | 423 | ||
| 370 | /// <summary> | 424 | /// <summary> | ... | ... |
No preview for this file type
No preview for this file type
| ... | @@ -88,5 +88,25 @@ namespace TestProject1 | ... | @@ -88,5 +88,25 @@ namespace TestProject1 |
| 88 | if (inLoadTest) TestContext.EndTimer("UnitTestTransaction1"); | 88 | if (inLoadTest) TestContext.EndTimer("UnitTestTransaction1"); |
| 89 | 89 | ||
| 90 | } | 90 | } |
| 91 | |||
| 92 | [TestMethod] | ||
| 93 | public void GereratePnum() | ||
| 94 | { | ||
| 95 | String fromDateStr = "1950-01-01"; | ||
| 96 | String toDateStr = "1990-01-01"; | ||
| 97 | |||
| 98 | DateTime fDate = DateTime.Parse(fromDateStr); | ||
| 99 | DateTime tDate = DateTime.Parse(toDateStr); | ||
| 100 | |||
| 101 | int numDays = (int)tDate.Subtract(fDate).TotalDays; | ||
| 102 | |||
| 103 | Random rnd = new Random(); | ||
| 104 | |||
| 105 | DateTime newDate = fDate.AddDays(rnd.Next(numDays)); | ||
| 106 | |||
| 107 | string newDateStr = newDate.ToString("yyyyMMdd") + "-" + rnd.Next(999).ToString(); | ||
| 108 | |||
| 109 | System.Console.WriteLine("Personnummer: " + newDateStr); | ||
| 110 | } | ||
| 91 | } | 111 | } |
| 92 | } | 112 | } | ... | ... |
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <WebTest Name="WebTest3" Id="f36a8078-a24b-41a0-ac62-678ed0b4ac50" 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="WebTest3" Id="f36a8078-a24b-41a0-ac62-678ed0b4ac50" Owner="" Priority="2147483647" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="proxyvip:8080" StopOnError="False" RecordedResultFile="" ResultsLocale=""> |
| 3 | <Items> | 3 | <Items> |
| 4 | <Request Method="GET" Guid="359feba0-105f-4dbf-a630-32d640c10817" Version="1.1" Url="https://new.vinnarum.com/" ThinkTime="0" 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="359feba0-105f-4dbf-a630-32d640c10817" Version="1.1" Url="https://www.lightsinline.se/" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> |
| 5 | <Request Method="GET" Guid="359feba0-105f-4dbf-a630-32d640c10817" Version="1.1" Url="https://new.vinnarum.com/" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> | 5 | <Request Method="GET" Guid="88ecadc7-6996-40c3-b058-eb2734863145" Version="1.1" Url="https://spg21.ws1.s02.ttm.swedbank.se/" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> |
| 6 | <Request Method="GET" Guid="359feba0-105f-4dbf-a630-32d640c10817" Version="1.1" Url="https://new.vinnarum.com/" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> | ||
| 7 | </Items> | 6 | </Items> |
| 8 | <WebTestPlugins> | 7 | <WebTestPlugins> |
| 9 | <WebTestPlugin Classname="LIL_VSTT_Plugins.ServiceManagerWebTestPlugin, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Service Manager Config" Description="(C) Copyright 2015 LIGHTS IN LINE AB
Sätter config värden i Service Manager instansen för hela testet."> | 8 | <WebTestPlugin Classname="LIL_VSTT_Plugins.ServiceManagerWebTestPlugin, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Service Manager Config" Description="(C) Copyright 2015 LIGHTS IN LINE AB
Sätter config värden i Service Manager instansen för hela testet."> |
| ... | @@ -14,12 +13,19 @@ | ... | @@ -14,12 +13,19 @@ |
| 14 | <RuleParameter Name="timeOut" Value="5000" /> | 13 | <RuleParameter Name="timeOut" Value="5000" /> |
| 15 | <RuleParameter Name="interVal" Value="1000" /> | 14 | <RuleParameter Name="interVal" Value="1000" /> |
| 16 | <RuleParameter Name="useNagle" Value="False" /> | 15 | <RuleParameter Name="useNagle" Value="False" /> |
| 17 | <RuleParameter Name="useTls12" Value="True" /> | 16 | <RuleParameter Name="useTls12" Value="False" /> |
| 17 | <RuleParameter Name="useProxy" Value="True" /> | ||
| 18 | <RuleParameter Name="proxyOverride" Value="True" /> | ||
| 19 | <RuleParameter Name="proxyBypassLocal" Value="False" /> | ||
| 20 | <RuleParameter Name="proxyBypass" Value="ttm.swedbank.se" /> | ||
| 21 | <RuleParameter Name="proxyURI" Value="http://proxyvip:8080" /> | ||
| 22 | <RuleParameter Name="proxyUser" Value="p950gec" /> | ||
| 23 | <RuleParameter Name="proxyPass" Value="p950gec" /> | ||
| 18 | </RuleParameters> | 24 | </RuleParameters> |
| 19 | </WebTestPlugin> | 25 | </WebTestPlugin> |
| 20 | <WebTestPlugin Classname="LIL_VSTT_Plugins.dataGenInteger, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Data Generator Integer" Description="(C) Copyright 2016 LIGHTS IN LINE AB
Genererar en slumpad integer som context parameter"> | 26 | <WebTestPlugin Classname="LIL_VSTT_Plugins.dataGenInteger, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Data Generator Integer" Description="(C) Copyright 2016 LIGHTS IN LINE AB
Genererar en slumpad integer som context parameter"> |
| 21 | <RuleParameters> | 27 | <RuleParameters> |
| 22 | <RuleParameter Name="ParamNameVal" Value="TimeStampParameter1" /> | 28 | <RuleParameter Name="ParamNameVal" Value="RandomInteger" /> |
| 23 | <RuleParameter Name="IntegerMin" Value="0" /> | 29 | <RuleParameter Name="IntegerMin" Value="0" /> |
| 24 | <RuleParameter Name="IntegerMax" Value="100" /> | 30 | <RuleParameter Name="IntegerMax" Value="100" /> |
| 25 | <RuleParameter Name="PrePageVal" Value="True" /> | 31 | <RuleParameter Name="PrePageVal" Value="True" /> | ... | ... |
-
Please register or sign in to post a comment