-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig_test.go
More file actions
40 lines (35 loc) · 959 Bytes
/
config_test.go
File metadata and controls
40 lines (35 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"github.com/nuts-foundation/nuts-admin/oidc"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
"testing"
)
type MessageHook string
func (m *MessageHook) Run(_ *zerolog.Event, _ zerolog.Level, message string) {
*m = MessageHook(message)
}
func TestConfig_Print(t *testing.T) {
var capturedMessage MessageHook
logger = log.Hook(&capturedMessage)
t.Run("redacting", func(t *testing.T) {
t.Run("no OIDC client secret set", func(t *testing.T) {
config := Config{}
config.Print()
assert.Contains(t, string(capturedMessage), `"Secret":""`)
})
t.Run("OIDC client secret set", func(t *testing.T) {
config := Config{
OIDC: oidc.Config{
Client: oidc.ClientConfig{
Secret: "changeme",
},
},
}
config.Print()
assert.NotContains(t, string(capturedMessage), "changeme")
assert.Contains(t, string(capturedMessage), `"Secret":"*****"`)
})
})
}