检查点:保存成员接口分页与失败审计专项通过候选

This commit is contained in:
xuans committed 2026-09-28 18:57:10 +08:00
1 parent 66422bbac0
commit 3857dac5c8
12 files changed
+822 -2

No files matched your search

+2 -1
View File
@@ -155,7 +155,8 @@ func NewWithConfigPath(ctx context.Context, cfg config.Config, configPath string
}, management)
server = httpapi.New(httpapi.Dependencies{
Config: cfg, ConfigPath: configPath, Logger: logger, Repository: repo, Servers: serverRepo, Users: userRepo, SSHKeys: sshKeys, DeploymentFactory: deployment.SSHFactory{Secrets: secretStore},
SetupDNS: dnsVerification, Secrets: secretStore, Firewall: firewall.NewManager(), AliyunChecker: aliyunAuthChecker,
ProjectMembers: repository.NewSQLProjectMemberRepository(db.DB, runtimeDatabaseConfig.Driver),
SetupDNS: dnsVerification, Secrets: secretStore, Firewall: firewall.NewManager(), AliyunChecker: aliyunAuthChecker,
IssueCertificate: workflow.IssueForHTTP,
IssueSetupCertificate: func(ctx context.Context, request certificate.SetupCertificateRequest) (certificate.SavedResource, error) {
return certificates.IssueForSetup(ctx, request)
@@ -0,0 +1,35 @@
package app
import (
"net/http"
"net/http/httptest"
"path/filepath"
"strings"
"testing"
)
// 从真实应用装配入口登录并读取默认项目,防止只在 HTTP 测试夹具中注入新仓储。
func TestApplicationWiresProjectMemberAPI(t *testing.T) {
cfg := readyApplicationConfig(t)
application, err := NewWithConfigPath(t.Context(), cfg, filepath.Join(cfg.Paths.Config, "scert.json"))
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = application.Close() })
login := httptest.NewRequest(http.MethodPost, "/api/v1/auth/login", strings.NewReader(`{"identifier":"admin","password":"Test1234!"}`))
login.Header.Set("Content-Type", "application/json")
response := httptest.NewRecorder()
application.HTTP.Handler().ServeHTTP(response, login)
if response.Code != http.StatusOK {
t.Fatalf("实际应用登录失败:%d,%s", response.Code, response.Body.String())
}
request := httptest.NewRequest(http.MethodGet, "/api/v1/projects/default/members?page_size=5", nil)
for _, cookie := range response.Result().Cookies() {
request.AddCookie(cookie)
}
listed := httptest.NewRecorder()
application.HTTP.Handler().ServeHTTP(listed, request)
if listed.Code != http.StatusOK || !strings.Contains(listed.Body.String(), `"items":[]`) {
t.Fatalf("实际应用未接入成员仓储或默认项目隐式增加成员:%d,%s", listed.Code, listed.Body.String())
}
}