Keep session with Cookies in Jmeter - session

I am trying to run a simple test in jmeter but i am stuck. The steps are:
Log in
Set the Cookie Manager
Access the landing page
The first 2 steps are successful, but i get status 403 "errorId":"AUTHENTICATION_REQUIRED" on the 3rd step. My guess is it is not getting the session from log in, but everything i 've tried hasn't worked. Here is my test plan:
Any suggestions?

JMeter's HTTP Cookie Manager obeys JMeter Scoping Rules, so if you put it as a child of the Setting Cookies request it will be applied to that request only, therefore cookies will not be available to the Landing Page
Try moving the HTTP Cookie Manager one level higher so your test plan would look like:
You should be able to see which cookies are being received and sent out using View Results Tree listener

Related

how to load test nexcloud server with jmeter or smashbox

We are installing a nextcloud server in my organization and i would like to load test it before we deploy more broadly.
I have managed to do some testing with jmeter...(see answer below)
Now i would like to load test other features of nextcloud. I have found this repo but it seems it is not updated anymore : https://github.com/owncloud/smashbox
Anyone know if it is still working? (i dont have yet access to the nexcloud server os).
Apparently smashbox is designed for owncloud and not nextcloud...any hint on tools for nextcloud?
Thank you
If you "dont have yet access to the nexcloud server" then how do you know that "doesnt log in with http authorization manager"?
Whatever. Given Nextcloud doesn't ask your credentials most probably it's configured for Single-Sign-On and most probably it's Kerberos
If this is the case you will need to not only to add the HTTP Authorization Manager but also perform the relevant configuration in krb5.conf and jaas.conf files (live in "bin" folder of your JMeter installation).
You can check out Windows Authentication with Apache JMeter article for example setup and more comprehensive explanations.
So here is the answer :
You have to create two sampler http request.
the first request is a get request on the login page.
the second request is a post request on the login page.
You have to create a regular expression extractor to extract data-requesttoken:
data-requesttoken="(.+)"
You can reuse it in the post request (name : requesttoken) with the variable set in the extractor.
You also need to add a http cookie manager to the thread group and leave it blank so it handles the cookies set in the get request and in the post request.
Then the login works properly and you can tune in the loop, number of threads and ramp up
There is only one problem on my machine: the request randomly succeed or fail because the cookie manager sometimes set the proper cookies in the redirect after post request and sometimes not... (see here : JMeter randomly setting proper cookies so my request succeed )

How to save cookies in jmeter recording and replay

Here i have two questions regarding capturing the cookies through JMeter. I am using JMeter recording to capture the web browser flow . And i have added Cookies Manager under the Test plan (common for all requests) Below is my flow :
launch >select Providers >sign-In
While recording it is capturing the cookies properly . i am able to see in the "Request Data" in "View Results Tree" . But while trying to replay i am not seeing the cookies in the results.
Please let me know if i am missing some settings here.
How this will work when we increase the no of users and run.
Thanks In Advance.
JMeter doesn't record cookies, if you add HTTP Cookie Manager to your Test Plan it will automatically extract the cookies from the application's Set-Cookie response header, parse them, validate and send with Cookie header during the next request.
If you cannot see any cookies the reasons could be in:
Cookies are invalid (i.e. expired, not matching the domain/path)
Your test fails somewhere somehow, i.e. your sign-in request fails because you haven't implemented correlation of the dynamic parameters
Inspect response details using "Response Data" tab of the View Results Tree listener and ensure that your test is doing what it is supposed to be doing as it looks like it doesn't go further than first page in your case

Jmeter Log On in SAP CRM web client Error

