···1313)
14141515type OpenBaoManager struct {
1616- client *vault.Client
1717- mountPath string
1818- logger *slog.Logger
1616+ client *vault.Client
1717+ mountPath string
1818+ logger *slog.Logger
1919+ connectionTimeout time.Duration
1920}
20212122type OpenBaoManagerOpt func(*OpenBaoManager)
···2627 }
2728}
28293030+func WithConnectionTimeout(timeout time.Duration) OpenBaoManagerOpt {
3131+ return func(v *OpenBaoManager) {
3232+ v.connectionTimeout = timeout
3333+ }
3434+}
3535+2936// NewOpenBaoManager creates a new OpenBao manager that connects to a Bao Proxy
3037// The proxyAddress should point to the local Bao Proxy (e.g., "http://127.0.0.1:8200")
3138// The proxy handles all authentication automatically via Auto-Auth
···4350 }
44514552 manager := &OpenBaoManager{
4646- client: client,
4747- mountPath: "spindle", // default KV v2 mount path
4848- logger: logger,
5353+ client: client,
5454+ mountPath: "spindle", // default KV v2 mount path
5555+ logger: logger,
5656+ connectionTimeout: 10 * time.Second, // default connection timeout
4957 }
50585159 for _, opt := range opts {
···62706371// testConnection verifies that we can connect to the proxy
6472func (v *OpenBaoManager) testConnection() error {
6565- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
7373+ ctx, cancel := context.WithTimeout(context.Background(), v.connectionTimeout)
6674 defer cancel()
67756876 // try token self-lookup as a quick way to verify proxy works
+5-2
spindle/secrets/openbao_test.go
···152152 for _, tt := range tests {
153153 t.Run(tt.name, func(t *testing.T) {
154154 logger := slog.New(slog.NewTextHandler(os.Stderr, nil))
155155- manager, err := NewOpenBaoManager(tt.proxyAddr, logger, tt.opts...)
155155+ // Use shorter timeout for tests to avoid long waits
156156+ opts := append(tt.opts, WithConnectionTimeout(1*time.Second))
157157+ manager, err := NewOpenBaoManager(tt.proxyAddr, logger, opts...)
156158157159 if tt.expectError {
158160 assert.Error(t, err)
···596598597599 // All these will fail because no real proxy is running
598600 // but we can test that the configuration is properly accepted
599599- manager, err := NewOpenBaoManager(tt.proxyAddr, logger)
601601+ // Use shorter timeout for tests to avoid long waits
602602+ manager, err := NewOpenBaoManager(tt.proxyAddr, logger, WithConnectionTimeout(1*time.Second))
600603 assert.Error(t, err) // Expected because no real proxy
601604 assert.Nil(t, manager)
602605 assert.Contains(t, err.Error(), "failed to connect to bao proxy")