(t *testing.T)
| 1155 | } |
| 1156 | |
| 1157 | func TestTLSRoundTripper_Inline(t *testing.T) { |
| 1158 | handler := func(w http.ResponseWriter, r *http.Request) { |
| 1159 | fmt.Fprint(w, ExpectedMessage) |
| 1160 | } |
| 1161 | testServer, err := newTestServer(handler) |
| 1162 | if err != nil { |
| 1163 | t.Fatal(err.Error()) |
| 1164 | } |
| 1165 | defer testServer.Close() |
| 1166 | |
| 1167 | testCases := []struct { |
| 1168 | caText, caFile string |
| 1169 | certText, certFile string |
| 1170 | keyText, keyFile string |
| 1171 | |
| 1172 | errMsg string |
| 1173 | }{ |
| 1174 | { |
| 1175 | // File-based everything. |
| 1176 | caFile: TLSCAChainPath, |
| 1177 | certFile: ClientCertificatePath, |
| 1178 | keyFile: ClientKeyNoPassPath, |
| 1179 | }, |
| 1180 | { |
| 1181 | // Inline CA. |
| 1182 | caText: readFile(t, TLSCAChainPath), |
| 1183 | certFile: ClientCertificatePath, |
| 1184 | keyFile: ClientKeyNoPassPath, |
| 1185 | }, |
| 1186 | { |
| 1187 | // Inline cert. |
| 1188 | caFile: TLSCAChainPath, |
| 1189 | certText: readFile(t, ClientCertificatePath), |
| 1190 | keyFile: ClientKeyNoPassPath, |
| 1191 | }, |
| 1192 | { |
| 1193 | // Inline key. |
| 1194 | caFile: TLSCAChainPath, |
| 1195 | certFile: ClientCertificatePath, |
| 1196 | keyText: readFile(t, ClientKeyNoPassPath), |
| 1197 | }, |
| 1198 | { |
| 1199 | // Inline everything. |
| 1200 | caText: readFile(t, TLSCAChainPath), |
| 1201 | certText: readFile(t, ClientCertificatePath), |
| 1202 | keyText: readFile(t, ClientKeyNoPassPath), |
| 1203 | }, |
| 1204 | |
| 1205 | { |
| 1206 | // Invalid inline CA. |
| 1207 | caText: "badca", |
| 1208 | certText: readFile(t, ClientCertificatePath), |
| 1209 | keyText: readFile(t, ClientKeyNoPassPath), |
| 1210 | |
| 1211 | errMsg: "unable to use inline CA cert", |
| 1212 | }, |
| 1213 | { |
| 1214 | // Invalid cert. |
nothing calls this directly
no test coverage detected