]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: add more e2e for cephx users 51867/head
authorNizamudeen A <nia@redhat.com>
Wed, 24 May 2023 16:45:59 +0000 (22:15 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 29 Aug 2023 05:20:48 +0000 (10:50 +0530)
Fixes: https://tracker.ceph.com/issues/61421
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit 6bac361b54eb6233b04dfb34c62086a9d3df3c43)

src/pybind/mgr/dashboard/controllers/rgw.py
src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/users.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/users.po.ts

index 875fbb0385536da60564581b7e87dcf7380fcd37..b29e424206e3ccb6f3dca4bff9b5c90b82a23322 100644 (file)
@@ -16,8 +16,8 @@ from ..tools import json_str_to_object, str_to_bool
 from . import APIDoc, APIRouter, BaseController, CRUDCollectionMethod, \
     CRUDEndpoint, Endpoint, EndpointDoc, ReadPermission, RESTController, \
     UIRouter, allow_empty_body
-from ._crud import CRUDMeta, Form, FormField, FormTaskInfo, Icon, \
-    MethodType, TableAction, Validator, VerticalContainer
+from ._crud import CRUDMeta, Form, FormField, FormTaskInfo, Icon, MethodType, \
+    TableAction, Validator, VerticalContainer
 from ._version import APIVersion
 
 logger = logging.getLogger("controllers.rgw")
index d3078937b608e80d9af50ad6097c570fa74f9d22..0d50d0a22d7325f5bcf903883f5aaba159c3c1fb 100644 (file)
@@ -15,6 +15,9 @@ describe('Cluster Ceph Users', () => {
   });
 
   describe('Cluster users table', () => {
+    const entityName = 'client.test';
+    const entity = 'mgr';
+    const caps = 'allow r';
     it('should verify the table is not empty', () => {
       users.checkForUsers();
     });
@@ -22,5 +25,22 @@ describe('Cluster Ceph Users', () => {
     it('should verify the keys are hidden', () => {
       users.verifyKeysAreHidden();
     });
+
+    it('should create a new user', () => {
+      users.navigateTo('create');
+      users.create(entityName, entity, caps);
+      users.existTableCell(entityName, true);
+    });
+
+    it('should edit a user', () => {
+      const newCaps = 'allow *';
+      users.edit(entityName, 'allow *');
+      users.existTableCell(entityName, true);
+      users.checkCaps(entityName, [`${entity}: ${newCaps}`]);
+    });
+
+    it('should delete a user', () => {
+      users.delete(entityName);
+    });
   });
 });
index bce659ff005c68b15e3b93018f0669aee5e0c98e..a5b32b72307f452e18a5b9f0544b0cc578927730 100644 (file)
@@ -1,7 +1,8 @@
 import { PageHelper } from '../page-helper.po';
 
 const pages = {
-  index: { url: '#/ceph-users', id: 'cd-crud-table' }
+  index: { url: '#/ceph-users', id: 'cd-crud-table' },
+  create: { url: '#/cluster/user/create', id: 'cd-crud-form' }
 };
 
 export class UsersPageHelper extends PageHelper {
@@ -26,4 +27,33 @@ export class UsersPageHelper extends PageHelper {
         expect(serviceInstances).not.contains(/^[a-z0-9]+$/i);
       });
   }
+
+  @PageHelper.restrictTo(pages.create.url)
+  create(entityName: string, entityType: string, caps: string) {
+    cy.get('#formly_2_string_user_entity_0').type(entityName);
+    cy.get('#formly_5_string_entity_0').type(entityType);
+    cy.get('#formly_5_string_cap_1').type(caps);
+    cy.get("[aria-label='Create User']").should('exist').click();
+    cy.get('cd-crud-table').should('exist');
+  }
+
+  edit(name: string, newCaps: string) {
+    this.navigateEdit(name);
+    cy.get('#formly_5_string_cap_1').clear().type(newCaps);
+    cy.get("[aria-label='Edit User']").should('exist').click();
+    cy.get('cd-crud-table').should('exist');
+  }
+
+  checkCaps(entityName: string, capabilities: string[]) {
+    this.getTableCell(this.columnIndex.entity, entityName)
+      .click()
+      .parent()
+      .find(`datatable-body-cell:nth-child(${this.columnIndex.capabilities}) .badge`)
+      .should(($ele) => {
+        const newCaps = $ele.toArray().map((v) => v.innerText);
+        for (const cap of capabilities) {
+          expect(newCaps).to.include(cap);
+        }
+      });
+  }
 }