Exemplo n.º 1
0
# -*- coding:utf-8 -*-
import test_core
import demjson

test_core.title("登录测试")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "" or jsonfiledata["token"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"] + "chktoken.php"
udataarr = {
    'token': jsonfiledata["token"],
}
test_core.postarray(uurl, udataarr, True)
Exemplo n.º 2
0
# -*- coding:utf-8 -*-
import test_core
test_core.title("加密 I/O 测试")
uurl = "http://127.0.0.1/NyarukoLogin/tests/conntest.php"
udataarr = {'testkey1': "testval1", 'testkey2': "testval2"}
test_core.postarray(uurl, udataarr, True)
default_public_key = '''-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAq47jTLBnFvlBWu/c7fIG
rsw2vMW0xOF+AnQR8L9+i7Em32KVejbSVeIrISGC+0xIfjgQpkRKYRB+xJag8c6J
QDrHFkdckIvitYc4iiuvmAnTyiOCzLQgH9lVUdJ67+2qK5k3dc9ojhPFVWwpTknx
eX7XdkLOG6Ei0locKwh27YusgBrkkRpAM8EqO6E+19vS7Hr8V1KsrEz/9a232fhf
vqF/F347f/RCwX4Iuu0djYeaS9Je+DtMjqWO47ZUDwgQxhWSXpfjCqxSyi1a+b0b
JCWP2vejXbHVeWaihlzAs+XLNd6Kefq4BGNmK+FH0lT70NWnPMJVpWf0/L3znJrm
v3wVXpeh4uP2TvpucNtjrF8eVMTzc1y/Un2zYF/HBcRlcl8/yJZnCYHOdTqfj0xI
uXgAy/wzDmgfKL+kJ3kLWdCJwdnE2HLS8BWwI07Uq/T2iL3qSAqFcM84Ouv3bZ9B
Ex669h82eEMWp0j0xAB/MIoy93N0nEDU5WijZYK3z044i5lO2utks8wCav5OrT57
zjt3lRoJibBBeZUG/rAKnJ7RQgT/YuuTwRBp9IsTgkU5iwFmCLJ+3n30fgF+Lpsh
uvtl5EyR2WhL/yFjTkocydcWiK/w0y3VDy74Zgsd4M0FL5e7ig17baOEo5PhEYsp
si0uFCjCOiY4lgOH/E+BJVkCAwEAAQ==
-----END PUBLIC KEY-----'''

test_core.title("请求加密密钥")
# 需要提供與資料庫 app 表中記錄的內容
jsonfiledata = test_core.getjsonfiledata(False)
if jsonfiledata["publickey"] == "" or jsonfiledata["privatekey"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
# 建立一個金鑰對
test_core.tlog("正在生成本地密钥对 ...")
rsakeys = RSA.gen_key(4096, 65537)
bio = BIO.MemoryBuffer()
rsakeys.save_key_bio(bio, None)
privatekey = bio.read_all()
rsakeys.save_pub_key_bio(bio)
publickey = bio.read_all()
privatekeymd5 = test_core.md5(test_core.clearkey(str(privatekey, encoding = "utf-8")))
publickeymd5 = test_core.md5(test_core.clearkey(str(publickey, encoding = "utf-8")))
# -*- coding:utf-8 -*-
import test_core
import sys
import demjson
test_core.title("检查邮件或短信验证码是否正确并获取临时令牌")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"]+"nyavcode.php"
udataarr = {
    "apiver": 2,
    "vcode": "573702",
    "type": "mail"
}
test_core.postarray(uurl, udataarr, True)
# -*- coding:utf-8 -*-
import test_core
import webbrowser
import demjson
test_core.title("获得验证码测试")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"] + "nyacaptcha.php"
udataarr = {}
img = test_core.postarray(uurl, udataarr, True)["img"]
webbrowser.open(img)
Exemplo n.º 6
0
# -*- coding:utf-8 -*-
import test_core
import demjson
import datetime
test_core.title("媒体可以提供的尺寸和格式")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"]+"nyamediafiles.php"
udataarr = {
    'path':"/2020/03/03/23d241520fb0c06282f16d11082b5903"
}
test_core.postarray(uurl,udataarr,True)
Exemplo n.º 7
0
# -*- coding:utf-8 -*-
import test_core
import sys
import demjson
test_core.title("用户资料")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"] + "nyauserinfo.php"
udataarr = {"token": jsonfiledata["token"]}
test_core.postarray(uurl, udataarr, True)
# -*- coding:utf-8 -*-
import test_core
import sys
import demjson
test_core.title("获取站内信")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"] + "nyamessage.php"
udataarr = {
    "token": jsonfiledata["token"],
    "mode": 2,  # 0 重要未讀 1 普通未讀 2 所有未讀 3 已讀 ? 所有
    "onlylen": 0,
    "limit": 0,
    "offset": 10
}
test_core.postarray(uurl, udataarr, True)
# -*- coding:utf-8 -*-
import test_core
import sys
import demjson
test_core.title("设置站内信的已读和未读状态")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"] + "nyamessage.php"
udataarr = {
    "token": jsonfiledata["token"],
    "msghash":
    "ZisdNxnCkvUQBJrRJ4vtQ7NUuBHhCtgd8pgSX7U74rpCQNQZuJXdymVDVrcDRhzJ",
    "readstat": 0  # 0 未讀 1 已讀 2 全部已讀
}
test_core.postarray(uurl, udataarr, True)
Exemplo n.º 10
0
# -*- coding:utf-8 -*-
import test_core
import webbrowser
import sys
test_core.title("注册用户测试")
udataarr = {}
udataarr["user"] = test_core.instr("请输入邮箱或手机号码(默认值 [email protected]): ")
if (udataarr["user"] == ""): udataarr["user"] = "******"
test_core.tlog("用户名: " + udataarr["user"])
udataarr["password"] = test_core.instr("请输入新密码(默认值 testpassword): ")
if (udataarr["password"] == ""): udataarr["password"] = "******"
test_core.tlog("密码: " + udataarr["password"])
udataarr["nickname"] = test_core.instr("请输入昵称(默认值 测试用户): ")
if (udataarr["nickname"] == ""): udataarr["nickname"] = "测试用户"
test_core.tlog("昵称: " + udataarr["nickname"])
test_core.tlog("正在申请验证码 ...")
uurl = "http://127.0.0.1/NyarukoLogin/nyacaptcha.php"
udataarr2 = {}
img = test_core.postarray(uurl, udataarr2, True)["img"]
test_core.tlog("在浏览器中打开验证码图像: " + img)
webbrowser.open(img)
udataarr["captcha"] = test_core.instr("请输入验证码(默认值 0000): ")
if (udataarr["captcha"] == ""): udataarr["captcha"] = "0000"
test_core.tlog("验证码: " + udataarr["captcha"])
uurl = "http://127.0.0.1/NyarukoLogin/nyasignup.php"
test_core.postarray(uurl, udataarr, True)
Exemplo n.º 11
0
# -*- coding:utf-8 -*-
import test_core
import sys
import demjson
test_core.title("获取邮件验证码")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"] + "nyavcode.php"
udataarr = {
    "to": "*****@*****.**",
    "captcha": sys.argv[1]  # 请先运行 test_getcaptcha.py 获取验证码,并将验证码作为参数输入
}
test_core.postarray(uurl, udataarr, True)
Exemplo n.º 12
0
# -*- coding:utf-8 -*-
import test_core
import sys
import demjson
import random
import string

test_core.title("注册子账户")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"] + "nyastand.php"
salt = ''.join(random.sample(string.ascii_letters + string.digits, 16))
udataarr = {
    "token": jsonfiledata["token"],
    "nickname": "小雅诗" + salt,
    "gender": "2",
    "age": "18"
}
test_core.postarray(uurl, udataarr, True)
Exemplo n.º 13
0
# -*- coding:utf-8 -*-
import test_core
import sys
import demjson
test_core.title("搜索用户")
f = open("testconfig.json", 'r')
lines = f.read()
f.close()
jsonfiledata = demjson.decode(lines)
if jsonfiledata["url"] == "":
    test_core.terr("错误: 'testconfig.json' 配置不完全。")
    exit()
uurl = jsonfiledata["url"] + "search.php"
udataarr = {'type': "username", 'word': sys.argv[1]}
test_core.postarray(uurl, udataarr, True)