c# - visual studio enterprise - load testing - how to log in to ADFS within coded test -
i have recorded performance test using perf/load test project in visual studio per these instructions microsoft: https://msdn.microsoft.com/en-us/library/dn250793.aspx. turned coded test clicking "generate code".
now trying run test, doesn't recognise of code it's written,
request6body.formpostparameters.add("authmethod", this.context["$hidden1.authmethod"].tostring());
(in case says there's no context parameter called "$hidden1.authmethod").
i know because adfs screen doesn't return same headers etc. each time, has written code around this, , if so, how's done?
thanks!
for our tests, developed method allows use simulated/fake login, allows use app without adfs , without redirections. of course, should disabled in production. next time record test, start straight away fake login.
we use asp.net mvc can show how works in asp.net mvc.
controller action
[allowanonymous] public actionresult impersonate([bind(prefix = "id")]string email) { impersonalisator.impersonatebyemail(email, request); return redirecttoroute("default", new { action = string.empty, controller = string.empty }); }
(so can execute: /home/impersonate/demouser@example.com
impersonalisator.impersonatebyemail
public static void impersonatebyemail(string email, httprequestbase request) { // don't need if clause, or introduce appsetting in web.config if ("true" == configurationmanager.appsettings["enableimpersonate"]) { var impersonatedidentity = new claimsidentity("applicationcookie"); impersonatedidentity.addclaim(new claim(claimtypes.email, email)); // add other claims might need var owincontext = request.getowincontext(); owincontext.authentication.signout("applicationcookie"); owincontext.authentication.signin(impersonatedidentity); } }
you can start logged in without going on adfs, don't want have adfs or other authentication services in tests anyway, e.g. in load tests might "attack" services , cause failures etc.
Comments
Post a Comment