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

Function TestRevocationScenario3

rest/revocation_test.go:300–350  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

298}
299
300func TestRevocationScenario3(t *testing.T) {
301 defer db.SuspendSequenceBatching()()
302
303 revocationTester, rt := InitScenario(t, nil)
304 defer rt.Close()
305
306 resp := rt.SendAdminRequest("PUT", "/{{.keyspace}}/doc1", `{"channels": "ch1"}`)
307 RequireStatus(t, resp, http.StatusCreated)
308
309 revocationTester.fillToSeq(4)
310 revocationTester.addRoleChannel("foo", "ch1")
311
312 changes := revocationTester.getChanges(5, 0)
313 assert.Equal(t, "5", changes.Last_Seq.String())
314
315 revocationTester.fillToSeq(19)
316 revocationTester.addRole("user", "foo")
317 revocationTester.fillToSeq(25)
318
319 changes = revocationTester.getChanges(5, 1)
320 assert.Equal(t, "20:3", changes.Last_Seq.String())
321
322 revocationTester.fillToSeq(44)
323 revocationTester.removeRole("user", "foo")
324 revocationTester.fillToSeq(54)
325 revocationTester.removeRoleChannel("foo", "ch1")
326
327 revocationTester.fillToSeq(60)
328 changes = revocationTester.getChanges(25, 1)
329 assert.Equal(t, "45:3", changes.Last_Seq.String())
330 assert.True(t, changes.Results[0].Revoked)
331
332 revocationTester.fillToSeq(64)
333 revocationTester.addRole("user", "foo")
334 revocationTester.fillToSeq(74)
335 revocationTester.addRoleChannel("foo", "ch1")
336 revocationTester.fillToSeq(80)
337
338 changes = revocationTester.getChanges(50, 1)
339 assert.Equal(t, "75:3", changes.Last_Seq.String())
340
341 revocationTester.fillToSeq(84)
342 revocationTester.removeRoleChannel("foo", "ch1")
343 revocationTester.fillToSeq(94)
344 revocationTester.removeRole("user", "foo")
345 revocationTester.fillToSeq(110)
346
347 changes = revocationTester.getChanges(80, 1)
348 assert.Equal(t, "85:3", changes.Last_Seq.String())
349 assert.True(t, changes.Results[0].Revoked)
350}
351
352func TestRevocationScenario4(t *testing.T) {
353 defer db.SuspendSequenceBatching()()

Callers

nothing calls this directly

Calls 13

SuspendSequenceBatchingFunction · 0.92
InitScenarioFunction · 0.85
RequireStatusFunction · 0.85
SendAdminRequestMethod · 0.80
fillToSeqMethod · 0.80
addRoleChannelMethod · 0.80
getChangesMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.65
EqualMethod · 0.45
addRoleMethod · 0.45
removeRoleMethod · 0.45

Tested by

no test coverage detected