Exemple #1
0
 def test_write_cr_file_v_foo_rh(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: RedHat
       - If instance running with uid that doesn't match crontab user uid, run with -u flag
     '''
     cron.__grains__ = {'os_family': 'RedHat'}
     with patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}):
         cron.write_cron_file_verbose('foo', STUB_PATH)
         cron.__salt__['cmd.run_all'].assert_called_with(
             "crontab -u foo /tmp", python_shell=False)
Exemple #2
0
 def test_write_cr_file_v_foo_rh(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: RedHat
       - If instance running with uid that doesn't match crontab user uid, run with -u flag
     '''
     cron.__grains__ = {'os_family': 'RedHat'}
     with patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}):
         cron.write_cron_file_verbose('foo', STUB_PATH)
         cron.__salt__['cmd.run_all'].assert_called_with("crontab -u foo /tmp",
                                                         python_shell=False)
Exemple #3
0
 def test_write_cr_file_v_foo_aix(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: AIX
       - AIX should always run without a -u flag
     '''
     with patch.dict(cron.__grains__, {'os_family': 'AIX'}):
         with patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}):
             cron.write_cron_file_verbose('foo', STUB_PATH)
             cron.__salt__['cmd.run_all'].assert_called_with(
                 "crontab /tmp", runas='foo', python_shell=False)
Exemple #4
0
 def test_write_cr_file_v_root_sol(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: Solaris
       - Solaris should always run without a -u flag
     '''
     with patch.dict(cron.__grains__, {'os_family': 'Solaris'}):
         with patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}):
             cron.write_cron_file_verbose(STUB_USER, STUB_PATH)
             cron.__salt__['cmd.run_all'].assert_called_with(
                 "crontab /tmp", runas=STUB_USER, python_shell=False)
Exemple #5
0
 def test_write_cr_file_v_root_rh(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: RedHat
       - If instance running uid matches crontab user uid, runas STUB_USER without -u flag.
     '''
     with patch.dict(cron.__grains__, {'os_family': 'Redhat'}):
         with patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}):
             cron.write_cron_file_verbose(STUB_USER, STUB_PATH)
             cron.__salt__['cmd.run_all'].assert_called_with(
                 "crontab /tmp", runas=STUB_USER, python_shell=False)
Exemple #6
0
 def test_write_cr_file_v_foo_aix(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: AIX
       - AIX should always run without a -u flag
     '''
     cron.__grains__ = {'os_family': 'AIX'}
     with patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}):
         cron.write_cron_file_verbose('foo', STUB_PATH)
         cron.__salt__['cmd.run_all'].assert_called_with("crontab /tmp",
                                                         runas='foo',
                                                         python_shell=False)
Exemple #7
0
 def test_write_cr_file_v_root_sol(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: Solaris
       - Solaris should always run without a -u flag
     '''
     cron.__grains__ = {'os_family': 'Solaris'}
     with patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}):
         cron.write_cron_file_verbose(STUB_USER, STUB_PATH)
         cron.__salt__['cmd.run_all'].assert_called_with("crontab /tmp",
                                                         runas=STUB_USER,
                                                         python_shell=False)
Exemple #8
0
 def test_write_cr_file_v_root_rh(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: RedHat
       - If instance running uid matches crontab user uid, runas STUB_USER without -u flag.
     '''
     cron.__grains__ = {'os_family': 'RedHat'}
     with patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}):
         cron.write_cron_file_verbose(STUB_USER, STUB_PATH)
         cron.__salt__['cmd.run_all'].assert_called_with("crontab /tmp",
                                                         runas=STUB_USER,
                                                         python_shell=False)
Exemple #9
0
 def test_write_cr_file_v_root_aix(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: AIX
       - AIX should always run without a -u flag
     '''
     with patch.dict(cron.__grains__, {'os_family': 'AIX'}), \
             patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}), \
                 patch('salt.modules.cron._check_instance_uid_match',
                       MagicMock(return_value=True)):
         cron.write_cron_file_verbose(STUB_USER, STUB_PATH)
         cron.__salt__['cmd.run_all'].assert_called_with("crontab /tmp",
                                                         runas=STUB_USER,
                                                         python_shell=False)
Exemple #10
0
 def test_write_cr_file_v_foo_rh(self):
     '''
     Assert that write_cron_file_verbose() is called with the correct cron command and user: RedHat
       - If instance running with uid that doesn't match crontab user uid, runas 'foo'
     '''
     with patch.dict(cron.__grains__, {'os_family': 'Redhat'}), \
             patch.dict(cron.__salt__, {'cmd.run_all': MagicMock()}), \
                 patch('salt.modules.cron._check_instance_uid_match',
                         MagicMock(return_value=False)):
         cron.write_cron_file_verbose('foo', STUB_PATH)
         cron.__salt__['cmd.run_all'].assert_called_with("crontab /tmp",
                                                         runas='foo',
                                                         python_shell=False)