JMeter Security Token not parsed - apache

I'm busy with a performance test for Confluence created by JMeter. But I'm having a problem with a security token that is required for creating a page with a post function. This is the query I use, the atl_token is presented in the query:
spaceKey=BD&titleWritten=false&linkCreation=false&title=TEST1&wysiwygContent=TEST1kahdjkaskdjadhkajdlkajsdjaldkjsadlajksdjakldjlkacmnlknmclknmlsanmclanmlclanmldmaldlksadlasmdcalcmlamlamclmalkdjsakjdalksxlakmkslmlknmdlasmdlasdad&confirm=Save&parentPageString=Backend+Development+Home&moveHierarchy=true&atl_token=c52cba0fa075e0fde71e3a5546b95a049e9926a8
But when I use this query and paste into a webpage it says the following:
Your session has expired. You may need to re-submit the form or reload the page.
Is this a timeout or should I do something else in Jmeter?

Try adding HTTP Cookie Manager and HTTP Header Manager to your test plan. They will in most cases keep track of SessionID (store and send it).
You could also read few articles online about how to use these components in practice to get better understanding of them...

There are following measures you can take to get rid of this issue:
Add cookie manager to your script.
Check the response of the request before the Post request. Ideally if should have atl_token.
If you find the token in earlier request, add Regular Expression Extractor to that request and fetch the token.
Pass that token in actual query that you are calling to create page.

Related

Is it possible to redirect back to a POST or PUT request URL after a successful SAML SSO assertion?

I have read about the relayState parameter in SAML SSO, and how the SP can redirect the user back to the original incoming URL by making use of relayState, but to my knowledge HTTP redirect only works for GET requests.
I am wondering if the same can be done for POST, PUT and DELETE requests, considering these requests usually come with data in the request body as well. I thought of returning a self-submitting form for POST requests, but this won't work for any other HTTP verb, and the original request must be a form based request too, unless the framework supports treating all types of parameters (query string, form field, json element) similarly. I also thought of making the frontend reconstruct the original request and sending it back to SP with AJAX, but I'm not sure if AJAX can actually update the browser's current page address.
My compromise solution in the end was to only relay URLs that result in a whole new page rendering with a GET verb only, and for any other requests, use the referrer URL for relaying instead. This means for the latter, the user will have to perform the task manually again after landing on the page he last saw before the SSO flow.
Not sure what the common practice in the industry is.
Thank you!
you would to maintain / save the POST data on the SP end and re-use them after SAML flow succeed. SAML as such does not provide any mean to achieve this.

Can't re-use Https Test Scripts recorder to complete actions because response code- 401 showing

Check the below scenario:
Earlier I recorded a Https Test-script recorder and completed "Login", "File-upload" & "Log-out" operations.
today I again tried to run or re-use the recorded samplers, now it's giving me the 401, unauthorized or Expired JWt token errors.
I want to get rid of this error and re-use the recorded samplers to complete my actions in teh system.enter image description here
Your request is failing to to missing or improperly implemented correlation, when you recorded your test it contained a JWT Token which probably was active for some time and has expired since then.
You need to add a suitable JMeter Post-Processor (most probably JSON Extractor) as a child of the login request, extract the token and save it into a JMeter Variable and substitute recorded hard-coded value with the variable from the JSON Extractor.

JMeter: auth2.0 Authentication Process (B2C Architecture)

Steps:
Hitting the website- It is being redirected to an URL which contains parameters such as STATE, NONCE and CLIENT-REQUEST-ID which are dynamic.
So, in JMeter, I am unable to fetch those values as those are coming directly in a HTTP request.
Any Idea, how to fetch it?
While clicking on sign in with credentials, authentication process is happening which is generating a token id.
Then in next request, redirects occur and same kind of URL is achieved (as in step1). Again same parameters are passed.
And with this request, Access token is generated.
I am unable to fetch those parameter (nonce, state, client request id). Is there anything we can do?
According to Microsoft, client-request-id is optional (so you can probably just leave it off) and if I read this right is generated by the client. So you may be able to just generate a random GUID in JMeter.
If you're being redirected to an URL which contains the parameters you're looking for you should be able to capture them from the sub-sampler
using a suitable Post-Processor like Regular Expression Extractor
Also some values like consumer key are static and never change and some values like nonce are random
If you don't need to load test the OAuth login challenge itself you can ask developers or administrators to provide you a permanent token which you can send in the Authorization header using HTTP Header Manager
Yes, you are correct but in my case I am not getting any sub-sampler(s).
That's where trouble lies!
Also, those parameters are coming from 3rd Party which is hosting the site(not in the hands of Devs)..
The whole process I am doing is for load testing.
So, any thing you wanna add for this?

