MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / newTestServerWithOptions

Function newTestServerWithOptions

internal/api/server_test.go:30–57  ·  view source on GitHub ↗
(t *testing.T, opts ...ServerOption)

Source from the content-addressed store, hash-verified

28}
29
30func newTestServerWithOptions(t *testing.T, opts ...ServerOption) *Server {
31 t.Helper()
32
33 gin.SetMode(gin.TestMode)
34
35 tmpDir := t.TempDir()
36 authDir := filepath.Join(tmpDir, "auth")
37 if err := os.MkdirAll(authDir, 0o700); err != nil {
38 t.Fatalf("failed to create auth dir: %v", err)
39 }
40
41 cfg := &proxyconfig.Config{
42 SDKConfig: sdkconfig.SDKConfig{
43 APIKeys: []string{"test-key"},
44 },
45 Port: 0,
46 AuthDir: authDir,
47 Debug: true,
48 LoggingToFile: false,
49 UsageStatisticsEnabled: false,
50 }
51
52 authManager := auth.NewManager(nil, nil, nil)
53 accessManager := sdkaccess.NewManager()
54
55 configPath := filepath.Join(tmpDir, "config.yaml")
56 return NewServer(cfg, authManager, accessManager, configPath, opts...)
57}
58
59func TestHealthz(t *testing.T) {
60 server := newTestServer(t)

Calls 2

NewManagerFunction · 0.92
NewServerFunction · 0.85

Tested by

no test coverage detected