[ARVADOS-WORKBENCH2] updated: 2.3.0-144-g39f2ecd2

Git user git at public.arvados.org
Wed Jan 26 23:54:17 UTC 2022


Summary of changes:
 cypress/integration/virtual-machine-admin.spec.js  | 181 +++++++++++++++++++++
 cypress/support/commands.js                        |  11 +-
 .../virtual-machine-admin-panel.tsx                |   4 +-
 .../virtual-machine-user-panel.tsx                 |   2 +-
 4 files changed, 194 insertions(+), 4 deletions(-)
 create mode 100644 cypress/integration/virtual-machine-admin.spec.js

       via  39f2ecd2cfa22d7dd6e1dc94f9952bd5c5c13ef2 (commit)
      from  85836abe716b2403f3b7fe75c551e4ace3995157 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 39f2ecd2cfa22d7dd6e1dc94f9952bd5c5c13ef2
Author: Stephen Smith <stephen at curii.com>
Date:   Wed Jan 26 18:53:04 2022 -0500

    18284: Fix small bug and add tests for vm login admin
    
    Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>

diff --git a/cypress/integration/virtual-machine-admin.spec.js b/cypress/integration/virtual-machine-admin.spec.js
new file mode 100644
index 00000000..534e7a9e
--- /dev/null
+++ b/cypress/integration/virtual-machine-admin.spec.js
@@ -0,0 +1,181 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+describe('Virtual machine login manage tests', function() {
+    let activeUser;
+    let adminUser;
+
+    const vmHost = `vm-${Math.floor(999999 * Math.random())}.host`;
+
+    before(function() {
+        // Only set up common users once. These aren't set up as aliases because
+        // aliases are cleaned up after every test. Also it doesn't make sense
+        // to set the same users on beforeEach() over and over again, so we
+        // separate a little from Cypress' 'Best Practices' here.
+        cy.getUser('admin', 'Admin', 'User', true, true)
+            .as('adminUser').then(function() {
+                adminUser = this.adminUser;
+            }
+        );
+        cy.getUser('user', 'Active', 'User', false, true)
+            .as('activeUser').then(function() {
+                activeUser = this.activeUser;
+            }
+        );
+    });
+
+    it('adds and removes vm logins', function() {
+        cy.loginAs(adminUser);
+        cy.createVirtualMachine(adminUser.token, {hostname: vmHost});
+
+        // Navigate to VM admin
+        cy.get('header button[title="Admin Panel"]').click();
+        cy.get('#admin-menu').contains('Virtual Machines').click();
+
+        // Add login permission to admin
+        cy.get('[data-cy=vm-admin-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                cy.get('button[title="Add Login Permission"]').click();
+            });
+        cy.get('[data-cy=form-dialog]')
+            .should('contain', 'Add login permissions')
+            .within(() => {
+                cy.get('label')
+                  .contains('Search for users')
+                  .parent()
+                  .within(() => {
+                    cy.get('input').type('admin');
+                  })
+            });
+        cy.get('[role=tooltip]').click();
+        cy.get('[data-cy=form-dialog]')
+            .should('contain', 'Add login permissions')
+            .within(() => {
+                cy.get('label')
+                  .contains('Add groups')
+                  .parent()
+                  .within(() => {
+                    cy.get('input').type('sudo{enter}');
+                  })
+            });
+        cy.get('[data-cy=form-dialog]').within(() => {
+            cy.get('[data-cy=form-submit-btn]').click();
+        });
+        cy.get('[data-cy=vm-admin-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                cy.get('td').contains('admin');
+        });
+
+        // Add login permission to activeUser
+        cy.get('[data-cy=vm-admin-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                cy.get('button[title="Add Login Permission"]').click();
+            });
+        cy.get('[data-cy=form-dialog]')
+            .should('contain', 'Add login permissions')
+            .within(() => {
+                cy.get('label')
+                  .contains('Search for users')
+                  .parent()
+                  .within(() => {
+                    cy.get('input').type('active user');
+                  })
+            });
+        cy.get('[role=tooltip]').click();
+        cy.get('[data-cy=form-dialog]').within(() => {
+            cy.get('[data-cy=form-submit-btn]').click();
+        });
+        cy.get('[data-cy=vm-admin-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                cy.get('td').contains('user');
+        });
+
+        // Check admin's vm page for login
+        cy.get('header button[title="Account Management"]').click();
+        cy.get('#account-menu').contains('Virtual Machines').click();
+
+        cy.get('[data-cy=vm-user-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                cy.get('td').contains('admin');
+                cy.get('td').contains('docker');
+                cy.get('td').contains('sudo');
+                cy.get('td').contains('ssh admin@' + vmHost);
+        });
+
+        // Check activeUser's vm page for login
+        cy.loginAs(activeUser);
+        cy.get('header button[title="Account Management"]').click();
+        cy.get('#account-menu').contains('Virtual Machines').click();
+
+        cy.get('[data-cy=vm-user-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                cy.get('td').contains('user');
+                cy.get('td').contains('docker');
+                cy.get('td').contains('ssh user@' + vmHost);
+        });
+
+        // Remove login permissions
+        cy.loginAs(adminUser);
+        cy.get('header button[title="Admin Panel"]').click();
+        cy.get('#admin-menu').contains('Virtual Machines').click();
+        cy.get('[data-cy=vm-admin-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                // Remove user login
+                cy.get('div[role=button]').contains('user').parents('[role=button]').within(() => {
+                    cy.get('svg').click();
+                });
+            });
+        cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+
+        cy.get('[data-cy=vm-admin-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                cy.get('div[role=button]').should('not.contain', 'user');
+                cy.get('div[role=button]').should('have.length', 1)
+
+                // Remove admin login
+                cy.get('div[role=button]').contains('admin').parents('[role=button]').within(() => {
+                    cy.get('svg').click();
+                });
+            });
+        cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+
+        cy.get('[data-cy=vm-admin-table]')
+            .contains(vmHost)
+            .parents('tr')
+            .within(() => {
+                cy.get('div[role=button]').should('not.contain', 'admin');
+            });
+
+        // Check admin's vm page for login
+        cy.get('header button[title="Account Management"]').click();
+        cy.get('#account-menu').contains('Virtual Machines').click();
+
+        cy.get('[data-cy=vm-user-table]')
+            .should('not.contain', vmHost);
+
+        // Check activeUser's vm page for login
+        cy.loginAs(activeUser);
+        cy.get('header button[title="Account Management"]').click();
+        cy.get('#account-menu').contains('Virtual Machines').click();
+
+        cy.get('[data-cy=vm-user-table]')
+            .should('not.contain', vmHost);
+    });
+});
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index 07290e55..cfdfa9ec 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -150,6 +150,15 @@ Cypress.Commands.add(
     }
 )
 
