''' # Import Python Libs from __future__ import absolute_import # Import Salt Testing Libs from salttesting import TestCase, skipIf from salttesting.helpers import ensure_in_syspath from salttesting.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) ensure_in_syspath('../../') # Import Salt Libs from salt.states import iptables # Globals iptables.__salt__ = {} iptables.__opts__ = {} @skipIf(NO_MOCK, NO_MOCK_REASON) class IptablesTestCase(TestCase): ''' Validate the iptables state ''' def test_chain_present(self):
:codeauthor: :email:`Pedro Algarvio ([email protected])` :copyright: © 2013 by the SaltStack Team, see AUTHORS for more details. :license: Apache 2.0, see LICENSE for more details. ''' # Import python libs import os import tempfile # Import salt testing libs from salttesting.helpers import ensure_in_syspath from salttesting.parser.cover import SaltCoverageTestingParser TEST_DIR = os.path.abspath(os.path.dirname(__file__)) SALTCLOUD_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) ensure_in_syspath(SALTCLOUD_ROOT) XML_OUTPUT_DIR = os.environ.get( 'XML_TEST_REPORTS', os.path.join( tempfile.gettempdir(), 'xml-test-reports' ) ) HTML_OUTPUT_DIR = os.environ.get( 'HTML_OUTPUT_DIR', os.path.join( tempfile.gettempdir(), 'html-test-results' ) ) try: if SALTCLOUD_ROOT:
# -*- coding: utf-8 -*- # Import python libs from __future__ import absolute_import # Import Salt Libs from salt import acl # Import Salt Testing Libs from salttesting import TestCase, skipIf from salttesting.mock import NO_MOCK, NO_MOCK_REASON from salttesting.helpers import ensure_in_syspath ensure_in_syspath("../../") @skipIf(NO_MOCK, NO_MOCK_REASON) class ClientACLTestCase(TestCase): """ Unit tests for salt.acl.ClientACL """ def setUp(self): self.blacklist = { "users": ["joker", "penguin", "*bad_*", "blocked_.*", "^Homer$"], "modules": ["cmd.run", "test.fib", "rm-rf.*"], } def test_user_is_blacklisted(self): """ test user_is_blacklisted
) INTEGRATION_TEST_DIR = os.path.dirname( os.path.normpath(os.path.abspath(__file__)) ) CODE_DIR = os.path.dirname(os.path.dirname(INTEGRATION_TEST_DIR)) SALT_LIBS = os.path.dirname(CODE_DIR) # Import Salt Testing libs from salttesting import TestCase from salttesting.case import ShellTestCase from salttesting.mixins import CheckShellBinaryNameAndVersionMixIn from salttesting.parser import PNUM, print_header, SaltTestcaseParser from salttesting.helpers import ensure_in_syspath, RedirectStdStreams # Update sys.path ensure_in_syspath(CODE_DIR, SALT_LIBS) # Import Salt libs import salt import salt._compat import salt.config import salt.master import salt.minion import salt.runner import salt.output import salt.version import salt.utils from salt.utils import fopen, get_colors from salt.utils.verify import verify_env # Import 3rd-party libs
# -*- coding: utf-8 -*- # Import Salt Testing libs from salttesting import TestCase, skipIf from salttesting.helpers import ensure_in_syspath #from salttesting.mock import patch, call, NO_MOCK, NO_MOCK_REASON #, MagicMock ensure_in_syspath('../../../_modules') import profiles profiles.__salt__ = {} class ProfilesTestCase(TestCase): def test_payloadcontent_to_uuid(self): uuid = profiles._content_to_uuid('ABCDEF') print(uuid) if __name__ == '__main__': from ..integration import run_tests run_tests(ProfilesTestCase, needs_daemon=False)
Tests to ensure that the file permissions are set correctly when importing from the git repo. ''' # Import python libs import os import stat import pprint # Import salt testing libs from salttesting import TestCase from salttesting.helpers import ensure_in_syspath ensure_in_syspath('..') from integration import CODE_DIR EXEMPT_DIRS = [] EXEMPT_FILES = [ 'debian/rules', 'doc/.scripts/compile-translation-catalogs', 'doc/.scripts/download-translation-catalog', 'doc/.scripts/setup-transifex-config', 'doc/.scripts/update-transifex-source-translations', 'pkg/arch/Makefile', 'pkg/arch/PKGBUILD', 'pkg/arch/PKGBUILD-git', 'pkg/arch/PKGBUILD-local', 'pkg/arch/git/PKGBUILD',
# -*- coding: utf-8 -*- # Import python libs from __future__ import absolute_import, print_function import os # Import Salt Testing libs from salttesting import skipIf, TestCase from salttesting.helpers import ensure_in_syspath from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch ensure_in_syspath( os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../../')) ensure_in_syspath( os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../')) # Import salt libs from salt.modules import deb_postgres deb_postgres.__grains__ = None # in order to stub it w/patch below deb_postgres.__salt__ = None # in order to stub it w/patch below LSCLUSTER = '''\ 8.4 main 5432 online postgres /srv/8.4/main \ /var/log/postgresql/postgresql-8.4-main.log 9.1 main 5433 online postgres /srv/9.1/main \ /var/log/postgresql/postgresql-9.1-main.log ''' if NO_MOCK is False: SALT_STUB = { 'config.option': Mock(),
# -*- coding: utf-8 -*- ''' Tests for the salt-run command ''' # Import python libs from __future__ import absolute_import import os import yaml import shutil # Import Salt Testing libs from salttesting.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs import integration from integration.utils import testprogram import salt.utils class RunTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixIn): ''' Test the salt-run command ''' _call_binary_ = 'salt-run' def test_in_docs(self): '''