Skip to content

Commit

Permalink
Add API integration test for 404 condition
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego committed Apr 29, 2021
1 parent d0aca90 commit 8f1ae02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -22,8 +22,8 @@ export function defineGetFieldsRoutes({ router }: RouteDefinitionParams) {
body: indexMappings,
} = await context.core.elasticsearch.client.asCurrentUser.indices.getFieldMapping({
index: request.params.query,
allow_no_indices: false,
fields: '*',
allow_no_indices: false,
include_defaults: true,
filter_path: '*.mappings.*.mapping.*.type',
});
Expand Down
10 changes: 10 additions & 0 deletions x-pack/test/api_integration/apis/security/index_fields.ts
Expand Up @@ -71,6 +71,16 @@ export default function ({ getService }: FtrProviderContext) {

expect(actualFields).to.eql(expectedFields);
});

it('should return an empty result for indices that do not exist', async () => {
const { body: actualFields } = (await supertest
.get('/internal/security/fields/this-index-name-definitely-does-not-exist-*')
.set('kbn-xsrf', 'xxx')
.send()
.expect(200)) as { body: string[] };

expect(actualFields).to.eql([]);
});
});
});
}

0 comments on commit 8f1ae02

Please sign in to comment.