Commit ddcecd6
authored
[8.x] [FTR] support custom native roles in serverless tests (elastic#194677) (elastic#196351)
# Backport
This will backport the following commits from `main` to `8.x`:
- [[FTR] support custom native roles in serverless tests
(elastic#194677)](elastic#194677)
<!--- Backport version: 8.9.8 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)
<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-11T15:11:23Z","message":"[FTR]
support custom native roles in serverless tests (elastic#194677)\n\n##
Summary\r\n\r\nThis PR updates FTR services to support authentication
with custom\r\nnative role. Few notes:\r\n- for compatibility with MKI
we reserve **\"customRole\"** as a custom\r\nrole name used in
tests\r\n- test user is **automatically assigned** to this role, but
before login\r\nin browser/ generating cookie header or API key in each
test suite\r\n**role privileges must me updated according test
scenario**\r\n\r\nHow to test:\r\nI added a new test file for Search
project:\r\n`x-pack/test_serverless/functional/test_suites/search/custom_role_access.ts`\r\n\r\nIt
can be run locally with:\r\n```\r\n node scripts/functional_tests
--config=x-pack/test_serverless/functional/test_suites/search/config.ts
--grep \"With custom role\"\r\n```\r\n\r\nFTR UI test
example:\r\n\r\n```ts\r\n// First set privileges for custom
role\r\nawait samlAuth.setCustomRole({\r\n elasticsearch: {\r\n indices:
[{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata']
}],\r\n },\r\n kibana: [\r\n {\r\n feature: {\r\n discover:
['read'],\r\n },\r\n spaces: ['*'],\r\n },\r\n ],\r\n });\r\n
});\r\n\r\n// Then you can login in browser as a user with newly defined
privileges\r\nawait
pageObjects.svlCommonPage.loginWithCustomRole();\r\n```\r\n\r\nFTR
api_integration test example:\r\n\r\n```ts\r\n// First set privileges
for custom role\r\nawait samlAuth.setCustomRole({\r\n elasticsearch:
{\r\n indices: [{ names: ['logstash-*'], privileges: ['read',
'view_index_metadata'] }],\r\n },\r\n kibana: [\r\n {\r\n feature: {\r\n
discover: ['read'],\r\n },\r\n spaces: ['*'],\r\n },\r\n ],\r\n });\r\n
});\r\n// Then you can generate an API key with newly defined
privileges\r\nconst roleAuthc = await
samlAuth.createM2mApiKeyWithRoleScope('customRole');\r\n// Don't forget
to invalidate the API key in the end\r\nawait
samlAuth.invalidateM2mApiKeyWithRoleScope(roleAuthc);\r\n```","sha":"f00ac7a8a21463e6bb4a2784c3a3884f36c62900","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","FTR","v8.16.0","backport:version"],"number":194677,"url":"https://github.com/elastic/kibana/pull/194677","mergeCommit":{"message":"[FTR]
support custom native roles in serverless tests (elastic#194677)\n\n##
Summary\r\n\r\nThis PR updates FTR services to support authentication
with custom\r\nnative role. Few notes:\r\n- for compatibility with MKI
we reserve **\"customRole\"** as a custom\r\nrole name used in
tests\r\n- test user is **automatically assigned** to this role, but
before login\r\nin browser/ generating cookie header or API key in each
test suite\r\n**role privileges must me updated according test
scenario**\r\n\r\nHow to test:\r\nI added a new test file for Search
project:\r\n`x-pack/test_serverless/functional/test_suites/search/custom_role_access.ts`\r\n\r\nIt
can be run locally with:\r\n```\r\n node scripts/functional_tests
--config=x-pack/test_serverless/functional/test_suites/search/config.ts
--grep \"With custom role\"\r\n```\r\n\r\nFTR UI test
example:\r\n\r\n```ts\r\n// First set privileges for custom
role\r\nawait samlAuth.setCustomRole({\r\n elasticsearch: {\r\n indices:
[{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata']
}],\r\n },\r\n kibana: [\r\n {\r\n feature: {\r\n discover:
['read'],\r\n },\r\n spaces: ['*'],\r\n },\r\n ],\r\n });\r\n
});\r\n\r\n// Then you can login in browser as a user with newly defined
privileges\r\nawait
pageObjects.svlCommonPage.loginWithCustomRole();\r\n```\r\n\r\nFTR
api_integration test example:\r\n\r\n```ts\r\n// First set privileges
for custom role\r\nawait samlAuth.setCustomRole({\r\n elasticsearch:
{\r\n indices: [{ names: ['logstash-*'], privileges: ['read',
'view_index_metadata'] }],\r\n },\r\n kibana: [\r\n {\r\n feature: {\r\n
discover: ['read'],\r\n },\r\n spaces: ['*'],\r\n },\r\n ],\r\n });\r\n
});\r\n// Then you can generate an API key with newly defined
privileges\r\nconst roleAuthc = await
samlAuth.createM2mApiKeyWithRoleScope('customRole');\r\n// Don't forget
to invalidate the API key in the end\r\nawait
samlAuth.invalidateM2mApiKeyWithRoleScope(roleAuthc);\r\n```","sha":"f00ac7a8a21463e6bb4a2784c3a3884f36c62900"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194677","number":194677,"mergeCommit":{"message":"[FTR]
support custom native roles in serverless tests (elastic#194677)\n\n##
Summary\r\n\r\nThis PR updates FTR services to support authentication
with custom\r\nnative role. Few notes:\r\n- for compatibility with MKI
we reserve **\"customRole\"** as a custom\r\nrole name used in
tests\r\n- test user is **automatically assigned** to this role, but
before login\r\nin browser/ generating cookie header or API key in each
test suite\r\n**role privileges must me updated according test
scenario**\r\n\r\nHow to test:\r\nI added a new test file for Search
project:\r\n`x-pack/test_serverless/functional/test_suites/search/custom_role_access.ts`\r\n\r\nIt
can be run locally with:\r\n```\r\n node scripts/functional_tests
--config=x-pack/test_serverless/functional/test_suites/search/config.ts
--grep \"With custom role\"\r\n```\r\n\r\nFTR UI test
example:\r\n\r\n```ts\r\n// First set privileges for custom
role\r\nawait samlAuth.setCustomRole({\r\n elasticsearch: {\r\n indices:
[{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata']
}],\r\n },\r\n kibana: [\r\n {\r\n feature: {\r\n discover:
['read'],\r\n },\r\n spaces: ['*'],\r\n },\r\n ],\r\n });\r\n
});\r\n\r\n// Then you can login in browser as a user with newly defined
privileges\r\nawait
pageObjects.svlCommonPage.loginWithCustomRole();\r\n```\r\n\r\nFTR
api_integration test example:\r\n\r\n```ts\r\n// First set privileges
for custom role\r\nawait samlAuth.setCustomRole({\r\n elasticsearch:
{\r\n indices: [{ names: ['logstash-*'], privileges: ['read',
'view_index_metadata'] }],\r\n },\r\n kibana: [\r\n {\r\n feature: {\r\n
discover: ['read'],\r\n },\r\n spaces: ['*'],\r\n },\r\n ],\r\n });\r\n
});\r\n// Then you can generate an API key with newly defined
privileges\r\nconst roleAuthc = await
samlAuth.createM2mApiKeyWithRoleScope('customRole');\r\n// Don't forget
to invalidate the API key in the end\r\nawait
samlAuth.invalidateM2mApiKeyWithRoleScope(roleAuthc);\r\n```","sha":"f00ac7a8a21463e6bb4a2784c3a3884f36c62900"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->1 parent c08dbf1 commit ddcecd6
File tree
13 files changed
+319
-41
lines changed- packages/kbn-ftr-common-functional-services
- services/saml_auth
- serverless
- stateful
- x-pack
- test_serverless
- api_integration
- functional
- page_objects
- test_suites/search
- test/api_integration/deployment_agnostic/default_configs
13 files changed
+319
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
Lines changed: 90 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
30 | 43 | | |
31 | 44 | | |
32 | 45 | | |
| |||
35 | 48 | | |
36 | 49 | | |
37 | 50 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 51 | + | |
| 52 | + | |
41 | 53 | | |
42 | 54 | | |
43 | 55 | | |
| |||
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
64 | 92 | | |
65 | 93 | | |
66 | 94 | | |
| 95 | + | |
| 96 | + | |
67 | 97 | | |
68 | 98 | | |
| 99 | + | |
69 | 100 | | |
| 101 | + | |
| 102 | + | |
70 | 103 | | |
71 | 104 | | |
| 105 | + | |
72 | 106 | | |
73 | 107 | | |
74 | 108 | | |
75 | 109 | | |
76 | 110 | | |
77 | 111 | | |
78 | 112 | | |
| 113 | + | |
79 | 114 | | |
80 | | - | |
81 | | - | |
| 115 | + | |
| 116 | + | |
82 | 117 | | |
| 118 | + | |
83 | 119 | | |
84 | 120 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 121 | + | |
88 | 122 | | |
| 123 | + | |
89 | 124 | | |
90 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
91 | 129 | | |
92 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
93 | 135 | | |
94 | 136 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 137 | + | |
98 | 138 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 139 | + | |
102 | 140 | | |
103 | 141 | | |
| 142 | + | |
104 | 143 | | |
105 | 144 | | |
106 | 145 | | |
107 | 146 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 147 | + | |
113 | 148 | | |
114 | 149 | | |
115 | 150 | | |
| |||
120 | 155 | | |
121 | 156 | | |
122 | 157 | | |
123 | | - | |
| 158 | + | |
124 | 159 | | |
125 | 160 | | |
| 161 | + | |
126 | 162 | | |
127 | 163 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 164 | + | |
139 | 165 | | |
140 | 166 | | |
141 | 167 | | |
142 | 168 | | |
143 | 169 | | |
144 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
145 | 174 | | |
146 | 175 | | |
147 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
148 | 202 | | |
149 | 203 | | |
150 | 204 | | |
151 | 205 | | |
152 | 206 | | |
153 | 207 | | |
154 | 208 | | |
| 209 | + | |
155 | 210 | | |
| 211 | + | |
156 | 212 | | |
157 | 213 | | |
Lines changed: 25 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | | - | |
54 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
55 | 66 | | |
| 67 | + | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
59 | 80 | | |
60 | 81 | | |
61 | 82 | | |
| 83 | + | |
62 | 84 | | |
63 | 85 | | |
64 | 86 | | |
| 87 | + | |
65 | 88 | | |
66 | 89 | | |
67 | 90 | | |
| |||
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
23 | 32 | | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
27 | 46 | | |
28 | 47 | | |
29 | 48 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| |||
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
112 | 120 | | |
113 | 121 | | |
114 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
205 | 258 | | |
206 | 259 | | |
207 | 260 | | |
| |||
0 commit comments