postman interface test data association between interfaces


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 postman. This article uses the login interface that needs to be encrypted as an example to describe the process of postman 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.
Insert image description here

2. Operation steps

1. Create global variables and environment variables

Create 3 global variables to facilitate subsequent interface calls
Create global variables
environment variables

2. 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 get the value of RSA in Tests under the public key request and store it in the global variable of postman for easy reference in the next step.
Get public key
Code analysis:
1. Obtain the response json string
2. Obtain the RSA value of the json string and splice it into a public key
3. Store the public key in the postman environment variable

3. Use the public key to encrypt the password

Under the login request, write a script in the Pre-request-Script tab to encrypt the password and store it in the environment variable.
encryption

3. Initiate a request after encrypting the password

Initiate a login request after password encryption


Summarize

The above is what I will talk about today. This article only briefly introduces the data association operations in postman. The focus is on mastering the setting of postman's environment variables and global variables, and referencing them.

Guess you like

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