Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress 9.6.0- Unable to login to applications via Github using cy.origin #21363

Closed
mohinid opened this issue May 6, 2022 · 4 comments · Fixed by #22320
Closed

Cypress 9.6.0- Unable to login to applications via Github using cy.origin #21363

mohinid opened this issue May 6, 2022 · 4 comments · Fixed by #22320
Assignees
Labels
topic: cy.origin Problems or enhancements related to cy.origin command type: bug

Comments

@mohinid
Copy link

mohinid commented May 6, 2022

Current behavior

I am trying to use cy.origin to login to CircleCi(https://circleci.com/vcs-authorize/). Also, have 2Factor disabled on my GitHub Id. My login is successful and authorized via GitHub but after then it is failing to redirect me to the CircleCi dashboard(https://app.circleci.com/).

A similar issue is happening on Netlify. I am able to login to github from cy.origin but then it is not redirecting me to the netlify home page(https://app.netlify.com/).

I am trying to replicate what is mentioned in the cypress blog. It is mentioned that cy.origin can be used for third part login such as Auth0 and Github. I need your investigation.

https://cypress.io/blog/2022/04/25/cypress-9-6-0-easily-test-multi-domain-workflows-with-cy-origin/
Screenshot 2022-05-05 at 6 12 14 PM

Screenshot 2022-05-05 at 6 18 33 PM

Desired behavior

After successful login from Github, user should be redirected to the application under test.

Test code to reproduce

describe("Test visiting multiple domains in single test", () => 

  it("should login to circle ci with github", () => {
    //visit circleci login page
    cy.visit("https://circleci.com/vcs-authorize/");

    //click on sign in link
    cy.contains("Log In with GitHub").click({ force: true });

    //click on 'login with Github' button
    cy.origin("https://github.com", () => {
      cy.get("#login_field").type("************");
      cy.get("#password").type("********");
      cy.get("input").contains("Sign in").click();
    });

    // should load circleci app with logged in user
    cy.url().should("contain", "https://app.circleci.com/");
  });

  it("should login to netlify with github", () => {
    //visit netlify
    cy.visit("https://www.netlify.com/");
    
    // click on menu option
    cy.get(".icon-hamburger").click({ force: true });

    //click on login 
    cy.contains("Log in").click({ force: true });
   
    //click on 'login with Github' button
    cy.contains("GitHub").click({ force: true });

    //enter login credentials for github
    cy.origin("https://github.com", () => {
      cy.get("#login_field").type("************");
      cy.get("#password").type("********");
      cy.get("input").contains("Sign in").click();
      cy.wait(10000);
    });

    // should load netlify app with logged in user
    cy.url().should("contain", "https://app.netlify.com/");
  });
});

Cypress Version

9.6.0

Other

No response

@cypress-bot cypress-bot bot added the stage: investigating Someone from Cypress is looking into this label May 6, 2022
@mjhenkes mjhenkes self-assigned this May 6, 2022
@mjhenkes
Copy link
Member

mjhenkes commented May 6, 2022

@mohinid, thanks for logging this and providing the test cases. Based on my preliminary digging, I think there is an issue with cookie. Specifically when run in cypress the https://circleci.com/api/v1/me api call fails with a 401 unauthorized, looking at the cookies, it appears for the ring-session cookie we set samesite to none when run in cypress but it is unset outside of cypress. This may be fixed by #20685.

I also verified that this does run successfully in firefox.

@cypress-bot cypress-bot bot added stage: routed to e2e-auth and removed stage: investigating Someone from Cypress is looking into this labels May 6, 2022
@mjhenkes mjhenkes removed their assignment May 6, 2022
@mohinid
Copy link
Author

mohinid commented May 7, 2022

Thanks, @mjhenkes for acknowledging. Will wait for the fix on chrome, electron, and edge.
I have also verified that it works fine on firefox.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 23, 2022

The code for this is done in cypress-io/cypress#22320, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 28, 2022

Released in 10.3.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v10.3.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 28, 2022
@emilyrohrbough emilyrohrbough added the topic: cy.origin Problems or enhancements related to cy.origin command label Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: cy.origin Problems or enhancements related to cy.origin command type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants