Skip to content

Commit

Permalink
Cypress/negative test login (#390)
Browse files Browse the repository at this point in the history
* adding wrong login check
* Reconverting test to be skipped in Rancher
* Changing '||' for '&&' to take effect into Rancher
* adding tags
* simplifying condition
  • Loading branch information
mmartin24 authored Oct 9, 2023
1 parent a45bc50 commit f0f6fbc
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions cypress/e2e/unit_tests/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Menu testing', () => {
});


it.skip('Check binaries, version related links and downloads from About menu', { tags: '@menu-4' }, () => {
it('Check binaries, version related links and downloads from About menu', { tags: '@menu-4' }, () => {
// Go to About page
cy.get('.version.text-muted > a').click();
// Check binaries number, download them and chek See All Package page
Expand Down Expand Up @@ -108,41 +108,43 @@ describe('Menu testing', () => {
// Note: this test needs to be adapted for Rancher Dashboard
// Currently we are good if the custom user is unable to login when chart installed over Rancher
// We'd need to apply values.yaml with the users first in Edit YAML
// For this reason we only test it in STD UI for the moment
if (Cypress.env('ui') == null) {
describe('Login with special usernames / passwords', { tags: ['@menu-7', '@smoke'] }, () => {
const userType = new Map([
['user1', ['Hell@World', 'special']],
['user2', ['Hell#@~%/=World', 'several special']],
['user@test', ['Hell@World', 'standard']],
['0123456789', ['password', 'standard']],
]);

for (const [key, value] of userType.entries()) {

it(`Username '${key}' & password with '${value[1]}' characters should log in`, () => {
cy.login(key, value[0])
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
})
};
});
}

describe('Login with special usernames / passwords', () => {
describe('Login with wrong username / password is not allowed and correctly handled', { tags: ['@menu-8', '@smoke'] }, () => {
const userType = new Map([
['user1', ['Hell@World', 'special']],
['user2', ['Hell#@~%/=World', 'several special']],
['user@test', ['Hell@World', 'standard']],
['0123456789', ['password', 'standard']],
['admin', ['wrongpassword', 'standard']],
['baduser', ['password', 'standard']],
]);

for (const [key, value] of userType.entries()) {

if (Cypress.env('ui') == null) {

it(`Username '${key}' & password with '${value[1]}' characters should log in`, () => {
cy.login(key, value[0])
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
})
}

// Login fails when installed from rancher
else if (Cypress.env('ui') == 'epinio-rancher' || Cypress.env('ui') == 'rancher') {
it(`Username '${key}' & password with '${value[1]}' characters should not log in unless values-users.yaml is applied (negative testing)`, () => {
cy.login(key, value[0])
cy.contains('Invalid username or password. Please try again.').should('exist')
cy.exec('echo "Negative testing for users. This user not allowed to log in unless values-users.yaml is applied."')
})
}

else {
throw new Error('ERROR: Variable "ui" is set to an unexpected value.')
}
};
}
);
// Login fails and it is correctly handled
it(`Username '${key}' & password with '${value[1]}' characters should not log in`, () => {
cy.login(key, value[0])
cy.contains('Invalid username or password. Please try again.').should('exist')
}
)
}
});

describe('Dex testing', () => {
it('Check Dex login works with granted access', { tags: '@dex-1' }, () => {
Expand Down

0 comments on commit f0f6fbc

Please sign in to comment.