def test_verify_message_with_rekey(self): message = jwts.make_jws({'c': 3}, [ self.mock_proj_keypair, self.mock_oneid_keypair, self.mock_resetA_keypair, self.mock_resetB_keypair, self.mock_resetC_keypair, ]) sess = session.DeviceSession( self.id_credentials, self.proj_credentials, self.oneid_credentials, ) claims = sess.verify_message(message, rekey_credentials=[ self.resetA_credentials, self.resetB_credentials, self.resetC_credentials, ]) self.assertIsInstance(claims, dict) self.assertIn("c", claims) self.assertEqual(claims.get("c"), 3)
def test_prepare_message(self): sess = session.DeviceSession(self.id_credentials) jws = sess.prepare_message(a=1) claims = jwts.verify_jws(jws, self.id_credentials.keypair) self.assertIsInstance(claims, dict) self.assertIn("a", claims) self.assertEqual(claims.get("a"), 1)
def test_verify_message(self): message = jwts.make_jws( {'b': 2}, [self.mock_proj_keypair, self.mock_oneid_keypair]) sess = session.DeviceSession(self.id_credentials, self.proj_credentials, self.oneid_credentials) claims = sess.verify_message(message) self.assertIsInstance(claims, dict) self.assertIn("b", claims) self.assertEqual(claims.get("b"), 2)
def test_prepare_message_encrypted_to_other(self): sess = session.DeviceSession(self.id_credentials) jws = sess.prepare_message(a=1, other_recipients=[self.peer_credentials]) jwe = jwts.verify_jws(jws, self.id_credentials.keypair) self.assertTrue(jose.is_jwe(jwe)) claims = jwes.decrypt_jwe(jwe, self.peer_credentials.keypair) self.assertIsInstance(claims, dict) self.assertIn("a", claims) self.assertEqual(claims.get("a"), 1)
def test_add_signature_to_jws(self): claims = { 'a': 1, } sess = session.DeviceSession(self.id_credentials) jws1 = jwts.make_jws(claims, self.alt_credentials.keypair) jws2 = sess.add_signature(jws1) claims = jwts.verify_jws( jws2, [self.alt_credentials.keypair, self.id_credentials.keypair]) self.assertIsInstance(claims, dict) self.assertIn("a", claims) self.assertEqual(claims.get("a"), 1)
def test_verify_encrypted_session_message(self): jwe = jwes.make_jwe( {'b': 2}, self.proj_credentials.keypair, self.id_credentials.keypair, jsonify=False, ) jws = jwts.make_jws(jwe, [self.mock_proj_keypair, self.mock_oneid_keypair]) sess = session.DeviceSession(self.id_credentials, self.proj_credentials, self.oneid_credentials) claims = sess.verify_message(jws) self.assertIsInstance(claims, dict) self.assertIn("b", claims) self.assertEqual(claims.get("b"), 2)