CBG-1535 - test Bootstrap.UseTLSServer option
(t *testing.T)
| 489 | |
| 490 | // CBG-1535 - test Bootstrap.UseTLSServer option |
| 491 | func TestUseTLSServer(t *testing.T) { |
| 492 | base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll) |
| 493 | errorMustBeSecure := "Must use secure scheme in Couchbase Server URL, or opt out by setting bootstrap.use_tls_server to false. Current URL: %v" |
| 494 | errorAllowInsecureAndBeSecure := "Couchbase server URL cannot use secure protocol when bootstrap.use_tls_server is false. Current URL: %v" |
| 495 | testCases := []struct { |
| 496 | name string |
| 497 | useTLSServer bool |
| 498 | server string |
| 499 | expectedError *string |
| 500 | }{ |
| 501 | { |
| 502 | name: "Walrus allowed without flag", |
| 503 | useTLSServer: false, |
| 504 | server: "walrus://", |
| 505 | expectedError: nil, |
| 506 | }, |
| 507 | { |
| 508 | name: "Walrus allowed with flag", |
| 509 | useTLSServer: true, |
| 510 | server: "walrus://", |
| 511 | expectedError: nil, |
| 512 | }, |
| 513 | { |
| 514 | name: "couchbase: not allowed", |
| 515 | useTLSServer: true, |
| 516 | server: "couchbase://localhost:1212", |
| 517 | expectedError: &errorMustBeSecure, |
| 518 | }, |
| 519 | { |
| 520 | name: "http not allowed", |
| 521 | useTLSServer: true, |
| 522 | server: "http://localhost:1212", |
| 523 | expectedError: &errorMustBeSecure, |
| 524 | }, |
| 525 | { |
| 526 | name: "http allowed", |
| 527 | useTLSServer: false, |
| 528 | server: "http://localhost:1212", |
| 529 | expectedError: nil, |
| 530 | }, |
| 531 | { |
| 532 | name: "Https not secure (due to unsupported)", |
| 533 | useTLSServer: true, |
| 534 | server: "https://localhost:1234", |
| 535 | expectedError: &errorMustBeSecure, |
| 536 | }, |
| 537 | { |
| 538 | name: "couchbases:", |
| 539 | useTLSServer: true, |
| 540 | server: "couchbases://localhost:1234", |
| 541 | expectedError: nil, |
| 542 | }, |
| 543 | { |
| 544 | name: "ftps:", // Testing if the S at the end is what makes it secure |
| 545 | useTLSServer: true, |
| 546 | server: "ftps://localhost:1234", |
| 547 | expectedError: &errorMustBeSecure, |
| 548 | }, |
nothing calls this directly
no test coverage detected