def test_verify_token_raises_with_no_sub_or_azp_claim(self): del self.claims['sub'] self.assertNotIn('sub', self.claims) self.assertNotIn('azp', self.claims) token = jwt.encode(payload=self.claims, key=utils.get_private_key(), algorithm=settings.DJANGO_JWTAUTH['JWT_ALGORITHM']) with self.assertRaises(jwt.exceptions.MissingRequiredClaimError): utils.verify_token(token.decode()), get_user_model()
def test_command_email(self): with self.settings(DEBUG=True): token = call_command('generate_token', email=self.test_user.email, stdout=OUT) user = verify_token(token) self.assertEqual(user.id, self.test_user.id)
def test_verify_token_passes_with_sub_claim(self): self.assertNotIn('azp', self.claims) token = jwt.encode(payload=self.claims, key=utils.get_private_key(), algorithm=settings.DJANGO_JWTAUTH['JWT_ALGORITHM']) self.assertIsInstance(utils.verify_token(token.decode()), get_user_model())