Skip to content

Commit 083d2a1

Browse files
author
Naman Munet
committed
mgr/dashboard: accept dot(.) in user_id & (alphanumeric chars, _) in tenant in user form
fixes: https://tracker.ceph.com/issues/71341 Signed-off-by: Naman Munet <[email protected]>
1 parent b71625d commit 083d2a1

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ describe('RgwUserFormComponent', () => {
176176
formHelper.expectValid('user_id');
177177
}));
178178

179+
it('should validate that username can contain dot(.)', fakeAsync(() => {
180+
spyOn(rgwUserService, 'get').and.returnValue(throwError('foo'));
181+
formHelper.setValue('user_id', 'user.name', true);
182+
tick(DUE_TIMER);
183+
formHelper.expectValid('user_id');
184+
}));
185+
179186
it('should validate that username is invalid', fakeAsync(() => {
180187
spyOn(rgwUserService, 'get').and.returnValue(observableOf({}));
181188
formHelper.setValue('user_id', 'abc', true);
@@ -184,6 +191,24 @@ describe('RgwUserFormComponent', () => {
184191
}));
185192
});
186193

194+
describe('tenant validation', () => {
195+
it('should validate that tenant is valid', fakeAsync(() => {
196+
spyOn(rgwUserService, 'get').and.returnValue(throwError('foo'));
197+
formHelper.setValue('show_tenant', true, true);
198+
formHelper.setValue('tenant', 'new_tenant123', true);
199+
tick(DUE_TIMER);
200+
formHelper.expectValid('tenant');
201+
}));
202+
203+
it('should validate that tenant is invalid', fakeAsync(() => {
204+
spyOn(rgwUserService, 'get').and.returnValue(observableOf({}));
205+
formHelper.setValue('show_tenant', true, true);
206+
formHelper.setValue('tenant', 'new-tenant.dummy', true);
207+
tick(DUE_TIMER);
208+
formHelper.expectError('tenant', 'pattern');
209+
}));
210+
});
211+
187212
describe('max buckets', () => {
188213
beforeEach(() => {
189214
component.loading = LoadingStatus.Ready;

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit {
8282
// General
8383
user_id: [
8484
null,
85-
[Validators.required, Validators.pattern(/^[a-zA-Z0-9!@#%^&*()_-]+$/)],
85+
[Validators.required, Validators.pattern(/^[a-zA-Z0-9!@#%^&*()._-]+$/)],
8686
this.editing
8787
? []
8888
: [
@@ -94,7 +94,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit {
9494
show_tenant: [this.editing],
9595
tenant: [
9696
null,
97-
[Validators.pattern(/^[a-zA-Z0-9!@#%^&*()_-]+$/)],
97+
[Validators.pattern(/^[a-zA-Z0-9_]+$/)],
9898
this.editing
9999
? []
100100
: [

0 commit comments

Comments
 (0)