def test_deserialize_bad_proto(self): tok = tokens.base64_encode('not a proto') with self.assertRaises(delegation.BadTokenError): delegation.deserialize_token(tok)
def test_deserialize_huge(self): msg = fake_token_proto() msg.serialized_subtoken = 'huge' * 10000 tok = tokens.base64_encode(msg.SerializeToString()) with self.assertRaises(delegation.BadTokenError): delegation.deserialize_token(tok)
def test_deserialize_not_base64(self): msg = fake_token_proto() tok = serialize_token(msg) tok += 'not base 64' with self.assertRaises(delegation.BadTokenError): delegation.deserialize_token(tok)
def decode_token(token): return auth_delegation.unseal_token( auth_delegation.deserialize_token(token))
def test_serialization_works(self): msg = fake_token_proto() tok = serialize_token(msg) self.assertEqual(msg, delegation.deserialize_token(tok))
def test_deserialize_not_base64(self): msg = fake_token_proto() tok = delegation.serialize_token(msg) tok += 'not base 64' with self.assertRaises(delegation.BadTokenError): delegation.deserialize_token(tok)
def test_deserialize_huge(self): msg = fake_token_proto() msg.serialized_subtoken_list = 'huge' * 10000 tok = tokens.base64_encode(msg.SerializeToString()) with self.assertRaises(delegation.BadTokenError): delegation.deserialize_token(tok)
def test_serialization_works(self): msg = fake_token_proto() tok = delegation.serialize_token(msg) self.assertEqual(msg, delegation.deserialize_token(tok))
def test_deserialize_bad_proto(self): tok = b64.encode('not a proto') with self.assertRaises(exceptions.BadTokenError): delegation.deserialize_token(tok)