(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestAutomationPolicyIsSubset(t *testing.T) { |
| 11 | for i, test := range []struct { |
| 12 | a, b []string |
| 13 | expect bool |
| 14 | }{ |
| 15 | { |
| 16 | a: []string{"example.com"}, |
| 17 | b: []string{}, |
| 18 | expect: true, |
| 19 | }, |
| 20 | { |
| 21 | a: []string{}, |
| 22 | b: []string{"example.com"}, |
| 23 | expect: false, |
| 24 | }, |
| 25 | { |
| 26 | a: []string{"foo.example.com"}, |
| 27 | b: []string{"*.example.com"}, |
| 28 | expect: true, |
| 29 | }, |
| 30 | { |
| 31 | a: []string{"foo.example.com"}, |
| 32 | b: []string{"foo.example.com"}, |
| 33 | expect: true, |
| 34 | }, |
| 35 | { |
| 36 | a: []string{"foo.example.com"}, |
| 37 | b: []string{"example.com"}, |
| 38 | expect: false, |
| 39 | }, |
| 40 | { |
| 41 | a: []string{"example.com", "foo.example.com"}, |
| 42 | b: []string{"*.com", "*.*.com"}, |
| 43 | expect: true, |
| 44 | }, |
| 45 | { |
| 46 | a: []string{"example.com", "foo.example.com"}, |
| 47 | b: []string{"*.com"}, |
| 48 | expect: false, |
| 49 | }, |
| 50 | } { |
| 51 | apA := &caddytls.AutomationPolicy{SubjectsRaw: test.a} |
| 52 | apB := &caddytls.AutomationPolicy{SubjectsRaw: test.b} |
| 53 | if actual := automationPolicyIsSubset(apA, apB); actual != test.expect { |
| 54 | t.Errorf("Test %d: Expected %t but got %t (A: %v B: %v)", i, test.expect, actual, test.a, test.b) |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | func TestAutomationPoliciesAllowSameHostOnDifferentPorts(t *testing.T) { |
| 60 | input := `https://example.com:5000 localhost:5000 { |
nothing calls this directly
no test coverage detected