2024-02-01 09:11:08 -05:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
|
|
|
|
package command
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/cli"
|
|
|
|
|
"github.com/hashicorp/vault/sdk/physical"
|
|
|
|
|
physInmem "github.com/hashicorp/vault/sdk/physical/inmem"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestServerCommand(tb testing.TB) (*cli.MockUi, *ServerCommand) {
|
|
|
|
|
tb.Helper()
|
|
|
|
|
return testServerCommand(tb)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *ServerCommand) StartedCh() chan struct{} {
|
|
|
|
|
return c.startedCh
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *ServerCommand) ReloadedCh() chan struct{} {
|
|
|
|
|
return c.reloadedCh
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-03 13:31:56 -04:00
|
|
|
func (c *ServerCommand) LicenseReloadedCh() chan error {
|
|
|
|
|
return c.licenseReloadedCh
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-01 09:11:08 -05:00
|
|
|
func testServerCommand(tb testing.TB) (*cli.MockUi, *ServerCommand) {
|
|
|
|
|
tb.Helper()
|
|
|
|
|
|
|
|
|
|
ui := cli.NewMockUi()
|
|
|
|
|
return ui, &ServerCommand{
|
|
|
|
|
BaseCommand: &BaseCommand{
|
|
|
|
|
UI: ui,
|
|
|
|
|
},
|
|
|
|
|
ShutdownCh: MakeShutdownCh(),
|
|
|
|
|
SighupCh: MakeSighupCh(),
|
|
|
|
|
SigUSR2Ch: MakeSigUSR2Ch(),
|
|
|
|
|
PhysicalBackends: map[string]physical.Factory{
|
2024-05-02 08:43:55 -04:00
|
|
|
"inmem": physInmem.NewInmem,
|
|
|
|
|
"inmem_ha": physInmem.NewInmemHA,
|
|
|
|
|
"inmem_transactional": physInmem.NewTransactionalInmem,
|
2024-02-01 09:11:08 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// These prevent us from random sleep guessing...
|
|
|
|
|
startedCh: make(chan struct{}, 5),
|
|
|
|
|
reloadedCh: make(chan struct{}, 5),
|
|
|
|
|
licenseReloadedCh: make(chan error),
|
|
|
|
|
}
|
|
|
|
|
}
|