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 @@ -852,6 +852,18 @@ describe('getFullAgentPolicy', () => {
});
});

it('should not populate agent.protection and signed properties for standalone policies', async () => {
appContextService.start(createAppContextStartContractMock());

mockAgentPolicy({});
const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy', {
standalone: true,
});

expect(agentPolicy!.agent!.protection).toBeUndefined();
expect(agentPolicy!.signed).toBeUndefined();
});

it('should compile full policy with correct namespaces', async () => {
mockedGetPackageInfo.mockResolvedValue({
data_streams: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export async function getFullAgentPolicy(

// populate protection and signed properties
const messageSigningService = appContextService.getMessageSigningService();
if (messageSigningService && fullAgentPolicy.agent) {
if (options?.standalone !== true && messageSigningService && fullAgentPolicy.agent) {
const publicKey = await messageSigningService.getPublicKey();
const tokenHash =
(await appContextService
Expand Down Expand Up @@ -345,6 +345,11 @@ export async function getFullAgentPolicy(
if (agentPolicy.overrides) {
return deepMerge<FullAgentPolicy>(fullAgentPolicy, agentPolicy.overrides);
}
if (options?.standalone) {
delete fullAgentPolicy.agent?.protection;
delete fullAgentPolicy.signed;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do we need this line if signed is not set in the previous conditional?

}

return fullAgentPolicy;
}

Expand Down
Loading