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

Function TestRevocationScenario2

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

Source from the content-addressed store, hash-verified

246}
247
248func TestRevocationScenario2(t *testing.T) {
249 defer db.SuspendSequenceBatching()()
250
251 revocationTester, rt := InitScenario(t, nil)
252 defer rt.Close()
253
254 resp := rt.SendAdminRequest("PUT", "/{{.keyspace}}/doc1", `{"channels": "ch1"}`)
255 RequireStatus(t, resp, http.StatusCreated)
256
257 revocationTester.fillToSeq(4)
258 revocationTester.addRoleChannel("foo", "ch1")
259
260 changes := revocationTester.getChanges(5, 0)
261 assert.Equal(t, "5", changes.Last_Seq.String())
262
263 revocationTester.fillToSeq(19)
264 revocationTester.addRole("user", "foo")
265 revocationTester.fillToSeq(25)
266
267 changes = revocationTester.getChanges(5, 1)
268 assert.Equal(t, "20:3", changes.Last_Seq.String())
269
270 revocationTester.fillToSeq(44)
271 revocationTester.removeRole("user", "foo")
272
273 revocationTester.fillToSeq(50)
274 changes = revocationTester.getChanges(25, 1)
275 assert.Equal(t, "45:3", changes.Last_Seq.String())
276 assert.True(t, changes.Results[0].Revoked)
277
278 revocationTester.fillToSeq(54)
279 revocationTester.removeRoleChannel("foo", "ch1")
280 revocationTester.fillToSeq(64)
281 revocationTester.addRole("user", "foo")
282 revocationTester.fillToSeq(74)
283 revocationTester.addRoleChannel("foo", "ch1")
284 revocationTester.fillToSeq(80)
285
286 changes = revocationTester.getChanges(50, 1)
287 assert.Equal(t, "75:3", changes.Last_Seq.String())
288
289 revocationTester.fillToSeq(84)
290 revocationTester.removeRoleChannel("foo", "ch1")
291 revocationTester.fillToSeq(94)
292 revocationTester.removeRole("user", "foo")
293 revocationTester.fillToSeq(110)
294
295 changes = revocationTester.getChanges(80, 1)
296 assert.Equal(t, "85:3", changes.Last_Seq.String())
297 assert.True(t, changes.Results[0].Revoked)
298}
299
300func TestRevocationScenario3(t *testing.T) {
301 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