Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Failing Test] Fixes intermittent failures in audit log integration tests #154935

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions x-pack/test/security_api_integration/tests/audit/audit_log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export default function ({ getService }: FtrProviderContext) {
const retry = getService('retry');
const { username, password } = getService('config').get('servers.kibana');

// FLAKY: https://github.com/elastic/kibana/issues/119267
describe.skip('Audit Log', function () {
describe('Audit Log', function () {
const logFilePath = Path.resolve(__dirname, '../../plugins/audit_log/audit.log');
const logFile = new FileWrapper(logFilePath, retry);

Expand All @@ -27,12 +26,12 @@ export default function ({ getService }: FtrProviderContext) {
it('logs audit events when reading and writing saved objects', async () => {
await supertest.get('/audit_log?query=param').set('kbn-xsrf', 'foo').expect(204);
await retry.waitFor('logs event in the dest file', async () => await logFile.isNotEmpty());

const content = await logFile.readJSON();

const httpEvent = content.find((c) => c.event.action === 'http_request');
expect(httpEvent).to.be.ok();
expect(httpEvent.trace.id).to.be.ok();

expect(httpEvent.user.name).to.be(username);
expect(httpEvent.kibana.space_id).to.be('default');
expect(httpEvent.http.request.method).to.be('get');
Expand All @@ -45,7 +44,12 @@ export default function ({ getService }: FtrProviderContext) {
expect(createEvent.user.name).to.be(username);
expect(createEvent.kibana.space_id).to.be('default');

const findEvent = content.find((c) => c.event.action === 'saved_object_find');
// There are two 'saved_object_find' events in the log. One is by the fleet app for
// "epm - packages", the other is by the user for a dashboard (this is the one we are
// concerned with).
const findEvent = content.find(
(c) => c.event.action === 'saved_object_find' && c.kibana.saved_object.type === 'dashboard'
);
expect(findEvent).to.be.ok();
expect(findEvent.trace.id).to.be.ok();
expect(findEvent.user.name).to.be(username);
Expand All @@ -65,7 +69,6 @@ export default function ({ getService }: FtrProviderContext) {
})
.expect(200);
await retry.waitFor('logs event in the dest file', async () => await logFile.isNotEmpty());

const content = await logFile.readJSON();

const loginEvent = content.find((c) => c.event.action === 'user_login');
Expand All @@ -90,7 +93,6 @@ export default function ({ getService }: FtrProviderContext) {
})
.expect(401);
await retry.waitFor('logs event in the dest file', async () => await logFile.isNotEmpty());

const content = await logFile.readJSON();

const loginEvent = content.find((c) => c.event.action === 'user_login');
Expand Down