test_i_aws_encryption_sdk_cli.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:aws-encryption-sdk-cli 作者: awslabs 项目源码 文件源码
def test_file_to_file_decrypt_required_encryption_context_fail(tmpdir, required_encryption_context):
    plaintext = tmpdir.join('source_plaintext')
    plaintext.write_binary(os.urandom(1024))
    ciphertext = tmpdir.join('ciphertext')
    metadata_file = tmpdir.join('metadata')
    decrypted = tmpdir.join('decrypted')

    encrypt_args = encrypt_args_template().format(
        source=str(plaintext),
        target=str(ciphertext)
    )
    decrypt_args = decrypt_args_template(metadata=True).format(
        source=str(ciphertext),
        target=str(decrypted),
        metadata=' --metadata-output ' + str(metadata_file)
    ) + ' --encryption-context ' + required_encryption_context

    aws_encryption_sdk_cli.cli(shlex.split(encrypt_args, posix=not is_windows()))
    aws_encryption_sdk_cli.cli(shlex.split(decrypt_args, posix=not is_windows()))

    assert not decrypted.isfile()
    raw_metadata = metadata_file.read()
    parsed_metadata = json.loads(raw_metadata)
    assert parsed_metadata['skipped']
    assert parsed_metadata['reason'] == 'Missing encryption context key or value'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号