Giter VIP home page Giter VIP logo

cypress-2f-authentication-sms-twillio's Introduction

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


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

cypress-2f-authentication-sms-twillio's People

Contributors

ebazhanov avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

gummiebearz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.