2018-04-11 18:47:08 +02:00
|
|
|
From 589d90117783a126dce695cf76a3b8fc2953f8b6 Mon Sep 17 00:00:00 2001
|
2018-03-19 09:54:13 +01:00
|
|
|
From: Mihai Dinca <mdinca@suse.de>
|
|
|
|
Date: Fri, 2 Mar 2018 17:17:58 +0100
|
|
|
|
Subject: [PATCH] Fix openscap push
|
|
|
|
|
|
|
|
---
|
2018-04-11 18:47:08 +02:00
|
|
|
salt/modules/openscap.py | 4 +---
|
|
|
|
tests/unit/modules/test_openscap.py | 10 +++++-----
|
|
|
|
2 files changed, 6 insertions(+), 8 deletions(-)
|
2018-03-19 09:54:13 +01:00
|
|
|
|
|
|
|
diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py
|
|
|
|
index c5b51a1846..e3190e1e11 100644
|
|
|
|
--- a/salt/modules/openscap.py
|
|
|
|
+++ b/salt/modules/openscap.py
|
|
|
|
@@ -13,7 +13,6 @@ from subprocess import Popen, PIPE
|
|
|
|
|
|
|
|
# Import Salt libs
|
|
|
|
from salt.ext import six
|
|
|
|
-from salt.client import Caller
|
|
|
|
|
|
|
|
|
|
|
|
ArgumentParser = object
|
|
|
|
@@ -105,8 +104,7 @@ def xccdf(params):
|
|
|
|
success = _OSCAP_EXIT_CODES_MAP[proc.returncode]
|
|
|
|
returncode = proc.returncode
|
|
|
|
if success:
|
|
|
|
- caller = Caller()
|
|
|
|
- caller.cmd('cp.push_dir', tempdir)
|
|
|
|
+ __salt__['cp.push_dir'](tempdir)
|
|
|
|
shutil.rmtree(tempdir, ignore_errors=True)
|
|
|
|
upload_dir = tempdir
|
|
|
|
|
2018-04-11 18:47:08 +02:00
|
|
|
diff --git a/tests/unit/modules/test_openscap.py b/tests/unit/modules/test_openscap.py
|
|
|
|
index eb8ad1225b..6e17148de1 100644
|
|
|
|
--- a/tests/unit/modules/test_openscap.py
|
|
|
|
+++ b/tests/unit/modules/test_openscap.py
|
|
|
|
@@ -28,8 +28,10 @@ class OpenscapTestCase(TestCase):
|
|
|
|
policy_file = '/usr/share/openscap/policy-file-xccdf.xml'
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
+ import salt.modules.openscap
|
|
|
|
+ salt.modules.openscap.__salt__ = MagicMock()
|
|
|
|
patchers = [
|
|
|
|
- patch('salt.modules.openscap.Caller', MagicMock()),
|
|
|
|
+ patch('salt.modules.openscap.__salt__', MagicMock()),
|
|
|
|
patch('salt.modules.openscap.shutil.rmtree', Mock()),
|
|
|
|
patch(
|
|
|
|
'salt.modules.openscap.tempfile.mkdtemp',
|
|
|
|
@@ -68,8 +70,7 @@ class OpenscapTestCase(TestCase):
|
|
|
|
cwd=openscap.tempfile.mkdtemp.return_value,
|
|
|
|
stderr=PIPE,
|
|
|
|
stdout=PIPE)
|
|
|
|
- openscap.Caller().cmd.assert_called_once_with(
|
|
|
|
- 'cp.push_dir', self.random_temp_dir)
|
|
|
|
+ openscap.__salt__['cp.push_dir'].assert_called_once_with(self.random_temp_dir)
|
|
|
|
self.assertEqual(openscap.shutil.rmtree.call_count, 1)
|
|
|
|
self.assertEqual(
|
|
|
|
response,
|
|
|
|
@@ -106,8 +107,7 @@ class OpenscapTestCase(TestCase):
|
|
|
|
cwd=openscap.tempfile.mkdtemp.return_value,
|
|
|
|
stderr=PIPE,
|
|
|
|
stdout=PIPE)
|
|
|
|
- openscap.Caller().cmd.assert_called_once_with(
|
|
|
|
- 'cp.push_dir', self.random_temp_dir)
|
|
|
|
+ openscap.__salt__['cp.push_dir'].assert_called_once_with(self.random_temp_dir)
|
|
|
|
self.assertEqual(openscap.shutil.rmtree.call_count, 1)
|
|
|
|
self.assertEqual(
|
|
|
|
response,
|
2018-03-19 09:54:13 +01:00
|
|
|
--
|
|
|
|
2.16.2
|
|
|
|
|
|
|
|
|