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

Function TestCreateDBSpecificBucketPerm

rest/admin_api_auth_test.go:1465–1494  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1463}
1464
1465func TestCreateDBSpecificBucketPerm(t *testing.T) {
1466 if base.UnitTestUrlIsWalrus() {
1467 t.Skip("This test only works against Couchbase Server")
1468 }
1469
1470 base.RequireNumTestBuckets(t, 2)
1471
1472 tb := base.GetTestBucket(t)
1473 ctx := base.TestCtx(t)
1474 defer tb.Close(ctx)
1475
1476 rt := NewRestTester(t, &RestTesterConfig{
1477 AdminInterfaceAuthentication: true,
1478 })
1479 defer rt.Close()
1480
1481 SGWorBFArole := RouteRole{MobileSyncGatewayRole.RoleName, true}
1482 if base.TestsUseServerCE() {
1483 SGWorBFArole = RouteRole{BucketFullAccessRole.RoleName, true}
1484 }
1485
1486 eps, httpClient, err := rt.ServerContext().ObtainManagementEndpointsAndHTTPClient()
1487 require.NoError(t, err)
1488
1489 MakeUser(t, httpClient, eps[0], SGWorBFArole.RoleName, "password", []string{fmt.Sprintf("%s[%s]", SGWorBFArole.RoleName, tb.GetName())})
1490 defer DeleteUser(t, httpClient, eps[0], SGWorBFArole.RoleName)
1491
1492 resp := rt.SendAdminRequestWithAuth("PUT", "/db2/", `{"bucket": "`+tb.GetName()+`", "username": "`+base.TestClusterUsername()+`", "password": "`+base.TestClusterPassword()+`", "num_index_replicas": 0, "use_views": `+strconv.FormatBool(base.TestsDisableGSI())+`}`, SGWorBFArole.RoleName, "password")
1493 RequireStatus(t, resp, http.StatusCreated)
1494}
1495
1496// Tests to make sure login required is returned when admin auth is enabled
1497func TestLoginRequiredForAdmin(t *testing.T) {

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
ServerContextMethod · 0.95
UnitTestUrlIsWalrusFunction · 0.92
RequireNumTestBucketsFunction · 0.92
GetTestBucketFunction · 0.92
TestCtxFunction · 0.92
TestsUseServerCEFunction · 0.92
TestClusterUsernameFunction · 0.92
TestClusterPasswordFunction · 0.92
TestsDisableGSIFunction · 0.92
NewRestTesterFunction · 0.85

Tested by

no test coverage detected