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

Function DeleteUser

rest/utilities_testing_user.go:56–77  ·  view source on GitHub ↗
(t *testing.T, httpClient *http.Client, serverURL, username string)

Source from the content-addressed store, hash-verified

54}
55
56func DeleteUser(t *testing.T, httpClient *http.Client, serverURL, username string) {
57 retryWorker := func() (shouldRetry bool, err error, value *http.Response) {
58 req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/settings/rbac/users/local/%s", serverURL, username), nil)
59 require.NoError(t, err)
60
61 req.SetBasicAuth(base.TestClusterUsername(), base.TestClusterPassword())
62
63 resp, err := httpClient.Do(req)
64 if err != nil {
65 return true, err, resp
66 }
67 assert.NoError(t, resp.Body.Close())
68 return false, err, resp
69 }
70
71 err, resp := base.RetryLoop(base.TestCtx(t), "Admin Auth testing DeleteUser", retryWorker, base.CreateSleeperFunc(10, 100))
72 require.NoError(t, err)
73
74 require.Equal(t, http.StatusOK, resp.StatusCode)
75
76 require.NoError(t, resp.Body.Close(), "Error closing response body")
77}
78
79func GetBasicAuthHeader(_ testing.TB, username, password string) string {
80 return "Basic " + base64.StdEncoding.EncodeToString([]byte(username+":"+password))

Callers 13

TestRemoveCollectionFunction · 0.92
TestNotExistentDBRequestFunction · 0.92
TestAuditLoggingFieldsFunction · 0.85
TestCheckPermissionsFunction · 0.85
TestCheckRolesFunction · 0.85
TestAdminAuthFunction · 0.85
TestAdminAPIAuthFunction · 0.85

Calls 7

TestClusterUsernameFunction · 0.92
TestClusterPasswordFunction · 0.92
RetryLoopFunction · 0.92
TestCtxFunction · 0.92
CreateSleeperFuncFunction · 0.92
CloseMethod · 0.65
EqualMethod · 0.45

Tested by 13

TestRemoveCollectionFunction · 0.74
TestNotExistentDBRequestFunction · 0.74
TestAuditLoggingFieldsFunction · 0.68
TestCheckPermissionsFunction · 0.68
TestCheckRolesFunction · 0.68
TestAdminAuthFunction · 0.68
TestAdminAPIAuthFunction · 0.68