更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -12,19 +12,15 @@ import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// TestVerifyFilesEndToEnd 走真实 HTTP 链路验证:
|
||||
// 根路径下的验证文件能被吐出来,且不带白名单的路径仍然 404。
|
||||
func TestVerifyFilesEndToEnd(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "1XXl8fPHr9.txt"), []byte("1XXl8fPHr9"), 0o644); err != nil {
|
||||
t.Fatalf("准备测试文件失败: %v", err)
|
||||
}
|
||||
// 注册到全局 beego(与线上 router.go 的注册方式一致)
|
||||
RegisterVerifyFiles(dir, "")
|
||||
|
||||
beego.BeeApp.Handlers.Init()
|
||||
|
||||
// 1) 验证文件正常返回
|
||||
req := httptest.NewRequest(http.MethodGet, "/1XXl8fPHr9.txt", nil)
|
||||
req.Host = "api.yunzer.cn"
|
||||
rec := httptest.NewRecorder()
|
||||
@@ -40,7 +36,6 @@ func TestVerifyFilesEndToEnd(t *testing.T) {
|
||||
t.Logf("Content-Type: %s", ct)
|
||||
}
|
||||
|
||||
// 2) 不存在的验证文件仍走正常路由(404),行为不变
|
||||
req2 := httptest.NewRequest(http.MethodGet, "/not-exist-verify.txt", nil)
|
||||
req2.Host = "api.yunzer.cn"
|
||||
rec2 := httptest.NewRecorder()
|
||||
@@ -51,7 +46,6 @@ func TestVerifyFilesEndToEnd(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAppRootFrom 确认服务根目录按「含 conf/app.conf 的目录」定位。
|
||||
func TestAppRootFrom(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(root, "conf"), 0o755); err != nil {
|
||||
@@ -74,9 +68,6 @@ func TestAppRootFrom(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestDefaultDirResolvesToRepoVerifyDir 确认默认目录落在「服务根目录/verify」下,
|
||||
// 且仓库里的验证文件能被解析出来、内容正确。
|
||||
// 线上等价:服务根目录 /www/wwwroot/api.yunzer.cn → verify/1XXl8fPHr9.txt。
|
||||
func TestDefaultDirResolvesToRepoVerifyDir(t *testing.T) {
|
||||
orig, err := os.Getwd()
|
||||
if err != nil {
|
||||
@@ -84,7 +75,6 @@ func TestDefaultDirResolvesToRepoVerifyDir(t *testing.T) {
|
||||
}
|
||||
defer os.Chdir(orig)
|
||||
|
||||
// 切到 go/ 目录:这里有 conf/app.conf,等价于线上服务根目录
|
||||
goRoot := filepath.Dir(orig)
|
||||
if err := os.Chdir(goRoot); err != nil {
|
||||
t.Fatalf("切换工作目录失败: %v", err)
|
||||
|
||||
Reference in new issue
Block a user