2015-03-25 08:16:11 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
2018-05-28 21:13:12 +00:00
|
|
|
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
|
2015-03-25 08:16:11 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
# Import Python Libs
|
2018-01-24 20:47:14 +00:00
|
|
|
from __future__ import absolute_import, unicode_literals, print_function
|
2016-04-08 16:19:41 +00:00
|
|
|
import sys
|
2015-03-25 08:16:11 +00:00
|
|
|
|
|
|
|
# Import Salt Testing Libs
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.unit import TestCase, skipIf
|
|
|
|
from tests.support.mock import (
|
2015-03-25 08:16:11 +00:00
|
|
|
patch,
|
|
|
|
mock_open,
|
|
|
|
NO_MOCK,
|
|
|
|
NO_MOCK_REASON
|
|
|
|
)
|
|
|
|
|
|
|
|
# Import Salt Libs
|
2017-03-21 17:15:36 +00:00
|
|
|
import salt.modules.pam as pam
|
2015-03-25 08:16:11 +00:00
|
|
|
|
|
|
|
MOCK_FILE = 'ok ok ignore '
|
|
|
|
|
|
|
|
|
|
|
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
2016-11-09 20:58:08 +00:00
|
|
|
@skipIf(sys.platform.startswith('openbsd'), 'OpenBSD does not use PAM')
|
2015-03-25 08:16:11 +00:00
|
|
|
class PamTestCase(TestCase):
|
|
|
|
'''
|
|
|
|
Test cases for salt.modules.pam
|
|
|
|
'''
|
|
|
|
# 'read_file' function tests: 1
|
|
|
|
|
|
|
|
def test_read_file(self):
|
|
|
|
'''
|
|
|
|
Test if the parsing function works
|
|
|
|
'''
|
2017-09-07 21:18:14 +00:00
|
|
|
with patch('os.path.exists', return_value=True), \
|
2017-09-11 16:55:39 +00:00
|
|
|
patch('salt.utils.files.fopen', mock_open(read_data=MOCK_FILE)):
|
2015-03-25 08:16:11 +00:00
|
|
|
self.assertListEqual(pam.read_file('/etc/pam.d/login'),
|
|
|
|
[{'arguments': [], 'control_flag': 'ok',
|
|
|
|
'interface': 'ok', 'module': 'ignore'}])
|