summaryrefslogtreecommitdiff
path: root/tests/daemon/test_daemon.py
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2017-05-18 19:58:02 +0200
committerusd-importer <ubuntu-server@lists.ubuntu.com>2017-05-31 09:53:12 +0000
commit4fb0b5a09b26135ade285844da5d7dfe582a8d4c (patch)
tree09b1e5867d6e7501118cdd0af0012b51fc216530 /tests/daemon/test_daemon.py
parent473ad6fbfe0b9c3b362b530492928303f2b4c7f3 (diff)
downloadvyos-walinuxagent-4fb0b5a09b26135ade285844da5d7dfe582a8d4c.tar.gz
vyos-walinuxagent-4fb0b5a09b26135ade285844da5d7dfe582a8d4c.zip
Import patches-unapplied version 2.2.12-0ubuntu1 to ubuntu/artful-proposed
Imported using git-ubuntu import. Changelog parent: 473ad6fbfe0b9c3b362b530492928303f2b4c7f3 New changelog entries: * New upstream release (LP: #1690854). - Refreshed debian/patches/disable_import_test.patch.
Diffstat (limited to 'tests/daemon/test_daemon.py')
-rw-r--r--tests/daemon/test_daemon.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/daemon/test_daemon.py b/tests/daemon/test_daemon.py
index dd31fd7..5694dc9 100644
--- a/tests/daemon/test_daemon.py
+++ b/tests/daemon/test_daemon.py
@@ -14,7 +14,9 @@
#
# Requires Python 2.4+ and Openssl 1.0+
#
-from azurelinuxagent.daemon import get_daemon_handler
+
+from azurelinuxagent.daemon import *
+from azurelinuxagent.daemon.main import OPENSSL_FIPS_ENVIRONMENT
from tests.tools import *
@@ -30,8 +32,9 @@ class MockDaemonCall(object):
self.daemon_handler.running = False
raise Exception("Mock unhandled exception")
-@patch("time.sleep")
class TestDaemon(AgentTestCase):
+
+ @patch("time.sleep")
def test_daemon_restart(self, mock_sleep):
#Mock daemon function
daemon_handler = get_daemon_handler()
@@ -45,6 +48,7 @@ class TestDaemon(AgentTestCase):
mock_sleep.assert_any_call(15)
self.assertEquals(2, daemon_handler.daemon.call_count)
+ @patch("time.sleep")
@patch("azurelinuxagent.daemon.main.conf")
@patch("azurelinuxagent.daemon.main.sys.exit")
def test_check_pid(self, mock_exit, mock_conf, mock_sleep):
@@ -58,6 +62,25 @@ class TestDaemon(AgentTestCase):
daemon_handler.check_pid()
mock_exit.assert_any_call(0)
+
+ @patch("azurelinuxagent.daemon.main.DaemonHandler.check_pid")
+ @patch("azurelinuxagent.common.conf.get_fips_enabled", return_value=True)
+ def test_set_openssl_fips(self, mock_conf, mock_daemon):
+ daemon_handler = get_daemon_handler()
+ daemon_handler.running = False
+ with patch.dict("os.environ"):
+ daemon_handler.run()
+ self.assertTrue(OPENSSL_FIPS_ENVIRONMENT in os.environ)
+ self.assertEqual('1', os.environ[OPENSSL_FIPS_ENVIRONMENT])
+
+ @patch("azurelinuxagent.daemon.main.DaemonHandler.check_pid")
+ @patch("azurelinuxagent.common.conf.get_fips_enabled", return_value=False)
+ def test_does_not_set_openssl_fips(self, mock_conf, mock_daemon):
+ daemon_handler = get_daemon_handler()
+ daemon_handler.running = False
+ with patch.dict("os.environ"):
+ daemon_handler.run()
+ self.assertFalse(OPENSSL_FIPS_ENVIRONMENT in os.environ)
if __name__ == '__main__':
unittest.main()