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

Fixed actingAs, withCookies, withHeaders, assertAuthenticated, assertGuest in TestCase and fixed Auth which was not persisting user #588

Merged
merged 10 commits into from
Apr 23, 2022

Conversation

girardinsamuel
Copy link
Contributor

@girardinsamuel girardinsamuel commented Apr 14, 2022

Rewrite of those two PRs #579 and #551.

Fixed

  1. Fixed TestCase withHeaders() and withCookies() methods
    headers and cookies were added after the request/response cycle was done, so it was not correct.
    Adding them before, was the solution, but it requires to add them in the WSGI environ object.

  2. Fixed actingAs test helper during requests and fixed assertAuthenticated and assertGuest assertions

self.get("/about").assertGuest()
# you can also pass the guard used to check that user is not authenticated
self.get("/about").assertGuest("web")

self.get("/login").assertAuthenticated()
user = User.find(1)
# you can pass the user that should be authenticated
self.get("/login").assertAuthenticated(user)
# you can also pass the guard used to check that user is authenticated
self.get("/login").assertAuthenticated(user, "web")
  1. Fixed Auth by persisting user in Auth instance: user is now persisted in the Auth instance, added when logged in and removed when logged out.

@girardinsamuel girardinsamuel added help wanted Next Minor Non-breaking change that can go into the next minor version labels Apr 15, 2022
@girardinsamuel girardinsamuel changed the title WIP: Refactor testing http request Fixed actingAs, withCookies, withHeaders and added dump and dd helpers in TestCase Apr 22, 2022
@girardinsamuel girardinsamuel changed the title Fixed actingAs, withCookies, withHeaders and added dump and dd helpers in TestCase Fixed actingAs, withCookies, withHeaders, assertAuthenticated, assertGuest and added dump and dd helpers in TestCase Apr 22, 2022
@girardinsamuel girardinsamuel changed the title Fixed actingAs, withCookies, withHeaders, assertAuthenticated, assertGuest and added dump and dd helpers in TestCase Fixed actingAs, withCookies, withHeaders, assertAuthenticated, assertGuest in TestCase Apr 22, 2022
@girardinsamuel girardinsamuel changed the title Fixed actingAs, withCookies, withHeaders, assertAuthenticated, assertGuest in TestCase Fixed actingAs, withCookies, withHeaders, assertAuthenticated, assertGuest in TestCase and fixed Auth which was not persisting user Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Next Minor Non-breaking change that can go into the next minor version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants