def test_write_encrypted_read_encrypted(self): encrypted_keyset = example_encrypted_keyset() stream = io.StringIO() writer = core.JsonKeysetWriter(stream) writer.write_encrypted(encrypted_keyset) reader = core.JsonKeysetReader(stream.getvalue()) self.assertEqual(encrypted_keyset, reader.read_encrypted())
def test_write_read_with_unicode_chars(self): keyset = tink_pb2.Keyset() key = keyset.key.add() key.key_data.type_url = ( u'\xe3\x82\xb3\xe3\x83\xb3\xe3\x83\x8b\xe3\x83\x81\xe3\x83\x8f') stream = io.StringIO() writer = core.JsonKeysetWriter(stream) writer.write(keyset) reader = core.JsonKeysetReader(stream.getvalue()) self.assertEqual(keyset, reader.read())
def test_write_encrypted_invalid_fails(self): with self.assertRaisesRegex(core.TinkError, 'invalid encrypted keyset'): stream = io.StringIO() writer = core.JsonKeysetWriter(stream) writer.write_encrypted(example_keyset())