Skip to content

Commit

Permalink
Merge pull request ceph#45020 from rhcs-dashboard/snmp-priv-protocol-fix
Browse files Browse the repository at this point in the history
mgr/dashboard: change privacy protocol field from required to optional
  • Loading branch information
avanthakkar authored Feb 16, 2022
2 parents 2e2513d + 2866db1 commit fd5f5f3
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ export class ServicesPageHelper extends PageHelper {
});
}

addService(serviceType: string, exist?: boolean, count = '1', snmpVersion?: string) {
addService(
serviceType: string,
exist?: boolean,
count = '1',
snmpVersion?: string,
snmpPrivProtocol?: boolean
) {
cy.get(`${this.pages.create.id}`).within(() => {
this.selectServiceType(serviceType);
switch (serviceType) {
Expand Down Expand Up @@ -67,12 +73,14 @@ export class ServicesPageHelper extends PageHelper {
} else {
cy.get('#engine_id').type('800C53F00000');
this.selectOption('auth_protocol', 'SHA');
this.selectOption('privacy_protocol', 'DES');
if (snmpPrivProtocol) {
this.selectOption('privacy_protocol', 'DES');
cy.get('#snmp_v3_priv_password').type('testencrypt');
}

// Credentials
cy.get('#snmp_v3_auth_username').type('test');
cy.get('#snmp_v3_auth_password').type('testpass');
cy.get('#snmp_v3_priv_password').type('testencrypt');
}
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,20 @@ describe('Services page', () => {

it('should create and delete snmp-gateway service with version V3', () => {
services.navigateTo('create');
services.addService('snmp-gateway', false, '1', 'V3');
services.addService('snmp-gateway', false, '1', 'V3', true);
services.checkExist('snmp-gateway', true);

services.clickServiceTab('snmp-gateway', 'Details');
cy.get('cd-service-details').within(() => {
services.checkServiceStatus('snmp-gateway');
});

services.deleteService('snmp-gateway');
});

it('should create and delete snmp-gateway service with version V3 and w/o privacy protocol', () => {
services.navigateTo('create');
services.addService('snmp-gateway', false, '1', 'V3', false);
services.checkExist('snmp-gateway', true);

services.clickServiceTab('snmp-gateway', 'Details');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
</div>

<!-- Service id -->
<div class="form-group row">
<div class="form-group row"
*ngIf="serviceForm.controls.service_type.value !== 'snmp-gateway'">
<label i18n
class="cd-col-form-label"
[ngClass]="{'required': ['mds', 'rgw', 'nfs', 'iscsi', 'ingress'].includes(serviceForm.controls.service_type.value)}"
Expand All @@ -83,7 +84,8 @@
</div>

<!-- unmanaged -->
<div class="form-group row">
<div class="form-group row"
*ngIf="serviceForm.controls.service_type.value !== 'snmp-gateway'">
<div class="cd-col-form-offset">
<div class="custom-control custom-checkbox">
<input class="custom-control-input"
Expand Down Expand Up @@ -486,6 +488,9 @@
<span class="invalid-feedback"
*ngIf="serviceForm.showError('engine_id', frm, 'required')"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="serviceForm.showError('engine_id', frm, 'snmpEngineIdPattern')"
i18n>The value does not match the pattern: <strong>Must be in hexadecimal and length must be multiple of 2 with min value = 10 amd max value = 64.</strong></span>
</div>
</div>
<!-- Auth protocol for snmp V3 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ x4Ea7kGVgx9kWh5XjWz9wjZvY49UKIT5ppIAWPMbLl3UpfckiuNhTA==
}
});
});

it('should test snmp-gateway service with V3', () => {
formHelper.setValue('snmp_version', 'V3');
formHelper.setValue('engine_id', '800C53F00000');
Expand All @@ -484,12 +485,25 @@ x4Ea7kGVgx9kWh5XjWz9wjZvY49UKIT5ppIAWPMbLl3UpfckiuNhTA==
}
});
});

it('should submit invalid snmp destination', () => {
formHelper.setValue('snmp_version', 'V2c');
formHelper.setValue('snmp_destination', '192.168.20.1');
formHelper.setValue('snmp_community', 'public');
formHelper.expectError('snmp_destination', 'snmpDestinationPattern');
});

it('should submit invalid snmp engine id', () => {
formHelper.setValue('snmp_version', 'V3');
formHelper.setValue('snmp_destination', '192.168.20.1');
formHelper.setValue('engine_id', 'AABBCCDDE');
formHelper.setValue('auth_protocol', 'SHA');
formHelper.setValue('privacy_protocol', 'DES');
formHelper.setValue('snmp_v3_auth_username', 'testuser');
formHelper.setValue('snmp_v3_auth_password', 'testpass');

formHelper.expectError('engine_id', 'snmpEngineIdPattern');
});
});

describe('check edit fields', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
export class ServiceFormComponent extends CdForm implements OnInit {
readonly RGW_SVC_ID_PATTERN = /^([^.]+)(\.([^.]+)\.([^.]+))?$/;
readonly SNMP_DESTINATION_PATTERN = /^[^\:]+:[0-9]/;
readonly SNMP_ENGINE_ID_PATTERN = /^[0-9A-Fa-f]{10,64}/g;
@ViewChild(NgbTypeahead, { static: false })
typeahead: NgbTypeahead;

Expand Down Expand Up @@ -219,8 +220,7 @@ export class ServiceFormComponent extends CdForm implements OnInit {
null,
[
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
service_type: 'snmp-gateway'
})
]
],
Expand All @@ -229,8 +229,7 @@ export class ServiceFormComponent extends CdForm implements OnInit {
{
validators: [
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
service_type: 'snmp-gateway'
}),
CdValidators.custom('snmpDestinationPattern', (value: string) => {
if (_.isEmpty(value)) {
Expand All @@ -245,62 +244,54 @@ export class ServiceFormComponent extends CdForm implements OnInit {
null,
[
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
service_type: 'snmp-gateway'
}),
CdValidators.custom('snmpEngineIdPattern', (value: string) => {
if (_.isEmpty(value)) {
return false;
}
return !this.SNMP_ENGINE_ID_PATTERN.test(value);
})
]
],
auth_protocol: [
'SHA',
[
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
})
]
],
privacy_protocol: [
null,
[
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
service_type: 'snmp-gateway'
})
]
],
privacy_protocol: [null],
snmp_community: [
null,
[
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
snmp_version: 'V2c'
})
]
],
snmp_v3_auth_username: [
null,
[
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
service_type: 'snmp-gateway'
})
]
],
snmp_v3_auth_password: [
null,
[
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
service_type: 'snmp-gateway'
})
]
],
snmp_v3_priv_password: [
null,
[
CdValidators.requiredIf({
service_type: 'snmp-gateway',
unmanaged: false
privacy_protocol: { op: '!empty' }
})
]
]
Expand Down

0 comments on commit fd5f5f3

Please sign in to comment.