This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow longer FQDN and IPv4/v6 in host field (#128)
* Allow longer FQDN and IPv4/v6 in hot field * Allow short names as hostnames and add HTTP basic auth in URL
- Loading branch information
Showing
2 changed files
with
60 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,12 @@ describe('validateUrl', () => { | |
expect( | ||
validateUrl('https://opendistro.github.io/for-elasticsearch/news.html', typeFullUrl) | ||
).toBeUndefined(); | ||
expect( | ||
validateUrl('https://username:[email protected]/for-elasticsearch/news.html', typeFullUrl) | ||
).toBeUndefined(); | ||
expect( | ||
validateUrl('http://alerts-smtp-forwarder:8080/email', typeFullUrl) | ||
).toBeUndefined(); | ||
expect(validateUrl('http://127.0.0.1:8080/', typeFullUrl)).toBeUndefined(); | ||
expect( | ||
validateUrl('http://192.168.0.1/test.php?foo=bar&action=test', typeFullUrl) | ||
|
@@ -71,3 +77,38 @@ describe('validateUrl', () => { | |
).toBe(invalidText); | ||
}); | ||
}); | ||
|
||
describe('validateHost', () => { | ||
const typeAttributeUrl = { type: 'custom_webhook', custom_webhook: { urlType: URL_TYPE.ATTRIBUTE_URL } }; | ||
|
||
test('returns Required if is empty', () => { | ||
expect(validateHost('', typeAttributeUrl)).toBe('Required'); | ||
}); | ||
|
||
test('returns undefined if valid', () => { | ||
expect( | ||
validateHost('opendistro.github.io', typeAttributeUrl) | ||
).toBeUndefined(); | ||
expect( | ||
validateHost('alerts-smtp-forwarder', typeAttributeUrl) | ||
).toBeUndefined(); | ||
expect(validateHost('127.0.0.1', typeAttributeUrl)).toBeUndefined(); | ||
expect( | ||
validateHost('2001:0db8:85a3:0000:0000:0000:0000:7344', typeAttributeUrl) | ||
).toBeUndefined(); | ||
expect(validateHost('2001:0db8:85a3:0:0:0:0:7344', typeAttributeUrl)).toBeUndefined(); | ||
expect(validateHost('2001:0db8:85a3::7344', typeAttributeUrl)).toBeUndefined(); | ||
expect(validateHost('::ff', typeAttributeUrl)).toBeUndefined(); | ||
expect(validateHost('org.example', typeAttributeUrl)).toBeUndefined(); | ||
}); | ||
|
||
test('returns error string if invalid', () => { | ||
const invalidText = 'Invalid Host'; | ||
expect( | ||
validateHost( | ||
'org.exampleexampleexampleexampleexampleexampleexampleexampleexampleexampleexampleexample', | ||
typeAttributeUrl | ||
) | ||
).toBe(invalidText); | ||
}); | ||
}); |