Commit 8dfa4d7d 8dfa4d7d42c0135c89b94bbafe7cd312064f0d4e by Christian Gerdes

Ny funktionalitet i ServiceManagerCondig WebTest Plugin som anger avancerade proxy inställningar

1 parent aff38112
......@@ -52,6 +52,31 @@ namespace LIL_VSTT_Plugins
}
/// <summary>
/// LoadTest Context Copy
/// </summary>
[DisplayName("Personnummer Generator")]
[Description("(C) Copyright 2017 LIGHTS IN LINE AB\r\nGenererar personnummer och sätter dem som parameter till testernas context.")]
public class LoadTestPnumGen : ILoadTestPlugin
{
//store the load test object.
LoadTest mLoadTest;
public void Initialize(LoadTest loadTest)
{
mLoadTest = loadTest;
//connect to the TestStarting event.
mLoadTest.TestStarting += new EventHandler<TestStartingEventArgs>(mLoadTest_TestStarting);
}
void mLoadTest_TestStarting(object sender, TestStartingEventArgs e)
{
//TODO
}
}
/// <summary>
/// Service Manager Plugin
/// </summary>
[DisplayName("Service Manager Config")]
......
......@@ -355,16 +355,70 @@ namespace LIL_VSTT_Plugins
[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)")]
public bool useTls12 { get; set; }
[DisplayName("Apply Override"), DefaultValue(false)]
[Description("Ändrar proxy inställningarna för detta webtest enligt detta plugin")]
[Category("Web Proxy")]
public bool proxyOverride { get; set; }
[DisplayName("Proxy URI"), DefaultValue("http://host:port")]
[Description("Anger proxyserverns URI (http://host:port)")]
[Category("Web Proxy")]
public string proxyURI { get; set; }
[DisplayName("Bypass Local"), DefaultValue(false)]
[Description("True för att inte använda proxy på lokala hostnamn, i.e. utan domännamn")]
[Category("Web Proxy")]
public bool proxyBypassLocal { get; set; }
[DisplayName("Bypass RegExp"), DefaultValue("")]
[Description("Sätter ett reguljärt uttryck för URI (hostnamn) som INTE ska gå via proxyn")]
[Category("Web Proxy")]
public string proxyBypass { get; set; }
[DisplayName("User Name"), DefaultValue("")]
[Description("Sätter användarnamn för proxyn")]
[Category("Web Proxy")]
public string proxyUser { get; set; }
[DisplayName("User Password"), DefaultValue("")]
[Description("Sätter swedbanks proxy (temp lösning)")]
[Category("Web Proxy")]
public string proxyPass { get; set; }
System.Net.WebProxy myProxy = null;
public override void PreWebTest(object sender, PreWebTestEventArgs e)
{
base.PreWebTest(sender, e);
if (proxyOverride)
{
if (myProxy == null)
{
myProxy = new System.Net.WebProxy();
if(!String.IsNullOrWhiteSpace(proxyURI)) myProxy.Address = new Uri(proxyURI);
myProxy.BypassProxyOnLocal = proxyBypassLocal;
if (!String.IsNullOrWhiteSpace(proxyBypass)) myProxy.BypassList = new string[] { proxyBypass };
if (!String.IsNullOrWhiteSpace(proxyUser)) myProxy.Credentials = new System.Net.NetworkCredential(proxyUser, proxyPass);
}
// Change the webtests proxy setting
e.WebTest.Proxy = "lil";
e.WebTest.WebProxy = myProxy;
// Set context parameters
e.WebTest.Context["proxyOverride"] = proxyOverride;
e.WebTest.Context["proxyURI"] = proxyURI;
e.WebTest.Context["proxyBypassLocal"] = proxyBypassLocal;
e.WebTest.Context["proxyBypass"] = proxyBypass;
e.WebTest.Context["proxyUser"] = proxyUser;
e.WebTest.Context["proxyPass"] = proxyPass;
}
System.Net.ServicePointManager.Expect100Continue = exp100;
System.Net.ServicePointManager.MaxServicePointIdleTime = maxIdle;
System.Net.ServicePointManager.SetTcpKeepAlive(keepAlive, timeOut, interVal);
System.Net.ServicePointManager.UseNagleAlgorithm = useNagle;
if(useTls12) System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
}
}
/// <summary>
......
......@@ -88,5 +88,25 @@ namespace TestProject1
if (inLoadTest) TestContext.EndTimer("UnitTestTransaction1");
}
[TestMethod]
public void GereratePnum()
{
String fromDateStr = "1950-01-01";
String toDateStr = "1990-01-01";
DateTime fDate = DateTime.Parse(fromDateStr);
DateTime tDate = DateTime.Parse(toDateStr);
int numDays = (int)tDate.Subtract(fDate).TotalDays;
Random rnd = new Random();
DateTime newDate = fDate.AddDays(rnd.Next(numDays));
string newDateStr = newDate.ToString("yyyyMMdd") + "-" + rnd.Next(999).ToString();
System.Console.WriteLine("Personnummer: " + newDateStr);
}
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<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="">
<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="">
<Items>
<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" />
<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" />
<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" />
<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" />
<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" />
</Items>
<WebTestPlugins>
<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&#xD;&#xA;Sätter config värden i Service Manager instansen för hela testet.">
......@@ -14,12 +13,19 @@
<RuleParameter Name="timeOut" Value="5000" />
<RuleParameter Name="interVal" Value="1000" />
<RuleParameter Name="useNagle" Value="False" />
<RuleParameter Name="useTls12" Value="True" />
<RuleParameter Name="useTls12" Value="False" />
<RuleParameter Name="useProxy" Value="True" />
<RuleParameter Name="proxyOverride" Value="True" />
<RuleParameter Name="proxyBypassLocal" Value="False" />
<RuleParameter Name="proxyBypass" Value="ttm.swedbank.se" />
<RuleParameter Name="proxyURI" Value="http://proxyvip:8080" />
<RuleParameter Name="proxyUser" Value="p950gec" />
<RuleParameter Name="proxyPass" Value="p950gec" />
</RuleParameters>
</WebTestPlugin>
<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&#xD;&#xA;Genererar en slumpad integer som context parameter">
<RuleParameters>
<RuleParameter Name="ParamNameVal" Value="TimeStampParameter1" />
<RuleParameter Name="ParamNameVal" Value="RandomInteger" />
<RuleParameter Name="IntegerMin" Value="0" />
<RuleParameter Name="IntegerMax" Value="100" />
<RuleParameter Name="PrePageVal" Value="True" />
......