Regression test for CBG-2183.
(t *testing.T)
| 2477 | |
| 2478 | // Regression test for CBG-2183. |
| 2479 | func 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 | |
| 2522 | func TestReplicatorSwitchPurgeNoReset(t *testing.T) { |
| 2523 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) |
nothing calls this directly
no test coverage detected