Dynamic token handling of a gis application - dynamic

I m doing performance testing of a gis application using jmeter in which lot of map tiles load as i login to the application.each tile is a http request containing a dynamic token in its header which expires in 15 mins.I know handling of dynamic token using regex where i replace the token with a regex but problem here is that there are huge no.of map tiles so replacing each token one by one is not feasible option...can anyone suggest how do I change all the token at once or any other solution?

JMeter's HTTP Header Manager obeys JMeter Scoping Rules
so if you move it 1 level up (to be at the same position as your HTTP Request sampler) you will need to perform the change at one place only

Related

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?

Use authentication token in follow-up requests in Postman

My app API requires authentication via an authentication token. In short, we send a request to a /authentication endpoint and it responds with a JSON object containing a token, like:
{"token": "xxxxxxxxxxxxxxxxxxxxxx"}
Every other API endpoint in our application requires an authentication header containing this token. Now, in Postman it's possible to do the authentication request, copy the token, open the next endpoint and paste the authentication header in manually. But this becomes tedious and time-consuming when testing lots of endpoints.
Is there a way to have Postman save and automatically add the authentication token from one request in any follow-up requests?
Even better, could Postman automatically send the /authentication request prior to any of the other requests?
Postman allows you a wide variety of options when crafting API requests.
In your case, You can create a global variable for your token when you receive it by:
var jsonData = JSON.parse(responseBody);
postman.setGlobalVariable('token', jsonData.token);
This would go in your Tests tab, in order to execute this script after your request has been completed.
Now, a global variable token is set and can be accessed using {{token}} syntax in the following API requests you make.
I'll demonstrate it to you regarding the same, with a similar example:
1. Save the data of latitude and longitude into the global variables lat and long.
2. Reuse the data by referring to the name of the variable, i.e. lat and long by enclosing them within curly braces like {{lat}} and {{long}}.
You can also manage these global variables, by clicking on the gear icon in the top right corner, and selecting manage environments then opening the Globals tab.
Tip: You can also, save the request to obtain the token into your collections, so that each time, you don't have to craft the URL to obtain the token.

JMeter Security Token not parsed

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.

overwrite csv file using jmeter beanshell

i'm testing an API service using OAuth tokens.
we have to divide the load per api service, therefore i seperated all services in different thread groups (also to make requests in parallel). since extracted OAUTH tokens (you need the acces token to make request to api) are only local to thread groups, i used a small beanshell script to write all tokens to a CSV file.
later on, these tokens are used when doing the API calls.
the problem i'm facing is that the 'CSV Dataset Config' element is pre-loaded in memory (correct me if wrong), and because the tokens arent received yet at that point my API calls are failing with regex EOF. this happens only a few times where after the request succeed. i implemented a once only controller for the api requests to implement some thinktime, but this does only helps waiting for all users to get authenticated and receive the tokens.
question 1: how can i read token values in realtime from the CSV file for each api call (using custom code/beanshell)?
question 2: how can i make my beanshell script (see below) REWRITE the whole csv file each time the oauth2 sequence is run (now it keeps on appending to it..) ?
situation:
Issue fixed using 2 seperate testplans;
plan A) do one iteration with X amount of needed concurrent users to generate needed tokens + write tokens to CSV file.
plan B) call all API services divided in Throughput Controllers using CSV dataset (OAUTH sequence not needed).

What difference is token in header and body?

I found a doubt when I was designing API. Some documents guide developers how to make and deal with token.
If I will access a website requiring token authentication, I should set my token in HTTP header, let service ascertain my validity.
Although I think designing setting up method can be flexible, for examples, setting in header or body, I don't know what difference are they?
In this token case, because token is secret info, is setting in header safer than in body? or setting in header can't make HTTP be a burden? What information does it fit with setting in header?
It's no special when data sets in header or body.
Except you have specail data needs to set in header, and then your web application only accepts the specify method to do. It follows you how to desgin the processing workflow.