tests: Flush session in verify_desktop_flow_end_page in social auth.

As the relevant comment elaborates - what happens next in the test in
simulating the step that happens in the desktop app. Thus a new session
needs to be used. Otherwise, the old session created normally in the
browser pollutes the state and can give falsely passing tests.

This should be happening for all social auth tests using this, not just
in that one SAML test, thus moving it inside the helper method.
This commit is contained in:
Mateusz Mandera
2022-12-09 14:26:42 +01:00
committed by Tim Abbott
parent 8fb0fe96c6
commit 04f5358a76

View File

@@ -845,6 +845,12 @@ class DesktopFlowTestingLib(ZulipTestCase):
self.assertEqual(browser_url, "/login/") self.assertEqual(browser_url, "/login/")
decrypted_key = self.verify_desktop_data_and_return_key(desktop_data, desktop_flow_otp) decrypted_key = self.verify_desktop_data_and_return_key(desktop_data, desktop_flow_otp)
# Flush the session to have a clean slate - since up till now
# we were simulating the part of the flow that happens in the browser.
# Now we will simulating the last part of the flow, which gets executed
# in the desktop application - thus with a separate session.
self.client.session.flush()
result = self.client_get( result = self.client_get(
f"http://zulip.testserver/accounts/login/subdomain/{decrypted_key}" f"http://zulip.testserver/accounts/login/subdomain/{decrypted_key}"
) )
@@ -2153,11 +2159,6 @@ class SAMLAuthBackendTest(SocialAuthBase):
expect_choose_email_screen=False, expect_choose_email_screen=False,
desktop_flow_otp=desktop_flow_otp, desktop_flow_otp=desktop_flow_otp,
) )
# Flush the session to have a clean slate - since up till now
# we were simulating the part of the flow that happens in the browser.
# Now we will simulating the last part of the flow, which gets executed
# in the desktop application - thus with a separate session.
self.client.session.flush()
self.verify_desktop_flow_end_page(result, self.email, desktop_flow_otp) self.verify_desktop_flow_end_page(result, self.email, desktop_flow_otp)
# Ensure the SessionIndex gets plumbed through to the final session in the app. # Ensure the SessionIndex gets plumbed through to the final session in the app.