Esempio n. 1
0
    def test_bad_signature(self):
        msg = seal_token(fake_subtoken_proto())

        # make sure that pkcs1_sha256_sig is changed.
        msg.pkcs1_sha256_sig = msg.pkcs1_sha256_sig[:-1] + chr(
            ord(msg.pkcs1_sha256_sig[-1]) ^ 1)
        with self.assertRaises(exceptions.BadTokenError):
            delegation.unseal_token(msg)
Esempio n. 2
0
 def test_bad_signature(self):
     msg = seal_token(fake_subtoken_proto())
     msg.pkcs1_sha256_sig = msg.pkcs1_sha256_sig[:-1] + 'A'
     with self.assertRaises(delegation.BadTokenError):
         delegation.unseal_token(msg)
Esempio n. 3
0
 def test_unknown_signing_key_id(self):
     msg = seal_token(fake_subtoken_proto())
     msg.signing_key_id = 'blah'
     with self.assertRaises(delegation.BadTokenError):
         delegation.unseal_token(msg)
Esempio n. 4
0
 def test_unknown_signer_id(self):
     # Empty dict, no trusted signers.
     self.mock(delegation, 'get_trusted_signers', lambda: {})
     with self.assertRaises(delegation.BadTokenError):
         delegation.unseal_token(seal_token(fake_subtoken_proto()))
Esempio n. 5
0
 def test_bad_signer_id(self):
     msg = seal_token(fake_subtoken_proto())
     msg.signer_id = 'not an identity'
     with self.assertRaises(delegation.BadTokenError):
         delegation.unseal_token(msg)
Esempio n. 6
0
 def test_seal_round_trip(self):
     tok = fake_subtoken_proto()
     self.assertEqual(tok, delegation.unseal_token(seal_token(tok)))
Esempio n. 7
0
def decode_token(token):
  return auth_delegation.unseal_token(
      auth_delegation.deserialize_token(token))
Esempio n. 8
0
 def test_round_trip(self):
   toks = fake_subtoken_list_proto()
   self.assertEqual(toks, delegation.unseal_token(delegation.seal_token(toks)))
Esempio n. 9
0
 def test_bad_signature(self):
   msg = delegation.seal_token(fake_subtoken_list_proto())
   msg.pkcs1_sha256_sig = msg.pkcs1_sha256_sig[:-1] + 'A'
   with self.assertRaises(delegation.BadTokenError):
     delegation.unseal_token(msg)
Esempio n. 10
0
 def test_unknown_signing_key_id(self):
   msg = delegation.seal_token(fake_subtoken_list_proto())
   msg.signing_key_id = 'blah'
   with self.assertRaises(delegation.BadTokenError):
     delegation.unseal_token(msg)
Esempio n. 11
0
 def test_unknown_signer_id(self):
   checker = delegation.SignatureChecker() # empty, no trusted signers
   self.mock(delegation, 'get_signature_checker', lambda: checker)
   with self.assertRaises(delegation.BadTokenError):
     delegation.unseal_token(delegation.seal_token(fake_subtoken_list_proto()))
Esempio n. 12
0
 def test_bad_signer_id(self):
   msg = delegation.seal_token(fake_subtoken_list_proto())
   msg.signer_id = 'not an identity'
   with self.assertRaises(delegation.BadTokenError):
     delegation.unseal_token(msg)
Esempio n. 13
0
 def test_round_trip(self):
     toks = fake_subtoken_list_proto()
     self.assertEqual(toks,
                      delegation.unseal_token(delegation.seal_token(toks)))
Esempio n. 14
0
 def test_unknown_signer_id(self):
     checker = delegation.SignatureChecker()  # empty, no trusted signers
     self.mock(delegation, 'get_signature_checker', lambda: checker)
     with self.assertRaises(delegation.BadTokenError):
         delegation.unseal_token(
             delegation.seal_token(fake_subtoken_list_proto()))