]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-details/role-details.component.spec.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / core / auth / role-details / role-details.component.spec.ts
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { RouterTestingModule } from '@angular/router/testing';
4
5 import { ToastModule } from 'ng2-toastr';
6 import { TabsModule } from 'ngx-bootstrap/tabs';
7
8 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
9 import { CdTableSelection } from '../../../shared/models/cd-table-selection';
10 import { SharedModule } from '../../../shared/shared.module';
11 import { RoleDetailsComponent } from './role-details.component';
12
13 describe('RoleDetailsComponent', () => {
14 let component: RoleDetailsComponent;
15 let fixture: ComponentFixture<RoleDetailsComponent>;
16
17 configureTestBed({
18 imports: [
19 SharedModule,
20 ToastModule.forRoot(),
21 TabsModule.forRoot(),
22 RouterTestingModule,
23 HttpClientTestingModule
24 ],
25 declarations: [RoleDetailsComponent],
26 providers: i18nProviders
27 });
28
29 beforeEach(() => {
30 fixture = TestBed.createComponent(RoleDetailsComponent);
31 component = fixture.componentInstance;
32 fixture.detectChanges();
33 });
34
35 it('should create', () => {
36 expect(component).toBeTruthy();
37 });
38
39 it('should create scopes permissions [1/2]', () => {
40 component.scopes = ['log', 'rgw'];
41 component.selection = new CdTableSelection();
42 component.selection.selected = [
43 {
44 description: 'RGW Manager',
45 name: 'rgw-manager',
46 scopes_permissions: {
47 rgw: ['read', 'create', 'update', 'delete']
48 },
49 system: true
50 }
51 ];
52 component.selection.update();
53 expect(component.scopes_permissions.length).toBe(0);
54 component.ngOnChanges();
55 expect(component.scopes_permissions).toEqual([
56 { scope: 'log', read: false, create: false, update: false, delete: false },
57 { scope: 'rgw', read: true, create: true, update: true, delete: true }
58 ]);
59 });
60
61 it('should create scopes permissions [2/2]', () => {
62 component.scopes = ['cephfs', 'log', 'rgw'];
63 component.selection = new CdTableSelection();
64 component.selection.selected = [
65 {
66 description: 'Test',
67 name: 'test',
68 scopes_permissions: {
69 log: ['read', 'update'],
70 rgw: ['read', 'create', 'update']
71 },
72 system: false
73 }
74 ];
75 component.selection.update();
76 expect(component.scopes_permissions.length).toBe(0);
77 component.ngOnChanges();
78 expect(component.scopes_permissions).toEqual([
79 { scope: 'cephfs', read: false, create: false, update: false, delete: false },
80 { scope: 'log', read: true, create: false, update: true, delete: false },
81 { scope: 'rgw', read: true, create: true, update: true, delete: false }
82 ]);
83 });
84 });