Commit 229604a
CONSOLE-4734: Multi-group impersonation Combined (#15612)
* docs: clarify comment for multi-group impersonation feature flag
* Add groups to the redux store and actions
* CONSOLE-4784: WebSocket Subprotocol Parsing for multi-group impersonation
Support multiple Impersonate-Group subprotocols on WebSocket connections.
Maintains backward compatibility for single-group impersonation.
* CONSOLE-4788: Backend Request Headers Updates for multi-group impersonation
Handle X-Console-Impersonate-Groups header by splitting comma-separated
groups into multiple Impersonate-Group headers for Kubernetes API.
* CONSOLE-4785: GraphQL Context Updates for multi-group impersonation
Update GraphQL context to support array-valued headers for multi-group
impersonation. Change headers type from map[string]string to map[string]interface{}
to support both single string values and []string arrays.
* CONSOLE-4789: UI Actions for multi-group impersonation fetch utilities
Update fetch utilities to handle multi-group impersonation:
- Support array-valued Impersonate-Group headers
- Convert array to X-Console-Impersonate-Groups for fetch() API compatibility
- Add UserWithGroups kind support in header generation
* CONSOLE-4787: Redux Actions & States Updates for multi-group impersonation
Add multi-group support to Redux actions:
- Update startImpersonate to accept groups parameter
- Encode multiple groups as WebSocket subprotocols in UserWithGroups mode
- Pass groups to beginImpersonate action
- Expose store and UIActions for testing (temporary)
* CONSOLE-4782: Group Impersonation Modal
Add modal component for multi-group user impersonation:
- TypeScript React component with group selection
- Multi-select group input with search/filter
- Chip display for selected groups
- Form validation for username
- Internationalization support
* CONSOLE-4782: UI Integration for multi-group impersonation
Integrate multi-group impersonation into the UI:
- Update impersonation banner to display multiple groups
- Add modal trigger in masthead toolbar
- Update user component to show impersonated user
- Add feature flag checks in app component
- Add masthead menu items for start/stop impersonation
- Add enabled parameter to usePackageManifestCheck hook
* fix: fix logonoff's review comment
* fix: fix the suggestions from Kevin regarding the frontend UI changes in the multi-group impersonation modal.
* nit: formatting change
* fix: fix the review comment regarding the frontend changes provided by logonoff
Co-authored-by: logonoff <[email protected]>
* feat: integrate dynamic group fetching in ImpersonateUserModal
* test: Add IMPERSONATE flag to featureReducer tests
* fix: revert the debug work
* fix: fix logonoff's review comment
* i18n: run translation
* refactor: use useCallBack to prevent unnecessary rerendering
* feat: add error alert for group loading failure in ImpersonateUserModal
* feat: enhance accessibility in ImpersonateUserModal with ARIA labels and descriptions
* fix: remove outdated comment
* refactor: simplify impersonation group handling with backward compatibility
Consolidate ImpersonateGroup and ImpersonateGroups fields into a single
ImpersonateGroup []string field with custom UnmarshalJSON method that
supports both string (single group) and array (multiple groups) formats
for backward compatibility.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* CONSOLE-4782: Remove IMPERSONATE feature flag
Multi-group impersonation is now always enabled. Removed the feature flag
and all associated conditional checks to simplify the codebase.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: refresh the page after stop impersonation
* fix: address the review comments from @TheRealJon
* test: add comprehensive unit tests for ImpersonateUserModal
Add 21 unit tests covering:
- Modal rendering in open/closed states
- Username input handling (typing, prefilled, readonly, edge cases)
- Groups multi-select field functionality
- Form validation (empty username, disabled submit button)
- Loading and error states
- Form submission with trimming and modal closing
- Modal lifecycle and reset behavior
- Expandable groups feature (>5 selected groups)
* Display all groups when ≤5 selected
* Hide groups beyond 5 and show "+N" button
* Expand to show all groups when "+N" clicked
* Auto-collapse when count reduces to ≤5
All tests use data-test attributes for stable selectors and properly
handle PatternFly v6 modal portal rendering.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* test: add integration tests for ImpersonateUserModal with Redux
Add 10 integration tests covering complete workflows with Redux state:
- Redux action dispatching (startImpersonate with user only)
- Redux action dispatching (startImpersonate with user and groups)
- Complete group selection workflow
* Select single group
* Select multiple groups
* Deselect groups
- Search and filter groups functionality
- Error handling workflow with Redux
- Modal lifecycle with state management
- Readonly mode behavior
Integration tests use Provider wrapper with mock Redux store to verify
complete user flows from UI interaction through to Redux action dispatch.
All tests properly handle async operations and PatternFly v6 components.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* refactor: update navigation handling in MastheadToolbar and ImpersonateUserModal
* refactor: remove unnecessary React imports from impersonate user modal tests
* test: add smoke tests for Multi-Group Impersonation functionality
Introduce a comprehensive suite of smoke tests for the impersonation feature, ensuring critical paths are validated. The tests cover:
- Modal opening and user impersonation
- Banner persistence across navigation
- Stopping impersonation
- Validation of username input and group selection
These tests are designed to quickly identify major breaking changes and ensure the core functionality remains intact. Expected run time is approximately 2-3 minutes.
* test: add E2E Cypress tests for Multi-Group Impersonation with RBAC
Introduce a comprehensive suite of end-to-end tests for the Multi-Group Impersonation feature, focusing on role-based access control (RBAC). The tests cover:
- Setup of Kubernetes resources (namespaces, users, groups, role bindings)
- Verification of access control when impersonating users across different groups
- Cleanup of resources post-testing
These tests ensure that the impersonation functionality adheres to expected RBAC permissions and provides a robust validation of user access across multiple namespaces.
* nit: the word "more" is mistreated as noun in the i18n
* fix: apply CodeRabbit's suggestion
* feat: enhance impersonation handling and feature refresh - the feature didn't work on firefox, but this fix it, and on both chrome and firefox it works.
* fix: apply the review comment from coderabbit
* i18n: run i18n to fix the failing CI
* i18n: running on a different laptop
* refactor: extract impersonation feature refresh logic into a custom hook
* fix: Implement normalizeConsoleHeaders utility to ensure compatibility with fetch API.
* test: fix the flaky guided tour issue
* test: thanks to @yapei suggestion, I added more guidedTour.close to the test to reduce the flake
* test: thanks to @yapei's suggestion, put guidedTour.close after the impersonation button is clicked: since after staritng the impersonation, the modal might show up and blocking the test
* test: remove the cypress test per discussion with @yapei
---------
Co-authored-by: logonoff <[email protected]>
Co-authored-by: Claude <[email protected]>1 parent 2243c06 commit 229604a
File tree
21 files changed
+1745
-80
lines changed- frontend
- packages
- console-app/src/actions/hooks
- console-dynamic-plugin-sdk/src
- app
- core
- actions
- reducers
- utils/fetch
- operator-lifecycle-manager-v1/src/hooks
- public
- actions
- components
- masthead
- modals
- __tests__
- locales/en
- pkg
- graphql/resolver
- proxy
- server
21 files changed
+1745
-80
lines changedLines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
30 | 42 | | |
31 | 43 | | |
| |||
42 | 54 | | |
43 | 55 | | |
44 | 56 | | |
45 | | - | |
| 57 | + | |
46 | 58 | | |
47 | 59 | | |
48 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
49 | 65 | | |
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
Lines changed: 46 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
43 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
44 | 55 | | |
45 | 56 | | |
46 | 57 | | |
47 | 58 | | |
48 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| 28 | + | |
25 | 29 | | |
26 | | - | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
192 | 206 | | |
193 | 207 | | |
194 | 208 | | |
| |||
198 | 212 | | |
199 | 213 | | |
200 | 214 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 215 | + | |
208 | 216 | | |
209 | 217 | | |
210 | 218 | | |
211 | 219 | | |
212 | | - | |
213 | | - | |
| 220 | + | |
214 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
215 | 231 | | |
216 | 232 | | |
217 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
218 | 237 | | |
219 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
220 | 247 | | |
221 | 248 | | |
222 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
14 | 31 | | |
15 | 32 | | |
16 | 33 | | |
| |||
0 commit comments