synthetics - fall back to checking verification mode to determine if tls is enabled (#117181) (#118943)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Dominique Clarke <doclarke71@gmail.com>
This commit is contained in:
Kibana Machine 2021-11-17 17:41:49 -05:00 committed by GitHub
parent 309df6c3df
commit 7b9e727cdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 12 deletions

View file

@ -573,16 +573,43 @@ describe('<SyntheticsPolicyEditExtension />', () => {
});
});
it('shows tls fields when metadata.is_tls_enabled is true', async () => {
const { getByLabelText } = render(<WrappedComponent />);
const verificationMode = getByLabelText('Verification mode') as HTMLInputElement;
const enableTLSConfig = getByLabelText('Enable TLS configuration') as HTMLInputElement;
expect(enableTLSConfig.getAttribute('aria-checked')).toEqual('true');
expect(verificationMode).toBeInTheDocument();
expect(verificationMode.value).toEqual(
`${defaultHTTPConfig[ConfigKeys.TLS_VERIFICATION_MODE]}`
);
});
it.each([[true], [false]])(
'shows tls fields when metadata.is_tls_enabled is or verification mode is truthy true',
async (isTLSEnabledInUIMetadataKey) => {
const currentPolicy = {
...defaultCurrentPolicy,
inputs: [
{
...defaultNewPolicy.inputs[0],
enabled: true,
streams: [
{
...defaultNewPolicy.inputs[0].streams[0],
vars: {
...defaultNewPolicy.inputs[0].streams[0].vars,
__ui: {
type: 'yaml',
value: JSON.stringify({
is_tls_enabled: isTLSEnabledInUIMetadataKey,
}),
},
},
},
],
},
],
};
const { getByLabelText } = render(<WrappedComponent policy={currentPolicy} />);
const verificationMode = getByLabelText('Verification mode') as HTMLInputElement;
const enableTLSConfig = getByLabelText('Enable TLS configuration') as HTMLInputElement;
expect(enableTLSConfig.getAttribute('aria-checked')).toEqual('true');
expect(verificationMode).toBeInTheDocument();
expect(verificationMode.value).toEqual(
`${defaultHTTPConfig[ConfigKeys.TLS_VERIFICATION_MODE]}`
);
}
);
it('handles browser validation', async () => {
const currentPolicy = {
@ -1128,6 +1155,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {
expect(getByText(text)).toBeInTheDocument();
}
);
it('hides tls fields when metadata.is_tls_enabled is false', async () => {
const { getByLabelText, queryByLabelText } = render(
<WrappedComponent

View file

@ -71,9 +71,11 @@ export const SyntheticsPolicyEditExtensionWrapper = memo<PackagePolicyEditExtens
};
enableTLS =
formattedDefaultConfigForMonitorType[ConfigKeys.METADATA].is_tls_enabled || false;
formattedDefaultConfigForMonitorType[ConfigKeys.METADATA].is_tls_enabled ||
Boolean(vars?.[ConfigKeys.TLS_VERIFICATION_MODE]?.value);
enableZipUrlTLS =
formattedDefaultConfigForMonitorType[ConfigKeys.METADATA].is_zip_url_tls_enabled || false;
formattedDefaultConfigForMonitorType[ConfigKeys.METADATA].is_zip_url_tls_enabled ||
Boolean(vars?.[ConfigKeys.ZIP_URL_TLS_VERIFICATION_MODE]?.value);
const formattedDefaultConfig: Partial<PolicyConfig> = {
[type]: formattedDefaultConfigForMonitorType,