MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestTLSSkipVerifyGetBucketSpec

Function TestTLSSkipVerifyGetBucketSpec

rest/server_context_test.go:445–488  ·  view source on GitHub ↗

CBG-1518 - Test GetbucketSpec() ServerTLSSkipVerify and empty CA Cert behaviour. Does not test validation of having CA Cert provided and TLS Skip verify on. See TestTLSSkipVerifyCombinations for that.

(t *testing.T)

Source from the content-addressed store, hash-verified

443// CBG-1518 - Test GetbucketSpec() ServerTLSSkipVerify and empty CA Cert behaviour.
444// Does not test validation of having CA Cert provided and TLS Skip verify on. See TestTLSSkipVerifyCombinations for that.
445func TestTLSSkipVerifyGetBucketSpec(t *testing.T) {
446 testCases := []struct {
447 name string
448 serverTLSSkipVerify *bool
449 caCert string
450 }{
451 {
452 name: "CA Provided, explicitly not skipping TLS validation",
453 serverTLSSkipVerify: base.Ptr(false),
454 caCert: "t.ca",
455 },
456 {
457 name: "CA Provided only",
458 caCert: "t.ca",
459 },
460 {
461 name: "Skipping TLS validation, no CA",
462 serverTLSSkipVerify: base.Ptr(true),
463 caCert: "",
464 },
465 {
466 name: "No CA, no TLS validation skip",
467 },
468 {
469 name: "No CA, no TLS validation skip explicitly",
470 serverTLSSkipVerify: base.Ptr(false),
471 },
472 }
473 for _, test := range testCases {
474 t.Run(test.name, func(t *testing.T) {
475 ctx := base.TestCtx(t)
476 startupConfig := &StartupConfig{Bootstrap: BootstrapConfig{ServerTLSSkipVerify: test.serverTLSSkipVerify}}
477 dbConfig := &DatabaseConfig{DbConfig: DbConfig{BucketConfig: BucketConfig{CACertPath: test.caCert}}}
478 spec, err := GetBucketSpec(ctx, dbConfig, startupConfig)
479
480 assert.NoError(t, err)
481 assert.Equal(t, test.caCert, spec.CACertPath)
482 if test.serverTLSSkipVerify == nil {
483 test.serverTLSSkipVerify = base.Ptr(false)
484 }
485 assert.Equal(t, spec.TLSSkipVerify, *test.serverTLSSkipVerify)
486 })
487 }
488}
489
490// CBG-1535 - test Bootstrap.UseTLSServer option
491func TestUseTLSServer(t *testing.T) {

Callers

nothing calls this directly

Calls 5

PtrFunction · 0.92
TestCtxFunction · 0.92
GetBucketSpecFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected