From 6d9beff826e98d30fe3b8bbdde5085fcc986bb60 Mon Sep 17 00:00:00 2001 From: Kersom <9053044+nixocio@users.noreply.github.com> Date: Thu, 11 Jul 2024 13:48:41 -0400 Subject: [PATCH] Update a few tests (#2682) --- .../notifiers/notifiersTabs.cy.ts | 1 - cypress/e2e/awx/resources/credentials.cy.ts | 546 +++++++----------- .../resources/projects/project-details.cy.ts | 1 - 3 files changed, 219 insertions(+), 329 deletions(-) diff --git a/cypress/e2e/awx/administration/notifiers/notifiersTabs.cy.ts b/cypress/e2e/awx/administration/notifiers/notifiersTabs.cy.ts index 0e55db94ed..00dccfa2a3 100644 --- a/cypress/e2e/awx/administration/notifiers/notifiersTabs.cy.ts +++ b/cypress/e2e/awx/administration/notifiers/notifiersTabs.cy.ts @@ -71,7 +71,6 @@ describe('Notifications', () => { }); tag(['upstream'], () => { - //these tests will not function in a downstream build describe('Notifications Tab for Organizations', () => { const orgName = randomE2Ename(); diff --git a/cypress/e2e/awx/resources/credentials.cy.ts b/cypress/e2e/awx/resources/credentials.cy.ts index c0669a53ff..ec068f876a 100644 --- a/cypress/e2e/awx/resources/credentials.cy.ts +++ b/cypress/e2e/awx/resources/credentials.cy.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import { randomString } from '../../../../framework/utils/random-string'; import { Credential } from '../../../../frontend/awx/interfaces/Credential'; import { Inventory } from '../../../../frontend/awx/interfaces/Inventory'; @@ -6,34 +7,29 @@ import { Project } from '../../../../frontend/awx/interfaces/Project'; import { Team } from '../../../../frontend/awx/interfaces/Team'; import { AwxUser } from '../../../../frontend/awx/interfaces/User'; import { awxAPI } from '../../../support/formatApiPathForAwx'; -import { randomE2Ename } from '../../../support/utils'; import { tag } from '../../../support/tag'; +import { randomE2Ename } from '../../../support/utils'; describe('Credentials', () => { - let user: AwxUser; - let project: Project; let awxOrganization: Organization; - let credential: Credential; + let project: Project; - before(function () { - cy.createAwxOrganization().then((thisAwxOrg) => { - awxOrganization = thisAwxOrg; + before(() => { + cy.createAwxOrganization().then((org) => { + awxOrganization = org; cy.createAwxProject(awxOrganization).then((proj) => { project = proj; - cy.createAwxUser({ organization: awxOrganization.id }).then((testUser) => { - user = testUser; - }); }); }); }); after(() => { cy.deleteAwxProject(project, { failOnStatusCode: false }); - cy.deleteAwxUser(user, { failOnStatusCode: false }); cy.deleteAwxOrganization(awxOrganization, { failOnStatusCode: false }); }); describe('Credentials: List View', () => { + let credential: Credential; beforeEach(() => { cy.createAWXCredential({ kind: 'machine', @@ -43,7 +39,6 @@ describe('Credentials', () => { credential = cred; }); }); - afterEach(() => { cy.deleteAwxCredential(credential, { failOnStatusCode: false }); }); @@ -129,6 +124,7 @@ describe('Credentials', () => { }); describe('Credentials: Details View', () => { + let credential: Credential; beforeEach(() => { cy.createAWXCredential({ name: 'E2E Credential ' + randomString(4), @@ -144,8 +140,7 @@ describe('Credentials', () => { afterEach(() => { cy.deleteAwxCredential(credential, { failOnStatusCode: false }); }); - - it('renders the details page boolean field', () => { + it('details page should render boolean field', () => { const credentialName = 'E2E Credential ' + randomString(4); cy.navigateTo('awx', 'credentials'); cy.clickButton(/^Create credential$/); @@ -265,6 +260,7 @@ describe('Credentials', () => { }); describe('Credentials Edit: External test modal', () => { + let credential: Credential; before(() => { cy.createAWXCredential({ name: 'E2E Credential ' + randomString(4), @@ -321,314 +317,208 @@ describe('Credentials', () => { cy.clickButton(/^Cancel/); }); }); +}); - describe('Create Credentials of different types', () => { - type MockCredentialData = { - name: string; - required?: Array<{ field: string; dataCy: string }>; - fields?: Array<{ id: string; value: string; dataCy: string }>; - }; - - // FLAKY_06_13_2024 - it('can create credentials with 30 different credential types', function () { - cy.fixture('credentialsTestData').as('createCredentials'); - cy.get('@createCredentials').then((fixture) => { - const credentialTypes = fixture as unknown as MockCredentialData[]; - cy.intercept('GET', awxAPI`/credential_types/?page=1&page_size=200`).as( - 'getCredentialTypes' - ); - cy.navigateTo('awx', 'credentials'); - credentialTypes.forEach((item) => { - const credentialName = `E2E Credential ${randomE2Ename()}`; - cy.getByDataCy('create-credential').click(); - cy.verifyPageTitle('Create Credential'); - cy.getByDataCy('name').should('be.visible').type(credentialName); - cy.wait('@getCredentialTypes').then(() => { - cy.singleSelectByDataCy('credential_type', `${item.name}`, true); - if (Array.isArray(item.required)) { - (item.required as { field: string; dataCy: string }[]).forEach((credentialType) => { - switch (item.name) { - case 'HashiCorp Vault Secret Lookup': - cy.get(`[data-cy="${credentialType.dataCy}"]`).type(`${credentialType.field}`); - cy.selectDropdownOptionByResourceName('api-version', 'v1'); - break; - case 'Ansible Galaxy/Automation Hub API Token': - cy.singleSelectByDataCy('organization', awxOrganization.name); - cy.get(`[data-cy="${credentialType.dataCy}"]`).type(`${credentialType.field}`); - break; - case 'GPG Public Key': - cy.get('#gpg-public-key').type(`${credentialType.field}`); - break; - case 'Terraform backend configuration': - cy.get('[data-cy="configuration-form-group"]').type(`${credentialType.field}`); - break; - default: - cy.get(`[data-cy="${credentialType.dataCy}"]`).type(`${credentialType.field}`); - } - }); - } - cy.intercept('POST', awxAPI`/credentials/`).as('created'); - cy.getByDataCy('Submit').click(); - cy.wait('@created'); - cy.verifyPageTitle(credentialName); - cy.clickPageAction('delete-credential'); - cy.get('#confirm').click(); - cy.clickButton(/^Delete credential/); - cy.verifyPageTitle('Credentials'); - }); - }); - }); - }); - - describe('Credentials: Credential Types Tests', () => { - it('can create credential using custom credential type', () => { - cy.createAwxCredentialType().then((credType) => { - const credentialName = 'E2E Credential ' + randomString(4); - cy.navigateTo('awx', 'credentials'); - cy.clickButton(/^Create credential$/); - cy.getByDataCy('name').type(credentialName); - cy.singleSelectBy('[data-cy="credential_type"]', credType.name, true); - cy.clickButton(/^Create credential$/); - cy.verifyPageTitle(credentialName); - cy.getByDataCy('name').contains(credentialName); - //delete created credential - cy.clickPageAction('delete-credential'); - cy.get('#confirm').click(); - cy.clickButton(/^Delete credential/); - cy.verifyPageTitle('Credentials'); - cy.deleteAwxCredentialType(credType); - }); - }); - - it('cannot edit vault id field for Vault credential type', () => { - const credentialName = 'E2E Credential ' + randomString(4); - cy.navigateTo('awx', 'credentials'); - cy.clickButton(/^Create credential$/); - cy.getByDataCy('name').type(credentialName); - cy.singleSelectBy('[data-cy="credential_type"]', 'Vault', true); - cy.contains('Type Details').should('be.visible'); - cy.getByDataCy('vault-password').type('password'); - cy.getByDataCy('vault-id').type('id'); - cy.singleSelectByDataCy('organization', awxOrganization.name); - cy.clickButton(/^Create credential$/); - cy.verifyPageTitle(credentialName); - cy.getByDataCy('name').contains(credentialName); - cy.contains('Vault Identifier').should('be.visible'); - cy.getByDataCy('vault-identifier').contains('id'); - cy.contains('Vault Password').should('be.visible'); - cy.getByDataCy('vault-password').contains('Encrypted'); - cy.getByDataCy('edit-credential').click(); - cy.verifyPageTitle('Edit Credential'); - cy.get('[data-cy="vault-password"]').then(($pwd) => { - cy.wrap($pwd).should('have.value', 'ENCRYPTED'); - }); - cy.getByDataCy('ask_vault_password').check(); - cy.clickButton(/^Save credential$/); - cy.getByDataCy('name').contains(credentialName); - cy.contains('Vault Identifier').should('be.visible'); - cy.getByDataCy('vault-identifier').contains('id'); - cy.contains('Vault Password').should('be.visible'); - cy.getByDataCy('vault-password').contains('Prompt on launch'); - //delete created credential - cy.clickPageAction('delete-credential'); - cy.get('#confirm').click(); - cy.clickButton(/^Delete credential/); - cy.verifyPageTitle('Credentials'); - }); - }); +describe('Credentials: Credential Types Tests', () => { + let organization: Organization; + beforeEach(() => { + cy.createAwxOrganization().then((o) => (organization = o)); }); - - describe('Credentials: Sub Form Testing', () => { - it('can create and delete a credential that renders a sub form', () => { - const credentialName = 'E2E Credential ' + randomString(4); - cy.navigateTo('awx', 'credentials'); - cy.clickButton(/^Create credential$/); - cy.getByDataCy('name').type(credentialName); - cy.singleSelectByDataCy('credential_type', 'Amazon Web Services'); - cy.contains('Type Details').should('be.visible'); - cy.singleSelectByDataCy('organization', awxOrganization.name); - cy.getByDataCy('username').type('username'); - cy.getByDataCy('password').type('password'); - cy.getByDataCy('security-token').type('security-token'); - cy.getByDataCy('description').type('description'); - cy.intercept('POST', awxAPI`/credentials/`).as('newCred'); - cy.clickButton(/^Create credential$/); - cy.wait('@newCred') - .its('response.body') - .then((newCred: Credential) => { - cy.getByDataCy('name').contains(credentialName); - cy.getByDataCy('label-credential-type').contains('Credential type'); - cy.getByDataCy('credential-type').contains('Amazon Web Services'); - cy.getByDataCy('label-access-key').contains('Access Key'); - cy.getByDataCy('access-key').contains('username'); - cy.getByDataCy('label-secret-key').contains('Secret Key'); - cy.getByDataCy('secret-key').contains('Encrypted'); - cy.getByDataCy('label-sts-token').contains('STS Token'); - cy.getByDataCy('label-organization').contains('Organization'); - cy.getByDataCy('organization').contains(awxOrganization.name); - cy.getByDataCy('label-description').contains('Description'); - cy.getByDataCy('description').contains('description'); - cy.getByDataCy('edit-credential').click(); - cy.verifyPageTitle('Edit Credential'); - const ModifiedCredentialName = credentialName + ' - edited'; - cy.getByDataCy('name').type(ModifiedCredentialName); - cy.get('input[data-cy="username"]').then(($username) => { - cy.wrap($username).should('have.value', 'username'); - }); - cy.get('input[data-cy="password"]').then(($pwd) => { - cy.wrap($pwd).should('have.value', 'ENCRYPTED'); - }); - cy.get('input[data-cy="security-token"]').then(($token) => { - cy.wrap($token).should('have.value', 'ENCRYPTED'); - }); - const newDescription = 'new description'; - cy.getByDataCy('description').clear().type(newDescription); - cy.clickButton(/^Save credential$/); - cy.getByDataCy('name').contains(ModifiedCredentialName); - cy.getByDataCy('label-credential-type').contains('Credential type'); - cy.getByDataCy('credential-type').contains('Amazon Web Services'); - cy.getByDataCy('label-access-key').contains('Access Key'); - cy.getByDataCy('access-key').contains('username'); - cy.getByDataCy('label-secret-key').contains('Secret Key'); - cy.getByDataCy('secret-key').contains('Encrypted'); - cy.getByDataCy('label-sts-token').contains('STS Token'); - cy.getByDataCy('sts-token').contains('Encrypted'); - cy.getByDataCy('label-description').contains('Description'); - cy.getByDataCy('description').contains(newDescription); - cy.clickPageAction('delete-credential'); - cy.get('#confirm').click(); - cy.intercept('DELETE', awxAPI`/credentials/${newCred.id.toString()}/`).as('deleted'); - cy.clickButton(/^Delete credential/); - cy.wait('@deleted') - .its('response') - .then((deleted) => { - expect(deleted?.statusCode).to.eql(204); - cy.verifyPageTitle('Credentials'); - }); - }); - }); - - it.skip('can edit credential type that renders a sub form', () => { - const credentialName = 'E2E Credential ' + randomString(4); - cy.navigateTo('awx', 'credentials'); - cy.clickButton(/^Create credential$/); - cy.get('[data-cy="name"]').type(credentialName); - cy.singleSelectBy('[data-cy="credential_type"]', 'Amazon Web Services'); - cy.contains('Type Details').should('be.visible'); - cy.get('[data-cy="username"]').type('username'); - cy.get('[data-cy="password"]').type('password'); - cy.get('[data-cy="security-token"]').type('security-token'); - cy.get('[data-cy="description"]').type('description'); - cy.singleSelectByDataCy('organization', awxOrganization.name); - cy.clickButton(/^Create credential$/); - cy.verifyPageTitle(credentialName); - cy.get('[data-cy="name"]').contains(credentialName); - cy.contains('Access Key').should('be.visible'); - cy.get('[data-cy="access-key"]').contains('username'); - cy.contains('Secret Key').should('be.visible'); - cy.get('[data-cy="secret-key"]').contains('Encrypted'); - cy.contains('Organization').should('be.visible'); - cy.contains(awxOrganization.name); - cy.get('[data-cy="edit-credential"]').click(); - cy.verifyPageTitle('Edit Credential'); - const ModifiedCredentialName = credentialName + ' - edited'; - cy.get('[data-cy="name"]').type(ModifiedCredentialName); - cy.get('[data-cy="username"]').should('be.visible'); - cy.get('[data-cy="username"]').then(($input) => { - expect($input.val()).to.eq('username'); - }); - cy.get('[data-cy="password"]').should('be.visible'); - cy.get('[data-cy="password"]').then(($input) => { - expect($input.val()).to.eq('ENCRYPTED'); - }); - cy.get('[data-cy="security-token"]').should('be.visible'); - cy.get('[data-cy="security-token"]').then(($input) => { - expect($input.val()).to.eq('ENCRYPTED'); - }); - const newDescription = 'new description'; - cy.get('[data-cy="description"]').clear().type(newDescription); - cy.clickButton(/^Save credential$/); - cy.get('[data-cy="name"]').contains(ModifiedCredentialName); - cy.contains(ModifiedCredentialName).should('be.visible'); - cy.contains('Access Key').should('be.visible'); - cy.get('[data-cy="access-key"]').contains('username'); - cy.contains('Secret Key').should('be.visible'); - cy.get('[data-cy="secret-key"]').contains('Encrypted'); - cy.get('[data-cy="sts-token"]').contains('Encrypted'); - cy.contains('Organization').should('be.visible'); - cy.contains('Description').should('be.visible'); - cy.get('[data-cy="description"]').contains(newDescription); - cy.clickPageAction('delete-credential'); - cy.get('#confirm').click(); - cy.clickButton(/^Delete credential/); - cy.verifyPageTitle('Credentials'); - }); + afterEach(() => { + cy.deleteAwxOrganization(organization); }); - describe('Credentials: Miscellaneous Testing', () => { - it('can create/edit a credential using prompt on launch', () => { + it('can create credential using custom credential type', () => { + cy.createAwxCredentialType().then((credType) => { const credentialName = 'E2E Credential ' + randomString(4); cy.navigateTo('awx', 'credentials'); cy.clickButton(/^Create credential$/); cy.getByDataCy('name').type(credentialName); - cy.singleSelectByDataCy('organization', awxOrganization.name); - cy.singleSelectBy('[data-cy="credential_type"]', 'Machine'); - cy.contains('Type Details').should('be.visible'); - cy.getByDataCy('ask_password').check(); - cy.getByDataCy('ask_ssh_key_unlock').check(); + cy.singleSelectBy('[data-cy="credential_type"]', credType.name, true); cy.clickButton(/^Create credential$/); cy.verifyPageTitle(credentialName); cy.getByDataCy('name').contains(credentialName); - cy.contains('Private Key Passphrase').should('be.visible'); - cy.getByDataCy('private-key-passphrase').contains('Prompt on launch'); - cy.contains('Password').should('be.visible'); - cy.getByDataCy('password').contains('Prompt on launch'); - cy.getByDataCy('edit-credential').click(); - cy.verifyPageTitle('Edit Credential'); - cy.getByDataCy('ask_password').uncheck(); - cy.getByDataCy('password').type('password'); - cy.clickButton(/^Save credential$/); - cy.contains('Password').should('be.visible'); - cy.getByDataCy('password').contains('Encrypted'); - cy.contains('Private Key Passphrase').should('be.visible'); - cy.getByDataCy('private-key-passphrase').contains('Prompt on launch'); + //delete created credential cy.clickPageAction('delete-credential'); cy.get('#confirm').click(); cy.clickButton(/^Delete credential/); cy.verifyPageTitle('Credentials'); + cy.deleteAwxCredentialType(credType); }); + }); - it('should render privilege escalation for machine credential type', () => { - // This is a test for the custom component that renders the privilege - // escalation method using a custom component - const credentialName = 'E2E Credential ' + randomString(4); - cy.navigateTo('awx', 'credentials'); - cy.clickButton(/^Create credential$/); - cy.getByDataCy('name').type(credentialName); - cy.singleSelectByDataCy('organization', awxOrganization.name); - cy.singleSelectBy('[data-cy="credential_type"]', 'Machine'); - cy.contains('Type Details').should('be.visible'); - // Use custom component to render the privilege escalation method is sudo - cy.contains('Privilege Escalation Method ').should('be.visible'); - cy.get('button[aria-label="Options menu"]').click(); - cy.getByDataCy('select-option-sudo').click(); - cy.clickButton(/^Create credential$/); - cy.verifyPageTitle(credentialName); - cy.getByDataCy('name').contains(credentialName); - cy.contains('Privilege Escalation Method').should('be.visible'); - cy.getByDataCy('privilege-escalation-method').contains('sudo'); - cy.clickPageAction('delete-credential'); - cy.get('#confirm').click(); - cy.clickButton(/^Delete credential/); - cy.verifyPageTitle('Credentials'); + it('cannot edit vault id for Vault credential type', () => { + const credentialName = 'E2E Credential ' + randomString(4); + cy.navigateTo('awx', 'credentials'); + cy.clickButton(/^Create credential$/); + cy.getByDataCy('name').type(credentialName); + cy.singleSelectBy('[data-cy="credential_type"]', 'Vault', true); + cy.contains('Type Details').should('be.visible'); + cy.getByDataCy('vault-password').type('password'); + cy.getByDataCy('vault-id').type('id'); + cy.singleSelectByDataCy('organization', organization.name); + cy.clickButton(/^Create credential$/); + cy.verifyPageTitle(credentialName); + cy.getByDataCy('name').contains(credentialName); + cy.contains('Vault Identifier').should('be.visible'); + cy.getByDataCy('vault-identifier').contains('id'); + cy.contains('Vault Password').should('be.visible'); + cy.getByDataCy('vault-password').contains('Encrypted'); + cy.getByDataCy('edit-credential').click(); + cy.verifyPageTitle('Edit Credential'); + cy.get('[data-cy="vault-password"]').then(($pwd) => { + cy.wrap($pwd).should('have.value', 'ENCRYPTED'); }); + cy.getByDataCy('ask_vault_password').check(); + cy.clickButton(/^Save credential$/); + cy.getByDataCy('name').contains(credentialName); + cy.contains('Vault Identifier').should('be.visible'); + cy.getByDataCy('vault-identifier').contains('id'); + cy.contains('Vault Password').should('be.visible'); + cy.getByDataCy('vault-password').contains('Prompt on launch'); + //delete created credential + cy.clickPageAction('delete-credential'); + cy.get('#confirm').click(); + cy.clickButton(/^Delete credential/); + cy.verifyPageTitle('Credentials'); }); - describe('Credentials Tabbed View - Job Templates', () => { - let machineCredential: Credential; - let awxInventory: Inventory; + it('can create, edit and delete a credential that renders a sub form', () => { + const credentialName = 'E2E Credential ' + randomString(4); + cy.navigateTo('awx', 'credentials'); + cy.clickButton(/^Create credential$/); + cy.getByDataCy('name').type(credentialName); + cy.singleSelectByDataCy('credential_type', 'Amazon Web Services'); + cy.contains('Type Details').should('be.visible'); + cy.singleSelectByDataCy('organization', organization.name); + cy.getByDataCy('username').type('username'); + cy.getByDataCy('password').type('password'); + cy.getByDataCy('security-token').type('security-token'); + cy.getByDataCy('description').type('description'); + cy.intercept('POST', awxAPI`/credentials/`).as('newCred'); + cy.clickButton(/^Create credential$/); + cy.wait('@newCred') + .its('response.body') + .then((newCred: Credential) => { + cy.getByDataCy('name').contains(credentialName); + cy.getByDataCy('label-credential-type').contains('Credential type'); + cy.getByDataCy('credential-type').contains('Amazon Web Services'); + cy.getByDataCy('label-access-key').contains('Access Key'); + cy.getByDataCy('access-key').contains('username'); + cy.getByDataCy('label-secret-key').contains('Secret Key'); + cy.getByDataCy('secret-key').contains('Encrypted'); + cy.getByDataCy('label-sts-token').contains('STS Token'); + cy.getByDataCy('label-organization').contains('Organization'); + cy.getByDataCy('organization').contains(organization.name); + cy.getByDataCy('label-description').contains('Description'); + cy.getByDataCy('description').contains('description'); + cy.getByDataCy('edit-credential').click(); + cy.verifyPageTitle('Edit Credential'); + const ModifiedCredentialName = credentialName + ' - edited'; + cy.getByDataCy('name').type(ModifiedCredentialName); + cy.get('input[data-cy="username"]').then(($username) => { + cy.wrap($username).should('have.value', 'username'); + }); + cy.get('input[data-cy="password"]').then(($pwd) => { + cy.wrap($pwd).should('have.value', 'ENCRYPTED'); + }); + cy.get('input[data-cy="security-token"]').then(($token) => { + cy.wrap($token).should('have.value', 'ENCRYPTED'); + }); + const newDescription = 'new description'; + cy.getByDataCy('description').clear().type(newDescription); + cy.clickButton(/^Save credential$/); + cy.getByDataCy('name').contains(ModifiedCredentialName); + cy.getByDataCy('label-credential-type').contains('Credential type'); + cy.getByDataCy('credential-type').contains('Amazon Web Services'); + cy.getByDataCy('label-access-key').contains('Access Key'); + cy.getByDataCy('access-key').contains('username'); + cy.getByDataCy('label-secret-key').contains('Secret Key'); + cy.getByDataCy('secret-key').contains('Encrypted'); + cy.getByDataCy('label-sts-token').contains('STS Token'); + cy.getByDataCy('sts-token').contains('Encrypted'); + cy.getByDataCy('label-description').contains('Description'); + cy.getByDataCy('description').contains(newDescription); - beforeEach(() => { + cy.clickPageAction('delete-credential'); + cy.get('#confirm').click(); + cy.intercept('DELETE', awxAPI`/credentials/${newCred.id.toString()}/`).as('deleted'); + cy.clickButton(/^Delete credential/); + cy.wait('@deleted') + .its('response') + .then((deleted) => { + expect(deleted?.statusCode).to.eql(204); + cy.verifyPageTitle('Credentials'); + }); + }); + }); + + it('create/edit a credential using prompt on launch', () => { + const credentialName = 'E2E Credential ' + randomString(4); + cy.navigateTo('awx', 'credentials'); + cy.clickButton(/^Create credential$/); + cy.getByDataCy('name').type(credentialName); + cy.singleSelectByDataCy('organization', organization.name); + cy.singleSelectBy('[data-cy="credential_type"]', 'Machine'); + cy.contains('Type Details').should('be.visible'); + cy.getByDataCy('ask_password').check(); + cy.getByDataCy('ask_ssh_key_unlock').check(); + cy.clickButton(/^Create credential$/); + cy.verifyPageTitle(credentialName); + cy.getByDataCy('name').contains(credentialName); + cy.contains('Private Key Passphrase').should('be.visible'); + cy.getByDataCy('private-key-passphrase').contains('Prompt on launch'); + cy.contains('Password').should('be.visible'); + cy.getByDataCy('password').contains('Prompt on launch'); + cy.getByDataCy('edit-credential').click(); + cy.verifyPageTitle('Edit Credential'); + cy.getByDataCy('ask_password').uncheck(); + cy.getByDataCy('password').type('password'); + cy.clickButton(/^Save credential$/); + cy.contains('Password').should('be.visible'); + cy.getByDataCy('password').contains('Encrypted'); + cy.contains('Private Key Passphrase').should('be.visible'); + cy.getByDataCy('private-key-passphrase').contains('Prompt on launch'); + cy.clickPageAction('delete-credential'); + cy.get('#confirm').click(); + cy.clickButton(/^Delete credential/); + cy.verifyPageTitle('Credentials'); + }); + + it('machine credential type should render privilege escalation', () => { + // This is a test for the custom component that renders the privilege + // escalation method using a custom component + const credentialName = 'E2E Credential ' + randomString(4); + cy.navigateTo('awx', 'credentials'); + cy.clickButton(/^Create credential$/); + cy.getByDataCy('name').type(credentialName); + cy.singleSelectByDataCy('organization', organization.name); + cy.singleSelectBy('[data-cy="credential_type"]', 'Machine'); + cy.contains('Type Details').should('be.visible'); + // Use custom component to render the privilege escalation method is sudo + cy.contains('Privilege Escalation Method ').should('be.visible'); + cy.get('button[aria-label="Options menu"]').click(); + cy.getByDataCy('select-option-sudo').click(); + cy.clickButton(/^Create credential$/); + cy.verifyPageTitle(credentialName); + cy.getByDataCy('name').contains(credentialName); + cy.contains('Privilege Escalation Method').should('be.visible'); + cy.getByDataCy('privilege-escalation-method').contains('sudo'); + cy.clickPageAction('delete-credential'); + cy.get('#confirm').click(); + cy.clickButton(/^Delete credential/); + cy.verifyPageTitle('Credentials'); + }); +}); + +describe('Credentials Tabbed View - Job Templates', () => { + let machineCredential: Credential; + let awxOrganization: Organization; + let awxInventory: Inventory; + + beforeEach(() => { + cy.createAwxOrganization().then((awxOrg) => { + awxOrganization = awxOrg; cy.createAWXCredential({ kind: 'machine', organization: awxOrganization.id, @@ -636,43 +526,43 @@ describe('Credentials', () => { }).then((cred) => { machineCredential = cred; }); + cy.createAwxInventory(awxOrganization).then((inv) => { awxInventory = inv; }); }); + }); - afterEach(() => { - cy.deleteAwxCredential(machineCredential, { failOnStatusCode: false }); - cy.deleteAwxInventory(awxInventory, { failOnStatusCode: false }); - }); + afterEach(() => { + cy.deleteAwxCredential(machineCredential, { failOnStatusCode: false }); + cy.deleteAwxInventory(awxInventory, { failOnStatusCode: false }); + cy.deleteAwxOrganization(awxOrganization, { failOnStatusCode: false }); + }); - it('can create a job template within the context of credential job template tab', function () { - const jobTemplateName = `E2E Job Template ${randomE2Ename()}`; - cy.intercept('POST', awxAPI`/job_templates`).as('createJT'); - cy.navigateTo('awx', 'credentials'); - cy.filterTableByMultiSelect('name', [machineCredential.name]); - cy.clickTableRowLink('name', machineCredential.name, { disableFilter: true }); - cy.clickTab('Job Templates', true); - cy.getByDataCy('create-template').click(); - cy.verifyPageTitle('Create Job Template'); - cy.getByDataCy('name').type(jobTemplateName); - cy.selectDropdownOptionByResourceName('inventory', awxInventory.name); - cy.selectDropdownOptionByResourceName('project', `${project.name}`); - cy.selectDropdownOptionByResourceName('playbook', 'hello_world.yml'); - cy.multiSelectByDataCy('credential', [machineCredential.name]); - cy.getByDataCy('Submit').click(); - }); + it('can create a job template within the context of credential job template tab', function () { + const jobTemplateName = `E2E Job Template ${randomE2Ename()}`; + cy.intercept('POST', awxAPI`/job_templates`).as('createJT'); + cy.navigateTo('awx', 'credentials'); + cy.filterTableByMultiSelect('name', [machineCredential.name]); + cy.clickTableRowLink('name', machineCredential.name, { disableFilter: true }); + cy.clickTab('Job Templates', true); + cy.getByDataCy('create-template').click(); + cy.verifyPageTitle('Create Job Template'); + cy.getByDataCy('name').type(jobTemplateName); + cy.selectDropdownOptionByResourceName('inventory', awxInventory.name); + cy.selectDropdownOptionByResourceName('project', `${(this.globalProject as Project).name}`); + cy.selectDropdownOptionByResourceName('playbook', 'hello_world.yml'); + cy.multiSelectByDataCy('credential', [machineCredential.name]); + cy.getByDataCy('Submit').click(); }); }); tag(['upstream'], () => { - //these tests will not work downstream describe('Credentials Tabbed View - Team and User Access', () => { let machineCredential: Credential; let createdAwxUser: AwxUser; let awxOrganization: Organization; let awxTeam: Team; - beforeEach(() => { cy.createAwxOrganization().then((awxOrg) => { awxOrganization = awxOrg; @@ -694,9 +584,9 @@ tag(['upstream'], () => { afterEach(() => { cy.deleteAwxCredential(machineCredential, { failOnStatusCode: false }); + cy.deleteAwxOrganization(awxOrganization, { failOnStatusCode: false }); cy.deleteAwxUser(createdAwxUser, { failOnStatusCode: false }); cy.deleteAwxTeam(awxTeam, { failOnStatusCode: false }); - cy.deleteAwxOrganization(awxOrganization, { failOnStatusCode: false }); }); function removeRoleFromListRow(roleName: string, assignmentType: string) { @@ -714,13 +604,13 @@ tag(['upstream'], () => { }); }); } - - it('can create a new credential, assign a team and apply role(s)', () => { + it('create a new credential, assign a team and apply role(s)', () => { cy.intercept('POST', awxAPI`/role_team_assignments/`).as('teamRoleAssignment'); cy.navigateTo('awx', 'credentials'); cy.filterTableByMultiSelect('name', [machineCredential.name]); cy.clickTableRowLink('name', machineCredential.name, { disableFilter: true }); cy.clickTab('Team Access', true); + cy.getByDataCy('add-roles').click(); cy.verifyPageTitle('Add roles'); cy.getWizard().within(() => { @@ -776,17 +666,19 @@ tag(['upstream'], () => { removeRoleFromListRow('Credential Use', 'team'); }); - it('can create a new credential, assign a user and apply role(s)', () => { + it('create a new credential, assign a user and apply role(s)', () => { cy.intercept('POST', awxAPI`/role_user_assignments/`).as('userRoleAssignment'); cy.navigateTo('awx', 'credentials'); cy.filterTableByMultiSelect('name', [machineCredential.name]); cy.clickTableRowLink('name', machineCredential.name, { disableFilter: true }); cy.clickTab('User Access', true); + cy.getByDataCy('add-roles').click(); cy.verifyPageTitle('Add roles'); cy.getWizard().within(() => { cy.contains('h1', 'Select user(s)').should('be.visible'); cy.selectTableRowByCheckbox('username', createdAwxUser.username); + cy.clickButton(/^Next/); cy.contains('h1', 'Select roles to apply').should('be.visible'); cy.filterTableByTextFilter('name', 'Credential Admin', { diff --git a/cypress/e2e/awx/resources/projects/project-details.cy.ts b/cypress/e2e/awx/resources/projects/project-details.cy.ts index 2c0ab5af67..5406eb9c38 100644 --- a/cypress/e2e/awx/resources/projects/project-details.cy.ts +++ b/cypress/e2e/awx/resources/projects/project-details.cy.ts @@ -274,7 +274,6 @@ describe('Projects', () => { }); }); - // FLAKY_06_13_2024 describe('Projects: Job Templates Tab', () => { let jobTemplate: JobTemplate; let inventory: Inventory;