Scenario 7 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, re-revoke channel, re-revoke role - Changes Request - Seq 100 - Doesn't have channel 1 access, hist
(t *testing.T)
| 2123 | // No Change |
| 2124 | // - Changes Request - Seq 110 - Doesn't have channel access, history retained |
| 2125 | func TestRevocationScenario7(t *testing.T) { |
| 2126 | ctx := base.TestCtx(t) |
| 2127 | testBucket := base.GetTestBucket(t) |
| 2128 | defer testBucket.Close(ctx) |
| 2129 | |
| 2130 | dataStore := testBucket.GetSingleDataStore() |
| 2131 | |
| 2132 | testMockComputer := mockComputerV2{ |
| 2133 | roles: map[string]ch.TimedSet{}, |
| 2134 | channels: map[string]ch.TimedSet{}, |
| 2135 | roleChannels: map[string]ch.TimedSet{}, |
| 2136 | } |
| 2137 | |
| 2138 | auth := NewTestAuthenticator(t, dataStore, &testMockComputer, DefaultAuthenticatorOptions(base.TestCtx(t))) |
| 2139 | initializeScenario(t, auth) |
| 2140 | |
| 2141 | testMockComputer.addRoleChannels(t, auth, "foo", "ch1", 5) |
| 2142 | testMockComputer.addRole(t, auth, "alice", "foo", 20) |
| 2143 | |
| 2144 | // Get Principals / Rebuild Seq 25 |
| 2145 | aliceUserPrincipal, fooPrincipal := getPrincipals(t, auth) |
| 2146 | |
| 2147 | // Ensure user can see ch1 (via role) |
| 2148 | // Verify history |
| 2149 | assert.ElementsMatch(t, []string{"!", "ch1"}, fooPrincipal.Channels().AllKeys()) |
| 2150 | requireCanSeeChannels(t, aliceUserPrincipal, "ch1") |
| 2151 | assert.Len(t, aliceUserPrincipal.RoleHistory(), 0) |
| 2152 | assert.Len(t, aliceUserPrincipal.ChannelHistory(), 0) |
| 2153 | assert.Len(t, fooPrincipal.ChannelHistory(), 0) |
| 2154 | revokedChannelsCombined, err := aliceUserPrincipal.revokedChannels(5, 0, 0) |
| 2155 | require.NoError(t, err) |
| 2156 | assert.Len(t, revokedChannelsCombined, 0) |
| 2157 | |
| 2158 | testMockComputer.removeRole(t, auth, "alice", "foo", 45) |
| 2159 | testMockComputer.removeRoleChannel(t, auth, "foo", "ch1", 55) |
| 2160 | |
| 2161 | testMockComputer.addRole(t, auth, "alice", "foo", 65) |
| 2162 | testMockComputer.addRoleChannels(t, auth, "foo", "ch1", 75) |
| 2163 | |
| 2164 | testMockComputer.removeRoleChannel(t, auth, "foo", "ch1", 85) |
| 2165 | testMockComputer.removeRole(t, auth, "alice", "foo", 95) |
| 2166 | |
| 2167 | // Get Principals / Rebuild Seq 100 |
| 2168 | aliceUserPrincipal, fooPrincipal = getPrincipals(t, auth) |
| 2169 | |
| 2170 | // Ensure user cannot see ch1 (via role) |
| 2171 | // Verify history |
| 2172 | requireCannotSeeChannels(t, aliceUserPrincipal, "ch1") |
| 2173 | userRoleHistory, ok := aliceUserPrincipal.RoleHistory()["foo"] |
| 2174 | require.True(t, ok) |
| 2175 | assert.Equal(t, GrantHistorySequencePair{StartSeq: 20, EndSeq: 45}, userRoleHistory.Entries[0]) |
| 2176 | |
| 2177 | channelHistory, ok := fooPrincipal.ChannelHistory()["ch1"] |
| 2178 | require.True(t, ok) |
| 2179 | assert.Equal(t, GrantHistorySequencePair{StartSeq: 5, EndSeq: 55}, channelHistory.Entries[0]) |
| 2180 | |
| 2181 | assert.Len(t, aliceUserPrincipal.ChannelHistory(), 0) |
| 2182 |
nothing calls this directly
no test coverage detected