예제 #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)
예제 #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)
예제 #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)
예제 #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()))
예제 #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)
예제 #6
0
 def test_seal_round_trip(self):
     tok = fake_subtoken_proto()
     self.assertEqual(tok, delegation.unseal_token(seal_token(tok)))
예제 #7
0
def decode_token(token):
  return auth_delegation.unseal_token(
      auth_delegation.deserialize_token(token))
예제 #8
0
 def test_round_trip(self):
   toks = fake_subtoken_list_proto()
   self.assertEqual(toks, delegation.unseal_token(delegation.seal_token(toks)))
예제 #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)
예제 #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)
예제 #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()))
예제 #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)
예제 #13
0
 def test_round_trip(self):
     toks = fake_subtoken_list_proto()
     self.assertEqual(toks,
                      delegation.unseal_token(delegation.seal_token(toks)))
예제 #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()))