-
-
Notifications
You must be signed in to change notification settings - Fork 964
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
fix: #1251 - fix return_to for expired flows #1697
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1697 +/- ##
==========================================
+ Coverage 73.92% 74.03% +0.10%
==========================================
Files 260 260
Lines 12662 12692 +30
==========================================
+ Hits 9360 9396 +36
+ Misses 2679 2672 -7
- Partials 623 624 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This is looking pretty good! I think we should still verify if this works end-to-end - so checking that you end up at the correct URL when you try to submit an expired flow. To do that, you could add a helper like this one
kratos/test/e2e/cypress/support/commands.js
Line 108 in 1cf61cd
Cypress.Commands.add('longRecoveryLifespan', ({} = {}) => { |
kratos/test/e2e/cypress/support/commands.js
Line 124 in 1cf61cd
Cypress.Commands.add('shortRecoveryLifespan', ({} = {}) => { |
and add a test to login
it('should sign in with case insensitive identifier', () => { | |
cy.get('input[name="password_identifier"]').type(email.toUpperCase()) | |
cy.get('input[name="password"]').type(password) | |
cy.get('button[type="submit"]').click() | |
cy.session().should((session) => { | |
const { identity } = session | |
expect(identity.id).to.not.be.empty | |
expect(identity.schema_id).to.equal('default') | |
expect(identity.schema_url).to.equal(`${APP_URL}/schemas/default`) | |
expect(identity.traits.website).to.equal(website) | |
expect(identity.traits.email).to.equal(email) | |
}) | |
}) |
(and the other flows) which has a beforeEach
that reset the lifespan like here:
cy.longRecoveryLifespan() |
and has one test with a short expiry time
cy.shortLinkLifespan() |
In pseudo-code it might look something like this:
it('should end up at the correct return to if flow is expired', () => {
cy.visit(APP_URL + '/auth/login?return_to=....')
cy.shortLoginLifespan()
cy.get('input[name="password_identifier"]').type(email.toUpperCase())
cy.get('input[name="password"]').type(password)
cy.get('button[type="submit"]').click()
// Try again
cy.longLoginLifespan()
cy.get('input[name="password_identifier"]').type(email.toUpperCase())
cy.get('input[name="password"]').type(password)
cy.get('button[type="submit"]').click()
cy.session()
cy.location().should('contain', '...')
})
You can run e2e test quickly using:
./test/e2e/run.sh --dev sqlite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forgot to submit this comment
|
||
f, err = reg.LoginFlowPersister().GetLoginFlow(context.Background(), uuid.FromStringOrNil(gjson.GetBytes(resBody, "id").String())) | ||
require.NoError(t, err) | ||
assert.Equal(t, f.RequestURL, oldReqUrl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for a sanity check maybe add this here:
assert.Equal(t, f.RequestURL, oldReqUrl) | |
assert.Equal(t, f.RequestURL, oldReqUrl) | |
assert.Contains(t, f.RequestURL, "?return_to=https://www.ory.sh") |
(and to the other tests as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks . I made the changes added ui tests for login and registration flows . I believe other flows stay on the settings ui instead of redirecting . Please check.
Let me know when you want this reviewed again :) |
Please review it :) again .
|
Oh sorry, I missed that! |
Awesome work! |
The CI failure is unrelated to your changes! |
Related issue(s)
Checklist
contributing code guidelines.
vulnerability. If this pull request addresses a security. vulnerability, I
confirm that I got green light (please contact
security@ory.sh) from the maintainers to push
the changes.
works.
Further Comments