Exemplo n.º 1
0
    def test_get_jws_headers_invalid_json(self):
        jws = jwts.make_jws({'message': 'hi'}, self.keypairs[:1])
        header = json.dumps({
            'typ': 'JWT',
            'alg': 'NONE',
        })

        header_str = utils.base64url_encode(header).decode('utf-8')
        bad_jws = '.'.join([header_str] + jws.split('.')[1:])

        with self.assertRaises(exceptions.InvalidFormatError):
            jwts.get_jws_headers(bad_jws)
Exemplo n.º 2
0
 def test_none_headers(self):
     jws = jwts.make_jws({'a': 1}, self.keypairs[:1], multiple_sig_headers=None)
     jws_headers = jwts.get_jws_headers(jws)
     self.assertIsInstance(jws_headers[0], dict)
Exemplo n.º 3
0
 def test_get_jws_headers(self):
     header = {'z': 99}
     jws = jwts.make_jws({'a': 1}, self.keypairs[:1], [header])
     jws_headers = jwts.get_jws_headers(jws)
     self.assertTrue(jws_headers[0]['z'] == header['z'])
Exemplo n.º 4
0
 def test_extend_jws_signatures_from_jws_multiple_without_sidx(self):
     jws = self.JWS_MISSING_2_SIGNATURE_INDEXES
     jws = jwts.extend_jws_signatures(jws, self.keypairs[2:])
     headers = jwts.get_jws_headers(jws)
     indexes = list(filter(None, [h.get('sidx', None) for h in headers]))
     self.assertEqual(len(indexes), 0)