def setUp(self): self.claims_schema = Schema({ 'taskId': 'xyz', 'exp': int, }, extra=True, required=True) self.token = sign_task("xyz", pvt_key=PVT_KEY) self.decode = jwt.decode(self.token, PUB_KEY, algorithms=[ALGORITHMS.RS512]) self.verify = jws.verify(self.token, PUB_KEY, algorithms=[ALGORITHMS.RS512])
def test_verify_bad_signature(self): token = sign_task("xyz", pvt_key=PVT_KEY) self.assertRaises(jws.JWSError, jws.verify, token, OTHER_PUB_KEY, [ALGORITHMS.RS512])
def test_verify(self): token = sign_task("xyz", pvt_key=PVT_KEY) claims = jws.verify(token, PUB_KEY, algorithms=[ALGORITHMS.RS512]) assert claims["taskId"] == "xyz"
def test_exp(self): token = sign_task("xyz", pvt_key=PVT_KEY) claims = jwt.decode(token, PUB_KEY, algorithms=[ALGORITHMS.RS512]) assert "exp" in claims
def test_exp_int(self): token = sign_task("xyz", pvt_key=PVT_KEY) claims = jwt.decode(token, PUB_KEY, algorithms=[ALGORITHMS.RS512]) assert isinstance(claims["exp"], int)
def test_task_id(self): token = sign_task("xyz", pvt_key=PVT_KEY) claims = jwt.decode(token, PUB_KEY, algorithms=[ALGORITHMS.RS512]) assert claims["taskId"] == "xyz"