mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
add HelloWorld example
This commit is contained in:
28
examples/HelloWorld/tests/debugtalk.py
Normal file
28
examples/HelloWorld/tests/debugtalk.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import hashlib
|
||||
import hmac
|
||||
import random
|
||||
import string
|
||||
|
||||
SECRET_KEY = "DebugTalk"
|
||||
default_request = {
|
||||
"base_url": "http://127.0.0.1:5000",
|
||||
"headers": {
|
||||
"Content-Type": "application/json",
|
||||
"device_sn": "$device_sn"
|
||||
}
|
||||
}
|
||||
|
||||
def gen_random_string(str_len):
|
||||
random_char_list = []
|
||||
for _ in range(str_len):
|
||||
random_char = random.choice(string.ascii_letters + string.digits)
|
||||
random_char_list.append(random_char)
|
||||
|
||||
random_string = ''.join(random_char_list)
|
||||
return random_string
|
||||
|
||||
def get_sign(*args):
|
||||
content = ''.join(args).encode('ascii')
|
||||
sign_key = SECRET_KEY.encode('ascii')
|
||||
sign = hmac.new(sign_key, content, hashlib.sha1).hexdigest()
|
||||
return sign
|
||||
Reference in New Issue
Block a user