From 2f950b3bda40ae717ce86b93f69a3070e44bf8b8 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 24 Jul 2019 23:11:44 +0100 Subject: [PATCH] [stream-refactor] allow doas_test to succeed on CentOS Unlike on Debian, some environment variables that tickle getpass.getuser() are being inherited. So use getuid() instead. Also install the doas binary on CentOS. CI was changed (I believe) to shrink the configuration matrix, and now these tests run on CentOS too. --- tests/doas_test.py | 3 +-- tests/image_prep/README.md | 3 +++ tests/image_prep/_container_setup.yml | 9 +++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/doas_test.py b/tests/doas_test.py index 43284367..560ada99 100644 --- a/tests/doas_test.py +++ b/tests/doas_test.py @@ -1,5 +1,4 @@ -import getpass import os import mitogen @@ -59,7 +58,7 @@ class DoasTest(testlib.DockerMixin, testlib.TestCase): password='has_sudo_password', ) context = self.router.su(via=ssh, password='rootpassword') - self.assertEquals('root', context.call(getpass.getuser)) + self.assertEquals(0, context.call(os.getuid)) if __name__ == '__main__': diff --git a/tests/image_prep/README.md b/tests/image_prep/README.md index d275672f..a970b319 100644 --- a/tests/image_prep/README.md +++ b/tests/image_prep/README.md @@ -11,10 +11,13 @@ code, the OS X config just has the user accounts. See ../README.md for a (mostly) description of the accounts created. + ## Building the containers ``./build_docker_images.sh`` +Requires Ansible 2.3.x.x in order to target CentOS 5 + ## Preparing an OS X box diff --git a/tests/image_prep/_container_setup.yml b/tests/image_prep/_container_setup.yml index 9662d498..9d001f48 100644 --- a/tests/image_prep/_container_setup.yml +++ b/tests/image_prep/_container_setup.yml @@ -87,27 +87,24 @@ shell: locale-gen when: distro == "Debian" - - name: Install prebuilt 'doas' binary on Debian + - name: Install prebuilt 'doas' binary unarchive: dest: / src: ../data/docker/doas-debian.tar.gz - when: distro == "Debian" - - name: Make prebuilt 'doas' binary executable on Debian + - name: Make prebuilt 'doas' binary executable file: path: /usr/local/bin/doas mode: 'u=rwxs,go=rx' owner: root group: root - when: distro == "Debian" - - name: Install doas.conf on Debian + - name: Install doas.conf copy: dest: /etc/doas.conf content: | permit :mitogen__group permit :root - when: distro == "Debian" - name: Vanilla Ansible needs simplejson on CentOS 5. shell: mkdir -p /usr/lib/python2.4/site-packages/simplejson/