mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 18:17:55 +00:00
replace global vault handlers with newVaultHandlers() (#27515)
This commit is contained in:
@@ -12,34 +12,35 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Test_extendAddonCommands tests extendAddonCommands() extends physical and logical backends with
|
||||
// those generated by newFullAddonCommands()
|
||||
func Test_extendAddonCommands(t *testing.T) {
|
||||
expMinPhysicalBackends := maps.Clone(physicalBackends)
|
||||
expMinLoginHandlers := maps.Clone(loginHandlers)
|
||||
// Test_extendAddonHandlers tests extendAddonHandlers() extends the minimal Vault handlers with handlers
|
||||
// generated by newFullAddonHandlers()
|
||||
func Test_extendAddonHandlers(t *testing.T) {
|
||||
handlers := newMinimalVaultHandlers()
|
||||
expMinPhysicalBackends := maps.Clone(handlers.physicalBackends)
|
||||
expMinLoginHandlers := maps.Clone(handlers.loginHandlers)
|
||||
|
||||
expAddonPhysicalBackends, expAddonLoginHandlers := newFullAddonCommands()
|
||||
expAddonPhysicalBackends, expAddonLoginHandlers := newFullAddonHandlers()
|
||||
|
||||
extendAddonCommands()
|
||||
extendAddonHandlers(handlers)
|
||||
|
||||
require.Equal(t, len(expMinPhysicalBackends)+len(expAddonPhysicalBackends), len(physicalBackends),
|
||||
require.Equal(t, len(expMinPhysicalBackends)+len(expAddonPhysicalBackends), len(handlers.physicalBackends),
|
||||
"extended total physical backends mismatch total of minimal and full addon physical backends")
|
||||
require.Equal(t, len(expMinLoginHandlers)+len(expAddonLoginHandlers), len(loginHandlers),
|
||||
require.Equal(t, len(expMinLoginHandlers)+len(expAddonLoginHandlers), len(handlers.loginHandlers),
|
||||
"extended total login handlers mismatch total of minimal and full addon login handlers")
|
||||
|
||||
for k := range expMinPhysicalBackends {
|
||||
require.Contains(t, physicalBackends, k, "expected to contain minimal physical backend")
|
||||
require.Contains(t, handlers.physicalBackends, k, "expected to contain minimal physical backend")
|
||||
}
|
||||
|
||||
for k := range expAddonPhysicalBackends {
|
||||
require.Contains(t, physicalBackends, k, "expected to contain full addon physical backend")
|
||||
require.Contains(t, handlers.physicalBackends, k, "expected to contain full addon physical backend")
|
||||
}
|
||||
|
||||
for k := range expMinLoginHandlers {
|
||||
require.Contains(t, loginHandlers, k, "expected to contain minimal login handler")
|
||||
require.Contains(t, handlers.loginHandlers, k, "expected to contain minimal login handler")
|
||||
}
|
||||
|
||||
for k := range expAddonLoginHandlers {
|
||||
require.Contains(t, loginHandlers, k, "expected to contain full addon login handler")
|
||||
require.Contains(t, handlers.loginHandlers, k, "expected to contain full addon login handler")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user