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

SessionID set-cookie doesn´t work when using electron #5508

Closed
johanneslundin opened this issue Oct 29, 2019 · 3 comments
Closed

SessionID set-cookie doesn´t work when using electron #5508

johanneslundin opened this issue Oct 29, 2019 · 3 comments
Assignees

Comments

@johanneslundin
Copy link

johanneslundin commented Oct 29, 2019

Current behavior:

sessions cookie is not set so not possible to bypass the login screen of my application.

Desired behavior:

Just like when using chrome, i want the sessionID to be set when using electron so i can run in headless

Steps to reproduce: (app code and test code)

Cypress.Commands.add(
  'loginRequest',
  (orgId) => {
    cy.request('POST', 'http://auth.xx.test:4000/oauth/login', {
      email: Cypress.env('email'),
      password: Cypress.env('password'),
      redirectUri: 'http://beta.xx.test:4200',
    }).then(response => {
      cy.request('POST', 'http://auth.xx.test:4000/oauth/token', {
        code: response.body.authorizationCode,
        grantType: 'authorizationCode',
        redirectUri: 'http://beta.xx.test:4200',
      });
    });
  }
);

beforeEach(function () {
    cy.loginRequest(3);
    cy.visit('xx/accounts');
});

No cookies are sent. when using chrome sessionsID was set by the http://auth.xx.test:4000/oauth/token request using set-cookie in the response header but this have stopped working.

image

Versions

Cypress 3.5.0
electron 73

@johanneslundin johanneslundin changed the title SessionID set-cookie doesn´t work SessionID set-cookie doesn´t work when using electron Oct 29, 2019
@jennifer-shehane
Copy link
Member

Hey @johanneslundin, you mentioned but this have stopped working. Are you saying that this previously worked in version 3.4.1? That would be helpful in narrowing down the issue.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Oct 29, 2019
@johanneslundin
Copy link
Author

johanneslundin commented Oct 30, 2019

Hey @johanneslundin, you mentioned but this have stopped working. Are you saying that this previously worked in version 3.4.1? That would be helpful in narrowing down the issue.

Yes, but i just manage to fix it. Previously i didn´t have to specify the domain when i set the cookie but now when i dit, it worked. It did something like this.

Cypress.Commands.add(
  'loginRequest',
  (orgId) => {
    cy.request('POST', 'http://auth.xx.test:4000/oauth/login', {
      email: Cypress.env('email'),
      password: Cypress.env('password'),
      redirectUri: 'http://beta.xx.test:4200',
    }).then(response => {
      cy.request('POST', 'http://auth.xx.test:4000/oauth/token', {
        code: response.body.authorizationCode,
        grantType: 'authorizationCode',
        redirectUri: 'http://beta.xx.test:4200',
      }).then((response)=> {
cy.setCookie(response.headers['set-cookie'][0], {domain:'.xx.test'})
});
    });
  }
);

We can close this issue:)

@flotwig
Copy link
Contributor

flotwig commented Nov 7, 2019

I think this change in behavior will be fixed by #5478.

Though, in 3.5.0, 3.6.0, and #5478, doing cy.setCookie('foo', 'bar') from the domain foo.bar.com always sets the cookie on .bar.com, so I was unable to reproduce the issue @johanneslundin mentions.

Also, @johanneslundin, cy.request() should set the cookie on the browser for you, there should be no need to do the cy.setCookie(). There are some bugs with this in the latest release that will be resolved when #5478 .

Closing for now.

@flotwig flotwig closed this as completed Nov 7, 2019
@jennifer-shehane jennifer-shehane removed the stage: needs information Not enough info to reproduce the issue label Dec 24, 2019
@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants