(self)
| 188 | self.assertEqual(user.username, created_user.username) |
| 189 | |
| 190 | async def test_aget_user_fallback_secret(self): |
| 191 | created_user = await User.objects.acreate_user( |
| 192 | "testuser", "test@example.com", "testpw" |
| 193 | ) |
| 194 | await self.client.alogin(username="testuser", password="testpw") |
| 195 | request = HttpRequest() |
| 196 | request.session = await self.client.asession() |
| 197 | prev_session_key = request.session.session_key |
| 198 | with override_settings( |
| 199 | SECRET_KEY="newsecret", |
| 200 | SECRET_KEY_FALLBACKS=[settings.SECRET_KEY], |
| 201 | ): |
| 202 | user = await aget_user(request) |
| 203 | self.assertIsInstance(user, User) |
| 204 | self.assertEqual(user.username, created_user.username) |
| 205 | self.assertNotEqual(request.session.session_key, prev_session_key) |
| 206 | # Remove the fallback secret. |
| 207 | # The session hash should be updated using the current secret. |
| 208 | with override_settings(SECRET_KEY="newsecret"): |
| 209 | user = await aget_user(request) |
| 210 | self.assertIsInstance(user, User) |
| 211 | self.assertEqual(user.username, created_user.username) |
nothing calls this directly
no test coverage detected