Is there any way to get a Bearer token now, since Robinhood has changed the API again?

We keep playing this cat and mouse game with Robinhood.com. I have a trading app which used to trade stocks with Robinhood, but they keep changing the unsupported unofficial API to make it difficult for traders to use. I know that many people are doing the same thing and I want to reach out to them to see if there is a new answer. The latest problem is when I try to get a Bearer token using the URL https://api.robinhood.com/oauth2/token/ the API returns the following JSON: {"detail":"This version of Robinhood is no longer supported. Please update your app or use Robinhood for Web to log in to your account."}. This started happening on 4/26/2019.
Has anyone found a work around for this, yet, or have they finally beaten us into submission?
A more complete solution (not need browser):
Use requests.session.
Obtain the login page by making a GET request to "https://robinhood.com/login".
At this point the session's cookies will contain 'device_id'.
Obtain this device_id and use it in making the oauth2 token request to "https://api.robinhood.com/oauth2/token/" also add in the data request "challenge_type" (either "sms" or "email").
This request will fail with a 400 error code. Robinhood will send an SMS message or Email with a temporary (5 minute) code.
Also at this point use the 400 response's body to get "id" from "challenge" inside of the JSON object.
Confirm the challenge by making a POST request to "https://api.robinhood.com/challenge/CHALLENGEID/respond/" where CHALLENGEID is the same id mentioned in the first failed /oauth2/token/ POST request.
Make the same POST request to "https://api.robinhood.com/oauth2/token/" and include in the header "X-ROBINHOOD-CHALLENGE-RESPONSE-ID" with the value CHALLENGEID.
You can reuse a device_id with user/pass after this even after logging out.
Be cautious with storing device_id as it is the result of user/pass login and successful SMS/email 2FA.
Just got it working. At the risk of them seeing this post and changing it more, here we go:
First, you're going to want to log into your RH account in a web browser
View Source on the page, and look for clientId - it should be a big hex number separated by dashes
Add that number to your POST requests to /oauth2/token under the field device_token
There's probably another way to retrieve the device token, and I'm not even sure it's unique, but that way should work.
Good to be back here after a very long time.
Not sure if anyone is still looking for answers to this, but I have a very simple solution.
At Robinhood's login screen, enter your username/email and your password, press F12 on your keyboard to bring up the console panel and switch to the "Network" tab then wait for the page to load completely. (During this time you will see a list of items being loaded rapidly depending on the connection speed.)
At this time you can keep clearing the list by clicking on the button highlighted in the below image.
Click on button highlighted repeatedly until the list is empty
Now, log into your Robinhood account. At this point your console should display a list similar to the one shown below.
Look for the name "token/", most likely it will be the second one you get all the information you need. And this information will be under the Headers then Request Payload
I was able to find this with past knowledge and experience of web scraping for fun. And also, I needed to know this as well, since I recently started doing trades via Robinhood.
Hope this help you curious ones out there.
For my Robinhood account I am using Google Authenticator for my 2FA. What I have so far is that I send the original call that I was sending before to https://api.robinhood.com/oauth2/token/. This is giving me a response of:
{"mfa_required":true,"mfa_type":"app"}
I then repeat my oauth token request, but this time providing the value from Google Authenticator (so my GUI has to prompt me to fill it in) with this payload in the request to https://api.robinhood.com/oauth2/token/:
{"grant_type":"password","scope":"internal","client_id":"c82SH0WZOsabOXGP2sxqcj34FxkvfnWRZBKlBjFS","expires_in":86400,"device_token":"***","username":"***","password":"****","mfa_code":"***"}
and then I am getting an access token in reply

JMeter: How to capture dynamic request parameter values in HTTP Request

I have recorded a login script which has form_key parameter as dynamic. With the user of regular expression extractor, how can I capture the dynamic value in form_key?
Please help.
You need to extract this form_key parameter from previous response, i.e.
GET request to login page
Post-Processor to fetch form_key (usually Regular Expression Extractor)
POST request to login page (credentials and form_key from the previous response)
Also I would suggest to add HTTP Cookie Manager to your Test Plan.
If you experience any problems - feel free to use JMeter Magento Login Test Plan for reference