forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] Accept socks5 proxy url (elastic#174338)
- Loading branch information
Showing
5 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../fleet/sections/settings/components/edit_fleet_proxy_flyout/use_fleet_proxy_form.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { createFleetTestRendererMock } from '../../../../../../mock'; | ||
|
||
import { useFleetProxyForm } from './use_fleet_proxy_form'; | ||
|
||
describe('useFleetProxyForm', () => { | ||
describe('validate url', () => { | ||
it('should accept http url', async () => { | ||
const testRenderer = createFleetTestRendererMock(); | ||
const { result } = testRenderer.renderHook(() => useFleetProxyForm(undefined, () => {})); | ||
result.current.inputs.urlInput.setValue('http://test.fr:8080'); | ||
expect(result.current.inputs.urlInput.validate()).toBeTruthy(); | ||
expect(result.current.inputs.urlInput.errors).toBeUndefined(); | ||
}); | ||
|
||
it('should accept https url', async () => { | ||
const testRenderer = createFleetTestRendererMock(); | ||
const { result } = testRenderer.renderHook(() => useFleetProxyForm(undefined, () => {})); | ||
result.current.inputs.urlInput.setValue('https://test.fr:8080'); | ||
expect(result.current.inputs.urlInput.validate()).toBeTruthy(); | ||
expect(result.current.inputs.urlInput.errors).toBeUndefined(); | ||
}); | ||
it('should accept socks5 url', async () => { | ||
const testRenderer = createFleetTestRendererMock(); | ||
const { result } = testRenderer.renderHook(() => useFleetProxyForm(undefined, () => {})); | ||
result.current.inputs.urlInput.setValue('socks5://test.fr:8080'); | ||
expect(result.current.inputs.urlInput.validate()).toBeTruthy(); | ||
expect(result.current.inputs.urlInput.errors).toBeUndefined(); | ||
}); | ||
|
||
it('should not accept invalid url', async () => { | ||
const testRenderer = createFleetTestRendererMock(); | ||
const { result } = testRenderer.renderHook(() => useFleetProxyForm(undefined, () => {})); | ||
result.current.inputs.urlInput.setValue('iamnotavaliderror'); | ||
expect(result.current.inputs.urlInput.validate()).toBeFalsy(); | ||
|
||
expect(result.current.inputs.urlInput.errors).toEqual(['Invalid URL']); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters