Illustration of how Jmeter does data association


Preface

Whether during performance testing or interface testing, you will always encounter the problem of interface dependency, which requires data association. Data association can be easily achieved using Jmeter. This article uses the login interface that needs to be encrypted as an example to describe the process of Jmeter data association.


1. Interface

As shown in the figure below, to implement the login function, you must first obtain the public key, then use the public key to encrypt the login password and then initiate a login request.
Get public key

get public key
Log in after encrypting the login password

2. Usage steps

1. Obtain the public key

The RSA in the response data of the public key interface is the public key of the RSA encryption algorithm.
The first step is to add a JSON extractor under the public key request to get the RSA value and store it in a variable for easy reference in the next step.
Insert image description here
In the second step, under the public key request, add a BeanShell post-processor and set the obtained account as an environment variable of Jmeter to facilitate reference in the next request.
Insert image description here

2. Use the public key to encrypt the password

Under the login request, add a BeanShell preprocessor to encrypt the password and store the encrypted string in a Jmeter variable
Insert image description here
Insert image description here

3. Initiate a request after encrypting the password

Insert image description here

4. Log in successfully

Insert image description here


Summarize

The above is what I will talk about today. This article only briefly introduces the data association operations in Jmeter. The focus is on mastering the use of BeanShell preprocessor and postprocessor, the use of Json extractor, how to set Jmeter's environment variables and variables, and Make a reference.

Guess you like

Origin blog.csdn.net/liangxiaoyan0426/article/details/130853052