diff --git a/test/conftest.py b/test/conftest.py index 407d00dc..e99e47a3 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -8,6 +8,20 @@ check_output = testinfra.get_backend( @pytest.fixture def Pihole(Docker): ''' used to contain some script stubbing, now pretty much an alias ''' + def run_bash(self, command, *args, **kwargs): + cmd = self.get_command(command, *args) + if self.user is not None: + out = self.run_local( + "docker exec -u %s %s /bin/bash -c %s", + self.user, self.name, cmd) + else: + out = self.run_local( + "docker exec %s /bin/bash -c %s", self.name, cmd) + out.command = self.encode(cmd) + return out + + funcType = type(Docker.run) + Docker.run = funcType(run_bash, Docker, testinfra.backend.docker.DockerBackend) return Docker @pytest.fixture diff --git a/test/test_automated_install.py b/test/test_automated_install.py index 6a3daf60..45fecfd0 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -69,11 +69,10 @@ def test_configureFirewall_firewalld_no_errors(Pihole): ''' confirms firewalld rules are applied when appopriate ''' mock_command('firewall-cmd', '0', Pihole) configureFirewall = Pihole.run(''' - bash -c " PHTEST=TRUE source /opt/pihole/basic-install.sh configureFirewall - " ''') + ''') expected_stdout = '::: Configuring firewalld for httpd and dnsmasq.' assert expected_stdout in configureFirewall.stdout firewall_calls = Pihole.run('cat /var/log/firewall-cmd').stdout