The strongest in the whole network, Jmeter interface test - SHA256 encryption interface test (detailed combat)


foreword

The interface documentation is as follows:

Interface address: http://47.96.181.17:8098/login
Return format: json
Request method: POST
request parameters: {"userName": "your username", "password": "sha256 encrypted password"}
request Header:
Key: Content-Type Value: application/x-www-form-urlencoded
Key: X-Requested-With Value: XMLHttpRequest

Example of successful return:

{
    
    
	'jumpUrl': 'index',
	'success': 'true',
	'systemUser': {
    
    'avatarName': None,
	'avatarPath': 'file/avatar/2020-02-06/',
	'nickname': 'sqqdcl3',
	'rememberMe': False,
	'securityDigest': None,
	'userId': '1',
	'userName': 'sqqdcl'}
}

Example of failure return:

{
    
    'error': {
    
    'password': '密码错误'}, 'success': 'false'}

method one

Use JMeter's built-in function
1. Open the function assistant and select __digest

D1

Parameter meaning:
Digest algorithm algorithm summary: MD2, MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512;
String to be hashed: the string to be calculated;
Salt to be used for hashing ( optional): the salt used to calculate the hash (optional);

Upper case result, defaults to false (optional): The result is capitalized, the default is false (optional), that is, the default summary value is lowercase;
Name of variable in which to store the result (optional) The variable name for storing the result (optional) ;

2. Add HTTP header manager

D2

3. Add http request

D3

4. Add a listener - view the result tree, click to view the result after running

D4

Method Two

Add "BeanShell Preprocessor"
1. Add preprocessor-BeanShell PreProcessor on "Thread Group"

D5

Write the following code in Script:

import org.apache.commons.codec.digest.DigestUtils;


String password = "111111";
String pwd_sha256 = DigestUtils.sha256Hex(password);
#结果是大写:String pwd_sha256 = DigestUtils.sha256Hex(password).toUpperCase();
vars.put("pwd-sha256", pwd_sha256);  

2. Add HTTP header manager

D6

3. Add http request

D7

4. Add a listener - view the result tree, click to view the result after running

D8

The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

No matter how rough the road ahead is, as long as you ignite the fire in your heart, you can conquer all challenges. Go forward bravely, persist in struggle, and create your own brilliance with sweat and hard work. Believe in your own potential and talent, and on the road of chasing your dreams, shine brightly and create real life value.

If the heart is firm, the dream will not be far away; if you keep walking, miracles will continue. With courage and wisdom, turn pressure into motivation, overcome difficulties, and become a butterfly from a cocoon. Believe in your own ability and forge ahead, you will eventually bloom your own brilliance and compose a song of life without regrets.

Guess you like

Origin blog.csdn.net/csdnchengxi/article/details/132069959