You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2024/01/02 16:40:40 UTC

(streampipes) branch dev updated: Add three new user management tests (#2382)

This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new fecb00f7c Add three new user management tests (#2382)
fecb00f7c is described below

commit fecb00f7c2413a463ea6f119d8fa10f94bd96bb0
Author: Marcelfrueh <78...@users.noreply.github.com>
AuthorDate: Tue Jan 2 17:40:35 2024 +0100

    Add three new user management tests (#2382)
    
    * Added Dialog window after deleting user + modified tests accordingly
    
    * added three new tests
---
 .../userManagement/testGroupManagement.spec.ts     | 145 +++++++++++++++++++++
 ....smoke.spec.ts => testUserRolePipeline.spec.ts} |  57 ++++++--
 .../testVariousUserRoles.smoke.spec.ts             | 102 +++++++++++++++
 3 files changed, 290 insertions(+), 14 deletions(-)

diff --git a/ui/cypress/tests/userManagement/testGroupManagement.spec.ts b/ui/cypress/tests/userManagement/testGroupManagement.spec.ts
new file mode 100644
index 000000000..1df9d793b
--- /dev/null
+++ b/ui/cypress/tests/userManagement/testGroupManagement.spec.ts
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { UserBuilder } from '../../support/builder/UserBuilder';
+import { UserRole } from '../../../src/app/_enums/user-role.enum';
+import { UserUtils } from '../../support/utils/UserUtils';
+import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
+import { PipelineUtils } from '../../support/utils/PipelineUtils';
+import { PipelineElementBuilder } from '../../support/builder/PipelineElementBuilder';
+import { PipelineBuilder } from '../../support/builder/PipelineBuilder';
+
+describe('Test Group Management for Pipelines', () => {
+    beforeEach('Setup Test', () => {
+        cy.initStreamPipesTest();
+        ConnectUtils.addMachineDataSimulator('simulator');
+        const pipelineInput = PipelineBuilder.create('Pipeline Test')
+            .addSource('simulator')
+            .addProcessingElement(
+                PipelineElementBuilder.create('field_renamer')
+                    .addInput('drop-down', 'convert-property', 'timestamp')
+                    .addInput('input', 'field-name', 't')
+                    .build(),
+            )
+            .addSink(
+                PipelineElementBuilder.create('data_lake')
+                    .addInput('input', 'db_measurement', 'demo')
+                    .build(),
+            )
+            .build();
+
+        PipelineUtils.addPipeline(pipelineInput);
+    });
+
+    it('Perform Test', () => {
+        // Add two new user with same role
+        UserUtils.goToUserConfiguration();
+
+        cy.dataCy('user-accounts-table-row', { timeout: 10000 }).should(
+            'have.length',
+            1,
+        );
+
+        const email = 'user1@streampipes.apache.org';
+        const name = 'test_user';
+        const user = UserBuilder.create(email)
+            .setName(name)
+            .setPassword(name)
+            .addRole(UserRole.ROLE_PIPELINE_USER)
+            .build();
+
+        UserUtils.addUser(user);
+
+        const email2 = 'user2@streampipes.apache.org';
+        const name2 = 'test_user2';
+        const user2 = UserBuilder.create(email2)
+            .setName(name2)
+            .setPassword(name2)
+            .addRole(UserRole.ROLE_PIPELINE_USER)
+            .build();
+
+        UserUtils.addUser(user2);
+
+        // Check if users were added successfully
+        cy.dataCy('user-accounts-table-row', { timeout: 10000 }).should(
+            'have.length',
+            3,
+        );
+
+        // Add new user group with pipeline admin role
+        cy.get('button').contains('New User Group').click();
+        cy.get('label').contains('Group Name').type('User_Group');
+        cy.get('input[value="ROLE_PIPELINE_ADMIN"]').check();
+        cy.dataCy('sp-element-edit-user-save').click();
+
+        // Add first user to group
+        cy.dataCy('user-edit-btn').eq(1).click();
+        cy.get('input[type="checkbox"]').eq(0).check();
+        cy.dataCy('sp-element-edit-user-save').click();
+
+        // Add user group to pipeline
+        PipelineUtils.goToPipelines();
+        cy.dataCy('share').click();
+        cy.get('label').contains('Authorized Groups').click();
+        cy.get('mat-option').contains('User_Group').click();
+        cy.dataCy('sp-element-edit-user-save').click();
+
+        // Login as first user which belongs to user group with pipeline admin role
+        cy.switchUser(user);
+
+        cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+            'have.length',
+            4,
+        );
+
+        // Check if pipeline is visible
+        PipelineUtils.goToPipelines();
+        cy.dataCy('all-pipelines-table', { timeout: 10000 }).should(
+            'have.length',
+            1,
+        );
+        cy.dataCy('all-pipelines-table', { timeout: 10000 }).should(
+            'contain',
+            'Pipeline Test',
+        );
+
+        // Login as user2
+        cy.switchUser(user2);
+
+        cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+            'have.length',
+            2,
+        );
+
+        // Check if pipeline is invisible to user2
+        PipelineUtils.goToPipelines();
+        cy.get('sp-pipeline-overview', { timeout: 10000 }).should(
+            'contain',
+            '(no pipelines available)',
+        );
+
+        // Log in as admin and delete users
+        cy.switchUser(UserUtils.adminUser);
+        UserUtils.deleteUser(user);
+        UserUtils.deleteUser(user2);
+
+        // Delete group
+        cy.dataCy('service-delete-btn').eq(1).click();
+        cy.dataCy('confirm-delete').click();
+    });
+});
diff --git a/ui/cypress/tests/userManagement/addUserDataExplorerAdmin.smoke.spec.ts b/ui/cypress/tests/userManagement/testUserRolePipeline.spec.ts
similarity index 52%
rename from ui/cypress/tests/userManagement/addUserDataExplorerAdmin.smoke.spec.ts
rename to ui/cypress/tests/userManagement/testUserRolePipeline.spec.ts
index 775bfa93f..9da4a9dab 100644
--- a/ui/cypress/tests/userManagement/addUserDataExplorerAdmin.smoke.spec.ts
+++ b/ui/cypress/tests/userManagement/testUserRolePipeline.spec.ts
@@ -19,19 +19,36 @@
 import { UserBuilder } from '../../support/builder/UserBuilder';
 import { UserRole } from '../../../src/app/_enums/user-role.enum';
 import { UserUtils } from '../../support/utils/UserUtils';
