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

Function TestBlipRevokeNonExistentRole

rest/revocation_test.go:2479–2520  ·  view source on GitHub ↗

Regression test for CBG-2183.

(t *testing.T)

Source from the content-addressed store, hash-verified

2477
2478// Regression test for CBG-2183.
2479func TestBlipRevokeNonExistentRole(t *testing.T) {
2480 base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll)
2481
2482 btcRunner := NewBlipTesterClientRunner(t)
2483
2484 btcRunner.Run(func(t *testing.T) {
2485 rt := NewRestTester(t,
2486 &RestTesterConfig{
2487 GuestEnabled: false,
2488 })
2489 defer rt.Close()
2490
2491 dataStore := rt.GetSingleDataStore()
2492
2493 // 1. Create user with admin_roles including two roles not previously defined (a1 and a2, for example)
2494 res := rt.SendAdminRequest(http.MethodPut, fmt.Sprintf("/%s/_user/bilbo", rt.GetDatabase().Name), GetUserPayload(t, "bilbo", RestTesterDefaultUserPassword, "", dataStore, []string{"c1"}, []string{"a1", "a2"}))
2495 RequireStatus(t, res, http.StatusCreated)
2496
2497 // Create a doc so we have something to replicate
2498 res = rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/testdoc", `{"channels": ["c1"]}`)
2499 RequireStatus(t, res, http.StatusCreated)
2500
2501 // 3. Update the user to not reference one of the roles (update to ['a1'], for example)
2502 // [also revoke channel c1 so the doc shows up in the revocation queries]
2503 res = rt.SendAdminRequest(http.MethodPut, fmt.Sprintf("/%s/_user/bilbo", rt.GetDatabase().Name), GetUserPayload(t, "bilbo", RestTesterDefaultUserPassword, "", dataStore, []string{}, []string{"a1"}))
2504 RequireStatus(t, res, http.StatusOK)
2505
2506 // 4. Try to sync
2507 bt := btcRunner.NewBlipTesterClientOptsWithRT(rt, &BlipTesterClientOpts{
2508 Username: "bilbo",
2509 SendRevocations: true,
2510 })
2511 defer bt.Close()
2512
2513 btcRunner.StartPull(bt.id)
2514
2515 // in the failing case we'll panic before hitting this
2516 base.RequireWaitForStat(t, func() int64 {
2517 return rt.GetDatabase().DbStats.CBLReplicationPull().NumPullReplCaughtUp.Value()
2518 }, 1)
2519 })
2520}
2521
2522func TestReplicatorSwitchPurgeNoReset(t *testing.T) {
2523 base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
GetSingleDataStoreMethod · 0.95
SendAdminRequestMethod · 0.95
GetDatabaseMethod · 0.95
SetUpTestLoggingFunction · 0.92
RequireWaitForStatFunction · 0.92
NewRestTesterFunction · 0.85
GetUserPayloadFunction · 0.85
RequireStatusFunction · 0.85
CBLReplicationPullMethod · 0.80

Tested by

no test coverage detected