桌面端医师签署身份:审核人填写证件姓名,修复内嵌核身页误拦截

- 未绑定签署账号的审核人(如 admin)显示「证件姓名」输入,与网页端一致,
  随手机号一并提交 signer_name;认证中可「修改证件姓名」重新发起
- 内嵌 e签宝 页面按编码后的 URL 校验白名单,含 %20 的官方资源不再被误拦
- 手动「检查认证状态」仍在认证中时,提示在认证页点击「查询认证结果」

Co-Authored-By: Claude Opus 5 (1M context) <[EMAIL]>
This commit is contained in:
Your Name
2026-11-27 09:42:37 +08:00
co-authored by Claude Opus 5 (1M context)
parent 301c04ca90
commit e4d788ed32
7 changed files with 169 additions and 17 deletions
+7
View File
@@ -33,6 +33,13 @@ def test_offsite_and_app_switch_navigation_is_rejected(url: str) -> None:
assert not authentication_navigation_allowed(url)
def test_encoded_space_on_official_host_is_not_mistaken_for_control_character() -> None:
url = QUrl("https://asset.esign.cn/img/icon%20_world_.svg?t=1%202")
assert not authentication_navigation_allowed(url.toString())
assert authentication_navigation_allowed(esign_webview._policy_url(url))
assert not authentication_navigation_allowed(esign_webview._policy_url(QUrl("https://evil.test/a%20b")))
@pytest.mark.skipif(not esign_webview.WEBENGINE_AVAILABLE, reason="QtWebEngine unavailable")
def test_page_blocks_popups_frames_custom_schemes_and_uploads() -> None:
blocked: list[str] = []
+73
View File
@@ -377,6 +377,79 @@ def test_doctor_retry_mobile_failure_does_not_reopen_previous_flow(immediate: No
dialog.close()
def test_reviewer_signer_name_is_validated_and_sent_only_when_editable() -> None:
sent: list[dict[str, Any]] = []
def post(endpoint: str, payload: dict[str, Any], **_kwargs: Any) -> dict[str, Any]:
sent.append(dict(payload))
return {"enabled": True, "status": "unbound", "can_edit_signer_name": True}
repository = RemoteDoctorRepository(SimpleNamespace(get=None, post=post))
assert repository.start_esign_doctor("13800138000", " 欧阳·娜娜 ")["can_edit_signer_name"] is True
repository.start_esign_doctor("13800138000")
with pytest.raises(ValueError, match="证件姓名"):
repository.start_esign_doctor("13800138000", "admin1")
assert sent == [{"mobile": "13800138000", "signer_name": "欧阳·娜娜"}, {"mobile": "13800138000"}]
doctor = doctor_module.esign_doctor_status({"enabled": True, "status": "unbound"})
assert "can_edit_signer_name" not in doctor
with pytest.raises(ApiProtocolError):
doctor_module.esign_doctor_status({"enabled": True, "status": "unbound", "can_edit_signer_name": 1})
def test_reviewer_enters_signer_name_before_face_authentication(immediate: None) -> None:
calls: list[tuple[str, ...]] = []
result: dict[str, Any] = {"enabled": True, "status": "unbound", "can_edit_signer_name": True}
def start(*proof: str) -> dict[str, Any]:
calls.append(proof)
return {**result, "status": "authenticating", "auth_url": "https://smlt.esign.cn/reviewer"}
repository = SimpleNamespace(get_esign_doctor_status=lambda: result, start_esign_doctor=start)
dialog = doctor_module.EsignDoctorDialog(repository)
dialog.show()
assert dialog.signer_form.isVisible() and dialog.mobile_form.isVisible()
assert "证件一致的姓名" in dialog.banner.label.text()
dialog.signer_input.setText("张")
dialog.mobile_input.setText("13800138000")
dialog.start_button.click()
assert calls == [] and "证件姓名" in dialog.banner.label.text()
dialog.signer_input.setText("高兴亮")
dialog.start_button.click()
assert calls == [("13800138000", "高兴亮")]
assert dialog.identity_view.urls == ["https://smlt.esign.cn/reviewer"]
assert dialog.signer_form.isHidden() and dialog.signer_input.text() == ""
dialog.close()
def test_manual_check_while_provider_pending_explains_next_step(immediate: None) -> None:
result = {"enabled": True, "status": "authenticating", "auth_url": "https://smlt.esign.cn/doctor"}
dialog = doctor_module.EsignDoctorDialog(SimpleNamespace(get_esign_doctor_status=lambda: result))
dialog.show()
view = dialog.identity_view
assert "查询认证结果" not in dialog.banner.label.text()
dialog.poll_timer.timeout.emit()
assert "查询认证结果" not in dialog.banner.label.text()
dialog.refresh_button.click()
assert "查询认证结果" in dialog.banner.label.text() and dialog.identity_view is view
result.update(status="binding_required")
dialog.refresh_button.click()
assert dialog.bind_button.isVisible() and "查询认证结果" not in dialog.banner.label.text()
dialog.close()
def test_reviewer_can_restart_authentication_with_another_signer_name(immediate: None) -> None:
result = {"enabled": True, "status": "authenticating", "auth_url": "https://smlt.esign.cn/old",
"can_edit_signer_name": True}
repository = SimpleNamespace(get_esign_doctor_status=lambda: result)
dialog = doctor_module.EsignDoctorDialog(repository)
dialog.show()
assert dialog.signer_form.isHidden()
assert dialog.change_mobile_button.text() == "修改证件姓名"
dialog.change_mobile_button.click()
assert dialog.signer_form.isVisible() and dialog.mobile_form.isVisible()
dialog.close()
def test_enrolled_doctor_authorizes_quicksign_without_reentering_identity(immediate: None) -> None:
calls: list[str] = []
result = {"enabled": True, "status": "ready", "cert_expires_at": 2_000_000_000,