Scenario 10 Initiate user and role Grant role channel and role, revoke role and role channel, re-grant role - Changes Request - Seq 70 - Doesn't have channel 1 access, no history Re-grant channel, re-revoke channel, re-revoke role - Changes Request - Seq 110 - Doesn't have channel 1 access
(t *testing.T)
| 2335 | // Re-grant channel, re-revoke channel, re-revoke role |
| 2336 | // - Changes Request - Seq 110 - Doesn't have channel 1 access, no history |
| 2337 | func TestRevocationScenario10(t *testing.T) { |
| 2338 | ctx := base.TestCtx(t) |
| 2339 | testBucket := base.GetTestBucket(t) |
| 2340 | defer testBucket.Close(ctx) |
| 2341 | |
| 2342 | dataStore := testBucket.GetSingleDataStore() |
| 2343 | |
| 2344 | testMockComputer := mockComputerV2{ |
| 2345 | roles: map[string]ch.TimedSet{}, |
| 2346 | channels: map[string]ch.TimedSet{}, |
| 2347 | roleChannels: map[string]ch.TimedSet{}, |
| 2348 | } |
| 2349 | |
| 2350 | auth := NewTestAuthenticator(t, dataStore, &testMockComputer, DefaultAuthenticatorOptions(base.TestCtx(t))) |
| 2351 | initializeScenario(t, auth) |
| 2352 | |
| 2353 | testMockComputer.addRoleChannels(t, auth, "foo", "ch1", 5) |
| 2354 | testMockComputer.addRole(t, auth, "alice", "foo", 20) |
| 2355 | |
| 2356 | testMockComputer.removeRole(t, auth, "alice", "foo", 45) |
| 2357 | testMockComputer.removeRoleChannel(t, auth, "foo", "ch1", 55) |
| 2358 | |
| 2359 | testMockComputer.addRole(t, auth, "alice", "foo", 65) |
| 2360 | |
| 2361 | // Get Principals / Rebuild Seq 70 |
| 2362 | aliceUserPrincipal, fooPrincipal := getPrincipals(t, auth) |
| 2363 | |
| 2364 | // Ensure user cannot see ch1 (via role) |
| 2365 | // Verify history |
| 2366 | requireCannotSeeChannels(t, aliceUserPrincipal, "ch1") |
| 2367 | assert.Len(t, aliceUserPrincipal.RoleHistory(), 0) |
| 2368 | assert.Len(t, aliceUserPrincipal.ChannelHistory(), 0) |
| 2369 | assert.Len(t, fooPrincipal.ChannelHistory(), 0) |
| 2370 | revokedChannelsCombined, err := aliceUserPrincipal.revokedChannels(5, 0, 0) |
| 2371 | require.NoError(t, err) |
| 2372 | assert.Len(t, revokedChannelsCombined, 0) |
| 2373 | |
| 2374 | testMockComputer.addRoleChannels(t, auth, "foo", "ch1", 75) |
| 2375 | |
| 2376 | testMockComputer.removeRoleChannel(t, auth, "foo", "ch1", 85) |
| 2377 | testMockComputer.removeRole(t, auth, "alice", "foo", 95) |
| 2378 | |
| 2379 | // Rebuild seq 110 |
| 2380 | aliceUserPrincipal, fooPrincipal = getPrincipals(t, auth) |
| 2381 | |
| 2382 | // Ensure user cannot see ch1 (via role) |
| 2383 | // Verify history |
| 2384 | requireCannotSeeChannels(t, aliceUserPrincipal, "ch1") |
| 2385 | userRoleHistory, ok := aliceUserPrincipal.RoleHistory()["foo"] |
| 2386 | require.True(t, ok) |
| 2387 | assert.Equal(t, GrantHistorySequencePair{StartSeq: 65, EndSeq: 95}, userRoleHistory.Entries[0]) |
| 2388 | assert.Len(t, aliceUserPrincipal.ChannelHistory(), 0) |
| 2389 | assert.Len(t, fooPrincipal.ChannelHistory(), 0) |
| 2390 | revokedChannelsCombined, err = aliceUserPrincipal.revokedChannels(70, 0, 0) |
| 2391 | require.NoError(t, err) |
| 2392 | assert.Len(t, revokedChannelsCombined, 0) |
| 2393 | } |
| 2394 |
nothing calls this directly
no test coverage detected