Skip to content

Commit

Permalink
fix more types
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallmain committed Jun 17, 2020
1 parent 85468e9 commit 244443e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ describe('data generator', () => {
const hostPolicyResponse = generator.generatePolicyResponse(timestamp);
expect(hostPolicyResponse['@timestamp']).toEqual(timestamp);
expect(hostPolicyResponse.event.created).toEqual(timestamp);
expect(hostPolicyResponse.endpoint).not.toBeNull();
expect(hostPolicyResponse.Endpoint).not.toBeNull();
expect(hostPolicyResponse.agent).not.toBeNull();
expect(hostPolicyResponse.host).not.toBeNull();
expect(hostPolicyResponse.endpoint.policy.applied).not.toBeNull();
expect(hostPolicyResponse.Endpoint.policy.applied).not.toBeNull();
});

it('creates alert event documents', () => {
Expand Down Expand Up @@ -364,7 +364,9 @@ describe('data generator', () => {
it('creates full resolver tree', () => {
const alertAncestors = 3;
const generations = 2;
const events = [...generator.fullResolverTreeGenerator(alertAncestors, generations)];
const events = [
...generator.fullResolverTreeGenerator({ ancestors: alertAncestors, generations }),
];
const rootNode = buildResolverTree(events);
const visitedEvents = countResolverEvents(rootNode, alertAncestors + generations);
expect(visitedEvents).toEqual(events.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const detailsError = (state: Immutable<HostState>) => state.detailsError;
* Returns the full policy response from the endpoint after a user modifies a policy.
*/
const detailsPolicyAppliedResponse = (state: Immutable<HostState>) =>
state.policyResponse && state.policyResponse.endpoint.policy.applied;
state.policyResponse && state.policyResponse.Endpoint.policy.applied;

/**
* Returns the response configurations from the endpoint after a user modifies a policy.
Expand Down Expand Up @@ -179,6 +179,6 @@ export const showView: (state: HostState) => 'policy_response' | 'details' = cre
export const policyResponseStatus: (state: Immutable<HostState>) => string = createSelector(
(state) => state.policyResponse,
(policyResponse) => {
return (policyResponse && policyResponse?.endpoint?.policy?.applied?.status) || '';
return (policyResponse && policyResponse?.Endpoint?.policy?.applied?.status) || '';
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ export const HostDetails = memo(({ details }: { details: HostMetadata }) => {
return [
getManagementUrl({
name: 'policyDetails',
policyId: details.endpoint.policy.applied.id,
policyId: details.Endpoint.policy.applied.id,
excludePrefix: true,
}),
getManagementUrl({
name: 'policyDetails',
policyId: details.endpoint.policy.applied.id,
policyId: details.Endpoint.policy.applied.id,
}),
];
}, [details.endpoint.policy.applied.id]);
}, [details.Endpoint.policy.applied.id]);

const policyDetailsClickHandler = useNavigateByRouterEventHandler(policyDetailsRoutePath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ describe('when on the hosts page', () => {
});
describe('when list data loads', () => {
const generatedPolicyStatuses: Array<
HostInfo['metadata']['endpoint']['policy']['applied']['status']
HostInfo['metadata']['Endpoint']['policy']['applied']['status']
> = [];
let firstPolicyID: string;
beforeEach(() => {
reactTestingLibrary.act(() => {
const hostListData = mockHostResultList({ total: 3 });
firstPolicyID = hostListData.hosts[0].metadata.endpoint.policy.applied.id;
firstPolicyID = hostListData.hosts[0].metadata.Endpoint.policy.applied.id;
[HostStatus.ERROR, HostStatus.ONLINE, HostStatus.OFFLINE].forEach((status, index) => {
hostListData.hosts[index] = {
metadata: hostListData.hosts[index].metadata,
host_status: status,
};
});
hostListData.hosts.forEach((item, index) => {
generatedPolicyStatuses[index] = item.metadata.endpoint.policy.applied.status;
generatedPolicyStatuses[index] = item.metadata.Endpoint.policy.applied.status;
});
const action: AppAction = {
type: 'serverReturnedHostList',
Expand Down Expand Up @@ -160,9 +160,9 @@ describe('when on the hosts page', () => {
overallStatus: HostPolicyResponseActionStatus = HostPolicyResponseActionStatus.success
) => {
const policyResponse = docGenerator.generatePolicyResponse();
policyResponse.endpoint.policy.applied.status = overallStatus;
policyResponse.endpoint.policy.applied.response.configurations.malware.status = overallStatus;
let downloadModelAction = policyResponse.endpoint.policy.applied.actions.find(
policyResponse.Endpoint.policy.applied.status = overallStatus;
policyResponse.Endpoint.policy.applied.response.configurations.malware.status = overallStatus;
let downloadModelAction = policyResponse.Endpoint.policy.applied.actions.find(
(action) => action.name === 'download_model'
);

Expand All @@ -172,7 +172,7 @@ describe('when on the hosts page', () => {
message: 'Failed to apply a portion of the configuration (kernel)',
status: overallStatus,
};
policyResponse.endpoint.policy.applied.actions.push(downloadModelAction);
policyResponse.Endpoint.policy.applied.actions.push(downloadModelAction);
}
if (
overallStatus === HostPolicyResponseActionStatus.failure ||
Expand Down Expand Up @@ -236,7 +236,7 @@ describe('when on the hosts page', () => {
const policyDetailsLink = await renderResult.findByTestId('policyDetailsValue');
expect(policyDetailsLink).not.toBeNull();
expect(policyDetailsLink.getAttribute('href')).toEqual(
`#/management/policy/${hostDetails.metadata.endpoint.policy.applied.id}`
`#/management/policy/${hostDetails.metadata.Endpoint.policy.applied.id}`
);
});

Expand All @@ -252,7 +252,7 @@ describe('when on the hosts page', () => {
});
const changedUrlAction = await userChangedUrlChecker;
expect(changedUrlAction.payload.pathname).toEqual(
`/management/policy/${hostDetails.metadata.endpoint.policy.applied.id}`
`/management/policy/${hostDetails.metadata.Endpoint.policy.applied.id}`
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const HostList = () => {
}),
truncateText: true,
// eslint-disable-next-line react/display-name
render: (policy: HostInfo['metadata']['endpoint']['policy']['applied']) => {
render: (policy: HostInfo['metadata']['Endpoint']['policy']['applied']) => {
const toRoutePath = getManagementUrl({
name: 'policyDetails',
policyId: policy.id,
Expand All @@ -186,7 +186,7 @@ export const HostList = () => {
defaultMessage: 'Policy Status',
}),
// eslint-disable-next-line react/display-name
render: (policy: HostInfo['metadata']['endpoint']['policy']['applied'], item: HostInfo) => {
render: (policy: HostInfo['metadata']['Endpoint']['policy']['applied'], item: HostInfo) => {
const toRoutePath = getManagementUrl({
name: 'endpointPolicyResponse',
selected_host: item.metadata.host.id,
Expand Down

0 comments on commit 244443e

Please sign in to comment.