Merge remote-tracking branch 'origin/benvin/pdbmux-source-fact-ast' into benvin/pdbmux-source-fact-fqdn
# Conflicts: # source_test.go
This commit is contained in:
@@ -657,3 +657,25 @@ func TestSourceInjector_ValueIsBackendHostname(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCertnameScope(t *testing.T) {
|
||||
tests := map[string]string{
|
||||
`["=","name","x"]`: ``,
|
||||
`["and",["=","name","x"],["=","environment","prod"]]`: ``,
|
||||
`["or",["=","certname","h1"],["=","name","x"]]`: ``,
|
||||
`["and",["not",["=","certname","h1"]],["=","name","x"]]`: ``,
|
||||
`["and",["=","certname","h1"],["=","name","x"]]`: `["=","certname","h1"]`,
|
||||
`["and",["~","certname","["],["=","name","x"]]`: ``,
|
||||
`["and",["in","certname",["extract","certname",["=","a","b"]]],["=","name","x"]]`: ``,
|
||||
`["and",["in","certname",["array",["h1","h2"]]],["~","certname","^h"],["=","name","x"]]`: `["and",["in","certname",["array",["h1","h2"]]],["~","certname","^h"]]`,
|
||||
}
|
||||
for in, want := range tests {
|
||||
var ast []json.RawMessage
|
||||
if err := json.Unmarshal([]byte(in), &ast); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := certnameScope(ast); got != want {
|
||||
t.Errorf("certnameScope(%s) = %q, want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user