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

DrupalAuthenticationManager is confused about login state across scenario's #641

Open
Kingdutch opened this issue Mar 6, 2023 · 0 comments

Comments

@Kingdutch
Copy link

In our test suite we reset the database between scenario's to ensure test isolation, we also do this because for some upgrade paths we require a specifically prepared database.

However in a feature file that has:

Scenario: One
    Given I am logged in as a user with the authenticated role
    And I am on "/user/2/edit"

Scenario: Two
    Given I am logged in as a user with the authenticated role
    And I am on "/user/2/edit"

Then Scenario "Two" will fail on the "/user/2/edit" page because the user doesn't exist. Even when we reset the session, Mink doesn't throw away the page. So the logic in DrupalAuthenticationManager::loggedIn will see a started session and the previous (logged in) page and assume that the user is still logged in. However, the user will no longer exist in the database so when actually visiting a page that requires authentication this will now fail.

I would expect the DrupalExtension to just assume people are logged out when a new scenario is started. I also don't see an easy way to make it do this without an internal change to the extension.

Kingdutch added a commit to goalgorilla/open_social that referenced this issue May 4, 2023
In newly written tests we were already doin this manually in each
scenario. Between scenario's the user manager in the DrupalExtension was
not correctly keeping track of the logged in user status which could
prevent a new scenario from logging a user in.

With the removal of clean-up in scenario's we now need that logout step
literally everywhere, so it's easier to add it as an `@afterScenario`
and run it every time than to require developers to decide about 100s of
places whether it's needed.

See jhedstrom/drupalextension#641
robertragas pushed a commit to goalgorilla/open_social that referenced this issue Jul 22, 2023
In newly written tests we were already doin this manually in each
scenario. Between scenario's the user manager in the DrupalExtension was
not correctly keeping track of the logged in user status which could
prevent a new scenario from logging a user in.

With the removal of clean-up in scenario's we now need that logout step
literally everywhere, so it's easier to add it as an `@afterScenario`
and run it every time than to require developers to decide about 100s of
places whether it's needed.

See jhedstrom/drupalextension#641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant