- 账号导入:支持'账号----密码----手机号----接码链接'四段式解析与持久化存储 - 旋转验证码 (rotate_auth / xz):逆向分析官方协议,基于圆周边界采样互相关算法秒级计算旋转还原角度 - 文本点选验证码 (dx_auth):内置成语与古诗名句语料,支持题干菜名提取与古诗/成语挖空正则求解及小图动态合成 - 短信二次验证 (sms_auth2):结合 sms_url 自动轮询接码链接并 Hex 编码提交官方过验 - 前端交互:增加接码标签、在线查询短信验证码、一键自动短信登录与测试接码链接功能 - 回归测试:新增旋转验证、短信接码流与文本点选测试用例(173 passed)
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
"""虎牙文本点选验证码 (dx_auth 填空/菜名/成语) 目标提取与提示图合成测试。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import cv2
|
|
import numpy as np
|
|
|
|
from core.huya.verification.solver import HuyaVerificationSolver
|
|
|
|
|
|
def test_extract_target_chars_from_dish_question() -> None:
|
|
question = '请按照菜名"客家盐焗鸡"中汉字的顺序,在给定图片中点选对应的汉字'
|
|
chars = HuyaVerificationSolver._extract_target_chars_from_question(question)
|
|
assert chars == ["客", "家", "盐", "焗", "鸡"]
|
|
|
|
|
|
def test_extract_target_chars_from_poem_cloze() -> None:
|
|
question = '请按照古诗"千_鸟_绝"中汉字被挖空的顺序,在给定图片中点选对应的汉字以填充完整给定古诗'
|
|
chars = HuyaVerificationSolver._extract_target_chars_from_question(question)
|
|
assert chars == ["山", "飞"]
|
|
|
|
|
|
def test_extract_target_chars_from_idiom_cloze() -> None:
|
|
question = '请按照成语"_眸皓_"中汉字被挖空的顺序,在给定图片中点选对应的汉字以填充完整给定成语'
|
|
chars = HuyaVerificationSolver._extract_target_chars_from_question(question)
|
|
assert chars == ["明", "齿"]
|
|
|
|
|
|
def test_synthesize_text_tip() -> None:
|
|
chars = ["客", "家", "盐", "焗", "鸡"]
|
|
img_bytes = HuyaVerificationSolver._synthesize_text_tip(chars)
|
|
assert len(img_bytes) > 0
|
|
arr = np.frombuffer(img_bytes, np.uint8)
|
|
img = cv2.imdecode(arr, cv2.IMREAD_COLOR)
|
|
assert img is not None
|
|
assert img.shape[0] == 44
|
|
assert img.shape[1] == 220
|