Skip to content

Commit

Permalink
Unskipped and added additional filters to test (#187869)
Browse files Browse the repository at this point in the history
## Summary

Unskipped and added additional filter for testing audit events when
reading and writing saved objects.
We were filtering event by action only (`http_request` and
`saved_object_create`), which probably sometimes returned audit events
logged for background tasks, that lack user information.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

__Fixes: https://github.com/elastic/kibana/issues/119267__

---------

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
elena-shostak and elasticmachine authored Jul 10, 2024
1 parent a0b018b commit 97e1163
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions x-pack/test/security_api_integration/tests/audit/audit_log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,27 @@ export default function ({ getService }: FtrProviderContext) {
await logFile.reset();
});

// FLAKY: https://github.com/elastic/kibana/issues/119267
it.skip('logs audit events when reading and writing saved objects', async () => {
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 logFile.isWritten();
const content = await logFile.readJSON();

const httpEvent = content.find((c) => c.event.action === 'http_request');
const httpEvent = content.find(
(c) => c.event.action === 'http_request' && c.url.path === '/audit_log'
);
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');
expect(httpEvent.url.path).to.be('/audit_log');
expect(httpEvent.url.query).to.be('query=param');

const createEvent = content.find((c) => c.event.action === 'saved_object_create');
const createEvent = content.find(
(c) =>
c.event.action === 'saved_object_create' && c.kibana.saved_object.type === 'dashboard'
);

expect(createEvent).to.be.ok();
expect(createEvent.trace.id).to.be.ok();
expect(createEvent.user.name).to.be(username);
Expand Down

0 comments on commit 97e1163

Please sign in to comment.