Skip to content

Commit

Permalink
fix: ensure return_to works for OIDC flows
Browse files Browse the repository at this point in the history
Closes #1773
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent eddeb85 commit d615734
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
19 changes: 15 additions & 4 deletions test/e2e/cypress/integration/profiles/oidc/login/success.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {gen, website} from '../../../../helpers'
import {appPrefix, gen, website} from '../../../../helpers'
import {routes as react} from "../../../../helpers/react";
import {routes as express} from "../../../../helpers/express";

Expand All @@ -7,17 +7,18 @@ context('Social Sign In Successes', () => {
{
login: react.login,
registration: react.registration,
app: 'react', profile: 'spa'
app: 'react' as 'react', profile: 'spa'
},
{
login: express.login,
registration: express.registration,
app: 'express', profile: 'oidc'
app: 'express' as 'express', profile: 'oidc'
}
].forEach(({login, registration, profile, app}) => {
describe(`for app ${app}`, () => {
before(() => {
cy.useConfigProfile(profile)
cy.proxy(app)
})

beforeEach(() => {
Expand All @@ -27,10 +28,20 @@ context('Social Sign In Successes', () => {
it('should be able to sign up, sign out, and then sign in', () => {
const email = gen.email()
cy.registerOidc({email, website, route: registration})
cy.get('[data-testid=logout]').click()
cy.logout()
cy.noSession()
cy.loginOidc({url: login})
})

it('should be able to sign up with redirects', () => {
const email = gen.email()
cy.registerOidc({email, website, route: registration + '?return_to=https://www.ory.sh/'})
cy.location('href').should('eq','https://www.ory.sh/')
cy.logout()
cy.noSession()
cy.loginOidc({url: login+ '?return_to=https://www.ory.sh/'})
cy.location('href').should('eq','https://www.ory.sh/')
})
})
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {APP_URL, gen, website} from '../../../../helpers'
import {APP_URL, appPrefix, gen, website} from '../../../../helpers'
import {routes as react} from "../../../../helpers/react";
import {routes as express} from "../../../../helpers/express";

Expand All @@ -7,17 +7,18 @@ context('Social Sign Up Successes', () => {
{
login: react.login,
registration: react.registration,
app: 'react', profile: 'spa'
app: 'react' as 'react', profile: 'spa'
},
{
login: express.login,
registration: express.registration,
app: 'express', profile: 'oidc'
app: 'express' as 'express', profile: 'oidc'
}
].forEach(({registration, login, profile, app}) => {
describe(`for app ${app}`, () => {
before(() => {
cy.useConfigProfile(profile)
cy.proxy(app)
})

beforeEach(() => {
Expand All @@ -40,7 +41,7 @@ context('Social Sign Up Successes', () => {
cy.registerOidc({email, expectSession: false, route: registration})

cy.get('#registration-password').should('not.exist')
cy.get('[name="traits.email"]').should('have.value', email)
cy.get(appPrefix(app)+'[name="traits.email"]').should('have.value', email)
cy.get('[data-testid="ui/message/4000002"]').should(
'contain.text',
'Property website is missing'
Expand Down Expand Up @@ -90,7 +91,7 @@ context('Social Sign Up Successes', () => {
const email = gen.email()

cy.registerOidc({email, website, route: registration})
cy.get('[data-testid=logout]').click()
cy.logout()
cy.noSession()
cy.visit(registration)
cy.triggerOidc()
Expand Down Expand Up @@ -130,6 +131,13 @@ context('Social Sign Up Successes', () => {

cy.getSession().should(shouldSession(email))
})

it('should be able to sign up with redirects', () => {
const email = gen.email()
cy.registerOidc({email, website, route: registration + '?return_to=https://www.ory.sh/'})
cy.location('href').should('eq','https://www.ory.sh/')
cy.logout()
})
})
})
})

0 comments on commit d615734

Please sign in to comment.