salt/tests/unit/modules/test_key.py
Erik Johnson c6b655b6e9
Move 14 more functions from salt.utils
These functions are:

salt.utils.test_mode -> salt.utils.args.test_mode
salt.utils.split_input -> salt.utils.args.split_input
alt.utils.pem_finger -> salt.utils.crypt.pem_finger
salt.utils.is_bin_file -> salt.utils.files.is_binary
salt.utils.list_files -> salt.utils.files.list_files
salt.utils.safe_walk -> salt.utils.files.safe_walk
salt.utils.st_mode_to_octal -> salt.utils.files.st_mode_to_octal
salt.utils.normalize_mode -> salt.utils.files.normalize_mode
salt.utils.human_size_to_bytes -> salt.utils.files.human_size_to_bytes
salt.utils.get_hash -> salt.utils.hashutils.get_hash
salt.utils.is_list -> salt.utils.data.is_list
salt.utils.is_iter -> salt.utils.data.is_iter
salt.utils.isorted -> salt.utils.data.sorted_ignorecase
salt.utils.is_true -> salt.utils.data.is_true
2017-10-13 09:29:03 -05:00

54 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Rupesh Tare <rupesht@saltstack.com>`
'''
# Import Python libs
from __future__ import absolute_import
import os.path
# Import Salt Testing Libs
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase, skipIf
from tests.support.mock import (
MagicMock,
patch,
NO_MOCK,
NO_MOCK_REASON
)
# Import Salt Libs
import salt.utils.crypt
import salt.modules.key as key
@skipIf(NO_MOCK, NO_MOCK_REASON)
class KeyTestCase(TestCase, LoaderModuleMockMixin):
'''
Test cases for salt.modules.key
'''
def setup_loader_modules(self):
return {key: {}}
def test_finger(self):
'''
Test for finger
'''
with patch.object(os.path, 'join', return_value='A'):
with patch.object(salt.utils.crypt,
'pem_finger', return_value='A'):
with patch.dict(key.__opts__,
{'pki_dir': MagicMock(return_value='A'), 'hash_type': 'sha256'}):
self.assertEqual(key.finger(), 'A')
def test_finger_master(self):
'''
Test for finger
'''
with patch.object(os.path, 'join', return_value='A'):
with patch.object(salt.utils.crypt,
'pem_finger', return_value='A'):
with patch.dict(key.__opts__,
{'pki_dir': 'A', 'hash_type': 'sha256'}):
self.assertEqual(key.finger_master(), 'A')