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

Function TestRevocationScenario4

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

Source from the content-addressed store, hash-verified

350}
351
352func TestRevocationScenario4(t *testing.T) {
353 defer db.SuspendSequenceBatching()()
354
355 revocationTester, rt := InitScenario(t, nil)
356 defer rt.Close()
357
358 resp := rt.SendAdminRequest("PUT", "/{{.keyspace}}/doc1", `{"channels": "ch1"}`)
359 RequireStatus(t, resp, http.StatusCreated)
360
361 revocationTester.fillToSeq(4)
362 revocationTester.addRoleChannel("foo", "ch1")
363
364 changes := revocationTester.getChanges(5, 0)
365 assert.Equal(t, "5", changes.Last_Seq.String())
366
367 revocationTester.fillToSeq(19)
368 revocationTester.addRole("user", "foo")
369 revocationTester.fillToSeq(25)
370
371 changes = revocationTester.getChanges(5, 1)
372 assert.Equal(t, "20:3", changes.Last_Seq.String())
373
374 revocationTester.fillToSeq(44)
375 revocationTester.removeRole("user", "foo")
376 revocationTester.fillToSeq(54)
377 revocationTester.removeRoleChannel("foo", "ch1")
378 revocationTester.fillToSeq(64)
379 revocationTester.addRole("user", "foo")
380
381 revocationTester.fillToSeq(70)
382 changes = revocationTester.getChanges(25, 1)
383 assert.Equal(t, "55:3", changes.Last_Seq.String())
384 assert.True(t, changes.Results[0].Revoked)
385
386 revocationTester.fillToSeq(74)
387 revocationTester.addRoleChannel("foo", "ch1")
388 revocationTester.fillToSeq(80)
389
390 changes = revocationTester.getChanges(50, 1)
391 assert.Equal(t, "75:3", changes.Last_Seq.String())
392
393 revocationTester.fillToSeq(84)
394 revocationTester.removeRoleChannel("foo", "ch1")
395 revocationTester.fillToSeq(94)
396 revocationTester.removeRole("user", "foo")
397 revocationTester.fillToSeq(110)
398
399 changes = revocationTester.getChanges(80, 1)
400 assert.Equal(t, "85:3", changes.Last_Seq.String())
401 assert.True(t, changes.Results[0].Revoked)
402}
403
404func TestRevocationScenario5(t *testing.T) {
405 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