Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ebazhanov/cypress-2f-authentication-sms-twillio
An example of how to access SMS for 2F authentication using Cypress automation
https://github.com/ebazhanov/cypress-2f-authentication-sms-twillio
Last synced: 26 days ago
JSON representation
An example of how to access SMS for 2F authentication using Cypress automation
- Host: GitHub
- URL: https://github.com/ebazhanov/cypress-2f-authentication-sms-twillio
- Owner: Ebazhanov
- Created: 2021-11-17T19:57:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-19T17:45:12.000Z (over 3 years ago)
- Last Synced: 2025-01-22T14:54:32.865Z (30 days ago)
- Language: JavaScript
- Homepage:
- Size: 52.7 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
Twilio + Cypress
--
> Get verification SMS and send it via Cypress automation framework#### To make it work don't forget to replace accountSid, authToken (twilio.com) and email, pass from github account
-----
```js
const accountSid = 'AC793683c4982a14f01714321bd3f90ca7';
const authToken = '819068e54369ac58bb8aad976fa517bc';
const githubEmail = 'your_github_email'
const githubPassword = 'your_github_password'describe('Login with github credentials', () => {
beforeEach(()=>{
cy.visit('https://github.com/login');
cy.get('#login_field').type(githubEmail);
cy.get('#password').type(githubPassword);
cy.get('input[type="submit"]').click()
})
it('Get SMS and apply it in 2FA form', () => {
cy.request({
method: 'GET',
url: `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages.json`,
auth: {
username: accountSid,
password: authToken,
AuthMethod: 'BasicAuth',
}
})
.its('body').then((res) => {
cy.wait(1500) //wait for SMS
const otpcode = res.messages[0].body.substring(0, 6)
cy.get('#otp').type(otpcode);
cy.url().should('eq', 'https://github.com/');
})
});
});
```## TODO
- try https://mailosaur.com/docs/frameworks-and-tools/cypress/
- compare [twillio](https://www.twilio.com/docs/verify/quickstarts/node-express) vs mailosaur