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

Function TestServerlessUnsuspendAPI

rest/serverless_test.go:605–638  ·  view source on GitHub ↗

Tests the public API unsuspending a database automatically

(t *testing.T)

Source from the content-addressed store, hash-verified

603
604// Tests the public API unsuspending a database automatically
605func TestServerlessUnsuspendAPI(t *testing.T) {
606 RequireBucketSpecificCredentials(t)
607 ctx := base.TestCtx(t)
608 // Get test bucket
609 tb := base.GetTestBucket(t)
610 defer tb.Close(ctx)
611
612 rt := NewRestTester(t, &RestTesterConfig{CustomTestBucket: tb.NoCloseClone(), PersistentConfig: true, serverless: true})
613 defer rt.Close()
614
615 sc := rt.ServerContext()
616
617 resp := rt.SendAdminRequest(http.MethodPut, "/db/", fmt.Sprintf(`{
618 "bucket": "%s",
619 "use_views": %t,
620 "num_index_replicas": 0
621 }`, tb.GetName(), base.TestsDisableGSI()))
622 RequireStatus(t, resp, http.StatusCreated)
623
624 err := sc.suspendDatabase(t, rt.Context(), "db")
625 assert.NoError(t, err)
626
627 // Confirm db is suspended
628 require.True(t, sc.isDatabaseSuspended(t, "db"))
629 require.Nil(t, sc._databases["db"])
630
631 // Attempt to unsuspend using unauthenticated public API request
632 resp = rt.SendRequest(http.MethodGet, "/db/doc", "")
633 AssertStatus(t, resp, http.StatusUnauthorized)
634
635 // Confirm db is unsuspended
636 require.False(t, sc.isDatabaseSuspended(t, "db"))
637 require.NotNil(t, sc._databases["db"])
638}
639
640// Makes sure admin API calls do not unsuspend DB if they fail authentication
641func TestServerlessUnsuspendAdminAuth(t *testing.T) {

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
ServerContextMethod · 0.95
SendAdminRequestMethod · 0.95
ContextMethod · 0.95
SendRequestMethod · 0.95
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
TestsDisableGSIFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
AssertStatusFunction · 0.85

Tested by

no test coverage detected