(t *testing.T)
| 104 | } |
| 105 | |
| 106 | func TestFileCAPoolUnmarshalCaddyfile(t *testing.T) { |
| 107 | type args struct { |
| 108 | d *caddyfile.Dispenser |
| 109 | } |
| 110 | tests := []struct { |
| 111 | name string |
| 112 | expected FileCAPool |
| 113 | args args |
| 114 | wantErr bool |
| 115 | }{ |
| 116 | { |
| 117 | name: "configuring no certificatest produces an error", |
| 118 | args: args{ |
| 119 | d: caddyfile.NewTestDispenser(` |
| 120 | file { |
| 121 | } |
| 122 | `), |
| 123 | }, |
| 124 | wantErr: true, |
| 125 | }, |
| 126 | { |
| 127 | name: "configuring certificates as arguments in-line produces an error", |
| 128 | args: args{ |
| 129 | d: caddyfile.NewTestDispenser(fmt.Sprintf(` |
| 130 | file %s |
| 131 | `, test_cert_file_1)), |
| 132 | }, |
| 133 | expected: FileCAPool{ |
| 134 | TrustedCACertPEMFiles: []string{test_cert_file_1}, |
| 135 | }, |
| 136 | }, |
| 137 | { |
| 138 | name: "single cert", |
| 139 | args: args{ |
| 140 | d: caddyfile.NewTestDispenser(fmt.Sprintf(` |
| 141 | file { |
| 142 | pem_file %s |
| 143 | } |
| 144 | `, test_cert_file_1)), |
| 145 | }, |
| 146 | expected: FileCAPool{ |
| 147 | TrustedCACertPEMFiles: []string{test_cert_file_1}, |
| 148 | }, |
| 149 | wantErr: false, |
| 150 | }, |
| 151 | { |
| 152 | name: "multiple certs inline and in-block are merged", |
| 153 | args: args{ |
| 154 | d: caddyfile.NewTestDispenser(fmt.Sprintf(` |
| 155 | file %s { |
| 156 | pem_file %s |
| 157 | } |
| 158 | `, test_cert_file_1, test_cert_file_1)), |
| 159 | }, |
| 160 | expected: FileCAPool{ |
| 161 | TrustedCACertPEMFiles: []string{test_cert_file_1, test_cert_file_1}, |
| 162 | }, |
| 163 | wantErr: false, |
nothing calls this directly
no test coverage detected