Skip to content

Commit

Permalink
[Security Solution] fix flashing authz on endpoint integration (elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
joeypoon authored and kertal committed May 24, 2022
1 parent 42e5982 commit 279c652
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,16 @@ describe('When displaying the EndpointPackageCustomExtension fleet UI extension'
expect(renderResult.queryByTestId('hostIsolationExceptions-fleetCard')).toBeNull();
});
});

it('should only show loading spinner if loading', () => {
useEndpointPrivilegesMock.mockReturnValue({
...getEndpointPrivilegesInitialStateMock(),
loading: true,
});
render();

expect(renderResult.getByTestId('endpointExtensionLoadingSpinner')).toBeInTheDocument();
expect(renderResult.queryByTestId('fleetEndpointPackageCustomContent')).toBeNull();
expect(renderResult.queryByTestId('noIngestPermissions')).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { memo, useMemo } from 'react';
import { EuiSpacer } from '@elastic/eui';
import { EuiSpacer, EuiLoadingSpinner } from '@elastic/eui';
import { PackageCustomExtensionComponentProps } from '@kbn/fleet-plugin/public';
import { useHttp } from '../../../../../../common/lib/kibana';
import { useCanSeeHostIsolationExceptionsMenu } from '../../../../host_isolation_exceptions/view/hooks';
Expand Down Expand Up @@ -34,7 +34,7 @@ export const EndpointPackageCustomExtension = memo<PackageCustomExtensionCompone
(props) => {
const http = useHttp();
const canSeeHostIsolationExceptions = useCanSeeHostIsolationExceptionsMenu();
const { canAccessEndpointManagement } = useEndpointPrivileges();
const { loading, canAccessEndpointManagement } = useEndpointPrivileges();

const trustedAppsApiClientInstance = useMemo(
() => TrustedAppsApiClient.getInstance(http),
Expand Down Expand Up @@ -106,7 +106,13 @@ export const EndpointPackageCustomExtension = memo<PackageCustomExtensionCompone
]
);

return canAccessEndpointManagement ? artifactCards : <NoPermissions />;
return loading ? (
<EuiLoadingSpinner data-test-subj="endpointExtensionLoadingSpinner" />
) : canAccessEndpointManagement ? (
artifactCards
) : (
<NoPermissions />
);
}
);

Expand Down

0 comments on commit 279c652

Please sign in to comment.