mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-17 12:28:55 +00:00
* Move copying functionality to module_utils. * Add docker_container_copy_into module. * Use new module in other tests. * Fix copyright and attributes. * Improve idempotency, improve stat code. * Document and test when a stopped container works. * Improve owner/group detection error handling when container is stopped. * Fix formulation. Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com> * Improve file comparison. * Avoid reading whole file at once. * Stream when fetching files from daemon. * Fix comment. * Use read() instead of read1(). * Stream files when copying into container. * Linting. * Add force parameter. * Simplify library code. * Linting. * Add content and content_is_b64 options. * Make force=false work as for copy module: only copy if the destination does not exist. * Improve docs. * content should be no_log. * Implement diff mode. * Improve error handling. * Lint and improve. * Set owner/group ID to avoid ID lookup (which fails in paused containers). * Apply suggestions from code review Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com> Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
30 lines
923 B
Python
30 lines
923 B
Python
# Copyright 2022 Red Hat | Ansible
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
__metaclass__ = type
|
|
|
|
import pytest
|
|
import tarfile
|
|
|
|
from ansible_collections.community.docker.plugins.module_utils._scramble import (
|
|
scramble,
|
|
unscramble,
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize('plaintext, key, scrambled', [
|
|
(u'', b'0', '=S='),
|
|
(u'hello', b'\x00', '=S=aGVsbG8='),
|
|
(u'hello', b'\x01', '=S=aWRtbW4='),
|
|
])
|
|
def test_scramble_unscramble(plaintext, key, scrambled):
|
|
scrambled_ = scramble(plaintext, key)
|
|
print('{0!r} == {1!r}'.format(scrambled_, scrambled))
|
|
assert scrambled_ == scrambled
|
|
|
|
plaintext_ = unscramble(scrambled, key)
|
|
print('{0!r} == {1!r}'.format(plaintext_, plaintext))
|
|
assert plaintext_ == plaintext
|