This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch
2337-cant-access-connect-with-user-role-connect-admin
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/2337-cant-access-connect-with-user-role-connect-admin by this push:
new 24615b7a44 test(#2337): e2e test to validate that a user can access
only the connect view
24615b7a44 is described below
commit 24615b7a441b5d73b8db8e3286173ea7c4a901e4
Author: Philipp Zehnder <[email protected]>
AuthorDate: Thu Mar 14 07:35:06 2024 +0100
test(#2337): e2e test to validate that a user can access only the connect
view
---
.../userManagement/testUserRoleConnect.spec.ts | 62 ++++++++++++++++++++++
ui/src/app/_guards/page-auth.can-active.guard.ts | 7 +--
.../existing-adapters.component.html | 1 +
3 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts
b/ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts
new file mode 100644
index 0000000000..ce7f66a3cc
--- /dev/null
+++ b/ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts
@@ -0,0 +1,62 @@
+/*
+ * 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 { ConnectBtns } from '../../support/utils/connect/ConnectBtns';
+
+describe('Test User Roles for Connect', () => {
+ beforeEach('Setup Test', () => {
+ cy.initStreamPipesTest();
+ ConnectUtils.addMachineDataSimulator('simulator');
+ });
+
+ it('Perform Test', () => {
+ // Add connect admin user
+ const connect_admin = UserBuilder.create('[email protected]')
+ .setName('connect_admin')
+ .setPassword('password')
+ .addRole(UserRole.ROLE_CONNECT_ADMIN)
+ .build();
+ UserUtils.addUser(connect_admin);
+
+ // Login as user and check if connect is visible to user
+ cy.switchUser(connect_admin);
+
+ cy.dataCy('navigation-icon', { timeout: 10000 }).should(
+ 'have.length',
+ 3,
+ );
+
+ ConnectUtils.goToConnect();
+ cy.dataCy('all-adapters-table', { timeout: 10000 }).should(
+ 'have.length',
+ 1,
+ );
+ cy.dataCy('all-adapters-table', { timeout: 10000 }).should(
+ 'contain',
+ 'simulator',
+ );
+
+ // validate that adapter can be stopped and edited
+ ConnectBtns.stopAdapter().click();
+ ConnectBtns.editAdapter().should('not.be.disabled');
+ ConnectBtns.editAdapter().click();
+ });
+});
diff --git a/ui/src/app/_guards/page-auth.can-active.guard.ts
b/ui/src/app/_guards/page-auth.can-active.guard.ts
index 6adedcfe07..fab5cecf00 100644
--- a/ui/src/app/_guards/page-auth.can-active.guard.ts
+++ b/ui/src/app/_guards/page-auth.can-active.guard.ts
@@ -16,17 +16,14 @@
*
*/
-import { ActivatedRouteSnapshot, Router } from '@angular/router';
+import { ActivatedRouteSnapshot } from '@angular/router';
import { AuthService } from '../services/auth.service';
import { PageName } from '../_enums/page-name.enum';
import { Injectable } from '@angular/core';
@Injectable()
export class PageAuthGuard {
- constructor(
- private router: Router,
- private authService: AuthService,
- ) {}
+ constructor(private authService: AuthService) {}
canActivateChild(activatedRouteSnapshot: ActivatedRouteSnapshot): boolean {
const pageNames: PageName[] =
activatedRouteSnapshot.data.authPageNames;
diff --git
a/ui/src/app/connect/components/existing-adapters/existing-adapters.component.html
b/ui/src/app/connect/components/existing-adapters/existing-adapters.component.html
index 4e5cfefc8b..495961296c 100644
---
a/ui/src/app/connect/components/existing-adapters/existing-adapters.component.html
+++
b/ui/src/app/connect/components/existing-adapters/existing-adapters.component.html
@@ -109,6 +109,7 @@
mat-table
[dataSource]="dataSource"
style="width: 100%"
+ data-cy="all-adapters-table"
matSort
>
<ng-container matColumnDef="start">