Skip to content

Commit

Permalink
[Cloud Security] Remove Add integration button from agent policy de…
Browse files Browse the repository at this point in the history
…tails page when the agent policy `supports_agentless` (elastic#202211)
  • Loading branch information
seanrathier authored and CAWilson94 committed Dec 9, 2024
1 parent 9b88197 commit 96aaa27
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 39 deletions.
40 changes: 40 additions & 0 deletions x-pack/plugins/fleet/cypress/e2e/agents/agentless.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { ADD_PACKAGE_POLICY_BTN } from '../../screens/fleet';
import { login } from '../../tasks/login';

describe('View agentless policy details', () => {
beforeEach(() => {
login();
cy.intercept('/api/fleet/agent_policies/policy-1', {
item: {
id: 'policy-1',
name: 'Agentless policy for cspm-1',
description: '',
namespace: 'default',
monitoring_enabled: ['logs', 'metrics'],
status: 'active',
supports_agentless: true,
package_policies: [
{
id: 'cspm-1',
name: 'cspm-1',
policy_id: 'policy-1',
policy_ids: ['policy-1'],
inputs: [],
},
],
},
});
});

it('should not show the add integration button if the policy support agentless', () => {
cy.visit('/app/fleet/policies/policy-1');
cy.getBySel(ADD_PACKAGE_POLICY_BTN).should('not.exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -400,45 +400,46 @@ export const PackagePoliciesTable: React.FunctionComponent<Props> = ({
}}
{...rest}
search={{
toolsRight: agentPolicy.is_managed
? []
: [
<EuiButtonWithTooltip
key="addPackagePolicyButton"
fill
isDisabled={!canWriteIntegrationPolicies}
iconType="plusInCircle"
onClick={() => {
application.navigateToApp(INTEGRATIONS_PLUGIN_ID, {
path: pagePathGetters.integrations_all({})[1],
state: { forAgentPolicyId: agentPolicy.id },
});
}}
data-test-subj="addPackagePolicyButton"
tooltip={
!canWriteIntegrationPolicies
? {
content: missingSecurityConfiguration ? (
<FormattedMessage
id="xpack.fleet.epm.addPackagePolicyButtonSecurityRequiredTooltip"
defaultMessage="To add Elastic Agent Integrations, you must have security enabled and have the All privilege for Fleet. Contact your administrator."
/>
) : (
<FormattedMessage
id="xpack.fleet.epm.addPackagePolicyButtonPrivilegesRequiredTooltip"
defaultMessage="Elastic Agent Integrations require the All privilege for Agent policies and All privilege for Integrations. Contact your administrator."
/>
),
}
: undefined
}
>
<FormattedMessage
id="xpack.fleet.policyDetails.addPackagePolicyButtonText"
defaultMessage="Add integration"
/>
</EuiButtonWithTooltip>,
],
toolsRight:
agentPolicy.is_managed || agentPolicy.supports_agentless
? []
: [
<EuiButtonWithTooltip
key="addPackagePolicyButton"
fill
isDisabled={!canWriteIntegrationPolicies}
iconType="plusInCircle"
onClick={() => {
application.navigateToApp(INTEGRATIONS_PLUGIN_ID, {
path: pagePathGetters.integrations_all({})[1],
state: { forAgentPolicyId: agentPolicy.id },
});
}}
data-test-subj="addPackagePolicyButton"
tooltip={
!canWriteIntegrationPolicies
? {
content: missingSecurityConfiguration ? (
<FormattedMessage
id="xpack.fleet.epm.addPackagePolicyButtonSecurityRequiredTooltip"
defaultMessage="To add Elastic Agent Integrations, you must have security enabled and have the All privilege for Fleet. Contact your administrator."
/>
) : (
<FormattedMessage
id="xpack.fleet.epm.addPackagePolicyButtonPrivilegesRequiredTooltip"
defaultMessage="Elastic Agent Integrations require the All privilege for Agent policies and All privilege for Integrations. Contact your administrator."
/>
),
}
: undefined
}
>
<FormattedMessage
id="xpack.fleet.policyDetails.addPackagePolicyButtonText"
defaultMessage="Add integration"
/>
</EuiButtonWithTooltip>,
],
box: {
incremental: true,
schema: true,
Expand Down

0 comments on commit 96aaa27

Please sign in to comment.