Article directory
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.
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.
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.
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
3. Initiate a request after encrypting the password
4. Log in successfully
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.