调整Log纯接口测试关键字及用例

This commit is contained in:
byb11
2021-05-08 14:42:29 +08:00
parent 3d8a75f8e5
commit f4e2eb0125
2 changed files with 40 additions and 46 deletions

View File

@@ -7,12 +7,12 @@ import LogResponseVAL
import time, datetime
# import allure
list = []
# 请求schema接口得到返回数据用于其他接口
def schema(schemauerl, token):
url = schemauerl # "http://192.168.44.72:8080/v1/log/schema?logType=security_event_log"
url = schemauerl
headers = {"Content-Type": "application/x-www-form-urlencoded", "Authorization": token}
response = requests.get(url=url, headers=headers)
return response.json()
@@ -68,10 +68,13 @@ def randrom_url():
def Filter1(schemauerl, token):
list = []
json_str = schema(schemauerl, token)
print("schemauerl",json_str)
print(type(json_str))
# 获取日志属性定义
fields = json_str["data"]["fields"]
print("1111111111",fields)
# 获取不同属性支持的部不同操作
operator = json_str["data"]["doc"]["schema_query"]["references"]["operator"]
for i in fields:
@@ -189,40 +192,34 @@ def Filter1(schemauerl, token):
list.append(str1)
print(list)
print("22222222222",list)
return list
# 根据Filter1方法中的的数据写入log请求接口中来验证log请求接口
def logapiverify(logurl, token, starttime, endtime, host,port,logtypelist):
for logtype in logtypelist:
schemauerl="http://"+host+":"+port+"/v1/log/schema?logType="+logtype
filter2 = Filter1(schemauerl, token)
a = schema(schemauerl, token)
fields = a["data"]["fields"]
print(fields)
str2 = ""
for i in filter2:
print("条件:",i)
str2 = str2 + i + " " + "and" + " "
url = logurl # "http://192.168.44.72:8080/v1/log/list"
headers = {"Content-Type": "application/json",
"Authorization": token}
data = {
"start_common_recv_time": starttime,
"end_common_recv_time": endtime,
"logType": logtype,
"fields": fields,
"filter": i
}
print(data)
print(json.dumps(data))
response1 = requests.post(url=url, data=json.dumps(data), headers=headers)
code = response1.json()["code"]
print("code",code)
assert code == 200
print(response1.json()["code"])
# return response1.json()
def logapiverify(schemauerl,logurl, token, starttime, endtime,logtype):
filter2 = Filter1(schemauerl, token)
a = schema(schemauerl, token)
fields = a["data"]["fields"]
print("333333333333",filter2)
for i in filter2:
print("条件:", i)
url = logurl # "http://192.168.44.72:8080/v1/log/list"
headers = {"Content-Type": "application/json",
"Authorization": token}
data = {
"start_common_recv_time": starttime,
"end_common_recv_time": endtime,
"logType": logtype,
"fields": fields,
"filter": i
}
print(json.dumps(data))
response1 = requests.post(url=url, data=json.dumps(data), headers=headers)
code = response1.json()["code"]
assert code == 200
print(response1.json()["code"])
return response1.json()
# print("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
# print(str2)
# str3 = str2[0:-4]