示例#1
0
文件: test_vapid.py 项目: jrmi/vapid
 def test_sign_01(self):
     v = Vapid01.from_string(T_DER)
     claims = {"aud": "https://example.com",
               "sub": "mailto:[email protected]"}
     result = v.sign(claims, "id=previous")
     eq_(result['Crypto-Key'],
         'id=previous;p256ecdsa=' + T_PUBLIC_RAW.decode('utf8'))
     pkey = binascii.b2a_base64(
         v.public_key.public_bytes(
             serialization.Encoding.X962,
             serialization.PublicFormat.UncompressedPoint
         )
     ).decode('utf8').replace('+', '-').replace('/', '_').strip()
     items = decode(result['Authorization'].split(' ')[1], pkey)
     for k in claims:
         eq_(items[k], claims[k])
     result = v.sign(claims)
     eq_(result['Crypto-Key'],
         'p256ecdsa=' + T_PUBLIC_RAW.decode('utf8'))
     # Verify using the same function as Integration
     # this should ensure that the r,s sign values are correctly formed
     ok_(Vapid01.verify(
         key=result['Crypto-Key'].split('=')[1],
         auth=result['Authorization']
     ))
示例#2
0
文件: test_vapid.py 项目: jrmi/vapid
 def test_from_string(self):
     v1 = Vapid01.from_string(T_DER)
     v2 = Vapid01.from_string(T_RAW.decode())
     self.check_keys(v1)
     self.check_keys(v2)
示例#3
0
 def test_from_string(self):
     v1 = Vapid01.from_string(TEST_KEY_PRIVATE_DER)
     v2 = Vapid01.from_string(TEST_KEY_PRIVATE_RAW.decode())
     self.check_keys(v1)
     self.check_keys(v2)