提交随机生成ipv4和ipv6和URL关键字,

This commit is contained in:
lyf
2021-03-29 17:59:57 +08:00
parent 1eceea995e
commit d4a80e7192

View File

@@ -4,8 +4,7 @@ import requests
import random
import json
#import allure
number = random.randint(0,100000)
str = random.choice('abcdefghijklmnopqrstuvwxyz')
list = []
#请求schema接口得到返回数据用于其他接口
def schema(schemauerl,token):
@@ -22,6 +21,40 @@ def schema(schemauerl,token):
#5、string要包含特殊字符
#6、给查询条件赋值要给出边界和正常值
#7、IPV4、V6和URL要给出专门的方法生成
import ipaddress
#生成随机ipv4或ipv6
MAX_IPV4 = ipaddress.IPv4Address._ALL_ONES # 2 ** 32 - 1
MAX_IPV6 = ipaddress.IPv6Address._ALL_ONES # 2 ** 128 - 1
def random_ipv4():
return ipaddress.IPv4Address._string_from_ip_int(
random.randint(0, MAX_IPV4)
)
def random_ipv6():
return ipaddress.IPv6Address._string_from_ip_int(
random.randint(0, MAX_IPV6)
)
from random import Random
# 生成 12 位随机 URL 地址
def randrom_url():
str = ''
str1 = ''
chars = 'abcdefghijklmnopqrstuvwxyz0123456789'
chars1 = 'abcdefghijklmnopqrstuvwxyz0123456789!#$%^&*()'
length = len(chars)
length1 = len(chars1)
random = Random()
for x in range(random.randint(8,16)):
str += chars[random.randint(0,length - 1)]
for pp in range(random.randint(8,16)):
str1 += chars1[random.randint(0,length1 - 1)]
url = str[0:-5]+"." + str[0:-6] + "." + str[0:-7] + "/" + str1
print(url)
return url
def Filter1(schemauerl,token):
json_str = schema(schemauerl,token)
print(type(json_str))
@@ -30,6 +63,10 @@ def Filter1(schemauerl,token):
#获取不同属性支持的部不同操作
operator = json_str["data"]["doc"]["schema_query"]["references"]["operator"]
for i in fields:
number = random.randint(-2147483648,2147483647)
maxnumber = 2147483647
minnumber = -2147483648
str = random.choice('abcdefghijklmnopqrstuvwxyz!@#$%^&*')
name = i["name"]
doc = i["doc"]
#获取无任何特殊说明列: