def test_parse_token_accepts_v1(self): with override_settings(SESAME_TOKENS=["sesame.tokens_v1"]): token = create_token(self.user) user = parse_token(token, self.get_user) self.assertEqual(user, self.user) self.assertLogsContain("Valid token for user john")
def test_parse_token_force_v1(self): with override_settings(SESAME_TOKENS=["sesame.tokens_v2"]): token = create_token(self.user) user = parse_token(token, self.get_user) self.assertEqual(user, None) self.assertLogsContain("Bad token: doesn't match a supported format")
def test_parse_token_accepts_v2(self): token = create_token(self.user) user = parse_token(token, self.get_user) self.assertEqual(user, self.user) self.assertLogsContain("Valid token for user john")