Skip to content

Commit

Permalink
Clean up tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
criamico committed Sep 5, 2022
1 parent 5318df8 commit 9cb7686
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { FLEET, navigateTo } from '../tasks/navigation';
import { cleanupAgentPolicies } from '../tasks/cleanup';
import { cleanupAgentPolicies, cleanupEnrollmentTokens } from '../tasks/cleanup';
import { ENROLLMENT_TOKENS_TAB, ENROLLMENT_TOKENS } from '../screens/fleet';

describe('Enrollment token page', () => {
Expand All @@ -29,6 +29,7 @@ describe('Enrollment token page', () => {

after(() => {
cleanupAgentPolicies();
cleanupEnrollmentTokens();
});

it('Create new Token', () => {
Expand Down
12 changes: 12 additions & 0 deletions x-pack/plugins/fleet/cypress/tasks/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,15 @@ export function deleteAgentDocs(ignoreUnavailable: boolean = false) {
ignoreUnavailable,
});
}

export function cleanupEnrollmentTokens() {
cy.request('/api/fleet/enrollment_api_keys').then((response: any) => {
response.body.items.forEach((item: any) => {
cy.request({
method: 'DELETE',
url: `/api/fleet/enrollment_api_keys/${item.id}`,
headers: { 'kbn-xsrf': 'kibana' },
});
});
});
}

0 comments on commit 9cb7686

Please sign in to comment.