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

Function TestNotExistentDBRequest

rest/adminapitest/admin_api_test.go:2939–2961  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2937}
2938
2939func TestNotExistentDBRequest(t *testing.T) {
2940 if base.UnitTestUrlIsWalrus() {
2941 t.Skip("Test requires Couchbase Server")
2942 }
2943
2944 rt := rest.NewRestTester(t, &rest.RestTesterConfig{AdminInterfaceAuthentication: true})
2945 defer rt.Close()
2946
2947 eps, httpClient, err := rt.ServerContext().ObtainManagementEndpointsAndHTTPClient()
2948 require.NoError(t, err)
2949
2950 rest.MakeUser(t, httpClient, eps[0], "random", "password", nil)
2951 defer rest.DeleteUser(t, httpClient, eps[0], "random")
2952
2953 // Request to non-existent db with valid credentials
2954 resp := rt.SendAdminRequestWithAuth("PUT", "/dbx/_config", "", "random", "password")
2955 rest.RequireStatus(t, resp, http.StatusForbidden)
2956
2957 // Request to non-existent db with invalid credentials
2958 resp = rt.SendAdminRequestWithAuth("PUT", "/dbx/_config", "", "random", "passwordx")
2959 rest.RequireStatus(t, resp, http.StatusUnauthorized)
2960 require.Contains(t, resp.Body.String(), rest.ErrInvalidLogin.Message)
2961}
2962
2963func TestConfigsIncludeDefaults(t *testing.T) {
2964 base.ResetGlobalTestLogging(t)

Callers

nothing calls this directly

Calls 11

CloseMethod · 0.95
ServerContextMethod · 0.95
UnitTestUrlIsWalrusFunction · 0.92
NewRestTesterFunction · 0.92
MakeUserFunction · 0.92
DeleteUserFunction · 0.92
RequireStatusFunction · 0.92
ContainsMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected