MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / TestNewHBAs

Function TestNewHBAs

internal/postgres/hba_test.go:16–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestNewHBAs(t *testing.T) {
17 matches := func(actual []*HostBasedAuthentication, expected string) cmp.Comparison {
18 printed := make([]string, len(actual))
19 for i := range actual {
20 printed[i] = actual[i].String()
21 }
22
23 parsed := strings.Split(strings.Trim(expected, "\t\n"), "\n")
24 for i := range parsed {
25 parsed[i] = strings.Join(strings.Fields(parsed[i]), " ")
26 }
27
28 return cmp.DeepEqual(printed, parsed)
29 }
30
31 hba := NewHBAs()
32 assert.Assert(t, matches(hba.Mandatory, `
33local all "postgres" "peer"
34hostssl replication "_crunchyrepl" all "cert"
35hostssl "postgres" "_crunchyrepl" all "cert"
36host all "_crunchyrepl" all "reject"
37 `))
38 assert.Assert(t, matches(hba.Default, `
39hostssl all all all "scram-sha-256"
40 `))
41}
42
43func TestHostBasedAuthentication(t *testing.T) {
44 assert.Equal(t, `local all "postgres","pgo" "peer"`,

Callers

nothing calls this directly

Calls 3

DeepEqualFunction · 0.92
NewHBAsFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected