mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-08 04:18:13 +02:00
restructure
This commit is contained in:
parent
40efa26257
commit
c7fd5a4752
7 changed files with 86 additions and 122 deletions
|
@ -1,29 +1,33 @@
|
|||
package bootstrap_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/zero/bootstrap"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/zero/bootstrap"
|
||||
"github.com/pomerium/pomerium/pkg/cryptutil"
|
||||
cluster_api "github.com/pomerium/zero-sdk/cluster"
|
||||
)
|
||||
|
||||
func TestFile(t *testing.T) {
|
||||
secret := []byte("secret")
|
||||
|
||||
src, err := bootstrap.New(secret)
|
||||
require.NoError(t, err)
|
||||
cfg := src.GetConfig()
|
||||
require.NotNil(t, cfg)
|
||||
|
||||
// test that the config is valid
|
||||
require.NoError(t, cfg.Options.Validate())
|
||||
|
||||
// test that the config is deterministic
|
||||
src2, err := bootstrap.New(secret)
|
||||
cipher, err := cryptutil.NewAEADCipher(cryptutil.NewKey())
|
||||
require.NoError(t, err)
|
||||
|
||||
cfg2 := src2.GetConfig()
|
||||
require.NotNil(t, cfg2)
|
||||
txt := "test"
|
||||
src := cluster_api.BootstrapConfig{
|
||||
DatabrokerStorageConnection: &txt,
|
||||
}
|
||||
|
||||
require.Equal(t, cfg.Options, cfg2.Options)
|
||||
fd, err := os.CreateTemp(t.TempDir(), "test.data")
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, fd.Close())
|
||||
|
||||
require.NoError(t, bootstrap.SaveBootstrapConfigToFile(&src, fd.Name(), cipher))
|
||||
|
||||
dst, err := bootstrap.LoadBootstrapConfigFromFile(fd.Name(), cipher)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, src, *dst)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue