[SECURITY_SOLUTION] 145: Advanced Policy Tests (#82898)

* 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>
This commit is contained in:
Jane Miller 2020-11-20 10:27:58 -05:00 committed by GitHub
parent 6417ee66d8
commit 7c80a6be68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 2 deletions

View file

@ -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 (
@ -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>
</>
);

View file

@ -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', () => {
@ -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(
@ -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 },

View file

@ -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
*/