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

Fix unenroll outputs shape #142895

Merged
merged 2 commits into from
Oct 6, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
…-ref HEAD~1..HEAD --fix'
kibanamachine committed Oct 6, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 648dfa6d695cc2cd0e39b391c04b0b1710ca6d0f
11 changes: 7 additions & 4 deletions x-pack/plugins/fleet/common/types/models/agent.ts
Original file line number Diff line number Diff line change
@@ -96,10 +96,13 @@ export interface Agent extends AgentBase {
access_api_key?: string;
// @deprecated
default_api_key_history?: FleetServerAgent['default_api_key_history'];
outputs?: Record<string, {
api_key_id: string;
to_retire_api_key_ids?: FleetServerAgent['default_api_key_history'];
}>;
outputs?: Record<
string,
{
api_key_id: string;
to_retire_api_key_ids?: FleetServerAgent['default_api_key_history'];
}
>;
status?: AgentStatus;
packages: string[];
sort?: Array<number | string | null>;
13 changes: 5 additions & 8 deletions x-pack/plugins/fleet/server/services/agents/unenroll.test.ts
Original file line number Diff line number Diff line change
@@ -334,10 +334,7 @@ describe('invalidateAPIKeysForAgents', () => {
outputs: {
output1: {
api_key_id: 'outputApiKey1',
to_retire_api_key_ids: [
{ id: 'outputApiKeyRetire1' },
{ id: 'outputApiKeyRetire2' },
]
to_retire_api_key_ids: [{ id: 'outputApiKeyRetire1' }, { id: 'outputApiKeyRetire2' }],
},
output2: {
api_key_id: 'outputApiKey2',
@@ -346,10 +343,10 @@ describe('invalidateAPIKeysForAgents', () => {
api_key_id: 'outputApiKey3',
to_retire_api_key_ids: [
// Somes Fleet Server agents don't have an id here (probably a bug)
{ retired_at: 'foo' }
]
{ retired_at: 'foo' },
],
},
}
},
} as any,
]);

@@ -363,7 +360,7 @@ describe('invalidateAPIKeysForAgents', () => {
'outputApiKeyRetire1',
'outputApiKeyRetire2',
'outputApiKey2',
'outputApiKey3'
'outputApiKey3',
]);
});
});
Original file line number Diff line number Diff line change
@@ -223,7 +223,7 @@ export async function invalidateAPIKeysForAgents(agents: Agent[]) {
if (output.to_retire_api_key_ids) {
Object.values(output.to_retire_api_key_ids).forEach((apiKey) => {
if (apiKey?.id) {
keys.push(apiKey.id)
keys.push(apiKey.id);
}
});
}