本文整理汇总了Python中src.stonix_resources.CommandHelper.CommandHelper类的典型用法代码示例。如果您正苦于以下问题:Python CommandHelper类的具体用法?Python CommandHelper怎么用?Python CommandHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommandHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: zzzTestRuleNoDirectRootLogin
class zzzTestRuleNoDirectRootLogin(RuleTest):
def setUp(self):
RuleTest.setUp(self)
self.rule = NoDirectRootLogin(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.checkUndo = True
self.ch = CommandHelper(self.logdispatch)
self.securettypath = "/etc/securetty"
def runTest(self):
self.simpleRuleTest()
def setConditionsForRule(self):
'''
Configure system to fail before the unit test
@param self: essential if you override this definition
@return: boolean - If successful True; If failure False
@author: Brandon R. Gonzales
'''
success = True
if os.path.exists(self.securettypath):
cmd = ["rm", self.securettypath]
self.ch.executeCommand(cmd)
return success
开发者ID:CSD-Public,项目名称:stonix,代码行数:30,代码来源:zzzTestRuleNoDirectRootLogin.py
示例2: zzzTestRuleEncryptSwap
class zzzTestRuleEncryptSwap(RuleTest):
def setUp(self):
RuleTest.setUp(self)
self.rule = EncryptSwap(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
def tearDown(self):
pass
def runTest(self):
self.simpleRuleTest()
def setConditionsForRule(self):
'''
This method runs the following command to make sure system is in a
non compliant state before rule runs:
sudo defaults write /Library/Preferences/com.apple.virtualMemory
UseEncryptedSwap -bool no
@author: dwalker
@return: bool - True if successful, False if not
'''
cmd = ["/usr/bin/defaults", "write",
"/Library/Preferences/com.apple.virtualMemory", "-bool", "no"]
if self.ch.executeCommand(cmd):
return True
else:
return False
开发者ID:CSD-Public,项目名称:stonix,代码行数:33,代码来源:zzzTestRuleEncryptSwap.py
示例3: zzzTestFrameworkCommandHelper
class zzzTestFrameworkCommandHelper(unittest.TestCase):
'''
Perform tests on different parts of the functionality for framework CommandHelper
@param unittest.TestCase: unittest TestCase class inheritance object reference
@author: ekkehard
@change: Breen Malmberg - 04/11/2018 - removed assertion tests -
you can't test for exception assertions in code that is wrapped by try
except because the try except intercepts the exception and throws it
and it never gets back to the assertraises call (see tf ticket for documentation)
'''
def setUp(self):
'''
'''
self.enviro = Environment()
self.enviro.setdebugmode(True)
self.logger = LogDispatcher(self.enviro)
self.commandhelper = CommandHelper(self.logger)
def tearDown(self):
'''
'''
pass
def testExecuteValidCommand(self):
'''
'''
self.assertTrue(self.commandhelper.executeCommand("ls -l /"),
"Execute Valid Command string Failed!")
self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]),
"Execute Valid Command List Failed!")
def testSetLogPriority(self):
'''
'''
self.assertTrue(self.commandhelper.setLogPriority(LogPriority.INFO),
"Execute setLogPriority(0) Command string Failed!")
self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]),
"Execute commandhelper.executeCommand(['ls','-l','/'])"
+ " Command List Failed!")
开发者ID:CSD-Public,项目名称:stonix,代码行数:47,代码来源:zzzTestFrameworkCommandHelper.py
示例4: zzzTestFrameworkCommandHelper
class zzzTestFrameworkCommandHelper(unittest.TestCase):
def setUp(self):
self.enviro = Environment()
self.enviro.setdebugmode(True)
self.logger = LogDispatcher(self.enviro)
self.commandhelper = CommandHelper(self.logger)
def tearDown(self):
pass
def testBlankCommand(self):
self.assertRaises(ValueError, self.commandhelper.setCommand, "")
self.assertRaises(TypeError, self.commandhelper.executeCommand, None)
self.assertRaises(ValueError, self.commandhelper.executeCommand, "")
self.assertRaises(ValueError, self.commandhelper.setCommand, [])
self.assertRaises(TypeError, self.commandhelper.executeCommand, None)
self.assertRaises(ValueError, self.commandhelper.executeCommand, [])
def testExecuteValidCommand(self):
self.assertTrue(self.commandhelper.executeCommand("ls -l /"),
"Execute Valid Command string Failed!")
self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]),
"Execute Valid Command List Failed!")
def testExecuteInvalidCommand(self):
self.assertRaises(TypeError, self.commandhelper.executeCommand, 0)
self.assertRaises(TypeError, self.commandhelper.executeCommand,
['ls', 0, '/'])
def testSetLogPriority(self):
self.assertRaises(TypeError, self.commandhelper.setLogPriority, 0)
self.assertTrue(self.commandhelper.setLogPriority(LogPriority.INFO),
"Execute setLogPriority(0) Command string Failed!")
self.assertTrue(self.commandhelper.executeCommand(["ls", "-l", "/"]),
"Execute commandhelper.executeCommand(['ls','-l','/'])"
+ " Command List Failed!")
开发者ID:inscriptionweb,项目名称:stonix,代码行数:46,代码来源:zzzTestFrameworkCommandHelper.py
示例5: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = DisableGUILogon(self.config, self.environ,
self.logdispatch, self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
self.sh = ServiceHelper(self.environ, self.logdispatch)
开发者ID:inscriptionweb,项目名称:stonix,代码行数:8,代码来源:zzzTestRuleDisableGUILogon.py
示例6: setUp
def setUp(self):
'''
'''
self.enviro = Environment()
self.enviro.setdebugmode(True)
self.logger = LogDispatcher(self.enviro)
self.commandhelper = CommandHelper(self.logger)
开发者ID:CSD-Public,项目名称:stonix,代码行数:8,代码来源:zzzTestFrameworkCommandHelper.py
示例7: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = ConfigureGatekeeper(self.config, self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
开发者ID:inscriptionweb,项目名称:stonix,代码行数:8,代码来源:zzzTestRuleConfigureGatekeeper.py
示例8: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = DisableGuestAccess(self.config, self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
self.dc = "/usr/bin/defaults"
开发者ID:inscriptionweb,项目名称:stonix,代码行数:9,代码来源:zzzTestRuleDisableGuestAccess.py
示例9: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = SystemAccounting(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
开发者ID:inscriptionweb,项目名称:stonix,代码行数:9,代码来源:zzzTestRuleSystemAccounting.py
示例10: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = DisableInactiveAccounts(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
开发者ID:CSD-Public,项目名称:stonix,代码行数:9,代码来源:zzzTestRuleDisableInactiveAccounts.py
示例11: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = EnableKernelAuditing(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
开发者ID:CSD-Public,项目名称:stonix,代码行数:9,代码来源:zzzTestRuleEnableKernelAuditing.py
示例12: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = NoCachedFDEKeys(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
开发者ID:CSD-Public,项目名称:stonix,代码行数:9,代码来源:zzzTestRuleNoCachedFDEKeys.py
示例13: __init__
def __init__(self, userName="", userShell="/bin/bash",
userComment="", userUid=1000, userPriGid=20,
userHomeDir="/tmp", logger=False):
super(MacOSUser, self).__init__(userName, userShell,
userComment, userUid, userPriGid,
userHomeDir, logger)
self.module_version = '20160225.125554.540679'
self.dscl = "/usr/bin/dscl"
self.cmdh = CommandHelper(self.logger)
开发者ID:CSD-Public,项目名称:stonix,代码行数:9,代码来源:macos_users.py
示例14: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = RestrictMounting(self.config, self.environ,
self.logdispatch, self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
self.ph = Pkghelper(self.logdispatch, self.environ)
self.sh = ServiceHelper(self.environ, self.logdispatch)
开发者ID:inscriptionweb,项目名称:stonix,代码行数:9,代码来源:zzzTestRuleRestrictMounting.py
示例15: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = ConfigureRemoteManagement(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.cmdhelper = CommandHelper(self.logdispatch)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
开发者ID:inscriptionweb,项目名称:stonix,代码行数:10,代码来源:zzzTestRuleConfigureRemoteManagement.py
示例16: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = ConfigureLoginWindow(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
self.dc = "/usr/bin/defaults"
开发者ID:inscriptionweb,项目名称:stonix,代码行数:10,代码来源:zzzTestRuleConfigureLoginWindow.py
示例17: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = ReqPassSysPref(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.cmdhelper = CommandHelper(self.logdispatch)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
开发者ID:CSD-Public,项目名称:stonix,代码行数:10,代码来源:zzzTestRuleReqPassSysPref.py
示例18: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = SetNTP(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.ch = CommandHelper(self.logdispatch)
self.ss = "/usr/sbin/systemsetup"
开发者ID:CSD-Public,项目名称:stonix,代码行数:10,代码来源:zzzTestRuleSetNTP.py
示例19: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = DisableAFPFileSharing(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.cmdhelper = CommandHelper(self.logdispatch)
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
开发者ID:CSD-Public,项目名称:stonix,代码行数:10,代码来源:zzzTestRuleDisableAFPFileSharing.py
示例20: setUp
def setUp(self):
RuleTest.setUp(self)
self.rule = NoCoreDumps(self.config,
self.environ,
self.logdispatch,
self.statechglogger)
self.logger = self.logdispatch
self.rulename = self.rule.rulename
self.rulenumber = self.rule.rulenumber
self.checkUndo = True
self.ch = CommandHelper(self.logger)
开发者ID:CSD-Public,项目名称:stonix,代码行数:11,代码来源:zzzTestRuleNoCoreDumps.py
注:本文中的src.stonix_resources.CommandHelper.CommandHelper类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论