Skip to content

Commit

Permalink
[Fleet] Fix preconfigured ca_trusted_fingerprint in output (#142109)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Sep 28, 2022
1 parent 61a3008 commit 13b283a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,33 @@ describe('output preconfiguration', () => {
expect(spyAgentPolicyServicBumpAllAgentPoliciesForOutput).not.toBeCalled();
});

it('should create a preconfigured output with ca_trusted_fingerprint that does not exists', async () => {
const soClient = savedObjectsClientMock.create();
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
await createOrUpdatePreconfiguredOutputs(soClient, esClient, [
{
id: 'non-existing-output-1',
name: 'Output 1',
type: 'elasticsearch',
is_default: false,
is_default_monitoring: false,
hosts: ['http://test.fr'],
ca_trusted_fingerprint: 'testfingerprint',
},
]);

expect(mockedOutputService.create).toBeCalled();
expect(mockedOutputService.create).toBeCalledWith(
expect.anything(),
expect.objectContaining({
ca_trusted_fingerprint: 'testfingerprint',
}),
expect.anything()
);
expect(mockedOutputService.update).not.toBeCalled();
expect(spyAgentPolicyServicBumpAllAgentPoliciesForOutput).not.toBeCalled();
});

it('should create preconfigured logstash output that does not exist', async () => {
const soClient = savedObjectsClientMock.create();
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function createOrUpdatePreconfiguredOutputs(
config_yaml: configYaml ?? null,
// Set value to null to update these fields on update
ca_sha256: outputData.ca_sha256 ?? null,
ca_trusted_fingerprint: outputData.ca_sha256 ?? null,
ca_trusted_fingerprint: outputData.ca_trusted_fingerprint ?? null,
ssl: outputData.ssl ?? null,
};

Expand Down

0 comments on commit 13b283a

Please sign in to comment.