mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-20 18:18:08 +02:00
core/zero: add support for managed mode from config file
This commit is contained in:
parent
eb729a53f8
commit
78f2793d38
4 changed files with 68 additions and 9 deletions
41
internal/zero/cmd/env_test.go
Normal file
41
internal/zero/cmd/env_test.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_getToken(t *testing.T) {
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
assert.Equal(t, "", getToken(""))
|
||||
})
|
||||
t.Run("env", func(t *testing.T) {
|
||||
t.Setenv("POMERIUM_ZERO_TOKEN", "FROM_ENV")
|
||||
assert.Equal(t, "FROM_ENV", getToken(""))
|
||||
})
|
||||
t.Run("json", func(t *testing.T) {
|
||||
fp := filepath.Join(t.TempDir(), "config.json")
|
||||
require.NoError(t, os.WriteFile(fp, []byte(`{
|
||||
"pomerium_zero_token": "FROM_JSON"
|
||||
}`), 0o644))
|
||||
assert.Equal(t, "FROM_JSON", getToken(fp))
|
||||
})
|
||||
t.Run("yaml", func(t *testing.T) {
|
||||
fp := filepath.Join(t.TempDir(), "config.yaml")
|
||||
require.NoError(t, os.WriteFile(fp, []byte(`
|
||||
pomerium_zero_token: FROM_YAML
|
||||
`), 0o644))
|
||||
assert.Equal(t, "FROM_YAML", getToken(fp))
|
||||
})
|
||||
t.Run("toml", func(t *testing.T) {
|
||||
fp := filepath.Join(t.TempDir(), "config.toml")
|
||||
require.NoError(t, os.WriteFile(fp, []byte(`
|
||||
pomerium_zero_token = "FROM_TOML"
|
||||
`), 0o644))
|
||||
assert.Equal(t, "FROM_TOML", getToken(fp))
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue