1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { ReactiveFormsModule } from '@angular/forms';
4 import { By } from '@angular/platform-browser';
5 import { RouterTestingModule } from '@angular/router/testing';
6 import { NgbActiveModal, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
7 import _ from 'lodash';
8 import { ToastrModule } from 'ngx-toastr';
9 import { of } from 'rxjs';
11 import { CephServiceService } from '~/app/shared/api/ceph-service.service';
12 import { PaginateObservable } from '~/app/shared/api/paginate.model';
13 import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
14 import { SharedModule } from '~/app/shared/shared.module';
15 import { configureTestBed, FormHelper, Mocks } from '~/testing/unit-test-helper';
16 import { ServiceFormComponent } from './service-form.component';
17 import { PoolService } from '~/app/shared/api/pool.service';
18 import { ButtonModule, CheckboxModule, ComboBoxModule, DropdownModule, FileUploaderModule, InputModule, ModalModule, NumberModule, ProgressIndicatorModule, SelectModule } from 'carbon-components-angular';
19 import { Router } from '@angular/router';
20 import { NO_ERRORS_SCHEMA } from '@angular/core';
22 // for 'nvmeof' service
24 Mocks.getPool('pool-1', 1, ['cephfs']),
25 Mocks.getPool('rbd', 2),
26 Mocks.getPool('pool-2', 3)
28 class MockPoolService {
34 describe('ServiceFormComponent', () => {
35 let component: ServiceFormComponent;
36 let fixture: ComponentFixture<ServiceFormComponent>;
37 let cephServiceService: CephServiceService;
38 let form: CdFormGroup;
39 let formHelper: FormHelper;
42 declarations: [ServiceFormComponent],
43 providers: [NgbActiveModal, { provide: PoolService, useClass: MockPoolService }
46 HttpClientTestingModule,
60 ProgressIndicatorModule,
61 ToastrModule.forRoot()
63 schemas: [NO_ERRORS_SCHEMA]
67 fixture = TestBed.createComponent(ServiceFormComponent);
68 component = fixture.componentInstance;
70 form = component.serviceForm;
71 formHelper = new FormHelper(form);
72 router = TestBed.inject(Router);
73 Object.defineProperty(router, 'url', {
74 get: jasmine.createSpy('url').and.returnValue('services/(modal:create')
76 fixture.detectChanges();
79 it('should create', () => {
80 expect(component).toBeTruthy();
83 describe('should test form', () => {
85 cephServiceService = TestBed.inject(CephServiceService);
86 spyOn(cephServiceService, 'create').and.stub();
89 it('should test placement (host)', () => {
90 formHelper.setValue('service_type', 'crash');
91 formHelper.setValue('placement', 'hosts');
92 formHelper.setValue('hosts', ['mgr0', 'mon0', 'osd0']);
93 formHelper.setValue('count', 2);
95 expect(cephServiceService.create).toHaveBeenCalledWith({
96 service_type: 'crash',
98 hosts: ['mgr0', 'mon0', 'osd0'],
105 it('should test placement (label)', () => {
106 formHelper.setValue('service_type', 'mgr');
107 formHelper.setValue('placement', 'label');
108 formHelper.setValue('label', 'foo');
109 component.onSubmit();
110 expect(cephServiceService.create).toHaveBeenCalledWith({
119 it('should submit valid count', () => {
120 formHelper.setValue('count', 1);
121 component.onSubmit();
122 formHelper.expectValid('count');
125 // it('should submit invalid count (1)', () => {
126 // formHelper.setValue('count', 0);
127 // component.onSubmit();
128 // formHelper.expectError('count', 'min');
131 it('should submit invalid count (2)', () => {
132 formHelper.setValue('count', 'abc');
133 component.onSubmit();
134 formHelper.expectError('count', 'pattern');
137 it('should test unmanaged', () => {
138 formHelper.setValue('service_type', 'mgr');
139 formHelper.setValue('service_id', 'svc');
140 formHelper.setValue('placement', 'label');
141 formHelper.setValue('label', 'bar');
142 formHelper.setValue('unmanaged', true);
143 component.onSubmit();
144 expect(cephServiceService.create).toHaveBeenCalledWith({
152 it('should test various services', () => {
154 ['alertmanager', 'crash', 'mds', 'mgr', 'mon', 'node-exporter', 'prometheus', 'rbd-mirror'],
156 formHelper.setValue('service_type', serviceType);
157 component.onSubmit();
158 expect(cephServiceService.create).toHaveBeenCalledWith({
159 service_type: serviceType,
167 describe('should test service grafana', () => {
169 formHelper.setValue('service_type', 'grafana');
172 it('should sumbit grafana', () => {
173 component.onSubmit();
174 expect(cephServiceService.create).toHaveBeenCalledWith({
175 service_type: 'grafana',
178 initial_admin_password: null,
183 it('should sumbit grafana with custom port and initial password', () => {
184 formHelper.setValue('grafana_port', 1234);
185 formHelper.setValue('grafana_admin_password', 'foo');
186 component.onSubmit();
187 expect(cephServiceService.create).toHaveBeenCalledWith({
188 service_type: 'grafana',
191 initial_admin_password: 'foo',
197 describe('should test service nfs', () => {
199 formHelper.setValue('service_type', 'nfs');
202 it('should submit nfs', () => {
203 component.onSubmit();
204 expect(cephServiceService.create).toHaveBeenCalledWith({
212 describe('should test service rgw', () => {
214 formHelper.setValue('service_type', 'rgw');
215 formHelper.setValue('service_id', 'svc');
218 it('should test rgw valid service id', () => {
219 formHelper.setValue('service_id', 'svc.realm.zone');
220 formHelper.expectValid('service_id');
221 formHelper.setValue('service_id', 'svc');
222 formHelper.expectValid('service_id');
225 it('should submit rgw with realm, zonegroup and zone', () => {
226 formHelper.setValue('service_id', 'svc');
227 formHelper.setValue('realm_name', 'my-realm');
228 formHelper.setValue('zone_name', 'my-zone');
229 formHelper.setValue('zonegroup_name', 'my-zonegroup');
230 component.onSubmit();
231 expect(cephServiceService.create).toHaveBeenCalledWith({
234 rgw_realm: 'my-realm',
236 rgw_zonegroup: 'my-zonegroup',
243 it('should submit rgw with port and ssl enabled', () => {
244 formHelper.setValue('rgw_frontend_port', 1234);
245 formHelper.setValue('ssl', true);
246 component.onSubmit();
247 expect(cephServiceService.create).toHaveBeenCalledWith({
255 rgw_frontend_port: 1234,
256 rgw_frontend_ssl_certificate: '',
261 it('should submit valid rgw port (1)', () => {
262 formHelper.setValue('rgw_frontend_port', 1);
263 component.onSubmit();
264 formHelper.expectValid('rgw_frontend_port');
267 it('should submit valid rgw port (2)', () => {
268 formHelper.setValue('rgw_frontend_port', 65535);
269 component.onSubmit();
270 formHelper.expectValid('rgw_frontend_port');
273 // it('should submit invalid rgw port (1)', () => {
274 // formHelper.setValue('rgw_frontend_port', 0);
275 // fixture.detectChanges();
276 // formHelper.expectError('rgw_frontend_port', 'min');
279 // it('should submit invalid rgw port (2)', () => {
280 // formHelper.setValue('rgw_frontend_port', 65536);
281 // fixture.detectChanges();
282 // formHelper.expectError('rgw_frontend_port', 'max');
285 it('should submit invalid rgw port (3)', () => {
286 formHelper.setValue('rgw_frontend_port', 'abc');
287 component.onSubmit();
288 formHelper.expectError('rgw_frontend_port', 'pattern');
291 it('should submit rgw w/o port', () => {
292 formHelper.setValue('ssl', false);
293 component.onSubmit();
294 expect(cephServiceService.create).toHaveBeenCalledWith({
306 it('should not show private key field', () => {
307 formHelper.setValue('ssl', true);
308 fixture.detectChanges();
309 const ssl_key = fixture.debugElement.query(By.css('#ssl_key'));
310 expect(ssl_key).toBeNull();
313 it('should test .pem file', () => {
315 -----BEGIN CERTIFICATE-----
316 iJ5IbgzlKPssdYwuAEI3yPZxX/g5vKBrgcyD3LttLL/DlElq/1xCnwVrv7WROSNu
317 -----END CERTIFICATE-----
318 -----BEGIN CERTIFICATE-----
319 mn/S7BNBEC7AGe5ajmN+8hBTGdACUXe8rwMNrtTy/MwBZ0VpJsAAjJh+aptZh5yB
320 -----END CERTIFICATE-----
321 -----BEGIN RSA PRIVATE KEY-----
322 x4Ea7kGVgx9kWh5XjWz9wjZvY49UKIT5ppIAWPMbLl3UpfckiuNhTA==
323 -----END RSA PRIVATE KEY-----`;
324 formHelper.setValue('ssl', true);
325 formHelper.setValue('ssl_cert', pemCert);
326 fixture.detectChanges();
327 formHelper.expectValid('ssl_cert');
331 describe('should test service iscsi', () => {
333 formHelper.setValue('service_type', 'iscsi');
334 formHelper.setValue('pool', 'xyz');
335 formHelper.setValue('api_user', 'user');
336 formHelper.setValue('api_password', 'password');
337 formHelper.setValue('ssl', false);
340 it('should submit iscsi', () => {
341 component.onSubmit();
342 expect(cephServiceService.create).toHaveBeenCalledWith({
343 service_type: 'iscsi',
348 api_password: 'password',
353 it('should submit iscsi with trusted ips', () => {
354 formHelper.setValue('ssl', true);
355 formHelper.setValue('trusted_ip_list', ' 172.16.0.5, 192.1.1.10 ');
356 component.onSubmit();
357 expect(cephServiceService.create).toHaveBeenCalledWith({
358 service_type: 'iscsi',
363 api_password: 'password',
367 trusted_ip_list: '172.16.0.5, 192.1.1.10'
371 it('should submit iscsi with port', () => {
372 formHelper.setValue('api_port', 456);
373 component.onSubmit();
374 expect(cephServiceService.create).toHaveBeenCalledWith({
375 service_type: 'iscsi',
380 api_password: 'password',
386 it('should submit valid iscsi port (1)', () => {
387 formHelper.setValue('api_port', 1);
388 component.onSubmit();
389 formHelper.expectValid('api_port');
392 it('should submit valid iscsi port (2)', () => {
393 formHelper.setValue('api_port', 65535);
394 component.onSubmit();
395 formHelper.expectValid('api_port');
398 // it('should submit invalid iscsi port (1)', () => {
399 // formHelper.setValue('api_port', 0);
400 // fixture.detectChanges();
401 // formHelper.expectError('api_port', 'min');
404 // it('should submit invalid iscsi port (2)', () => {
405 // formHelper.setValue('api_port', 65536);
406 // fixture.detectChanges();
407 // formHelper.expectError('api_port', 'max');
410 // it('should submit invalid iscsi port (3)', () => {
411 // formHelper.setValue('api_port', 'abc');
412 // component.onSubmit();
413 // formHelper.expectError('api_port', 'pattern');
416 // it('should throw error when there is no pool', () => {
417 // formHelper.expectErrorChange('pool', '', 'required');
421 describe('should test service nvmeof', () => {
423 component.serviceType = 'nvmeof';
424 formHelper.setValue('service_type', 'nvmeof');
425 component.ngOnInit();
426 fixture.detectChanges();
429 it('should set rbd pools correctly onInit', () => {
430 expect(component.pools.length).toBe(3);
431 expect(component.rbdPools.length).toBe(2);
434 it('should set default values correctly onInit', () => {
435 expect(form.get('service_type').value).toBe('nvmeof');
436 expect(form.get('group').value).toBe('default');
437 expect(form.get('pool').value).toBe('rbd');
438 expect(form.get('service_id').value).toBe('rbd.default');
441 it('should reflect correct values on group change', () => {
442 // Initially the group value should be 'default'
443 expect(component.serviceForm.get('group')?.value).toBe('default');
444 const groupInput = fixture.debugElement.query(By.css('#group')).nativeElement;
445 // Simulate input value change
446 groupInput.value = 'foo';
447 // Trigger the input event
448 groupInput.dispatchEvent(new Event('input'));
449 // Trigger the change event
450 groupInput.dispatchEvent(new Event('change'));
451 fixture.detectChanges();
452 // Verify values after change
453 expect(form.get('group').value).toBe('foo');
454 expect(form.get('service_id').value).toBe('rbd.foo');
457 it('should reflect correct values on pool change', () => {
458 // Initially the pool value should be 'rbd'
459 expect(component.serviceForm.get('pool')?.value).toBe('rbd');
460 const poolInput = fixture.debugElement.query(By.css('#pool')).nativeElement;
461 // Simulate input value change
462 poolInput.value = 'pool-2';
463 // Trigger the input event
464 poolInput.dispatchEvent(new Event('input'));
465 // Trigger the change event
466 poolInput.dispatchEvent(new Event('change'));
467 fixture.detectChanges();
468 // Verify values after change
469 expect(component.serviceForm.getValue('pool').value).equals('pool-2');
470 expect(component.serviceForm.getValue('service_id')).equals('pool-2.default');
473 it('should throw error when there is no service id', () => {
474 formHelper.expectErrorChange('service_id', '', 'required');
477 it('should throw error when there is no pool', () => {
478 formHelper.expectErrorChange('pool', '', 'required');
481 it('should throw error when there is no group', () => {
482 formHelper.expectErrorChange('group', '', 'required');
485 it('should hide the count element when service_type is "nvmeof"', () => {
486 const countEl = fixture.debugElement.query(By.css('#count'));
487 expect(countEl).toBeNull();
490 it('should not show certs and keys field with mTLS disabled', () => {
491 formHelper.setValue('ssl', true);
492 fixture.detectChanges();
493 const root_ca_cert = fixture.debugElement.query(By.css('#root_ca_cert'));
494 const client_cert = fixture.debugElement.query(By.css('#client_cert'));
495 const client_key = fixture.debugElement.query(By.css('#client_key'));
496 const server_cert = fixture.debugElement.query(By.css('#server_cert'));
497 const server_key = fixture.debugElement.query(By.css('#server_key'));
498 expect(root_ca_cert).toBeNull();
499 expect(client_cert).toBeNull();
500 expect(client_key).toBeNull();
501 expect(server_cert).toBeNull();
502 expect(server_key).toBeNull();
505 it('should submit nvmeof without mTLS', () => {
506 component.onSubmit();
507 expect(cephServiceService.create).toHaveBeenCalledWith({
508 service_type: 'nvmeof',
509 service_id: 'rbd.default',
518 it('should submit nvmeof with mTLS', () => {
519 formHelper.setValue('enable_mtls', true);
520 formHelper.setValue('root_ca_cert', 'root_ca_cert');
521 formHelper.setValue('client_cert', 'client_cert');
522 formHelper.setValue('client_key', 'client_key');
523 formHelper.setValue('server_cert', 'server_cert');
524 formHelper.setValue('server_key', 'server_key');
525 component.onSubmit();
526 expect(cephServiceService.create).toHaveBeenCalledWith({
527 service_type: 'nvmeof',
528 service_id: 'rbd.default',
534 root_ca_cert: 'root_ca_cert',
535 client_cert: 'client_cert',
536 client_key: 'client_key',
537 server_cert: 'server_cert',
538 server_key: 'server_key'
543 describe('should test service smb', () => {
545 formHelper.setValue('service_type', 'smb');
546 formHelper.setValue('service_id', 'foo');
547 formHelper.setValue('cluster_id', 'cluster_foo');
548 formHelper.setValue('config_uri', 'rados://.smb/foo/scc.toml');
551 it('should submit smb', () => {
552 component.onSubmit();
553 expect(cephServiceService.create).toHaveBeenCalledWith({
558 cluster_id: 'cluster_foo',
559 config_uri: 'rados://.smb/foo/scc.toml'
564 describe('should test service ingress', () => {
566 formHelper.setValue('service_type', 'ingress');
567 formHelper.setValue('backend_service', 'rgw.foo');
568 formHelper.setValue('virtual_ip', '192.168.20.1/24');
569 formHelper.setValue('ssl', false);
572 it('should submit ingress', () => {
573 component.onSubmit();
574 expect(cephServiceService.create).toHaveBeenCalledWith({
575 service_type: 'ingress',
578 backend_service: 'rgw.foo',
579 service_id: 'rgw.foo',
580 virtual_ip: '192.168.20.1/24',
581 virtual_interface_networks: null,
586 it('should pre-populate the service id', () => {
587 component.prePopulateId();
588 const prePopulatedID = component.serviceForm.getValue('service_id');
589 expect(prePopulatedID).toBe('rgw.foo');
592 it('should submit valid frontend and monitor port', () => {
594 formHelper.setValue('frontend_port', 1);
595 formHelper.setValue('monitor_port', 1);
596 fixture.detectChanges();
597 formHelper.expectValid('frontend_port');
598 formHelper.expectValid('monitor_port');
601 formHelper.setValue('frontend_port', 65535);
602 formHelper.setValue('monitor_port', 65535);
603 fixture.detectChanges();
604 formHelper.expectValid('frontend_port');
605 formHelper.expectValid('monitor_port');
608 // it('should submit invalid frontend and monitor port', () => {
610 // formHelper.setValue('frontend_port', 0);
611 // formHelper.setValue('monitor_port', 0);
612 // fixture.detectChanges();
613 // formHelper.expectError('frontend_port', 'min');
614 // formHelper.expectError('monitor_port', 'min');
617 // formHelper.setValue('frontend_port', 65536);
618 // formHelper.setValue('monitor_port', 65536);
619 // fixture.detectChanges();
620 // formHelper.expectError('frontend_port', 'max');
621 // formHelper.expectError('monitor_port', 'max');
624 // formHelper.setValue('frontend_port', 'abc');
625 // formHelper.setValue('monitor_port', 'abc');
626 // component.onSubmit();
627 // formHelper.expectError('frontend_port', 'pattern');
628 // formHelper.expectError('monitor_port', 'pattern');
631 it('should not show private key field with ssl enabled', () => {
632 formHelper.setValue('ssl', true);
633 fixture.detectChanges();
634 const ssl_key = fixture.debugElement.query(By.css('#ssl_key'));
635 expect(ssl_key).toBeNull();
638 it('should test .pem file with ssl enabled', () => {
640 -----BEGIN CERTIFICATE-----
641 iJ5IbgzlKPssdYwuAEI3yPZxX/g5vKBrgcyD3LttLL/DlElq/1xCnwVrv7WROSNu
642 -----END CERTIFICATE-----
643 -----BEGIN CERTIFICATE-----
644 mn/S7BNBEC7AGe5ajmN+8hBTGdACUXe8rwMNrtTy/MwBZ0VpJsAAjJh+aptZh5yB
645 -----END CERTIFICATE-----
646 -----BEGIN RSA PRIVATE KEY-----
647 x4Ea7kGVgx9kWh5XjWz9wjZvY49UKIT5ppIAWPMbLl3UpfckiuNhTA==
648 -----END RSA PRIVATE KEY-----`;
649 formHelper.setValue('ssl', true);
650 formHelper.setValue('ssl_cert', pemCert);
651 fixture.detectChanges();
652 formHelper.expectValid('ssl_cert');
656 describe('should test service snmp-gateway', () => {
658 formHelper.setValue('service_type', 'snmp-gateway');
659 formHelper.setValue('snmp_destination', '192.168.20.1:8443');
662 it('should test snmp-gateway service with V2c', () => {
663 formHelper.setValue('snmp_version', 'V2c');
664 formHelper.setValue('snmp_community', 'public');
665 component.onSubmit();
666 expect(cephServiceService.create).toHaveBeenCalledWith({
667 service_type: 'snmp-gateway',
671 snmp_destination: '192.168.20.1:8443',
673 snmp_community: 'public'
678 it('should test snmp-gateway service with V3', () => {
679 formHelper.setValue('snmp_version', 'V3');
680 formHelper.setValue('engine_id', '800C53F00000');
681 formHelper.setValue('auth_protocol', 'SHA');
682 formHelper.setValue('privacy_protocol', 'DES');
683 formHelper.setValue('snmp_v3_auth_username', 'testuser');
684 formHelper.setValue('snmp_v3_auth_password', 'testpass');
685 formHelper.setValue('snmp_v3_priv_password', 'testencrypt');
686 component.onSubmit();
687 expect(cephServiceService.create).toHaveBeenCalledWith({
688 service_type: 'snmp-gateway',
692 snmp_destination: '192.168.20.1:8443',
693 engine_id: '800C53F00000',
694 auth_protocol: 'SHA',
695 privacy_protocol: 'DES',
697 snmp_v3_auth_username: 'testuser',
698 snmp_v3_auth_password: 'testpass',
699 snmp_v3_priv_password: 'testencrypt'
704 it('should submit invalid snmp destination', () => {
705 formHelper.setValue('snmp_version', 'V2c');
706 formHelper.setValue('snmp_destination', '192.168.20.1');
707 formHelper.setValue('snmp_community', 'public');
708 formHelper.expectError('snmp_destination', 'snmpDestinationPattern');
711 it('should submit invalid snmp engine id', () => {
712 formHelper.setValue('snmp_version', 'V3');
713 formHelper.setValue('snmp_destination', '192.168.20.1');
714 formHelper.setValue('engine_id', 'AABBCCDDE');
715 formHelper.setValue('auth_protocol', 'SHA');
716 formHelper.setValue('privacy_protocol', 'DES');
717 formHelper.setValue('snmp_v3_auth_username', 'testuser');
718 formHelper.setValue('snmp_v3_auth_password', 'testpass');
720 formHelper.expectError('engine_id', 'snmpEngineIdPattern');
724 describe('should test service oauth2-proxy',()=>{
726 formHelper.setValue('service_type', 'oauth2-proxy');
727 formHelper.setValue('count', '1');
728 formHelper.setValue('provider_display_name', 'My OIDC provider');
729 formHelper.setValue('allowlist_domains', 'test:value');
731 it('should throw error when there is no client secret', () => {
732 component.onSubmit();
733 formHelper.expectErrorChange('client_secret', '', 'required');
735 it('should throw error when there is no oidc issuer url', () => {
736 component.onSubmit();
737 formHelper.expectErrorChange('oidc_issuer_url', '', 'required');
740 describe('should test service mgmt-gateway',()=>{
742 formHelper.setValue('service_type', 'mgmt-gateway');
743 formHelper.setValue('port', '443');
744 formHelper.setValue('service_id', 'mgmt-gateway');
746 it('should submit when service type is mgmt-gateway', () => {
747 component.onSubmit();
748 expect(cephServiceService.create).toHaveBeenCalledWith({
751 service_type: "mgmt-gateway",
753 ssl_certificate_key:"",
754 ssl_ciphers: undefined,
761 describe('should test service mds', () => {
763 formHelper.setValue('service_type', 'mds');
764 const paginate_obs = new PaginateObservable<any>(of({}));
765 spyOn(cephServiceService, 'list').and.returnValue(paginate_obs);
768 // it('should test mds valid service id', () => {
769 // formHelper.setValue('service_id', 'svc123');
770 // formHelper.expectValid('service_id');
771 // formHelper.setValue('service_id', 'svc_id-1');
772 // formHelper.expectValid('service_id');
775 // it('should test mds invalid service id', () => {
776 // formHelper.setValue('service_id', '123');
777 // formHelper.expectError('service_id', 'mdsPattern');
778 // formHelper.setValue('service_id', '123svc');
779 // formHelper.expectError('service_id', 'mdsPattern');
780 // formHelper.setValue('service_id', 'svc#1');
781 // formHelper.expectError('service_id', 'mdsPattern');
785 describe('check edit fields', () => {
787 component.editing = true;
790 // it('should check whether edit field is correctly loaded', () => {
791 // const paginate_obs = new PaginateObservable<any>(of({}));
792 // const cephServiceSpy = spyOn(cephServiceService, 'list').and.returnValue(paginate_obs);
793 // component.ngOnInit();
794 // expect(cephServiceSpy).toBeCalledTimes(2);
795 // expect(component.action).toBe('Edit');
796 // const serviceType = fixture.debugElement.query(By.css('#service_type')).nativeElement;
797 // const serviceId = fixture.debugElement.query(By.css('#service_id')).nativeElement;
798 // expect(serviceType.disabled).toBeTruthy();
799 // expect(serviceId.disabled).toBeTruthy();
802 it('should not edit pools for nvmeof service', () => {
803 component.serviceType = 'nvmeof';
804 formHelper.setValue('service_type', 'nvmeof');
805 component.ngOnInit();
806 fixture.detectChanges();
807 expect(component.serviceForm.get('pool').disabled).toBe(true);
810 it('should not edit groups for nvmeof service', () => {
811 component.serviceType = 'nvmeof';
812 formHelper.setValue('service_type', 'nvmeof');
813 component.ngOnInit();
814 fixture.detectChanges();
815 const groupId = fixture.debugElement.query(By.css('#group')).nativeElement;
816 expect(groupId.disabled).toBeTruthy();
819 it('should update nvmeof service to disable mTLS', () => {
820 spyOn(cephServiceService, 'update').and.stub();
821 component.serviceType = 'nvmeof';
822 formHelper.setValue('service_type', 'nvmeof');
823 formHelper.setValue('pool', 'rbd');
824 formHelper.setValue('group', 'default');
826 formHelper.setValue('enable_mtls', false);
827 component.onSubmit();
828 expect(cephServiceService.update).toHaveBeenCalledWith({
829 service_type: 'nvmeof',
838 describe("test cases for clearValidations",() => {
839 it('should call clearValidations when snmp_version is v3',()=>{
840 formHelper.setValue('snmp_version', 'V3');
841 formHelper.setValue('privacy_protocol', 'DES');
842 component.clearValidations();
843 fixture.detectChanges();
844 fixture.whenStable().then(() => {
845 expect(component.serviceForm.get('snmp_community').value).to.be(null);
848 it('should call clearValidations when snmp_version is v2',()=>{
849 formHelper.setValue('snmp_version', 'V2');
850 formHelper.setValue('privacy_protocol', 'DES');
851 component.clearValidations();
852 fixture.detectChanges();
853 fixture.whenStable().then(() => {
854 expect(form.get('engine_id').value).equals(null);
855 expect(form.get('auth_protocol').value).equals(null);
856 expect(form.get('privacy_protocol').value).equals(null);
857 expect(form.get('snmp_v3_auth_username').value).equals(null);
858 expect(form.get('snmp_v3_auth_password').value).equals(null);
863 // it('should call resolveRoute',()=>{
864 // spyOn(router , "url");
865 // Object.defineProperty(router, 'url', {
866 // get: jasmine.createSpy('url').and.returnValue('services/(modal:create')
869 // // it(`editTemplate() should navigate to template build module with query params`, inject(
871 // // (router: Router) => {
873 // spyOn(router, "navigate").and.stub();
874 // router.navigate(["services/(modal:create)"], {
875 // queryParams: { templateId: id }
877 // expect(router.navigate).toHaveBeenCalledWith(["services/(modal:create)"], {
878 // queryParams: { templateId: id }
882 // // const req2 = httpTesting.expectOne({
883 // // url: 'services/(modal:create)',
886 // // expect(req2.request.body).toEqual({
889 // // req2.flush({});
890 // // expect(router.url).toBe('/');
892 // it('should test closeModal', () => {
893 // spyOn(component, 'closeModal').and.callThrough();
894 // component.closeModal();
895 // expect(component.closeModal).to.tru