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

multiple domain exceptions with 2nd level sub domains #1175

Closed
datpham23 opened this issue Jan 9, 2018 · 6 comments
Closed

multiple domain exceptions with 2nd level sub domains #1175

datpham23 opened this issue Jan 9, 2018 · 6 comments
Milestone

Comments

@datpham23
Copy link

datpham23 commented Jan 9, 2018

Is this a Feature or Bug?

Bug

Current behavior:

I want to test an app deployed at https://apphost.lab.domain.com.

  1. When visiting my app https://apphost.lab.domain.com i'm redirected to an internal single sign on (SSO) at https://sso-host.dc1.domain.com
  2. I log in and then i'm redirected back to my app https://apphost.lab.domain.com.
  3. When I issue the command cy.visit('/some-path') I run into the multiple domain exceptions.

"...The previous domain you visited was: 'https://sso-host.dc1.domain.com'
You're attempting to visit this new domain: 'https://apphost.lab.domain.com' ..."

Desired behavior:

Should be able to issue cy.visit('/some-path') without exception.

How to reproduce:

Test code:

cypress.json
{
  "baseUrl" : "https://apphost.lab.domain.com/"
}

describe('Test', ()=>{
  before(()=>{
    cy.visit('/');
   //Redirected to single sign on page
    cy.get('#username').clear().type(Cypress.env('userName'));
    cy.get('#password').clear().type(Cypress.env('userPassword'));
    cy.get('#submit').click();
   //after logging in i'm redirected to my app at https://apphost.lab.domain.com/
  });

  it('show /my-page', ()=>{
    cy.visit('/my-page');  //exception occurs
  });

Additional Info (images, stack traces, etc)

Even though the sso host and app host is in the same sub domain i'm still seeing the multiple super domain exception.
Ideally we should just allow multiple super domains. Due to how our SSO work we can only be authenticated going through the browser, we can't simply make cy.request() to grab the token/cookie and manually set it our session.

@brian-mann
Copy link
Member

The subdomain parsing is the same problem as this here: #802

So it would just "work" once we fix that issue.

As for the cy.request not working I am very curious. It's impossible for a webserver to know where traffic is coming from. In order to try to distinguish traffic it can only look at the headers of a request.

So whatever that is - you can just set in cy.request itself.

Have you actually tried this yet? Because cy.request already sets the User Agent of the browser you're running. In other words - it'll look pretty damn close to what naturally comes from the browser anyway.

@brian-mann
Copy link
Member

Also related to #600

brian-mann added a commit that referenced this issue Feb 4, 2018
…sing tld, handle multiple different subdomains on cy.visit
@brian-mann brian-mann added this to the 1.4.2 milestone Feb 4, 2018
@brian-mann
Copy link
Member

brian-mann commented Feb 5, 2018

Released in 1.4.2.

@datpham23
Copy link
Author

Still facing this issue with version 2.1.0.

You may only visit a single unique domain per test.
Different subdomains are okay, but unique domains are not.

The previous domain you visited was: 'https://single-signon.corp.company.com'
You're attempting to visit this new domain: 'https://app-host.company.com'

@haiquan
Copy link

haiquan commented Aug 21, 2019

Still facing this issue with version 3.3.1.

CypressError: cy.visit() failed because you are attempting to visit a second unique domain.
You may only visit a single unique domain per test.
Different subdomains are okay, but unique domains are not.
The previous domain you visited was: 'http://azureinteractives.azurewebsites.net/'
You're attempting to visit this new domain: 'https://vsfutures.azurewebsites.net/'
You may need to restructure some of your code to prevent this from happening.
https://on.cypress.io/cannot-visit-second-unique-domain

@jennifer-shehane
Copy link
Member

This issue will be closed to further comment as the exact issue here was resolved and tested.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Jan 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants