最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Sample cypress script to bypass SSO - Stack Overflow

programmeradmin1浏览0评论

I am setting up new cypress tests to test some functionalities in Dynamics 365 application. But, I'm left with a browser window with the url / and the text Whoops, there is no test to run.

describe('Initial Cypress Tests', () => {
    it('navigate to D365', () => {
        cy.visit('')
    })
})

I am setting up new cypress tests to test some functionalities in Dynamics 365 application. But, I'm left with a browser window with the url https://login.microsoftonline./__/ and the text Whoops, there is no test to run.

describe('Initial Cypress Tests', () => {
    it('navigate to D365', () => {
        cy.visit('https://wipropoc.crm8.dynamics.')
    })
})
Share Improve this question edited Apr 16, 2020 at 19:02 shytikov 9,5889 gold badges61 silver badges105 bronze badges asked Mar 25, 2019 at 16:34 Akhil TabjulaAkhil Tabjula 711 gold badge1 silver badge4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 1

Would suggest you to directly do a POST call for getting SSO authentication token and fire cy.visit('https://wipropoc.crm8.dynamics.') with the obtained token.

Here are the steps to follow from official documentation,

  1. Login when authentication is done on a 3rd party server.
  2. Parse tokens using cy.request().
  3. Manually set tokens on local storage.
  4. Map external hosts and point to local servers.

cy.request('POST', 'https://sso.corp./auth', { username: 'foo', password: 'bar' })
    .then((response) => {
    // pull out the location redirect
    const loc = response.headers['Location']

    // parse out the token from the url (assuming its in there)
    const token = parseOutMyToken(loc)

    // do something with the token that your web application expects
    // likely the same behavior as what your SSO does under the hood
    // assuming it handles query string tokens like this
    cy.visit('http://localhost:8080?token=' + token)

    // if you don't need to work with the token you can sometimes
    // just visit the location header directly
    cy.visit(loc)
    })

You can read more about this here - https://docs.cypress.io/guides/guides/web-security.html#Form-Submission-Redirects

Real time example - https://xebia./blog/how-to-use-azure-ad-single-sign-on-with-cypress/

发布评论

评论列表(0)

  1. 暂无评论