Skip to content

Commit

Permalink
Add API integration test for handling auth error.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Sep 16, 2021
1 parent 83d62e4 commit e69c860
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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 { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertestWithoutAuth = getService('supertestWithoutAuth');
const security = getService('security');

describe('Elasticsearch deprecations', () => {
describe('GET /api/upgrade_assistant/es_deprecations', () => {
it('handles auth error', async () => {
const ROLE_NAME = 'authErrorRole';
const USER_NAME = 'authErrorUser';
const USER_PASSWORD = 'password';

try {
await security.role.create(ROLE_NAME, {});
await security.user.create(USER_NAME, {
password: USER_PASSWORD,
roles: [ROLE_NAME],
});

await supertestWithoutAuth
.get('/api/upgrade_assistant/es_deprecations')
.auth(USER_NAME, USER_PASSWORD)
.set('kbn-xsrf', 'kibana')
.send()
.expect(403);
} finally {
await security.role.delete(ROLE_NAME);
await security.user.delete(USER_NAME);
}
});
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
describe('Upgrade Assistant', () => {
loadTestFile(require.resolve('./upgrade_assistant'));
loadTestFile(require.resolve('./cloud_backup_status'));
loadTestFile(require.resolve('./es_deprecations'));
});
}

0 comments on commit e69c860

Please sign in to comment.