-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds message share and decryption e2e tests
- Loading branch information
1 parent
6e0a3c2
commit e8a6541
Showing
9 changed files
with
150 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
module.exports = { | ||
fixturesFolder: false, | ||
e2e: { | ||
supportFile: false, | ||
baseUrl: 'http://localhost:8080', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,115 @@ | ||
describe('messages spec', () => { | ||
it('joe can see his message in the list', () => { | ||
cy.visit('/accounts/login') | ||
cy.get('#username').type('joe') | ||
cy.get('#password').type('joe') | ||
cy.get('.btn-primary').click() | ||
cy.contains('footer', 'User: joe').should('be.visible') | ||
|
||
cy.loginJoe() | ||
cy.visit('/messages') | ||
cy.contains('h1', 'Messages').should('be.visible') | ||
cy.get('.message-row').should('have.length', 1) | ||
}) | ||
it('alice does not have messages', () => { | ||
cy.visit('/accounts/login') | ||
cy.get('#username').type('alice') | ||
cy.get('#password').type('alice') | ||
cy.get('.btn-primary').click() | ||
cy.contains('footer', 'User: alice').should('be.visible') | ||
it('joe can share his message with anonymous user', () => { | ||
cy.loginJoe() | ||
|
||
cy.visit('/messages') | ||
cy.contains('h1', 'Messages').should('be.visible') | ||
cy.get('.message-row').should('have.length', 0) | ||
cy.get('.message-row a') | ||
.should('have.attr', 'href') | ||
.then(($href) => { | ||
cy.logout() | ||
cy.visit($href) | ||
|
||
cy.contains('h1', 'Secret message').should('be.visible') | ||
}) | ||
}) | ||
|
||
it('alice creates a message, shares it and annon can decrypt it, then message is deleted', function() { | ||
|
||
cy.loginAlice() | ||
|
||
// create a message | ||
cy.get('.nav-link.messages-new').click() | ||
cy.contains('h3', 'Create new').should('be.visible') | ||
cy.get('#payload').type('foobar') | ||
cy.get('.btn-primary').click() | ||
cy.contains('h5', 'Message securely stored').should('be.visible') | ||
cy.get('.message-pin') | ||
.invoke('text') | ||
.then(parseFloat) | ||
.as('pinval') | ||
cy.get('@pinval').should('be.gte', 100) | ||
cy.get('.message-link').should('have.attr', 'href') | ||
.as('messageHref') | ||
.then(($href) => { | ||
cy.logout() | ||
}) | ||
|
||
cy.get('@messageHref').then($href => { | ||
cy.get('@pinval').then((pinval) => { | ||
cy.enterPin($href, pinval) | ||
}) | ||
}) | ||
|
||
cy.contains('.message-content-decrypted', 'foobar').should('be.visible') | ||
cy.get('input#pin').should('not.exist') | ||
|
||
cy.get('@messageHref') | ||
.then(($href) => { | ||
cy.visit($href, {failOnStatusCode: false}) | ||
cy.contains('h1', '404: Page not found').should('be.visible') | ||
}) | ||
}) | ||
|
||
it('new message gets deleted after unuccessful PIN attempts', function() { | ||
|
||
Cypress.Cookies.debug(true) | ||
|
||
cy.loginAlice() | ||
|
||
// create a message | ||
cy.get('.nav-link.messages-new').click() | ||
cy.contains('h3', 'Create new').should('be.visible') | ||
cy.get('#payload').type('foobar') | ||
cy.get('.btn-primary').click() | ||
cy.contains('h5', 'Message securely stored').should('be.visible') | ||
cy.get('.message-pin') | ||
.invoke('text') | ||
.then(parseFloat) | ||
.as('pinval') | ||
cy.get('@pinval').should('be.gte', 100) | ||
cy.get('.message-link').should('have.attr', 'href') | ||
.as('messageHref') | ||
.then(($href) => { | ||
cy.logout() | ||
}) | ||
|
||
// pin attempt | ||
cy.get('@messageHref').then($href => { | ||
cy.enterPin($href, '0000') | ||
}) | ||
cy.contains('p', 'failed to get a message').should('be.visible') | ||
// pin attempt | ||
cy.get('@messageHref').then($href => { | ||
cy.enterPin($href, '0000') | ||
}) | ||
cy.contains('p', 'failed to get a message').should('be.visible') | ||
// pin attempt | ||
cy.get('@messageHref').then($href => { | ||
cy.enterPin($href, '0000') | ||
}) | ||
cy.contains('p', 'failed to get a message').should('be.visible') | ||
// pin attempt | ||
cy.get('@messageHref').then($href => { | ||
cy.enterPin($href, '0000') | ||
}) | ||
cy.contains('p', 'failed to get a message').should('be.visible') | ||
// pin attempt | ||
cy.get('@messageHref').then($href => { | ||
cy.enterPin($href, '0000') | ||
}) | ||
cy.contains('p', 'failed to get a message').should('be.visible') | ||
// message should have been deleted | ||
cy.get('@messageHref').then($href => { | ||
cy.visit($href, {failOnStatusCode: false}) | ||
cy.contains('h1', '404: Page not found').should('be.visible') | ||
}) | ||
|
||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Cypress.Commands.add('loginJoe', () => { | ||
cy.visit('/accounts/login') | ||
cy.get('#username').type('joe') | ||
cy.get('#password').type('joe') | ||
cy.get('.btn-primary').click() | ||
cy.contains('footer', 'User: joe').should('be.visible') | ||
}) | ||
Cypress.Commands.add('loginAlice', () => { | ||
cy.visit('/accounts/login') | ||
cy.get('#username').type('alice') | ||
cy.get('#password').type('alice') | ||
cy.get('.btn-primary').click() | ||
cy.contains('footer', 'User: alice').should('be.visible') | ||
}) | ||
Cypress.Commands.add('logout', () => { | ||
cy.get('.logout-link').click() | ||
cy.contains('footer', 'User:').should('not.exist') | ||
cy.clearCookies() | ||
}) | ||
Cypress.Commands.add('enterPin', (requestPath, pinval) => { | ||
cy.visit(requestPath) | ||
// somehow csrf cookie value is not correctly set by cypress after "visit" | ||
cy.reload() | ||
cy.contains('h1', 'Secret message').should('be.visible') | ||
cy.get('input#pin').should('be.visible').type(pinval) | ||
cy.get('.btn-primary').click() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters