-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13282 from torchiaf/11239-validate-git-repo-url
Fleet: validate GitRepo Url
- Loading branch information
Showing
4 changed files
with
51 additions
and
1 deletion.
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
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 |
---|---|---|
|
@@ -87,6 +87,45 @@ describe('formRules', () => { | |
); | ||
}); | ||
|
||
describe('gitRepository', () => { | ||
const message = JSON.stringify({ message: 'validation.git.repository' }); | ||
const testCases = [ | ||
// Valid HTTP(s) | ||
['https://github.com/rancher/dashboard.git', undefined], | ||
['http://github.com/rancher/dashboard.git', undefined], | ||
['https://github.com/rancher/dashboard', undefined], | ||
['https://github.com/rancher/dashboard/', undefined], | ||
|
||
// Valid SSH | ||
['[email protected]:rancher/dashboard.git', undefined], | ||
['[email protected]:rancher/dashboard', undefined], | ||
['[email protected]:rancher/dashboard/', undefined], | ||
|
||
// Not valid HTTP(s) | ||
['https://github.com/rancher/ dashboard.git', message], | ||
['http://github.com/rancher/ dashboard.git', message], | ||
['https://github.com/rancher/dashboard ', message], | ||
['foo://github.com/rancher/dashboard/', message], | ||
['github.com/rancher/dashboard/', message], | ||
|
||
// Not valid SSH | ||
['[email protected]:rancher/ dashboard.git', message], | ||
['[email protected]:rancher/dashboard ', message], | ||
['[email protected]/dashboard', message], | ||
|
||
[undefined, undefined] | ||
]; | ||
|
||
it.each(testCases)( | ||
'should return undefined or correct message based on the provided Git url: %p', | ||
(url, expected) => { | ||
const formRuleResult = formRules.gitRepository(url); | ||
|
||
expect(formRuleResult).toStrictEqual(expected); | ||
} | ||
); | ||
}); | ||
|
||
describe('alphanumeric', () => { | ||
const message = JSON.stringify({ message: 'validation.alphanumeric', key: 'testDisplayKey' }); | ||
const testCases = [ | ||
|
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