Skip to content

Commit

Permalink
Merge pull request ceph#56390 from rhcs-dashboard/rgw-add-system-user
Browse files Browse the repository at this point in the history
mgr/dashboard: add system users to rgw user form

Reviewed-by: Ankush Behl <cloudbehl@gmail.com>
Reviewed-by: Nizamudeen A <nia@redhat.com>
  • Loading branch information
nizamial09 committed Mar 26, 2024
2 parents bf78b9d + b658bb9 commit 4a987d7
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 13 deletions.
8 changes: 6 additions & 2 deletions src/pybind/mgr/dashboard/controllers/rgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def get_emails(self, daemon_name=None):

@allow_empty_body
def create(self, uid, display_name, email=None, max_buckets=None,
suspended=None, generate_key=None, access_key=None,
system=None, suspended=None, generate_key=None, access_key=None,
secret_key=None, daemon_name=None):
params = {'uid': uid}
if display_name is not None:
Expand All @@ -590,6 +590,8 @@ def create(self, uid, display_name, email=None, max_buckets=None,
params['email'] = email
if max_buckets is not None:
params['max-buckets'] = max_buckets
if system is not None:
params['system'] = system
if suspended is not None:
params['suspended'] = suspended
if generate_key is not None:
Expand All @@ -604,14 +606,16 @@ def create(self, uid, display_name, email=None, max_buckets=None,

@allow_empty_body
def set(self, uid, display_name=None, email=None, max_buckets=None,
suspended=None, daemon_name=None):
system=None, suspended=None, daemon_name=None):
params = {'uid': uid}
if display_name is not None:
params['display-name'] = display_name
if email is not None:
params['email'] = email
if max_buckets is not None:
params['max-buckets'] = max_buckets
if system is not None:
params['system'] = system
if suspended is not None:
params['suspended'] = suspended
result = self.proxy(daemon_name, 'POST', 'user', params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
</tr>
<tr>
<td i18n
class="bold">System</td>
<td>{{ user.system === 'true' | booleanText }}</td>
class="bold">System user</td>
<td>{{ user.system | booleanText }}</td>
</tr>
<tr>
<td i18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ describe('RgwUserDetailsComponent', () => {
});

it('should show correct "System" info', () => {
component.selection = { uid: '', email: '', system: 'true', keys: [], swift_keys: [] };
component.selection = { uid: '', email: '', system: true, keys: [], swift_keys: [] };

component.ngOnChanges();
fixture.detectChanges();

const detailsTab = fixture.debugElement.nativeElement.querySelectorAll(
'.table.table-striped.table-bordered tr td'
);
expect(detailsTab[10].textContent).toEqual('System');
expect(detailsTab[10].textContent).toEqual('System user');
expect(detailsTab[11].textContent).toEqual('Yes');

component.selection.system = 'false';
component.selection.system = false;
component.ngOnChanges();
fixture.detectChanges();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@
</div>
</div>

<!-- System User -->
<div class="form-group row">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
id="system"
type="checkbox"
formControlName="system">
<label class="custom-control-label"
for="system"
i18n>System user</label>
<cd-helper i18n>System users are distinct from regular users, they are used by the RGW service to perform administrative tasks, manage buckets and objects</cd-helper>
</div>
</div>
</div>

<!-- S3 key -->
<fieldset *ngIf="!editing">
<legend i18n>S3 key</legend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ describe('RgwUserFormComponent', () => {
max_buckets: -1,
secret_key: '',
suspended: false,
system: false,
uid: null
});
});
Expand All @@ -200,7 +201,8 @@ describe('RgwUserFormComponent', () => {
display_name: null,
email: null,
max_buckets: -1,
suspended: false
suspended: false,
system: false
});
});

Expand All @@ -216,6 +218,7 @@ describe('RgwUserFormComponent', () => {
max_buckets: 0,
secret_key: '',
suspended: false,
system: false,
uid: null
});
});
Expand All @@ -229,7 +232,8 @@ describe('RgwUserFormComponent', () => {
display_name: null,
email: null,
max_buckets: 0,
suspended: false
suspended: false,
system: false
});
});

Expand All @@ -246,6 +250,7 @@ describe('RgwUserFormComponent', () => {
max_buckets: 100,
secret_key: '',
suspended: false,
system: false,
uid: null
});
});
Expand All @@ -260,7 +265,8 @@ describe('RgwUserFormComponent', () => {
display_name: null,
email: null,
max_buckets: 100,
suspended: false
suspended: false,
system: false
});
});
});
Expand All @@ -283,7 +289,8 @@ describe('RgwUserFormComponent', () => {
display_name: null,
email: '',
max_buckets: 1000,
suspended: false
suspended: false,
system: false
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit {
1000,
[CdValidators.requiredIf({ max_buckets_mode: '1' }), CdValidators.number(false)]
],
system: [false],
suspended: [false],
// S3 key
generate_key: [true],
Expand Down Expand Up @@ -577,7 +578,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit {
* @return {Boolean} Returns TRUE if the general user settings have been modified.
*/
private _isGeneralDirty(): boolean {
return ['display_name', 'email', 'max_buckets_mode', 'max_buckets', 'suspended'].some(
return ['display_name', 'email', 'max_buckets_mode', 'max_buckets', 'system', 'suspended'].some(
(path) => {
return this.userForm.get(path).dirty;
}
Expand Down Expand Up @@ -624,6 +625,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit {
const result = {
uid: this.getUID(),
display_name: this.userForm.getValue('display_name'),
system: this.userForm.getValue('system'),
suspended: this.userForm.getValue('suspended'),
email: '',
max_buckets: this.userForm.getValue('max_buckets'),
Expand Down Expand Up @@ -658,7 +660,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit {
*/
private _getUpdateArgs() {
const result: Record<string, any> = {};
const keys = ['display_name', 'email', 'max_buckets', 'suspended'];
const keys = ['display_name', 'email', 'max_buckets', 'system', 'suspended'];
for (const key of keys) {
result[key] = this.userForm.getValue(key);
}
Expand Down
4 changes: 4 additions & 0 deletions src/pybind/mgr/dashboard/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11511,6 +11511,8 @@ paths:
type: string
suspended:
type: string
system:
type: string
uid:
type: string
required:
Expand Down Expand Up @@ -11663,6 +11665,8 @@ paths:
type: string
suspended:
type: string
system:
type: string
type: object
responses:
'200':
Expand Down

0 comments on commit 4a987d7

Please sign in to comment.