Skip to content

Commit

Permalink
[7.17] fix(tests): update built-in ES privileges to expect `remote_cl…
Browse files Browse the repository at this point in the history
…uster` only starting from 8.15.0+. (#184454) (#184474)

# Backport

This will backport the following commits from `main` to `7.17`:
- [fix(tests): update built-in ES privileges to expect `remote_cluster`
only starting from 8.15.0+.
(#184454)](#184454)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Aleh
Zasypkin","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-05-29T18:11:24Z","message":"fix(tests):
update built-in ES privileges to expect `remote_cluster` only starting
from 8.15.0+. (#184454)\n\n## Summary\r\n\r\nUpdate built-in ES
privileges to expect `remote_cluster` only starting\r\nfrom
8.15.0+.\r\n\r\n```http\r\nGET /_security/privilege/_builtin
HTTP/1.1\r\nx-elastic-product-origin: kibana\r\nuser-agent:
Kibana/8.15.0\r\nx-elastic-client-meta:
es=8.13.0,js=20.13.1,t=8.4.1,hc=20.13.1\r\naccept:
application/vnd.elasticsearch+json;
compatible-with=8,text/plain\r\nHost: localhost:9220\r\n\r\nHTTP/1.1 200
OK\r\nX-elastic-product: Elasticsearch\r\ncontent-type:
application/json\r\ncontent-length: 1562\r\n\r\n{\r\n \"cluster\": [\r\n
\"all\",\r\n ...\r\n ],\r\n \"index\": [\r\n \"all\",\r\n ...\r\n ],\r\n
\"remote_cluster\": [\r\n \"monitor_enrich\"\r\n
]\r\n}\r\n```\r\n\r\n__Fixes:
https://github.com/elastic/kibana/issues/184431__\r\n__Fixes:
https://github.com/elastic/kibana/issues/184432__","sha":"c1846c34b820488d9e660d89b23cef1794231d59","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["test","Feature:CCR
and Remote
Clusters","release_note:skip","backport:prev-MAJOR","v8.15.0"],"number":184454,"url":"https://github.com/elastic/kibana/pull/184454","mergeCommit":{"message":"fix(tests):
update built-in ES privileges to expect `remote_cluster` only starting
from 8.15.0+. (#184454)\n\n## Summary\r\n\r\nUpdate built-in ES
privileges to expect `remote_cluster` only starting\r\nfrom
8.15.0+.\r\n\r\n```http\r\nGET /_security/privilege/_builtin
HTTP/1.1\r\nx-elastic-product-origin: kibana\r\nuser-agent:
Kibana/8.15.0\r\nx-elastic-client-meta:
es=8.13.0,js=20.13.1,t=8.4.1,hc=20.13.1\r\naccept:
application/vnd.elasticsearch+json;
compatible-with=8,text/plain\r\nHost: localhost:9220\r\n\r\nHTTP/1.1 200
OK\r\nX-elastic-product: Elasticsearch\r\ncontent-type:
application/json\r\ncontent-length: 1562\r\n\r\n{\r\n \"cluster\": [\r\n
\"all\",\r\n ...\r\n ],\r\n \"index\": [\r\n \"all\",\r\n ...\r\n ],\r\n
\"remote_cluster\": [\r\n \"monitor_enrich\"\r\n
]\r\n}\r\n```\r\n\r\n__Fixes:
https://github.com/elastic/kibana/issues/184431__\r\n__Fixes:
https://github.com/elastic/kibana/issues/184432__","sha":"c1846c34b820488d9e660d89b23cef1794231d59"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.15.0","labelRegex":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/184454","number":184454,"mergeCommit":{"message":"fix(tests):
update built-in ES privileges to expect `remote_cluster` only starting
from 8.15.0+. (#184454)\n\n## Summary\r\n\r\nUpdate built-in ES
privileges to expect `remote_cluster` only starting\r\nfrom
8.15.0+.\r\n\r\n```http\r\nGET /_security/privilege/_builtin
HTTP/1.1\r\nx-elastic-product-origin: kibana\r\nuser-agent:
Kibana/8.15.0\r\nx-elastic-client-meta:
es=8.13.0,js=20.13.1,t=8.4.1,hc=20.13.1\r\naccept:
application/vnd.elasticsearch+json;
compatible-with=8,text/plain\r\nHost: localhost:9220\r\n\r\nHTTP/1.1 200
OK\r\nX-elastic-product: Elasticsearch\r\ncontent-type:
application/json\r\ncontent-length: 1562\r\n\r\n{\r\n \"cluster\": [\r\n
\"all\",\r\n ...\r\n ],\r\n \"index\": [\r\n \"all\",\r\n ...\r\n ],\r\n
\"remote_cluster\": [\r\n \"monitor_enrich\"\r\n
]\r\n}\r\n```\r\n\r\n__Fixes:
https://github.com/elastic/kibana/issues/184431__\r\n__Fixes:
https://github.com/elastic/kibana/issues/184432__","sha":"c1846c34b820488d9e660d89b23cef1794231d59"}}]}]
BACKPORT-->

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
azasypkin and kibanamachine authored May 30, 2024
1 parent 9188799 commit 4369693
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export function defineGetBuiltinPrivilegesRoutes({ router }: RouteDefinitionPara

// Exclude the `none` privilege, as it doesn't make sense as an option within the Kibana UI
privileges.cluster = privileges.cluster.filter((privilege) => privilege !== 'none');
const indexPriviledges = Array.isArray(privileges.index)
const indexPrivileges = Array.isArray(privileges.index)
? privileges.index
: [privileges.index];
privileges.index = indexPriviledges.filter((privilege) => privilege !== 'none');
privileges.index = indexPrivileges.filter((privilege) => privilege !== 'none');

return response.ok({ body: privileges });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esVersion = getService('esVersion');

describe('Builtin ES Privileges', () => {
describe('GET /internal/security/esPrivileges/builtin', () => {
Expand All @@ -24,7 +25,15 @@ export default function ({ getService }: FtrProviderContext) {
const sampleOfExpectedIndexPrivileges = ['create', 'index', 'delete'];

const payload = response.body;
expect(Object.keys(payload).sort()).to.eql(['cluster', 'index']);

// The `remote_cluster` built-in privilege was introduced in 8.15.0, but these tests are also run for
// earlier stack versions (e.g., compatibility tests) where `remote_cluster` isn't available. We can get
// rid of logic once we release 9.0 and switch compatibility test from 7.x branch to 8.x.
expect(Object.keys(payload).sort()).to.eql(
esVersion.matchRange('>=8.15.0')
? ['cluster', 'index', 'remote_cluster']
: ['cluster', 'index']
);

sampleOfExpectedClusterPrivileges.forEach((privilege) =>
expect(payload.cluster).to.contain(privilege)
Expand Down

0 comments on commit 4369693

Please sign in to comment.