| 355 | } |
| 356 | |
| 357 | func TestBadConfig(t *testing.T) { |
| 358 | var testCases = []struct { |
| 359 | name string |
| 360 | file string |
| 361 | error string |
| 362 | }{ |
| 363 | { |
| 364 | "no file", |
| 365 | "testdata/nofile.yml", |
| 366 | "open testdata/nofile.yml: no such file or directory", |
| 367 | }, |
| 368 | { |
| 369 | "extra fields", |
| 370 | "testdata/bad.extra_fields.yml", |
| 371 | "unknown fields in cluster \"second cluster\": unknown_field", |
| 372 | }, |
| 373 | { |
| 374 | "empty users", |
| 375 | "testdata/bad.empty_users.yml", |
| 376 | "`users` must contain at least 1 user", |
| 377 | }, |
| 378 | { |
| 379 | "empty nodes", |
| 380 | "testdata/bad.empty_nodes.yml", |
| 381 | "either `cluster.nodes` or `cluster.replicas` must be set for \"second cluster\"", |
| 382 | }, |
| 383 | { |
| 384 | "empty replica nodes", |
| 385 | "testdata/bad.empty_replica_nodes.yml", |
| 386 | "`replica.nodes` cannot be empty for \"bar\"", |
| 387 | }, |
| 388 | { |
| 389 | "nodes and replicas", |
| 390 | "testdata/bad.nodes_and_replicas.yml", |
| 391 | "`cluster.nodes` cannot be simultaneously set with `cluster.replicas` for \"second cluster\"", |
| 392 | }, |
| 393 | { |
| 394 | "wrong scheme", |
| 395 | "testdata/bad.wrong_scheme.yml", |
| 396 | "`cluster.scheme` must be `http` or `https`, got \"tcp\" instead for \"second cluster\"", |
| 397 | }, |
| 398 | { |
| 399 | "empty https", |
| 400 | "testdata/bad.empty_https.yml", |
| 401 | "configuration `https` is missing. Must be specified `https.cache_dir` for autocert OR `https.key_file` and `https.cert_file` for already existing certs", |
| 402 | }, |
| 403 | { |
| 404 | "empty https cert key", |
| 405 | "testdata/bad.empty_https_key_file.yml", |
| 406 | "`https.key_file` must be specified", |
| 407 | }, |
| 408 | { |
| 409 | "double certification", |
| 410 | "testdata/bad.double_certification.yml", |
| 411 | "it is forbidden to specify certificate and `https.autocert` at the same time. Choose one way", |
| 412 | }, |
| 413 | { |
| 414 | "security no password", |