Scenario 5 Initiate user and role Grant role channel and role - Changes Request - Seq 25 - Has channel 1 access, no history Revoke role, revoke role channel, re-grant role, re-grant channel - Changes Request - Seq 80 - Has channel 1 access, no history Revoke role and role channel - Cha
(t *testing.T)
| 1951 | // Revoke role and role channel |
| 1952 | // - Changes Request - Seq 110 - Doesn't have channel access, history added for both role and channel |
| 1953 | func TestRevocationScenario5(t *testing.T) { |
| 1954 | ctx := base.TestCtx(t) |
| 1955 | testBucket := base.GetTestBucket(t) |
| 1956 | defer testBucket.Close(ctx) |
| 1957 | |
| 1958 | dataStore := testBucket.GetSingleDataStore() |
| 1959 | |
| 1960 | testMockComputer := mockComputerV2{ |
| 1961 | roles: map[string]ch.TimedSet{}, |
| 1962 | channels: map[string]ch.TimedSet{}, |
| 1963 | roleChannels: map[string]ch.TimedSet{}, |
| 1964 | } |
| 1965 | |
| 1966 | auth := NewTestAuthenticator(t, dataStore, &testMockComputer, DefaultAuthenticatorOptions(base.TestCtx(t))) |
| 1967 | initializeScenario(t, auth) |
| 1968 | |
| 1969 | testMockComputer.addRoleChannels(t, auth, "foo", "ch1", 5) |
| 1970 | testMockComputer.addRole(t, auth, "alice", "foo", 20) |
| 1971 | |
| 1972 | // Get Principals / Rebuild Seq 25 |
| 1973 | aliceUserPrincipal, fooPrincipal := getPrincipals(t, auth) |
| 1974 | |
| 1975 | // Ensure user can see ch1 (via role) |
| 1976 | // Verify history |
| 1977 | assert.ElementsMatch(t, []string{"!", "ch1"}, fooPrincipal.Channels().AllKeys()) |
| 1978 | requireCanSeeChannels(t, aliceUserPrincipal, "ch1") |
| 1979 | assert.Len(t, aliceUserPrincipal.RoleHistory(), 0) |
| 1980 | assert.Len(t, aliceUserPrincipal.ChannelHistory(), 0) |
| 1981 | assert.Len(t, fooPrincipal.ChannelHistory(), 0) |
| 1982 | revokedChannelsCombined, err := aliceUserPrincipal.revokedChannels(5, 0, 0) |
| 1983 | require.NoError(t, err) |
| 1984 | assert.Len(t, revokedChannelsCombined, 0) |
| 1985 | |
| 1986 | testMockComputer.removeRole(t, auth, "alice", "foo", 45) |
| 1987 | testMockComputer.removeRoleChannel(t, auth, "foo", "ch1", 55) |
| 1988 | |
| 1989 | testMockComputer.addRole(t, auth, "alice", "foo", 65) |
| 1990 | testMockComputer.addRoleChannels(t, auth, "foo", "ch1", 75) |
| 1991 | |
| 1992 | // Get Principals / Rebuild Seq 80 |
| 1993 | aliceUserPrincipal, fooPrincipal = getPrincipals(t, auth) |
| 1994 | |
| 1995 | // Ensure user can see ch1 (via role) |
| 1996 | // Verify history |
| 1997 | requireCanSeeChannels(t, aliceUserPrincipal, "ch1") |
| 1998 | assert.Len(t, aliceUserPrincipal.RoleHistory(), 0) |
| 1999 | assert.Len(t, aliceUserPrincipal.ChannelHistory(), 0) |
| 2000 | assert.Len(t, fooPrincipal.ChannelHistory(), 0) |
| 2001 | revokedChannelsCombined, err = aliceUserPrincipal.revokedChannels(25, 0, 0) |
| 2002 | require.NoError(t, err) |
| 2003 | assert.Len(t, revokedChannelsCombined, 0) |
| 2004 | |
| 2005 | testMockComputer.removeRoleChannel(t, auth, "foo", "ch1", 85) |
| 2006 | testMockComputer.removeRole(t, auth, "alice", "foo", 95) |
| 2007 | |
| 2008 | // Get Principals / Rebuild Seq 110 |
| 2009 | aliceUserPrincipal, fooPrincipal = getPrincipals(t, auth) |
| 2010 |
nothing calls this directly
no test coverage detected