Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ui/src/__tests__/components/constants/constants.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ describe('StaticWorkloadType', () => {
expect(externalApplicationCIDR).toMatch(
new RegExp(type.pattern)
);
const pattern = new RegExp(type.pattern);
// test ipv4
// false
expect('123').not.toMatch(pattern);
expect('123.').not.toMatch(pattern);
expect('123.123').not.toMatch(pattern);
expect('123.123.123').not.toMatch(pattern);
expect('123.123.123.').not.toMatch(pattern);
expect('123.123.123.123/').not.toMatch(pattern);
expect('123.123.123.123/33').not.toMatch(pattern);
expect('01.123.123.123').not.toMatch(pattern);
expect('256.123.123.123').not.toMatch(pattern);
// true
expect('255.255.255.255').toMatch(pattern);
expect('123.123.123.123/32').toMatch(pattern);
expect('0.0.0.0').toMatch(pattern);

// test cidr
// false
expect('com').not.toMatch(pattern);
expect('*ciea.ouryahoo.com').not.toMatch(pattern);
expect('ciea.*ouryahoo.com').not.toMatch(pattern);
expect('ciea.*.com').not.toMatch(pattern);
expect('ciea.ouryahoo.*com').not.toMatch(pattern);
expect('ciea.ouryahoo.*').not.toMatch(pattern);
// true
expect('*.ouryahoo.com').toMatch(pattern); // should match only wildcard as subdomain
expect('ouryahoo.com').toMatch(pattern);
expect('aaa.ouryahoo.com').toMatch(pattern);
break;
case 'CLOUD_MANAGED':
let externalCloudManagedName =
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const StaticWorkloadType = [
name: 'External Appliance',
value: 'EXTERNAL_APPLIANCE',
pattern:
'^(?=.*[^.]$)((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).?){4}(\\/([0-9]|[12][0-9]|3[012]))?$',
'^(((?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:/(?:[12]\\d|3[0-2]|[0-9]))?)|((?:\\*\\.(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z]{2,})))$',
},
{
name: 'Cloud Managed',
Expand Down
Loading