+import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
+import { PipelineUtils } from '../../support/utils/PipelineUtils';
+import { PipelineElementBuilder } from '../../support/builder/PipelineElementBuilder';
+import { PipelineBuilder } from '../../support/builder/PipelineBuilder';
 
-describe('Test User Management', () => {
+describe('Test User Roles for Pipelines', () => {
     beforeEach('Setup Test', () => {
         cy.initStreamPipesTest();
+        ConnectUtils.addMachineDataSimulator('simulator');
+        const pipelineInput = PipelineBuilder.create('Pipeline Test')
+            .addSource('simulator')
+            .addProcessingElement(
+                PipelineElementBuilder.create('field_renamer')
+                    .addInput('drop-down', 'convert-property', 'timestamp')
+                    .addInput('input', 'field-name', 't')
+                    .build(),
+            )
+            .addSink(
+                PipelineElementBuilder.create('data_lake')
+                    .addInput('input', 'db_measurement', 'demo')
+                    .build(),
+            )
+            .build();
+
+        PipelineUtils.addPipeline(pipelineInput);
     });
 
     it('Perform Test', () => {
         // Add new user
         UserUtils.goToUserConfiguration();
-        cy.dataCy('navigation-icon', { timeout: 10000 }).should(
-            'have.length',
-            11,
-        );
 
         cy.dataCy('user-accounts-table-row', { timeout: 10000 }).should(
             'have.length',
@@ -39,21 +56,29 @@ describe('Test User Management', () => {
         );
 
         const email = 'user@streampipes.apache.org';
-        const name = 'user';
+        const name = 'test_user';
         const user = UserBuilder.create(email)
             .setName(name)
             .setPassword(name)
-            .addRole(UserRole.ROLE_DATA_EXPLORER_ADMIN)
+            .addRole(UserRole.ROLE_PIPELINE_USER)
             .build();
 
         UserUtils.addUser(user);
 
+        // Check if user is added successfully
         cy.dataCy('user-accounts-table-row', { timeout: 10000 }).should(
             'have.length',
             2,
         );
 
-        // Login as user
+        // Add new authorized user to pipeline
+        PipelineUtils.goToPipelines();
+        cy.dataCy('share').click();
+        cy.get('label').contains('Authorized Users').click();
+        cy.get('mat-option').contains(email).click();
+        cy.dataCy('sp-element-edit-user-save').click();
+
+        // Login as user and check if pipeline is visible to user
         cy.switchUser(user);
 
         cy.dataCy('navigation-icon', { timeout: 10000 }).should(
@@ -61,14 +86,18 @@ describe('Test User Management', () => {
             2,
         );
 
-        cy.switchUser(UserUtils.adminUser);
-        UserUtils.goToUserConfiguration();
-        UserUtils.deleteUser(user);
-
-        // Validate that user is removed
-        cy.dataCy('user-accounts-table-row', { timeout: 10000 }).should(
+        PipelineUtils.goToPipelines();
+        cy.dataCy('all-pipelines-table', { timeout: 10000 }).should(
             'have.length',
             1,
         );
+        cy.dataCy('all-pipelines-table', { timeout: 10000 }).should(
+            'contain',
+            'Pipeline Test',
+        );
+
+        // Delete user
+        cy.switchUser(UserUtils.adminUser);
+        UserUtils.deleteUser(user);
     });
 });
diff --git a/ui/cypress/tests/userManagement/testVariousUserRoles.smoke.spec.ts b/ui/cypress/tests/userManagement/testVariousUserRoles.smoke.spec.ts
new file mode 100644
index 000000000..1d5195b1d
--- /dev/null
+++ b/ui/cypress/tests/userManagement/testVariousUserRoles.smoke.spec.ts
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { UserBuilder } from '../../support/builder/UserBuilder';
+import { UserRole } from '../../../src/app/_enums/user-role.enum';
+import { UserUtils } from '../../support/utils/UserUtils';
+
+const testedRoles = [
+    UserRole.ROLE_PIPELINE_ADMIN,
+    UserRole.ROLE_DASHBOARD_ADMIN,
+    UserRole.ROLE_DATA_EXPLORER_ADMIN,
+    UserRole.ROLE_CONNECT_ADMIN,
+    UserRole.ROLE_ASSET_ADMIN,
+];
+
+for (var i = 0; i < testedRoles.length; i++) {
+    const testRole = testedRoles[i];
+    describe('Test User Role ' + testedRoles[i], () => {
+        beforeEach('Setup Test', () => {
+            cy.initStreamPipesTest();
+        });
+
+        it('Perform Test', () => {
+            // Add new user
+            UserUtils.goToUserConfiguration();
+            cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+                'have.length',
+                11,
+            );
+
+            cy.dataCy('user-accounts-table-row', { timeout: 10000 }).should(
+                'have.length',
+                1,
+            );
+
+            const email = 'user@streampipes.apache.org';
+            const name = 'user';
+            const user = UserBuilder.create(email)
+                .setName(name)
+                .setPassword(name)
+                .addRole(testRole)
+                .build();
+
+            UserUtils.addUser(user);
+
+            cy.dataCy('user-accounts-table-row', { timeout: 10000 }).should(
+                'have.length',
+                2,
+            );
+
+            // Login as user
+            cy.switchUser(user);
+
+            // Check if every role displays correct navigation menu
+            if (testRole == UserRole.ROLE_PIPELINE_ADMIN) {
+                cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+                    'have.length',
+                    4,
+                );
+            } else if (testRole == UserRole.ROLE_DASHBOARD_ADMIN) {
+                cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+                    'have.length',
+                    2,
+                );
+            } else if (testRole == UserRole.ROLE_DATA_EXPLORER_ADMIN) {
+                cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+                    'have.length',
+                    2,
+                );
+            } else if (testRole == UserRole.ROLE_CONNECT_ADMIN) {
+                cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+                    'have.length',
+                    3,
+                );
+            } else if (testRole == UserRole.ROLE_ASSET_ADMIN) {
+                cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+                    'have.length',
+                    1,
+                );
+            }
+
+            // Login as admin and delete user
+            cy.switchUser(UserUtils.adminUser);
+            UserUtils.deleteUser(user);
+        });
+    });
+}