mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-05 12:23:03 +02:00
config: add decode hook for the SANMatcher type (#4464)
This commit is contained in:
parent
a2539839d3
commit
1b3ee7ff8f
3 changed files with 42 additions and 0 deletions
|
@ -341,6 +341,27 @@ func Test_parsePolicyFile(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func Test_decodeSANMatcher(t *testing.T) {
|
||||
// Verify that config file parsing will decode the SANMatcher type.
|
||||
const yaml = `
|
||||
downstream_mtls:
|
||||
match_subject_alt_names:
|
||||
- dns: 'example-1\..*'
|
||||
- dns: '.*\.example-2'
|
||||
`
|
||||
cfg := filepath.Join(t.TempDir(), "config.yaml")
|
||||
err := os.WriteFile(cfg, []byte(yaml), 0644)
|
||||
require.NoError(t, err)
|
||||
|
||||
o, err := optionsFromViper(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []SANMatcher{
|
||||
{Type: SANTypeDNS, Pattern: `example-1\..*`},
|
||||
{Type: SANTypeDNS, Pattern: `.*\.example-2`},
|
||||
}, o.DownstreamMTLS.MatchSubjectAltNames)
|
||||
}
|
||||
|
||||
func Test_Checksum(t *testing.T) {
|
||||
o := NewDefaultOptions()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue