-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...ck/test/rule_registry/security_and_spaces/tests/basic/get_browser_fields_by_feature_id.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
|
||
import { superUser, obsOnlySpacesAll, secOnlyRead } from '../../../common/lib/authentication/users'; | ||
import type { User } from '../../../common/lib/authentication/types'; | ||
import { FtrProviderContext } from '../../../common/ftr_provider_context'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default ({ getService }: FtrProviderContext) => { | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
const esArchiver = getService('esArchiver'); | ||
|
||
const TEST_URL = '/internal/rac/alerts/browser_fields'; | ||
|
||
const getBrowserFieldsByFeatureId = async ( | ||
user: User, | ||
featureIds: string[], | ||
expectedStatusCode: number = 200 | ||
) => { | ||
const resp = await supertestWithoutAuth | ||
.get(`${TEST_URL}?featureIds=${featureIds.toString()}`) | ||
.auth(user.username, user.password) | ||
.set('kbn-xsrf', 'true') | ||
.expect(expectedStatusCode); | ||
return resp.body; | ||
}; | ||
|
||
describe('Alert - Get browser fields by featureId', () => { | ||
before(async () => { | ||
await esArchiver.load('x-pack/test/functional/es_archives/rule_registry/alerts'); | ||
}); | ||
|
||
describe('Users:', () => { | ||
it(`${obsOnlySpacesAll.username} should be able to get feature id for o11y featureIds`, async () => { | ||
const browserFields = await getBrowserFieldsByFeatureId(obsOnlySpacesAll, [ | ||
'apm', | ||
'infrastructure', | ||
'logs', | ||
'uptime', | ||
]); | ||
expect(Object.keys(browserFields)).to.eql(['base']); | ||
}); | ||
|
||
it(`${superUser.username} should be able to get feature id for o11y featureIds`, async () => { | ||
const browserFields = await getBrowserFieldsByFeatureId(superUser, [ | ||
'apm', | ||
'infrastructure', | ||
'logs', | ||
'uptime', | ||
]); | ||
expect(Object.keys(browserFields)).to.eql(['base', 'kibana', 'message']); | ||
}); | ||
|
||
it(`${secOnlyRead.username} should not have access to o11y featureIds`, async () => { | ||
await getBrowserFieldsByFeatureId(secOnlyRead, ['siem'], 403); | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters