summaryrefslogtreecommitdiffstats
path: root/tests/docker_source.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-08-26 21:42:05 +0100
committerRadostin Stoyanov <rstoyanov1@gmail.com>2017-08-28 16:03:59 +0100
commit2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac (patch)
tree6d73ffc3effffc67e3ae67f9908a08f3ca5ff436 /tests/docker_source.py
parent7baf904cffdc4074ba5529b095f98a8c1ed6707a (diff)
downloadvirt-bootstrap.git-2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac.tar.gz
virt-bootstrap.git-2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac.tar.xz
virt-bootstrap.git-2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac.zip
Set root password with guestfs-python
Use the python bindings of libguestfs to create additional qcow2 image which has as backing file the last layer (layer-0.qcow2 for FileSource) and insert hashed value of given root password in the /etc/shadow file. Note: This additional qcow2 image is also used to apply UID/GID map.
Diffstat (limited to 'tests/docker_source.py')
-rw-r--r--tests/docker_source.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/docker_source.py b/tests/docker_source.py
index eeea379..9090988 100644
--- a/tests/docker_source.py
+++ b/tests/docker_source.py
@@ -286,6 +286,24 @@ class TestQcow2DockerSource(Qcow2ImageAccessor):
g.umount('/')
g.shutdown()
+ def test_qcow2_setting_root_password(self):
+ """
+ Ensures that the root password is set in the last qcow2 image.
+ """
+ self.root_password = "My secret password"
+ layers_rootfs = self.call_bootstrap()
+
+ g = guestfs.GuestFS(python_return_dict=True)
+ g.add_drive_opts(
+ self.get_image_path(len(layers_rootfs)),
+ readonly=True
+ )
+ g.launch()
+ g.mount('/dev/sda', '/')
+ self.validate_shadow_file_in_image(g)
+ g.umount('/')
+ g.shutdown()
+
class TestDockerSource(unittest.TestCase):
"""