I used Jmeter's HTTP(S) Test Script Recorder to record the Log in in SAP CRM Web client. I configured HTTP Cookie Manager using the cookies that I saw in browser developer tools ( MYSAPSSO2, Session ID, Sap-usercontext).
In the same recording test I filled some fields in SAP. I stopped the recording test.
I did it multiple times to see what parameters were dynamic and I realized that wfc-secure-id and C5_confighash and c7_confighash were dynamic. So I used regular expression to extract the dynamic values and I applied it in the requests where I filled the fields.
In View Results Tree I can see the HTML response in the Requests' response bodies that the log in was successful and the fields were filled. I also checked the SAP sessions metrics that the users are logging in.
After the successful login I went and did some recordings of a User roaming around inside the web client performing some operations and saving the results. I changed the dynamic values to fit the previously values I obtained in the login process.
The issue lies in the fact than when i went back to JMeter to do a test run, I get a logon error on the response header between the login and the new recordings. The response body of the new recordings also return empty.
I'm thinking that between the recordings, jmeter is losing the user session information
How can I connect the new records with the log in record?
You should not be hard-coding cookies in the HTTP Cookie Manager.
JMeter doesn't record cookies
headers.removeHeaderNamed(HTTPConstants.HEADER_COOKIE);// Always remove cookies
hence you should not be manually adding the cookies you see in browser to the HTTP Cookie Manager, adding an empty HTTP Cookie Manager should be enough to let JMeter automatically take care of incoming cookies.
If you don't see the cookies being added to the request(s) it usually means that:
Your HTTP Request sampler is not configured properly, i.e. "Server Name or IP" field is empty
Your server is not configured properly (i.e. it returns cookies which doesn't comply with the standard hence JMeter fails to add them)
The steps you could take are:
Enable debug logging for the HTTP Cookie Manager by adding the next line to log4j2.xml file:
<Logger name="org.apache.jmeter.protocol.http.control" level="debug" />
Use less-restrictive cookie policy, i.e. netscape
Add the next line to user.properties file:
CookieManager.check.cookies=false
Check out HTTP Cookie Manager Advanced Usage - A Guide for more information on JMeter's HTTP Cookie Manager usage/troubleshooting

Automated script logs out using JMeter

I am trying to automate testing of a web application.
I have recorded the test using JMeter proxy template (JMeter version is 3.2) and couple of times when I ran the test in the JMeter it ran properly but after sometime only some part runs properly.
Following are the steps I am doing:
Hitting the URL
Logging into the application
changing some feature in the application
and so on.
All the steps ran perfectly first few times but then after that only till login everything runs properly.
Just to be sure I tried passing the jsessionid from the first request to the next requests using the Regular "Expression Extractor". I can see in the View Results Tree that jsessionid is passed properly but next page after the step two still takes me into the login screen.
Any help will be very much appreciated.
I have attached screenshot for better understanding:
The response header of logged in page includes a sessionid which is used by another request while logging in.
All the sessionID are properly maintained still after logging in the next page takes me to the login page instead displaying what was done next in the recording.
When it comes to load testing of JSF-based web applications you need to take care at least of the following dynamic parameters:
JSESSIONID
javax.faces.Viewstate
JSESSIONID is a normal HTTP cookie so it is quite enough to add a HTTP Cookie Manager to deal with it
javax.faces.Viewstate is client state management mechanism which also acts as a security token to verify user's origin. So you will need to properly correlate it, i.e. extract from previous response using one of JMeter PostProcessors, store into a JMeter Variable and add as a parameter to the next request. Remember to do this for each and every request.
There might be more application specific dynamic parameters, the easiest way of detecting them is recording the same request (or scenario) 2 times, compare the recorded scripts, detect and work around the differences.

Session Expired Response in JMeter

I am testing particular application using JMeter 2.9.There My test plan is Thread group--> Transaction Controller.Inside that various recorded requests are there.I am using HTTP request defaults,HTTP Cookie manager and HTTP header manager,and a view result tree for validation.I found one token i.e. CSRF token to be correlated and I did correlation.But for a particular request I am finding "Session expired..Login again" response much before the logout request.My transaction flow is to Login--> Search a content-->Logout.
Please help me finding a solution.
Try put the element: HTTP Cookie Manager in Thread Group, first item.
the problem can be in the following areas:
-you were redirected automatically instead of following redirects
-login hasn't succeeded
-the session id has not been successfully passed on to the request after login
The JMeter documentation states this:
I've set up JMeter to sample the same URLs as my browser, why is JMeter not seeing the same responses?
There are various different reasons for this:
Cookies - make sure you added a Cookie Manager. Browsers process cookies unless you set them up otherwise, but JMeter does not process cookies unless you add a Cookie Manager.
User-Agent - the User-Agent is a header that is sent by browsers; it identifies the browser type. Some servers are sensitive to this setting and generate different results for what they think are different browsers. The Header Manager is used to add headers such as User-Agent.
Hidden fields - if you did not use the JMeter Proxy (or other application) to record the test plan, then it is easy to miss hidden fields from forms.
Dynamic field names/content - some servers use varying names for fields. So although the test plan may be correct at the time of creation, it does not work when replayed.
URL rewriting - TBA
from http://wiki.apache.org/jakarta-jmeter/DifferentBehaviour

Resources