Skip to content

Commit

Permalink
added some more test cases to validated FQDN field inputs
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Bachhav <[email protected]>
  • Loading branch information
sachin-msys committed Jan 29, 2020
1 parent dac3d1a commit 202f229
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions components/automate-ui/src/app/helpers/auth/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ export class Regex {
NO_MIXED_WILDCARD_ALLOW_SPECIAL: '^(\\*|[^:*]+)$',

// Allows valid FQDN only
VALID_FQDN: '^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-zA-Z0-9_]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,5}(:[0-9]{1,5})?(\/.*)?$',

VALID_FQDN: /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-zA-Z0-9_]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,5}(:[0-9]{1,5})?(\/.*)?$/,
// Allows valid IP Address only (ipv4)
VALID_IP_ADDRESS: '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ describe('ChefServersListComponent', () => {
errors = fqdn.errors || {};
expect(errors['pattern']).toBeTruthy();

fqdn.setValue('http://...foo.bar com/');
errors = fqdn.errors || {};
expect(errors['pattern']).toBeTruthy();

// Set fqdn to valid inputs
fqdn.setValue('http://fo_o.bar/');
errors = fqdn.errors || {};
Expand All @@ -196,6 +200,14 @@ describe('ChefServersListComponent', () => {
errors = fqdn.errors || {};
expect(errors['pattern']).toBeFalsy();

fqdn.setValue('http://demo.com/');
errors = fqdn.errors || {};
expect(errors['pattern']).toBeFalsy();

fqdn.setValue('https://example_test.co.in/2OWGwiL');
errors = fqdn.errors || {};
expect(errors['pattern']).toBeFalsy();

});
});
});
Expand Down

0 comments on commit 202f229

Please sign in to comment.