Skip to content

Commit

Permalink
[SECURITY_SOLUTION] 145: Advanced Policy Tests (#82898) (#84237)
Browse files Browse the repository at this point in the history
* Create Policies for each generated host

* Refactor Ingest setup to also setup Fleet

* Rename prop name

* Add generic response type to KbnClient.request + support for headers

* first attempt at adding fleet agent registration

* a little closer with fleet integration

* SUCCESS. Able to enroll agent and set it to online

* update names to be policy

* policy generator has advanced types in endpoint confit

* linting

* flesh out callback

* add submit button for verify_peer

* add verify hostname field

* 145 generalize cb

* 145 fix setAgain and getValue

* 145 merge conflict

* 145 add verify_hostname back, start loop for form

* 145 remove OS trick

* 145 make AdvancedPolicyForms its own component

* 145 grid partially working

* 145 back to basics

* 145 back to basics

* 145 rolled back grid

* 145 flex table working

* 145 undo accidental change

* 145 remove extra schema file

* 145 remove unused variable

* 145 kevin's PR feedback

* 145 fix type check and jest

* 145 EuiFlexGroups

* 145 use simple EuiFormRow and add show/hide buttons

* 145 move all advanced policy code to advanced file; remove unnec test code

* 145 fix IDs

* 145 take out unnecessary stuff

* 145 removed a couple more lines

* 145 add some fields back in

* 145 add spacer

* 145 start tests

* 145 add findAdvancedPolicyButton

* 145 test passing

* 145 remove comment

Co-authored-by: Paul Tavares <paul.tavares@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kevinlog <kevin.logan@elastic.co>
Co-authored-by: Candace Park <candace.park@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Jane Miller <57721870+jmiller263@users.noreply.github.com>
Co-authored-by: Paul Tavares <paul.tavares@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Candace Park <candace.park@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
6 people authored Nov 24, 2020
1 parent e77769a commit 820759b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const AdvancedPolicyForms = React.memo(() => {
/>
</h4>
</EuiText>
<EuiPanel paddingSize="s">
<EuiPanel data-test-subj="advancedPolicyPanel" paddingSize="s">
{AdvancedPolicySchema.map((advancedField, index) => {
const configPath = advancedField.key.split('.');
return (
Expand Down Expand Up @@ -114,7 +114,12 @@ const PolicyAdvanced = React.memo(
</EuiText>
}
>
<EuiFieldText fullWidth value={value as string} onChange={onChange} />
<EuiFieldText
data-test-subj={configPath.join('.')}
fullWidth
value={value as string}
onChange={onChange}
/>
</EuiFormRow>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
policyInfo.packagePolicy.name
);
});

it('and the show advanced settings button is clicked', async () => {
await testSubjects.missingOrFail('advancedPolicyPanel');

let advancedPolicyButton = await pageObjects.policy.findAdvancedPolicyButton();
await advancedPolicyButton.click();

await testSubjects.existOrFail('advancedPolicyPanel');

advancedPolicyButton = await pageObjects.policy.findAdvancedPolicyButton();
await advancedPolicyButton.click();
await testSubjects.missingOrFail('advancedPolicyPanel');
});
});

describe('and the save button is clicked', () => {
Expand Down Expand Up @@ -98,7 +111,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyLinuxEvent_file'),
pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyMacEvent_file'),
]);

const advancedPolicyButton = await pageObjects.policy.findAdvancedPolicyButton();
await advancedPolicyButton.click();

const advancedPolicyField = await pageObjects.policy.findAdvancedPolicyField();
await advancedPolicyField.clearValue();
await advancedPolicyField.click();
await advancedPolicyField.type('true');
await pageObjects.policy.confirmAndSave();

await testSubjects.existOrFail('policyDetailsSuccessMessage');

const agentFullPolicy = await policyTestResources.getFullAgentPolicy(
Expand Down Expand Up @@ -191,6 +213,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
linux: {
events: { file: false, network: true, process: true },
logging: { file: 'info' },
advanced: { agent: { connection_delay: 'true' } },
},
mac: {
events: { file: false, network: true, process: true },
Expand Down
16 changes: 16 additions & 0 deletions x-pack/test/security_solution_endpoint/page_objects/policy_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr
return await testSubjects.find('policyDetailsCancelButton');
},

/**
* Finds and returns the Advanced Policy Show/Hide Button
*/
async findAdvancedPolicyButton() {
await this.ensureIsOnDetailsPage();
return await testSubjects.find('advancedPolicyButton');
},

/**
* Finds and returns the linux connection_delay Advanced Policy field
*/
async findAdvancedPolicyField() {
await this.ensureIsOnDetailsPage();
return await testSubjects.find('linux.advanced.agent.connection_delay');
},

/**
* ensures that the Details Page is the currently display view
*/
Expand Down

0 comments on commit 820759b

Please sign in to comment.