(t *testing.T)
| 1268 | } |
| 1269 | |
| 1270 | func TestValidateAlertmanagerConfig(t *testing.T) { |
| 1271 | tests := map[string]struct { |
| 1272 | input any |
| 1273 | expected error |
| 1274 | }{ |
| 1275 | "*HTTPClientConfig": { |
| 1276 | input: &commoncfg.HTTPClientConfig{ |
| 1277 | BasicAuth: &commoncfg.BasicAuth{ |
| 1278 | UsernameFile: "/secrets", |
| 1279 | }, |
| 1280 | }, |
| 1281 | expected: errUsernameFileNotAllowed, |
| 1282 | }, |
| 1283 | "HTTPClientConfig": { |
| 1284 | input: commoncfg.HTTPClientConfig{ |
| 1285 | BasicAuth: &commoncfg.BasicAuth{ |
| 1286 | PasswordFile: "/secrets", |
| 1287 | }, |
| 1288 | }, |
| 1289 | expected: errPasswordFileNotAllowed, |
| 1290 | }, |
| 1291 | "*TLSConfig": { |
| 1292 | input: &commoncfg.TLSConfig{ |
| 1293 | CertFile: "/cert", |
| 1294 | }, |
| 1295 | expected: errTLSFileNotAllowed, |
| 1296 | }, |
| 1297 | "TLSConfig": { |
| 1298 | input: commoncfg.TLSConfig{ |
| 1299 | CertFile: "/cert", |
| 1300 | }, |
| 1301 | expected: errTLSFileNotAllowed, |
| 1302 | }, |
| 1303 | "struct containing *HTTPClientConfig as direct child": { |
| 1304 | input: config.GlobalConfig{ |
| 1305 | HTTPConfig: &commoncfg.HTTPClientConfig{ |
| 1306 | BasicAuth: &commoncfg.BasicAuth{ |
| 1307 | PasswordFile: "/secrets", |
| 1308 | }, |
| 1309 | }, |
| 1310 | }, |
| 1311 | expected: errPasswordFileNotAllowed, |
| 1312 | }, |
| 1313 | "struct containing *HTTPClientConfig as nested child": { |
| 1314 | input: config.Config{ |
| 1315 | Global: &config.GlobalConfig{ |
| 1316 | HTTPConfig: &commoncfg.HTTPClientConfig{ |
| 1317 | BasicAuth: &commoncfg.BasicAuth{ |
| 1318 | PasswordFile: "/secrets", |
| 1319 | }, |
| 1320 | }, |
| 1321 | }, |
| 1322 | }, |
| 1323 | expected: errPasswordFileNotAllowed, |
| 1324 | }, |
| 1325 | "struct containing *HTTPClientConfig as nested child within a slice": { |
| 1326 | input: config.Config{ |
| 1327 | Receivers: []config.Receiver{{ |
nothing calls this directly
no test coverage detected