cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.97k stars 3.18k forks source link

Programmatic Login with OKTA does not work if baseUrl not provided in cypress.config.js #27378

Closed bondar-artem closed 3 months ago

bondar-artem commented 1 year ago

Current behavior

Used documentation to implement Programmatic Login with OKTA. https://docs.cypress.io/guides/end-to-end-testing/okta-authentication#Programmatic-Login

This code works ONLY if baseUrl property defined in cypress.config.js

If baseUrl is not defined, programmatic login does not work. Error in the console: Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://testdoman.mycompany.com') does not match the recipient window's origin ('http://localhost:62570')

Error in runner: Your callback function returned a promise that never resolved

Trying to use Cypress.config('baseUrl', 'https://testdoman.mycompany.com') in the test body also does not work.is

Desired behavior

Programmatic Login with OKTA should work even if baseUrl is not defined in cypress.config.js. So I can run different tests against different origins using headless authorization.

Test code to reproduce

https://github.com/cypress-io/cypress-realworld-app/blob/develop/cypress/tests/ui-auth-providers/okta.spec.ts

Remove "baseUrl" from cypress.config.js Instead of cy.visit('/'), use a baseUrl value.

Run this spec.

Cypress Version

12.17.2

Node version

16.18.1

Operating System

macOS 12.3

Debug Logs

No response

Other

No response

bondar-artem commented 1 year ago

@astone123 do you have any updates on this issue? Or maybe any questions related to that? Thanks

cypress-app-bot commented 4 months ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot commented 3 months ago

This issue has been closed due to inactivity.