Jmeter Login Request with cookies have wrong Response - jmeter

I m new in jmeter i want to know if i send post request for login with cookies then in Response below information is displaying .
Request Error We’re sorry, there was a problem with your request.
Please make sure you have cookies enabled and try again.
What could be going wrong.?

It may be not about the missing or incorrect cookies.
You need to provide valid loginCsrfParam value as well, it needs to be extracted from previous response via one of the following PostProcessors:
Regular Expression Extractor
XPath Extractor
CSS/JQuery Extractor
converted into a JMeter Variable and used as a parameter in your login request.
See How to Load Test CSRF-Protected Web Sites guide for comprehensive information on bypassing CSRF protection in your JMeter test.

Related

How can I resolve a 403 response code in Jmeter?

I am working with Jmeter to do load testing. I created a simple login script using BlazeMeter. Then I imported the file into Jmeter.
Whenever I try to run the script, it fails. The first problem I encounter here is that in my first http request I receive a 403 response code:
I added a cookie manager and an authorization manager to try and solve this but it is not working. I think the problem is with cors in the manager header as 403 code means that it received the petition but the access to it was denied. Do you have any suggestions on how to resolve this? I tried adding post processors but couldn't make them work. Maybe because I am a newbie to jmeter and load testing. Idk.
As per HTTP Status 403 description
The HTTP 403 Forbidden client error status response code indicates that the server understood the request but refuses to authorize it.
so most probably your request is missing some authentication context.
Your recording seems to be incomplete, you seem to be testing a GeneXus-based application and it is using AJAX_SECURITY_TOKEN header as the security parameter.
From your screenshot it seems that you're sending recorded hard-coded value, however you should design your script as follows:
Perform initial request, i.e. open login page
Extract AJAX_SECURITY_TOKEN header value using Regular Expression Extractor
Substitute this e8985.... recorded value with the JMeter Variable from the Regular Expression Extractor
Check out Using Regular Expressions to Extract Tokens and Session IDs to Variables article for more information.

Get CSRF token in Jmeter for salesforce load-testing

I am trying to do the load testing of salesforce.com. I am logging via test.salesforce.com which is redirecting me to the console url. Now, subsequent post request accepts following post parameters.
ViewStateCSRF
ViewStateMAC
visualforce.ViewState
But this post request is failing with "invalid session" error message.
I am guessing this is because of CSRF token. I am trying to extract(post processor in Jmeter) CSRF token, but I am unable to find this token anywhere in the response/cookie of previous requests. In one of the HTML response, I can find few CSRF tokens(e.g: runApexCsrfToken, consoleAjaxCsrfToken etc). I have tried all of them but no result.
To summarize my problem: I need to pass csrf token in post login request but I am unable to find this token in previous responses.
Could you please help me with this.
PS: I have tried get request on "https://c.salesforce.com/libs/granite/csrf/token.json" after login but did not find any token in response.
Make sure to add HTTP Cookie Manager to your Test Plan
Make sure to check all response fields as the token can be a part of URL or come as a HTTP Header
You need to correlate not only ViewStateCSRF but all other dynamic parameters as well
If you have problems with identifying the source for the dynamic parameters values you can try recording your scenario using cloud-based proxy service, it is capable of exporting recorded scripts in "SmartJMX" mode with automatic detection and correlation of dynamic parameters. See How to Cut Your JMeter Scripting Time by 80% article for more details

Jmeter : getting 401 error

Does any one knows how to solve it with regular expression? here i am putting screen shot with valid access token and error response token.
thanks in advance.
Valid response token
invalid response token
and Regular expression exctracter
it is fine if you guys have any other solution for this unauthorized access thing.
Add JSON Extractor as a child of the authserver request and configure it as follows:
Variable Names: anything meaningful, i.e. token
JSON Path expressions: $.access_token
Add HTTP Header Manager as a child of the student request and configure it to send Authorization header with the value of Bearer ${token}
Going forward you can go for an alternative way of recording a JMeter test which is capable of exporting the recorded requests in SmartJMX mode with automatic correlation of dynamic parameters applied so you will be able to save your time for more creative work. See How to Cut Your JMeter Scripting Time by 80% article for more details.

Can't get authorized response on requests in JMeter, while they have the same CSRF token and sessionID

I'm having trouble with getting my site normally loaded during the performance testing in Apache JMeter. Firstly I recorded the script (by BadBoy), containing authorization and visiting some pages, unavailable without login. Next, I exported it to JMeter, configured Regular Expression Extractor to get the csrftoken from the request right before the authorization request and it looks like it works just fine:
no errors in http-requests
But if to look at the tab "Response data" of every post-authorized request, the content isn't like correctly loaded page, it just starts page with the empty authorization form, i.e. in some way session is new though all the requests have the same session id and csrftoken in Cookie Data and in Set-Cookie (Sample result), appeared in authorization request result.
HTTP Cookie Manager is added.
Did anyone face this trouble?
UPDATE: I've conducted an experiment with transferring cookies from Chrome to Mozilla Firefox, copied 'csrftoken' and 'session id', and - voila! - it worked, I got the same authorized session in two browsers. Still have no idea what's wrong with JMeter
JMeter automatically treats HTTP Response Codes below 400 as successful, it doesn't perform any checks of response body. Most likely your Regular Expression Extractor failed, add a Debug Sampler and double check resulting variable value.
There could be also the following possible reasons:
You might need to send CSRF token in encoded/escaped form so using i.e. __urlEncode() function will be required. Or vice versa.
Application may expect the token in multiple locations, i.e. not only as a form parameter, but as an extra HTTP Header. In that case you will need to pass it via HTTP Header Manager
You might also want to try the new step-by-step debugger for JMeter to get to the bottom of the issue.
This is the default behavior of this token. 1. make sure where these tokens are passed. It might be passed multiple times. Check the header. Generally, "xref-token" is again passed.
It should be in exact format, decode it if required, also remove , or ; or /. You can also use fiddler.
The solution was found after recording a script by Blazemeter plugin in Chrome and further exporting it in '.JMX' format. Adding an HTTP Header Manager like this (with its special fields, of course) to each HTTP Request solved the problem.

Facing issues in Jmeter script for asmx calls

We recorded a business flow with Jmeter. In our script we have some asmx calls. All calls are sending requests in http format.
The recorded asmx requests are not sending any parameters (not possible to do correlation).
But after replay, all asmx calls are failing where we are sending some session values in cookies in our requests in view result tree. But not
Getting those sessions in any of the previous response.
Please help me out to fix it.
Thanks in advance
I believe that the problem is in cookies.
Try adding a HTTP Cookie Manager to your test plan. JMeter should be smart enough to handle cookies for you. If you have any cookies being sent via "Browser-derived Headers" - remove them.
If point 1 doesn't help you should be able to manually extract cookie data from Set-Cookie header via Regular Expression Extractor. Inspect View Results Tree Listener output for any Set-Cookie headers being sent in responses.
Don't forget to "tell" your Regular Expression Extractor to look at Headers response field (it defaults to Body)

Resources