Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr/dashboard: fix cephfs name validation #56463

Merged
merged 1 commit into from Mar 27, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -47,7 +47,7 @@
i18n>This field is required!</span>
<span *ngIf="form.showError('name', formDir, 'pattern')"
class="invalid-feedback"
i18n>File System name should start with a letter and can only contain letters, numbers, '.', '-' or '_'</span>
i18n>File System name should start with a letter or dot (.) and can only contain letters, numbers, '.', '-' or '_'</span>
</div>
</div>

Expand Down
Expand Up @@ -42,7 +42,15 @@ describe('CephfsVolumeFormComponent', () => {
});

it('should validate proper names', fakeAsync(() => {
const validNames = ['test', 'test1234', 'test_1234', 'test-1234', 'test.1234', 'test12test'];
const validNames = [
'test',
'test1234',
'test_1234',
'test-1234',
'test.1234',
'test12test',
'.test'
];
const invalidNames = ['1234', 'test@', 'test)'];

for (const validName of validNames) {
Expand Down
Expand Up @@ -87,7 +87,10 @@ export class CephfsVolumeFormComponent extends CdForm implements OnInit {
});
this.form = this.formBuilder.group({
name: new FormControl('', {
validators: [Validators.pattern(/^[a-zA-Z][.A-Za-z0-9_-]+$/), Validators.required]
validators: [
Validators.pattern(/^(?:[.][A-Za-z0-9_-]+|[A-Za-z][.A-Za-z0-9_-]*)$/),
Validators.required
]
}),
placement: ['hosts'],
hosts: [[]],
Expand Down