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

Function TestNumAccessErrors

rest/access_test.go:245–265  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

243}
244
245func TestNumAccessErrors(t *testing.T) {
246 rtConfig := RestTesterConfig{
247 SyncFn: `function(doc, oldDoc){if (doc.channels.indexOf("foo") > -1){requireRole("foobar")}}`,
248 }
249
250 rt := NewRestTester(t, &rtConfig)
251 defer rt.Close()
252
253 ctx := rt.Context()
254 a := rt.ServerContext().Database(ctx, "db").Authenticator(ctx)
255
256 // Create a test user
257 user, err := a.NewUser("user", "letmein", channels.BaseSetOf(t, "A"))
258 assert.NoError(t, err)
259 assert.NoError(t, a.Save(user))
260
261 response := rt.SendUserRequest("PUT", "/{{.keyspace}}/doc", `{"prop":true, "channels":["foo"]}`, "user")
262 RequireStatus(t, response, 403)
263
264 base.RequireWaitForStat(t, func() int64 { return rt.GetDatabase().DbStats.SecurityStats.NumAccessErrors.Value() }, 1)
265}
266func TestUserHasDocAccessDocNotFound(t *testing.T) {
267 rt := NewRestTester(t, &RestTesterConfig{
268 DatabaseConfig: &DatabaseConfig{DbConfig: DbConfig{

Callers

nothing calls this directly

Calls 14

CloseMethod · 0.95
ContextMethod · 0.95
ServerContextMethod · 0.95
SendUserRequestMethod · 0.95
GetDatabaseMethod · 0.95
BaseSetOfFunction · 0.92
RequireWaitForStatFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
NewUserMethod · 0.80
SaveMethod · 0.80
AuthenticatorMethod · 0.45

Tested by

no test coverage detected