Tests the public API unsuspending a database automatically
(t *testing.T)
| 603 | |
| 604 | // Tests the public API unsuspending a database automatically |
| 605 | func 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 |
| 641 | func TestServerlessUnsuspendAdminAuth(t *testing.T) { |
nothing calls this directly
no test coverage detected