+Cypress.Commands.add(
+    "createVirtualMachine", (token, data) => {
+        return cy.createResource(token, 'virtual_machines', {
+            virtual_machine: JSON.stringify(data),
+            ensure_unique_name: true
+        })
+    }
+)
+
 Cypress.Commands.add(
     "createResource", (token, suffix, data) => {
         return cy.doRequest('POST', '/arvados/v1/' + suffix, data, null, token, true)
@@ -318,4 +327,4 @@ function b64toBlob(b64Data, contentType = '', sliceSize = 512) {
 
     const blob = new Blob(byteArrays, { type: contentType });
     return blob
-}
\ No newline at end of file
+}
diff --git a/src/views/virtual-machine-panel/virtual-machine-admin-panel.tsx b/src/views/virtual-machine-panel/virtual-machine-admin-panel.tsx
index 0f2c0033..bfa6be26 100644
--- a/src/views/virtual-machine-panel/virtual-machine-admin-panel.tsx
+++ b/src/views/virtual-machine-panel/virtual-machine-admin-panel.tsx
@@ -98,7 +98,7 @@ const CardContentWithVirtualMachines = (props: VirtualMachineProps) =>
     </Grid>;
 
 const virtualMachinesTable = (props: VirtualMachineProps) =>
-    <Table>
+    <Table data-cy="vm-admin-table">
         <TableHead>
             <TableRow>
                 <TableCell>Uuid</TableCell>
@@ -109,7 +109,7 @@ const virtualMachinesTable = (props: VirtualMachineProps) =>
             </TableRow>
         </TableHead>
         <TableBody>
-            {props.logins.items.length > 0 && props.virtualMachines.items.map((machine, index) =>
+            {props.virtualMachines.items.map((machine, index) =>
                 <TableRow key={index}>
                     <TableCell><ResourceUuid uuid={machine.uuid} /></TableCell>
                     <TableCell><VirtualMachineHostname uuid={machine.uuid} /></TableCell>
diff --git a/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx b/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx
index 091a8198..d0ee5634 100644
--- a/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx
+++ b/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx
@@ -172,7 +172,7 @@ const virtualMachineSendRequest = (props: VirtualMachineProps) =>
     </span>;
 
 const virtualMachinesTable = (props: VirtualMachineProps) =>
-    <Table>
+    <Table data-cy="vm-user-table">
         <TableHead>
             <TableRow>
                 <TableCell>Host name</TableCell>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list