已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// 功能描述:未配置短信及缓存不可用时不能返回虚假验证码成功;版本:1.0.0。
|
||||
package common
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/config"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// TestVerificationUnavailable 覆盖关闭Mock及缺少缓存的拒绝路径,不连接外部服务。
|
||||
func TestVerificationUnavailable(t *testing.T) {
|
||||
oldEnabled, oldCache := config.Spec.Global.MockVerificationEnabled, impl.RedisService
|
||||
defer func() { config.Spec.Global.MockVerificationEnabled, impl.RedisService = oldEnabled, oldCache }()
|
||||
impl.RedisService = nil
|
||||
for _, enabled := range []bool{false, true} {
|
||||
config.Spec.Global.MockVerificationEnabled = enabled
|
||||
response := httptest.NewRecorder()
|
||||
ctx, _ := gin.CreateTestContext(response)
|
||||
ctx.Request = httptest.NewRequest("POST", "/auth/verification-code", strings.NewReader(`{"phone":"13800000001","purpose":"set_payment_password"}`))
|
||||
ctx.Request.Header.Set("Content-Type", "application/json")
|
||||
SendVerificationCode("user_app")(ctx)
|
||||
body := response.Body.String()
|
||||
if strings.Contains(body, "request_identity") || strings.Contains(body, `"code":0`) {
|
||||
t.Fatalf("不可用服务不应创建成功请求:%s", body)
|
||||
}
|
||||
if !enabled && !strings.Contains(body, "2410") {
|
||||
t.Fatalf("关闭Mock必须说明短信尚未配置:%s", body)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user