MCPcopy
hub / github.com/django/django / test_aget_user_fallback_secret

Method test_aget_user_fallback_secret

tests/auth_tests/test_basic.py:190–211  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 6

HttpRequestClass · 0.90
override_settingsClass · 0.90
aget_userFunction · 0.90
aloginMethod · 0.80
asessionMethod · 0.80
acreate_userMethod · 0.45

Tested by

no test coverage detected