mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
8cdb9ea54f
This makes the 2.x usage invalid syntax and forces the use of print as a function. This adds the import to the files which I've updated in the last couple of days but forgot to add it.
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
'''
|
|
:codeauthor: :email:`Rupesh Tare <rupesht@saltstack.com>`
|
|
'''
|
|
|
|
# Import Python libs
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
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')
|