[Uptime] [Synthetics Integration] ensure that proxy url is not overwritten (#99944)
This commit is contained in:
parent
f492feee6e
commit
0bc97c4a58
|
@ -9,7 +9,7 @@ import React, { memo, useContext, useEffect } from 'react';
|
|||
import useDebounce from 'react-use/lib/useDebounce';
|
||||
import { PackagePolicyCreateExtensionComponentProps } from '../../../../fleet/public';
|
||||
import { useTrackPageview } from '../../../../observability/public';
|
||||
import { Config, ConfigKeys } from './types';
|
||||
import { Config, ConfigKeys, DataStream } from './types';
|
||||
import {
|
||||
SimpleFieldsContext,
|
||||
HTTPAdvancedFieldsContext,
|
||||
|
@ -63,6 +63,11 @@ export const SyntheticsPolicyCreateExtension = memo<PackagePolicyCreateExtension
|
|||
...httpAdvancedFields,
|
||||
...tcpAdvancedFields,
|
||||
...tlsFields,
|
||||
// ensure proxyUrl is not overwritten
|
||||
[ConfigKeys.PROXY_URL]:
|
||||
simpleFields[ConfigKeys.MONITOR_TYPE] === DataStream.HTTP
|
||||
? httpAdvancedFields[ConfigKeys.PROXY_URL]
|
||||
: tcpAdvancedFields[ConfigKeys.PROXY_URL],
|
||||
}));
|
||||
},
|
||||
250,
|
||||
|
|
|
@ -70,8 +70,8 @@ const defaultNewPolicy: NewPackagePolicy = {
|
|||
type: 'text',
|
||||
},
|
||||
timeout: {
|
||||
value: 1600,
|
||||
type: 'integer',
|
||||
value: '16s',
|
||||
type: 'text',
|
||||
},
|
||||
max_redirects: {
|
||||
value: 0,
|
||||
|
@ -173,7 +173,7 @@ const defaultNewPolicy: NewPackagePolicy = {
|
|||
type: 'text',
|
||||
},
|
||||
timeout: {
|
||||
type: 'integer',
|
||||
type: 'text',
|
||||
},
|
||||
max_redirects: {
|
||||
type: 'integer',
|
||||
|
@ -246,7 +246,7 @@ const defaultNewPolicy: NewPackagePolicy = {
|
|||
type: 'text',
|
||||
},
|
||||
timeout: {
|
||||
type: 'integer',
|
||||
type: 'text',
|
||||
},
|
||||
max_redirects: {
|
||||
type: 'integer',
|
||||
|
@ -311,7 +311,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('handles updating each field', async () => {
|
||||
it('handles updating fields', async () => {
|
||||
const { getByLabelText } = render(<WrappedComponent />);
|
||||
const url = getByLabelText('URL') as HTMLInputElement;
|
||||
const proxyUrl = getByLabelText('Proxy URL') as HTMLInputElement;
|
||||
|
@ -336,6 +336,54 @@ describe('<SyntheticsPolicyCreateExtension />', () => {
|
|||
expect(apmServiceName.value).toEqual('APM Service');
|
||||
expect(maxRedirects.value).toEqual('2');
|
||||
expect(timeout.value).toEqual('3');
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onChange).toBeCalledWith({
|
||||
isValid: true,
|
||||
updatedPolicy: {
|
||||
...defaultNewPolicy,
|
||||
inputs: [
|
||||
{
|
||||
...defaultNewPolicy.inputs[0],
|
||||
streams: [
|
||||
{
|
||||
...defaultNewPolicy.inputs[0].streams[0],
|
||||
vars: {
|
||||
...defaultNewPolicy.inputs[0].streams[0].vars,
|
||||
urls: {
|
||||
value: 'http://elastic.co',
|
||||
type: 'text',
|
||||
},
|
||||
proxy_url: {
|
||||
value: 'http://proxy.co',
|
||||
type: 'text',
|
||||
},
|
||||
schedule: {
|
||||
value: '"@every 1m"',
|
||||
type: 'text',
|
||||
},
|
||||
'service.name': {
|
||||
value: 'APM Service',
|
||||
type: 'text',
|
||||
},
|
||||
max_redirects: {
|
||||
value: '2',
|
||||
type: 'integer',
|
||||
},
|
||||
timeout: {
|
||||
value: '3s',
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultNewPolicy.inputs[1],
|
||||
defaultNewPolicy.inputs[2],
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('handles calling onChange', async () => {
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
TCPAdvancedFieldsContext,
|
||||
TLSFieldsContext,
|
||||
} from './contexts';
|
||||
import { Config, ConfigKeys } from './types';
|
||||
import { Config, ConfigKeys, DataStream } from './types';
|
||||
import { CustomFields } from './custom_fields';
|
||||
import { useUpdatePolicy } from './use_update_policy';
|
||||
import { validate } from './validation';
|
||||
|
@ -48,6 +48,11 @@ export const SyntheticsPolicyEditExtension = memo<SyntheticsPolicyEditExtensionP
|
|||
...httpAdvancedFields,
|
||||
...tcpAdvancedFields,
|
||||
...tlsFields,
|
||||
// ensure proxyUrl is not overwritten
|
||||
[ConfigKeys.PROXY_URL]:
|
||||
simpleFields[ConfigKeys.MONITOR_TYPE] === DataStream.HTTP
|
||||
? httpAdvancedFields[ConfigKeys.PROXY_URL]
|
||||
: tcpAdvancedFields[ConfigKeys.PROXY_URL],
|
||||
}));
|
||||
},
|
||||
250,
|
||||
|
|
|
@ -173,7 +173,7 @@ const defaultNewPolicy: NewPackagePolicy = {
|
|||
type: 'text',
|
||||
},
|
||||
timeout: {
|
||||
type: 'integer',
|
||||
type: 'text',
|
||||
},
|
||||
max_redirects: {
|
||||
type: 'integer',
|
||||
|
@ -247,7 +247,7 @@ const defaultNewPolicy: NewPackagePolicy = {
|
|||
type: 'text',
|
||||
},
|
||||
timeout: {
|
||||
type: 'integer',
|
||||
type: 'text',
|
||||
},
|
||||
max_redirects: {
|
||||
type: 'integer',
|
||||
|
@ -339,7 +339,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {
|
|||
expect(queryByLabelText('Monitor type')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('handles updating each field', async () => {
|
||||
it('handles updating fields', async () => {
|
||||
const { getByLabelText } = render(<WrappedComponent />);
|
||||
const url = getByLabelText('URL') as HTMLInputElement;
|
||||
const proxyUrl = getByLabelText('Proxy URL') as HTMLInputElement;
|
||||
|
@ -364,6 +364,54 @@ describe('<SyntheticsPolicyEditExtension />', () => {
|
|||
expect(apmServiceName.value).toEqual('APM Service');
|
||||
expect(maxRedirects.value).toEqual('2');
|
||||
expect(timeout.value).toEqual('3');
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onChange).toBeCalledWith({
|
||||
isValid: true,
|
||||
updatedPolicy: {
|
||||
...defaultNewPolicy,
|
||||
inputs: [
|
||||
{
|
||||
...defaultNewPolicy.inputs[0],
|
||||
streams: [
|
||||
{
|
||||
...defaultNewPolicy.inputs[0].streams[0],
|
||||
vars: {
|
||||
...defaultNewPolicy.inputs[0].streams[0].vars,
|
||||
urls: {
|
||||
value: 'http://elastic.co',
|
||||
type: 'text',
|
||||
},
|
||||
proxy_url: {
|
||||
value: 'http://proxy.co',
|
||||
type: 'text',
|
||||
},
|
||||
schedule: {
|
||||
value: '"@every 1m"',
|
||||
type: 'text',
|
||||
},
|
||||
'service.name': {
|
||||
value: 'APM Service',
|
||||
type: 'text',
|
||||
},
|
||||
max_redirects: {
|
||||
value: '2',
|
||||
type: 'integer',
|
||||
},
|
||||
timeout: {
|
||||
value: '3s',
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultNewPolicy.inputs[1],
|
||||
defaultNewPolicy.inputs[2],
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('handles calling onChange', async () => {
|
||||
|
|
Loading…
Reference in a new issue