JMetter, Encrypt requests, decrypt responses - jmeter

The system encrypts all requests and returns encrypted data. How can I encrypt all requests and decrypt responses? Also, can I load the JSON body of the request with the parameters from the file, something like:
{"Token":${token}, "SomeParam": ${somevalue}}

Encryption/decryption should be possible using JSR223 PreProcessor and JSR223 PostProcessor correspondingly, JMeter comes with Apache Commons Codec library which provides handy APIs for encryption/decryption of data using various algorithms
With regards to loading request parameters from the file containing nested JMeter Variables go for __eval() and __FileToString() functions combination like:
${__eval(${__FileToString(your_file.json,,)})}
Check out Here’s What to Do to Combine Multiple JMeter Variables for more information.

Related

is there way to use postman request with pre request script in jmeter?

I already have created a postman collection with a pre-request script and test is there any way to import those data into the JMeter to perform a load test ??
Depending on what the pre-request script is doing.
JMeter's equivalent for the Postman's pre-request script is JSR223 PreProcessor so if you choose javascript as the language theoretically you should be able to re-use your pre-request script in JMeter:
But be aware that
Unlike Postman JMeter is not a browser hence it cannot execute JavaScript so JavaScript support is being performed via Nashorn engine and it doesn't support everything
If you're using Postman JavaScript API (pm.* object and friends) - you will need to find equivalents in JMeter API
The only recommended scripting language for JMeter is Groovy so if massive refactoring of the pre-request script is required it worth considering re-writing it in Groovy

Unauthorized error while performing load testing on HMAC API using Jmeter

I am performing load testing of HMAC API, I get an error message "unauthorized".
The API requests in POSTMAN uses HMAC authentication and generates a code.
I tried converting into jmx format from json via Loadimpact. The converted file doesn't hold the HMAC code. In Jmeter, file doesn't load the HMAC code.
Can anyone advice what alternative solutions are available? Does it really work with bean shell pre/post procedures.
Postman per se isn't capable of performing HMAC encryption of the request, my expectation is that you're using some form of a pre-request script
This logic cannot be recorded and replayed, JMeter equivalent would be JSR223 PreProcessor
Request headers and body can be obtained/modified using prev shorthand for HTTPSamplerProxy class instance, see JavaDoc for all available functions and Top 8 JMeter Java Classes You Should Be Using with Groovy for more information on this and other JMeter API shortcuts available for the JSR223 Test Elements
Given that JMeter comes with Commons Codec you can easily use HmacUtils class to generate whatever you need

In JMeter, how can I correlate/parameterize from HTTP Header Manager?

My HTTP Request has child HTTP Header Manager. The HTTP Header Manager has dynamic values, and other parameters depending on search on GUI application. See picture. The xsrf-token is dynamic, and auditlog varies depending on my search by vEnl. I am using JMeter 4.0. The HTTP Requests are GET, and therefore cannot use the checkbox "Use multipart/form-data for POST" either. How can I correlate/parameterize in this situation?
Use Regular Expression Extractor in the response of whatever request which has the right value for this Header Manager. Name it for example :testDynaVar
Then use ${testDynaVar} in auditlog's value. The parameter value will be passed to this header manager.
You need to extract this xsrf-token from the previous response using a suitable JMeter Post-Processor, save it into a JMeter Variable and substitute recorded hard-coded value with this variable in the HTTP Header Manager, check out How to Load Test CSRF-Protected Web Sites article for example implementation.
HTTP Header Manager can evaluate JMeter Variables in the runtime and substitute the placeholders with the respective values:
with regards to this auditlog header your question doesn't contain enough information to come up with the proper configuration, from the first glance you can parameterize this ctime argument using __time() function

How to make working login into Laravel 5.+ with JMeter?

I'm trying to test a few functions on my Laravel based website. However, I'm having difficulties logging in the website. I've used BlazeMeters Chrome plugin to record my events and save it in jmx file. Was able to do that and imported the file in JMeter. Now at login we are not just examine the email and password, but also a _token variable. This is individual for all visitors. Do I need and if yes, then how can I fetch the token for one user and use that at login time and any other time, when the _token was requested?
Bert
Your test flow should look like:
Open Login Page (usually HTTP Get Request)
Extract the token from the response using one of JMeter's Post-Processors (normally people use Regular Expression Extractor or CSS/JQuery Extractor)
Perform Login (usually HTTP Post Request) providing credentials and the token from the step 1
The process is known as correlation and there is a plenty of information on it over the Internet.
If you want to get things done faster you could consider an alternative way of recording a JMeter test scenario which automatically detects dynamic parameters, generates the relevant post-processors to extract them and store into JMeter Variables and substitutes parameters with the variables so you won't have to do it manually. Check out How to Cut Your JMeter Scripting Time by 80% article for more details.

Capture WebDriver requests in Jmeter

One of the services I gonna test using Jmeter has complex authorization mechanism that requires some CS-based steps (JavaScript). So, to set up a session, I have to use WebDriver as Jmeter can't (and actually shouldn't) process JS.
I do it in the following way: at the beginning of each thread I open the resource in real browser (via Jmeter WebDriver plugin), complete authorization, store browser cookies that was set up by server and then use these cookies to generate load using standard Jmeter logic within defined HTTP-session.
This schema works fine and I successfully use it in different load tests.
But now the service I test requires not only cookies but also some important parameters that browser sends in POST as a part of authorization process. To prove that my requests belong to the same session, I should extract some sensitive parameters not from response (it can be easily done) but from request.
I can't find these values stored anywhere in DOM and it seems like these values are generated by JS attached to response page.
So, my question is: is there a way to capture parameters from request sent by WebDriver?
I understand that all requests done by browser initiated in Jmeter are not visible to it. And the only idea I see is to use Jmeter request recorder dynamically:
Open browser window.
Define Jmeter as a proxy for this browser.
Capture requests sent by browser in Jmeter using recorder.
Somehow extract sensitive data from requests.
Use the data to generate load.
Any ideas appreciated. Thanks in advance!
Solved the issue by running local proxy server (BrowserMob Proxy project) using BeanShell sampler. I retarget the WebDriver Sampler to this proxy, perform required actions using browser, then store captured data in HAR format and process it (extract required data from requests). Then just store valuable request parameters in variables (or properties) and use them in a regular way in HTTP sampler to generate load. Hope it can help anyone else in future.

Resources