Scenario 9 Initiate user and role Grant role channel and role, revoke role and role channel - Changes Request - Seq 60 - Doesn't have channel 1 access, no history Re-grant role, re-grant channel, re-revoke channel, re-revoke role - Changes Request - Seq 110 - Doesn't have channel 1 access,
(t *testing.T)
| 2273 | // Re-grant role, re-grant channel, re-revoke channel, re-revoke role |
| 2274 | // - Changes Request - Seq 110 - Doesn't have channel 1 access, no history |
| 2275 | func TestRevocationScenario9(t *testing.T) { |
| 2276 | ctx := base.TestCtx(t) |
| 2277 | testBucket := base.GetTestBucket(t) |
| 2278 | defer testBucket.Close(ctx) |
| 2279 | |
| 2280 | dataStore := testBucket.GetSingleDataStore() |
| 2281 | |
| 2282 | testMockComputer := mockComputerV2{ |
| 2283 | roles: map[string]ch.TimedSet{}, |
| 2284 | channels: map[string]ch.TimedSet{}, |
| 2285 | roleChannels: map[string]ch.TimedSet{}, |
| 2286 | } |
| 2287 | |
| 2288 | auth := NewTestAuthenticator(t, dataStore, &testMockComputer, DefaultAuthenticatorOptions(base.TestCtx(t))) |
| 2289 | initializeScenario(t, auth) |
| 2290 | |
| 2291 | testMockComputer.addRoleChannels(t, auth, "foo", "ch1", 5) |
| 2292 | testMockComputer.addRole(t, auth, "alice", "foo", 20) |
| 2293 | |
| 2294 | testMockComputer.removeRole(t, auth, "alice", "foo", 45) |
| 2295 | testMockComputer.removeRoleChannel(t, auth, "foo", "ch1", 55) |
| 2296 | |
| 2297 | // Get Principals / Rebuild Seq 60 |
| 2298 | aliceUserPrincipal, fooPrincipal := getPrincipals(t, auth) |
| 2299 | |
| 2300 | // Ensure user cannot see ch1 (via role) |
| 2301 | // Verify history |
| 2302 | requireCannotSeeChannels(t, aliceUserPrincipal, "ch1") |
| 2303 | assert.Len(t, aliceUserPrincipal.RoleHistory(), 0) |
| 2304 | assert.Len(t, aliceUserPrincipal.ChannelHistory(), 0) |
| 2305 | assert.Len(t, fooPrincipal.ChannelHistory(), 0) |
| 2306 | revokedChannelsCombined, err := aliceUserPrincipal.revokedChannels(5, 0, 0) |
| 2307 | require.NoError(t, err) |
| 2308 | assert.Len(t, revokedChannelsCombined, 0) |
| 2309 | |
| 2310 | testMockComputer.addRole(t, auth, "alice", "foo", 65) |
| 2311 | testMockComputer.addRoleChannels(t, auth, "foo", "ch1", 75) |
| 2312 | |
| 2313 | testMockComputer.removeRoleChannel(t, auth, "foo", "ch1", 85) |
| 2314 | testMockComputer.removeRole(t, auth, "alice", "foo", 95) |
| 2315 | |
| 2316 | // Rebuild seq 110 |
| 2317 | aliceUserPrincipal, fooPrincipal = getPrincipals(t, auth) |
| 2318 | |
| 2319 | // Ensure user cannot see ch1 (via role) |
| 2320 | // Verify history |
| 2321 | requireCannotSeeChannels(t, aliceUserPrincipal, "ch1") |
| 2322 | assert.Len(t, aliceUserPrincipal.RoleHistory(), 0) |
| 2323 | assert.Len(t, aliceUserPrincipal.ChannelHistory(), 0) |
| 2324 | assert.Len(t, fooPrincipal.ChannelHistory(), 0) |
| 2325 | revokedChannelsCombined, err = aliceUserPrincipal.revokedChannels(60, 0, 0) |
| 2326 | require.NoError(t, err) |
| 2327 | assert.Len(t, revokedChannelsCombined, 0) |
| 2328 | } |
| 2329 | |
| 2330 | // Scenario 10 |
| 2331 | // |
nothing calls this directly
no test coverage detected