Passing an email as login to JMeter HTTP Request - jmeter

Trying to create a JMeter test to login to a site where my username is my email. I've tried with encode checked and unchecked but it keeps coming back saying invalid login, and in the HTTP request i see it posting the variable with %40 instead of the # symbol. Any suggestions on what i'm doing wrong?

Actually I see 3 possibilities to pass email as login. I would recommend you to act in the following way(-s):
1) name login/password as variables and then pass them in POST login request as parameters:
2) to load login (as email) from .csv file and the pass it in POST request
3) to write jMeter script using Chrome extension without launching jMeter.
Hope this works for you.

Step 1: Check how the browser is sending your request (encoded or unencoded), you can use a recording with jmeter for that or you can use for example Fiddler.
Step 2: Base your input for the request on Step 1. So if the browser sends parameter x as encoded, your also going to have to send it encoded in Jmeter.

Related

JMeter - Should I remove Redirect from recorded script?

I used the Blazemeter Chrome plug-in to record. When the UserID is checked, browser is redirected to another URL. This redirect is recorded in the script.
Want to ask:
I read that the redirect will occur during the UserID check if I have Follow Redirects checked ? Is this correct ? The reason I ask is that I saw some extra HTTP request generated but they are not the same URL as the redirect which was sent from the server.
So I can actually just remove the redirect URL recorded ?
Thanks.
Your JMeter test must generate the same network footpring as the real browser does
So you can use a sniffer tool like Wireshark or Fiddler to compare the number/nature of the requests which originate from JMeter and from the real browser, the requests must be exactly the same (apart from dynamic parameters which needs to be correlated)
If HTTP Request sampler redirects automatically and the next request basically duplicates the redirected one - remove the recorded one.
If automatic redirect is causing troubles and you're not able to extract dynamic elements because they're "hidden" in 2nd level of sub-results - disable redirection in the HTTP Request sampler and leave the recorded separate request which mimics redirection.

Location parameter was not display in response header for extract access token in JMeter

The location field contains the token value for the next redirecting page. But I am unable to get that token value from the response header to navigate to the next page.
But while we run the browser manually we can see the location filed in the response header.
how can I get an access token without a location parameter else how to get the location parameter in JMeter response header?
If you're not getting the same response with JMeter comparing to the real browser it means that you're not sending the same request (or requests sequence)
Try playing with Redirect automatically / Follow redirects checkboxes, it might be the case JMeter is not properly redirecting you to the proper location
You need to compare the requests originating from JMeter and real browser using:
either browser developer tools and View Results Tree listener
or using a 3rd-party sniffer tool like Fiddler or Wireshark
Once you configure JMeter to behave exactly like the real browser you should get the same response including the Location header.
For Azure B2C login we need to follow the below steps:
Need to extract CSRF and State Properties from below endpoints
.........onmicrosoft.com/b2c_1_xxx_signup_signin_v2/oauth2/v2.0/authorize
Regex Expression Main sample only : "csrf":"([^"]+)","transId":"StateProperties=([^"]+)
Pass above value in below endpoints
............/B2C_1_xxx_SignUp_SignIn_V2/client/perftrace?tx=StateProperties=${csrf_sp_g2}&p=B2C_1_xxx_SignUp_SignIn_V2
3.Extract Code value from below endpoints Main and sub sample body : code=([^"]+)
....../B2C_1_xxx_SignUp_SignIn_V2/api/CombinedSigninAndSignup/confirmed
PAss above code value in below endpoints parameter
......../b2c_1_xxx_signup_signin_v2/oauth2/v2.0/token
You will find the token value in main sample only and also you will get location parameter in sub sample

Same POST works manually, results in 500 error via Jmeter

In my script, I'm using a JSESSIONID instead of a cookie; the JSESSIONID is extracted using a HTTP URL Re-writing Modifier and I can confirm that the correct value (the one which appears in the response data from the login page) is being applied in the Request.
e.g. POST https://qa67.ososinfo.org:446/Staff/staffdetail.xhtml;JSESSIONID=0655ca5420354753ae413984d34cfc27
I'm also using a VIEWSTATE, which I'm extracting prior to running the remainder of the test steps by using a Regular Expression Extractor and setting the resulting variable as a parameter in the HTTP Request,
e.g. javax.faces.ViewState=8d2%2BgOIseczB2FWSo74DqQfkmiYVaK73D8bnLTNWCx%2FB8EtE
The problem is that I'm hitting a Response code: 500 | Response message: Internal Server Error every time I attempt a post with all of the applicable data.
I tried running through the steps manually in a Firefox browser. I copied the contents of the Request tab from the failing page into a REST client, logged in using a separate tab of the same browser and grabbed the appropriate JSESSIONID and VIEWSTATE information, then posted with that info in place - and the manual post was successful.
Am I missing something? Is JMeter requiring something to accomplish this POST that a I'm not seeing in a manual attempt? Please note that I can verify the test is working through the point of login - I can manually see the jmeter user logged in from an admin screen.
Happy to share any/all of what I'm seeing if it might be helpful in helping to troubleshoot.

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.

Using cookie values in HTTP request post body with JMeter

I'm having a problem similar to the one in this post: JMeter; session cookie, but approached from a different angle.
The similarity is at the bottom of the post, where the OP writes:
How... can I set and submit a unique cookie for each user whose value is extracted from the first Response Header?
We're using JMeter for load testing, and need to have several users logged in to our email client at once. The way our website (and test plan) works is:
Enter username/ password, click Sign In.
Click Email.
Receive auth token (used for staying signed in to the email client) in a cookie.
Upon interaction with the email client (open a folder, mark an email as read, etc), send the auth token in the post body.
The problem is that the auth token is not getting stored as a value in such a way that it can be used in a POST request (and because the auth token is not sent as a cookie, we can't simply store it and send it with an HTTP Cookie Manager). The cookie is initially set like this:
AUTH_TOKEN=(long string of letters, numbers, and underscores); Domain=.ourdomain.net; Path=/
We've tried the following to extract the auth token value from the cookie:
Using a Regular Expression Extractor to extract the value from the response header of the "Click Email" step. We've tried two regular expressions; both simply cause JMeter to use the default auth token value when the test is run:
AUTH_TOKEN\=(\w+)\;
AUTH_TOKEN=([^;]+);
Defining the property "CookieManager.save.cookies=true" (as suggested by the user manual) and "CookieManager.check.cookies=false" (as suggested in this thread) in user.properties, then using "${COOKIE_AUTH_TOKEN}" in the post body.
With either or both of these in place, JMeter sets ${COOKIE_AUTH_TOKEN} as the auth token value in the post body.
We know that ${COOKIE_cookieName} is the correct format, as this has worked with other cookies that JMeter is storing.
I've read through a number of threads but none have dealt with this specific issue. I just started learning how to use JMeter a few weeks ago, so I'm not sure what to do here, and any help would be greatly appreciated. Thanks!
The problem was actually being caused by an incorrect request being sent to the server, to which it was then sending a blank response. Once we tore down and rewrote the entire test plan (what we were using was actually a modified version of another test plan) and had CookieManager.save.cookies=true in user.properties, we were able to use ${COOKIE_AUTH_TOKEN} and get the correct value.

Resources