| 70 | } |
| 71 | |
| 72 | func TestExternalCAOption(t *testing.T) { |
| 73 | testCases := []struct { |
| 74 | externalCA string |
| 75 | expected string |
| 76 | }{ |
| 77 | { |
| 78 | externalCA: "protocol=cfssl,url=anything", |
| 79 | expected: "cfssl: anything", |
| 80 | }, |
| 81 | { |
| 82 | externalCA: "protocol=CFSSL,url=anything", |
| 83 | expected: "cfssl: anything", |
| 84 | }, |
| 85 | { |
| 86 | externalCA: "protocol=Cfssl,url=https://example.com", |
| 87 | expected: "cfssl: https://example.com", |
| 88 | }, |
| 89 | { |
| 90 | externalCA: "protocol=Cfssl,url=https://example.com,foo=bar", |
| 91 | expected: "cfssl: https://example.com", |
| 92 | }, |
| 93 | { |
| 94 | externalCA: "protocol=Cfssl,url=https://example.com,foo=bar,foo=baz", |
| 95 | expected: "cfssl: https://example.com", |
| 96 | }, |
| 97 | } |
| 98 | for _, tc := range testCases { |
| 99 | opt := &ExternalCAOption{} |
| 100 | assert.NilError(t, opt.Set(tc.externalCA)) |
| 101 | assert.Check(t, is.Equal(tc.expected, opt.String())) |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | func TestExternalCAOptionMultiple(t *testing.T) { |
| 106 | opt := &ExternalCAOption{} |