Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -483,16 +483,14 @@ describe('API Keys', () => {
});
expect(mockValidateKibanaPrivileges).not.toHaveBeenCalled(); // this is only called if kibana_role_descriptors is defined
expect(mockClusterClient.asInternalUser.security.grantApiKey).toHaveBeenCalledWith({
body: {
api_key: {
name: 'test_api_key',
role_descriptors: { foo: true },
expiration: '1d',
},
grant_type: 'password',
username: 'foo',
password: 'bar',
api_key: {
name: 'test_api_key',
role_descriptors: { foo: true },
expiration: '1d',
},
grant_type: 'password',
username: 'foo',
password: 'bar',
});
});

Expand Down Expand Up @@ -522,15 +520,13 @@ describe('API Keys', () => {
});
expect(mockValidateKibanaPrivileges).not.toHaveBeenCalled(); // this is only called if kibana_role_descriptors is defined
expect(mockClusterClient.asInternalUser.security.grantApiKey).toHaveBeenCalledWith({
body: {
api_key: {
name: 'test_api_key',
role_descriptors: roleDescriptors,
expiration: '1d',
},
grant_type: 'access_token',
access_token: 'foo-access-token',
api_key: {
name: 'test_api_key',
role_descriptors: roleDescriptors,
expiration: '1d',
},
grant_type: 'access_token',
access_token: 'foo-access-token',
});
});

Expand Down Expand Up @@ -563,18 +559,16 @@ describe('API Keys', () => {
});
expect(mockValidateKibanaPrivileges).not.toHaveBeenCalled(); // this is only called if kibana_role_descriptors is defined
expect(mockClusterClient.asInternalUser.security.grantApiKey).toHaveBeenCalledWith({
body: {
api_key: {
name: 'test_api_key',
role_descriptors: { foo: true },
expiration: '1d',
},
grant_type: 'access_token',
access_token: 'foo-access-token',
client_authentication: {
scheme: 'SharedSecret',
value: 'secret',
},
api_key: {
name: 'test_api_key',
role_descriptors: { foo: true },
expiration: '1d',
},
grant_type: 'access_token',
access_token: 'foo-access-token',
client_authentication: {
scheme: 'SharedSecret',
value: 'secret',
},
});
});
Expand Down Expand Up @@ -857,29 +851,27 @@ describe('API Keys', () => {
name: 'key-name',
});
expect(mockClusterClient.asInternalUser.security.grantApiKey).toHaveBeenCalledWith({
body: {
api_key: {
name: 'key-name',
role_descriptors: {
synthetics_writer: {
applications: [
{
application: 'kibana-.kibana',
privileges: ['feature_uptime.all'],
resources: ['*'],
},
],
cluster: ['manage'],
indices: [],
run_as: [],
},
api_key: {
name: 'key-name',
role_descriptors: {
synthetics_writer: {
applications: [
{
application: 'kibana-.kibana',
privileges: ['feature_uptime.all'],
resources: ['*'],
},
],
cluster: ['manage'],
indices: [],
run_as: [],
},
expiration: '1d',
},
grant_type: 'password',
password: 'bar',
username: 'foo',
expiration: '1d',
},
grant_type: 'password',
password: 'bar',
username: 'foo',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ export class APIKeys implements APIKeysType {
// User needs `manage_api_key` or `grant_api_key` privilege to use this API
let result: GrantAPIKeyResult;
try {
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584 (client_authentication)
result = await this.clusterClient.asInternalUser.security.grantApiKey({ body: params });
result = await this.clusterClient.asInternalUser.security.grantApiKey(params);
this.logger.debug('API key was granted successfully');
} catch (e) {
this.logger.error(`Failed to grant API key: ${e.message}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe('Session index', () => {
expect(mockElasticsearchClient.indices.putMapping).toHaveBeenCalledTimes(1);
expect(mockElasticsearchClient.indices.putMapping).toHaveBeenCalledWith({
index: aliasName,
body: getSessionIndexSettings({ indexName, aliasName }).mappings,
...getSessionIndexSettings({ indexName, aliasName }).mappings,
});
});

Expand All @@ -367,7 +367,7 @@ describe('Session index', () => {
expect(mockElasticsearchClient.indices.putMapping).toHaveBeenCalledTimes(1);
expect(mockElasticsearchClient.indices.putMapping).toHaveBeenCalledWith({
index: aliasName,
body: getSessionIndexSettings({ indexName, aliasName }).mappings,
...getSessionIndexSettings({ indexName, aliasName }).mappings,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,7 @@ export class SessionIndex {
try {
await this.options.elasticsearchClient.indices.putMapping({
index: this.aliasName,
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
body: sessionIndexSettings.mappings,
...sessionIndexSettings.mappings,
});
this.options.logger.debug('Successfully updated session index mappings.');
} catch (err) {
Expand Down