From 66182361ee7cafc2dc579549705567ff1a5e70bf Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 17 Nov 2023 15:02:33 +0000 Subject: [PATCH] initial skeleton Signed-off-by: Sam --- .../integration/plugins/security/auth_spec.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/cypress/integration/plugins/security/auth_spec.js b/cypress/integration/plugins/security/auth_spec.js index ffe9ceedd..ce124286b 100644 --- a/cypress/integration/plugins/security/auth_spec.js +++ b/cypress/integration/plugins/security/auth_spec.js @@ -9,6 +9,47 @@ import { } from '../../../utils/constants'; if (Cypress.env('SECURITY_ENABLED')) { + + describe('OpenSearch Dashboards Security Plugin - User Creation', () => { + const username = 'newuser'; + const password = 'newpassword'; + + beforeEach(() => { + // Visit the OpenSearch Dashboards login page + cy.visit('/'); + + // Login as admin + cy.get('input[name="username"]').type(Cypress.env('username')); + cy.get('input[name="password"]').type(Cypress.env('password'), { log: false }); + cy.get('button[type="submit"]').click(); + + // Wait for the OpenSearch Dashboards home page to load + cy.contains('Welcome to OpenSearch Dashboards', { timeout: 60000 }).should('be.visible'); + }); + + it('should create a new internal user', () => { + // Navigate to Security/Internal User Database section + cy.visit('/app/security-dashboards#/users'); + + // Click on 'Add internal user' button + cy.get('button').contains('Add internal user').click(); + + // Provide username and password for the new user + cy.get('input[data-test-subj="user-name"]').type(username); + cy.get('input[data-test-subj="password"]').type(password); + cy.get('input[data-test-subj="password-confirmation"]').type(password); + + // Optionally add backend role and user attribute + // Skipping as per the instruction [No backend role] + + // Submit the form to create the user + cy.get('button').contains('Submit').click(); + + // Verify that the user is created + cy.contains(username).should('exist'); + }); + }); + describe('Authc and Authz page', () => { // start a server so that server responses can be mocked via fixtures // in all of the below test cases