def test_encrypt_with_metadata_output_write_to_file(tmpdir):
plaintext = tmpdir.join('source_plaintext')
plaintext.write_binary(os.urandom(1024))
ciphertext = tmpdir.join('ciphertext')
metadata = tmpdir.join('metadata')
encrypt_args = encrypt_args_template(metadata=True).format(
source=str(plaintext),
target=str(ciphertext),
metadata='--metadata-output ' + str(metadata)
)
aws_encryption_sdk_cli.cli(shlex.split(encrypt_args, posix=not is_windows()))
raw_metadata = metadata.read()
output_metadata = json.loads(raw_metadata)
for key, value in (('a', 'b'), ('c', 'd')):
assert output_metadata['header']['encryption_context'][key] == value
assert output_metadata['mode'] == 'encrypt'
assert output_metadata['input'] == str(plaintext)
assert output_metadata['output'] == str(ciphertext)
test_i_aws_encryption_sdk_cli.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录