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

Function TestRevocationScenario1

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

Source from the content-addressed store, hash-verified

195}
196
197func TestRevocationScenario1(t *testing.T) {
198 defer db.SuspendSequenceBatching()()
199
200 revocationTester, rt := InitScenario(t, nil)
201 defer rt.Close()
202
203 resp := rt.SendAdminRequest("PUT", "/{{.keyspace}}/doc1", `{"channels": "ch1"}`)
204 RequireStatus(t, resp, http.StatusCreated)
205
206 revocationTester.fillToSeq(4)
207 revocationTester.addRoleChannel("foo", "ch1")
208
209 changes := revocationTester.getChanges(5, 0)
210 assert.Equal(t, "5", changes.Last_Seq.String())
211
212 revocationTester.fillToSeq(19)
213 revocationTester.addRole("user", "foo")
214 revocationTester.fillToSeq(25)
215
216 changes = revocationTester.getChanges(5, 1)
217 assert.Equal(t, "20:3", changes.Last_Seq.String())
218
219 revocationTester.fillToSeq(40)
220
221 changes = revocationTester.getChanges(25, 0)
222 assert.Equal(t, "25", changes.Last_Seq.String())
223
224 revocationTester.fillToSeq(44)
225 revocationTester.removeRole("user", "foo")
226 revocationTester.fillToSeq(54)
227 revocationTester.removeRoleChannel("foo", "ch1")
228 revocationTester.fillToSeq(64)
229 revocationTester.addRole("user", "foo")
230 revocationTester.fillToSeq(74)
231 revocationTester.addRoleChannel("foo", "ch1")
232 revocationTester.fillToSeq(80)
233
234 changes = revocationTester.getChanges(40, 1)
235 assert.Equal(t, "75:3", changes.Last_Seq.String())
236
237 revocationTester.fillToSeq(84)
238 revocationTester.removeRoleChannel("foo", "ch1")
239 revocationTester.fillToSeq(94)
240 revocationTester.removeRole("user", "foo")
241 revocationTester.fillToSeq(110)
242
243 changes = revocationTester.getChanges(80, 1)
244 assert.Equal(t, "85:3", changes.Last_Seq.String())
245 assert.True(t, changes.Results[0].Revoked)
246}
247
248func TestRevocationScenario2(t *testing.T) {
249 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