def setUp(self):
     self.check_output = self.set_up_patch(
         'nginx_config_reloader.subprocess.check_output')
     self.tm = NginxConfigReloader(no_magento_config=False,
                                   no_custom_config=False,
                                   dir_to_watch='/data/web/nginx',
                                   magento2_flag=None)
class TestFixCustomConfigDirPermissions(TestCase):
    def setUp(self):
        self.check_output = self.set_up_patch(
            'nginx_config_reloader.subprocess.check_output')
        self.tm = NginxConfigReloader(no_magento_config=False,
                                      no_custom_config=False,
                                      dir_to_watch='/data/web/nginx',
                                      magento2_flag=None)

    def test_fix_custom_config_dir_permissions_chmods_all_dirs_to_755(self):
        self.tm.fix_custom_config_dir_permissions()

        self.check_output.assert_called_once_with(
            [
                'find', self.tm.dir_to_watch, '-type', 'd', '-exec', 'chmod',
                '0755', '{}', ';'
            ],
            preexec_fn=as_unprivileged_user,
            stderr=subprocess.STDOUT)

    def test_fix_custom_config_dir_permissions_does_not_raise_if_find_fails(
            self):
        self.check_output.side_effect = subprocess.CalledProcessError(
            '', '', '')
        self.tm.fix_custom_config_dir_permissions()
    def test_assert_no_includes_in_config_does_not_check_config_if_no_dir_to_watch(
            self):
        self.isdir.return_value = False

        NginxConfigReloader.check_no_forbidden_config_directives_are_present(
            NginxConfigReloader())

        self.assertFalse(self.check_output.called)
コード例 #4
0
    def test_assert_no_includes_in_config_checks_user_nginx_dir_for_forbidden_includes(self):
        NginxConfigReloader.assert_no_includes_in_config()

        expected_command = "[ $(grep -r -P '^(?!\\s*#)\\s*(include|load_module)" \
                           "\\s*(\\042|\\047)?(?=.*\\.\\.|/+etc/+nginx/+app_bak|" \
                           "/+(?!etc/+nginx))(\\042|\\047)?' " \
                           "'/data/web/nginx' | wc -l) -lt 1 ]"
        self.check_output.assert_called_once_with(expected_command, shell=True)
 def setUp(self):
     self.check_output = self.set_up_patch(
         'nginx_config_reloader.subprocess.check_output'
     )
     self.tm = NginxConfigReloader(
         no_magento_config=False,
         no_custom_config=False,
         dir_to_watch='/data/web/nginx',
         magento2_flag=None
     )
class TestFixCustomConfigDirPermissions(TestCase):
    def setUp(self):
        self.check_output = self.set_up_patch(
            'nginx_config_reloader.subprocess.check_output'
        )
        self.tm = NginxConfigReloader(
            no_magento_config=False,
            no_custom_config=False,
            dir_to_watch='/data/web/nginx',
            magento2_flag=None
        )

    def test_fix_custom_config_dir_permissions_chmods_all_dirs_to_755(self):
        self.tm.fix_custom_config_dir_permissions()

        self.check_output.assert_called_once_with(
            ['find', self.tm.dir_to_watch, '-type', 'd', '-exec', 'chmod', '0755', '{}', ';'],
            preexec_fn=as_unprivileged_user,
            stderr=subprocess.STDOUT
        )

    def test_fix_custom_config_dir_permissions_does_not_raise_if_find_fails(self):
        self.check_output.side_effect = subprocess.CalledProcessError('', '', '')
        self.tm.fix_custom_config_dir_permissions()
コード例 #7
0
    def test_assert_no_includes_in_config_does_not_check_config_if_no_dir_to_watch(self):
        self.isdir.return_value = False

        NginxConfigReloader.assert_no_includes_in_config()

        self.assertFalse(self.check_output.called)
    def test_assert_no_includes_in_config_does_not_check_config_if_no_dir_to_watch(self):
        self.isdir.return_value = False

        NginxConfigReloader.check_no_forbidden_config_directives_are_present(NginxConfigReloader())

        self.assertFalse(self.check_output.called)