Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 80fa121

Browse files
oodamienghillert
authored andcommitted
App registration: fix URI validation for a docker artifact
Added docker artifact regex validation Added tests for docker artifact Resolves #814
1 parent 9bf9234 commit 80fa121

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

ui/src/app/apps/apps-register/apps-register.validator.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {FormControl, FormGroup} from '@angular/forms';
2-
import {AppsRegisterValidator} from './apps-register.validator';
1+
import { FormControl, FormGroup } from '@angular/forms';
2+
import { AppsRegisterValidator } from './apps-register.validator';
33

44
/**
55
* Test Application Register Validator functions {AppsRegisterValidator}.
@@ -30,14 +30,13 @@ describe('AppsRegisterValidator', () => {
3030

3131
});
3232

33-
// TODO: to complete
3433
describe('uri', () => {
3534
it('invalid', () => {
3635
[
3736
' ',
38-
/*'http://foo. bar',
37+
'http://foo. bar',
3938
'http://foo.b@r',
40-
'http://foo.b%%r',*/
39+
'http://foo.b%%r',
4140
'f'
4241
].forEach((mock) => {
4342
const uri: FormControl = new FormControl(mock);
@@ -57,6 +56,11 @@ describe('AppsRegisterValidator', () => {
5756
'http://foo.bar:bar.foo:bar',
5857
'http://foo.bar:bar.foo-foo:bar',
5958
'http://foo.bar:bar.foo-foo:bar-bar',
59+
'docker:sabby/xfmr:0.0.7.BUILD-SNAPSHOT',
60+
'http://bit.ly/Celsius-BUILD-SNAPSHOT-stream-applications-kafka-10-maven',
61+
'http://bit.ly/Clark-BUILD-SNAPSHOT-task-applications-maven',
62+
'docker:springcloudstream/counter-sink-rabbit:1.3.1.RELEASE',
63+
'docker:spring_cloud_stream/counter-sink_rabbit:1.3.1.RELEASE'
6064
].forEach((mock) => {
6165
const uri: FormControl = new FormControl(mock);
6266
const result = AppsRegisterValidator.uri(uri);

ui/src/app/apps/apps-register/apps-register.validator.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {FormControl, FormGroup} from '@angular/forms';
1+
import { FormControl } from '@angular/forms';
22

33
/**
44
* Validators for Register Form
@@ -18,6 +18,12 @@ export class AppsRegisterValidator {
1818
*/
1919
static uriRegex = /^([a-zA-Z0-9-]+:\/\/)([\\w\\.:-]+)?([a-zA-Z0-9-\/.:-]+)*$/;
2020

21+
22+
/**
23+
* Docker artifact regex
24+
*/
25+
static dockerArtifactRegex = /^(docker:)([a-zA-Z0-9-.-_]*)(\/)([a-zA-Z0-9-.-_]*)(\:)([a-zA-Z0-9-.-_]*)$/;
26+
2127
/**
2228
* Validate the name conditions: no space, 2 characters min, no specials characters
2329
*
@@ -30,7 +36,7 @@ export class AppsRegisterValidator {
3036
}
3137

3238
if (!AppsRegisterValidator.nameRegex.test(formControl.value)) {
33-
return {invalid: true};
39+
return { invalid: true };
3440
}
3541

3642
return null;
@@ -47,8 +53,8 @@ export class AppsRegisterValidator {
4753
return null;
4854
}
4955

50-
if (!AppsRegisterValidator.uriRegex.test(formControl.value)) {
51-
return {invalid: true};
56+
if (!AppsRegisterValidator.uriRegex.test(formControl.value) && !AppsRegisterValidator.dockerArtifactRegex.test(formControl.value)) {
57+
return { invalid: true };
5258
}
5359

5460
return null;

0 commit comments

Comments
 (0)