From caddc9014d1108c7455e7b13e3ccee4b1ef1c4e1 Mon Sep 17 00:00:00 2001 From: Sid Mantri Date: Fri, 28 Jun 2024 18:54:13 +0200 Subject: [PATCH] update type guard to use correct key --- .../src/authentication/api_keys/api_keys.ts | 2 +- .../security/server/authentication/api_keys/api_keys.test.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/security/core-security-server/src/authentication/api_keys/api_keys.ts b/packages/core/security/core-security-server/src/authentication/api_keys/api_keys.ts index 3037114971be..e842c38d8674 100644 --- a/packages/core/security/core-security-server/src/authentication/api_keys/api_keys.ts +++ b/packages/core/security/core-security-server/src/authentication/api_keys/api_keys.ts @@ -264,5 +264,5 @@ export interface UpdateRestAPIKeyWithKibanaPrivilegesParams { } export function isCreateRestAPIKeyParams(params: any): params is CreateRestAPIKeyParams { - return 'role_descriptor' in params; + return 'role_descriptors' in params; } diff --git a/x-pack/plugins/security/server/authentication/api_keys/api_keys.test.ts b/x-pack/plugins/security/server/authentication/api_keys/api_keys.test.ts index 9c03cc7dc477..198bc004ecb6 100644 --- a/x-pack/plugins/security/server/authentication/api_keys/api_keys.test.ts +++ b/x-pack/plugins/security/server/authentication/api_keys/api_keys.test.ts @@ -243,6 +243,7 @@ describe('API Keys', () => { role_descriptors: roleDescriptors, expiration: '1d', }); + expect(result).toEqual({ api_key: 'abc123', expiration: '1d', @@ -254,7 +255,7 @@ describe('API Keys', () => { expect(mockScopedClusterClient.asCurrentUser.security.createApiKey).toHaveBeenCalledWith({ body: { name: 'key-name', - role_descriptors: { foo: true }, + role_descriptors: roleDescriptors, expiration: '1d', }, });