class test_Connectivity_is_page_available(unittest.TestCase):
    def setUp(self):
        ''' '''

        self.environ = Environment()
        self.logdispatcher = LogDispatcher(self.environ)
        self.conn = Connectivity(self.logdispatcher, use_proxy=True)

    def assert_value(self, expected, test_iteration, site, page):
        '''

        :param expected: 
        :param test_iteration: 
        :param site: 
        :param page: 

        '''

        if expected:
            self.assertTrue(
                self.conn.is_site_available(site, page),
                "Could not reach page " + page + " at site " + site)
        else:
            self.assertFalse(self.conn.is_site_available(site, page),
                             "Found page " + page + " at site " + site)
class test_Connectivity_is_site_socket_online(unittest.TestCase):
    def setUp(self):
        self.environ = Environment()
        self.logdispatcher = LogDispatcher(self.environ)
        self.conn = Connectivity(self.logdispatcher)

    def assert_value(self, test_iteration, pass_or_not, host):

        if pass_or_not:
            self.assertTrue(self.conn.is_site_socket_online(host))
        else:
            self.assertFalse(self.conn.is_site_socket_online(host))
class test_Connectivity_is_site_socket_online(unittest.TestCase):

    def setUp(self):
        self.environ = Environment()
        self.logdispatcher = LogDispatcher(self.environ)
        self.conn = Connectivity(self.logdispatcher)

    def assert_value(self, test_iteration, pass_or_not, host):

        if pass_or_not:
            self.assertTrue(self.conn.is_site_socket_online(host))
        else:
            self.assertFalse(self.conn.is_site_socket_online(host))
示例#4
0
class test_Connectivity_is_page_available(unittest.TestCase):

    def setUp(self):
        self.environ = Environment()
        self.logdispatcher = LogDispatcher(self.environ)
        self.conn = Connectivity(self.logdispatcher)

    def assert_value(self, expected, test_iteration, site, page):

        if expected:
            self.assertTrue(self.conn.is_site_available(site, page))
        else:
            self.assertFalse(self.conn.is_site_available(site, page))
示例#5
0
    def setUp(self):
        """
        Perform this task before running any of the tests in this class

        @author: Roy Nielsen
        """
        RuleTest.setUp(self)
        self.rule = InstallCasperSuite(self.config, self.environ,
                                       self.logdispatch, self.statechglogger)
        self.rulename = self.rule.rulename
        self.rulenumber = self.rule.rulenumber
        self.ch = CommandHelper(self.logdispatch)
        self.pkgr = MacPkgr(self.environ, self.logdispatch)
        self.pkgUrl = self.rule.reporoot + self.rule.package
        message = "Reporoot: " + str(self.rule.reporoot)
        self.logdispatch.log(LogPriority.DEBUG, message)
        self.connection = Connectivity(self.logdispatch)
    def setUpClass(self):
        """
        """
        self.macPackageName = "testStonixMacPkgr-0.0.3.pkg"
        self.reporoot = MACREPOROOT
        self.environ = Environment()
        self.logger = LogDispatcher(self.environ)
        self.pkgr = MacPkgr(self.environ, self.logger)
        if not self.environ.osfamily == "darwin":
            sys.exit(255)
        self.pkg_dirs = ["/tmp/testStonixMacPkgr-0.0.3/one/two/three/3.5", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/three", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two", \
                         "/tmp/testStonixMacPkgr-0.0.3/one", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/four/five", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/four", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/six/seven"]

        self.pkg_files = ["/tmp/testStonixMacPkgr-0.0.3/one/two/testfile1", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/two/four/five/testfile2", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/testfile3", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/testfile4", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/six/seven/testfile"]

        self.post_files = ["/tmp/testStonixMacPkgr-0.0.3/one/postfile2", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/two/three/3.5/postfile3"]

        self.post_dirs = ["/tmp/testStonixMacPkgr-0.0.3/one/six/6.5"]

        self.all_files = [self.pkg_files, self.post_files]
        self.all_dirs = [self.pkg_dirs, self.post_dirs]
        self.allowed_files_and_dirs = [self.pkg_dirs,
                                       self.pkg_dirs,
                                       self.post_dirs]
        self.ch = CommandHelper(self.logger)
        self.connection = Connectivity(self.logger)
        self.testDomain = "gov.lanl.testStonixMacPkgr.0.0.3.testStonixMacPkgr"
示例#7
0
class zzzTestRuleInstallCasperSuite(RuleTest):
    def setUp(self):
        """
        Perform this task before running any of the tests in this class

        @author: Roy Nielsen
        """
        RuleTest.setUp(self)
        self.rule = InstallCasperSuite(self.config, self.environ,
                                       self.logdispatch, self.statechglogger)
        self.rulename = self.rule.rulename
        self.rulenumber = self.rule.rulenumber
        self.ch = CommandHelper(self.logdispatch)
        self.pkgr = MacPkgr(self.environ, self.logdispatch)
        self.pkgUrl = self.rule.reporoot + self.rule.package
        message = "Reporoot: " + str(self.rule.reporoot)
        self.logdispatch.log(LogPriority.DEBUG, message)
        self.connection = Connectivity(self.logdispatch)

    ###########################################################################

    def tearDown(self):
        pass

    ###########################################################################

    def test_defaultOsInstall(self):
        """
        Test as if testing on a default OS install.  May result initial report
        pass, which would not run Fix mode.

        @author: Roy Nielsen
        """
        #####
        # Ensure the system is set as the default install would be set for this
        # OS
        self.removeJamfFramework()

        #####
        # Run simpleRuleTest
        self.simpleRuleTest()

        #####
        # Validate successful final state
        self.checkForBadInstallation()

    ###########################################################################

    def test_wrongSystemSettings(self):
        """
        Initial state for this test is set up to fail initial report run,
        forcing a fix run.

        @author: Roy Nielsen
        """
        #####
        # Put the system in a known bad state, then run the simpleRuleTest
        self.removeJamfFramework()

        #####
        # Run simpleRuleTest
        self.simpleRuleTest()

        #####
        # Validate successful final state
        self.checkForBadInstallation()

    ###########################################################################

    def test_correctSystemSettigns(self):
        """
        Only report should run.

        @author: Roy Nielsen
        """
        #####
        # Put the system in a known good state, then run the simpleRuleTest

        #####
        # If there is a network connection, install, otherwise just log
        hasconnection = self.connection.isPageAvailable(self.pkgUrl)
        if hasconnection:
            msg = "Connected to " + str(self.rule.package)
            self.logdispatch.log(LogPriority.DEBUG, msg)
            #####
            # Install the package
            if self.pkgr.installPackage(self.rule.package):
                self.rulesuccess = True
                self.rule.touch_imaged()

        #####
        # Run simpleRuleTest
        self.simpleRuleTest()

        #####
        # Validate successful final state
        self.checkForSuccessfullInstallation()

    ###########################################################################

    def test_resultAppend(self):
        """
        Test the unique rule method "resultAppend".

        @author: Roy Nielsen
        """
        #####
        # First test:
        # test the string case
        # self.detailedresults = string
        # passing in string
        self.rule.detailedresults = "Snow season looks good this year..."
        string_to_append = "The End"
        self.rule.resultAppend("The End")
        self.logdispatch.log(LogPriority.DEBUG,
                             "results: " + str(self.rule.detailedresults))
        self.assertTrue(
            re.search("%s" % string_to_append, self.rule.detailedresults))

        #####
        # second test:
        # test the first list case
        # self.detailedresults = list
        # passing in string
        self.rule.detailedresults = ["Snow season looks good this year..."]
        string_to_append = "The End"

        #####
        #####
        # Note here - we're not testing right, but the code passes test.
        # assertRasis isn't the right assert to be using
        self.assertRaises(TypeError, self.rule.resultAppend, string_to_append)

        #####
        # Third test:
        # test the second list case
        # self.detailedresults = list
        # passing in list
        self.rule.detailedresults = ["Snow season looks good this year..."]
        list_to_append = ["The End"]

        #####
        #####
        # Note here - we're not testing right, but the code passes test.
        # assertRasis isn't the right assert to be using
        self.assertRaises(TypeError, self.rule.resultAppend, list_to_append)

        #####
        # fourth test:
        # test the first "else" case
        # self.detailedresults = string
        # passing in boolean
        self.rule.detailedresults = "Snow season looks good this year..."

        #####
        #####
        # Note - assertRaises is being correctly used here
        self.assertRaises(TypeError, self.rule.resultAppend, False)

        #####
        # fifth test:
        # test the second "else" case
        # self.detailedresults = list
        # passing in False
        self.rule.detailedresults = ["Snow season looks good this year..."]

        #####
        #####
        # Note - assertRaises is being correctly used here
        self.assertRaises(TypeError, self.rule.resultAppend, False)

        #####
        # sixth test:
        # test the first "else" case
        # self.detailedresults = string
        # passing in None
        self.rule.detailedresults = "Snow season looks good this year..."

        #####
        #####
        # Note - assertRaises is being correctly used here
        self.assertRaises(TypeError, self.rule.resultAppend, None)

        #####
        # seventh test:
        # test the second "else" case
        # self.detailedresults = list
        # passing in None
        self.rule.detailedresults = ["Snow season looks good this year..."]

        #####
        #####
        # Note - assertRaises is being correctly used here
        self.assertRaises(TypeError, self.rule.resultAppend, None)

        #####
        #####
        # Note, we are not testing the passing in of every python type...
        # Be careful when choosing a representative selection of tests,
        # as critical tests might be missed.
        #
        # In this case, if another valid case is found, a test can be added
        # that will test that specific case, or class of cases.
        #
        # Testing is an iterative process.
        #

    ###########################################################################

    def test_touch_imaged(self):
        """
        Test the unique rule method "touch_imaged".

        The touched_imaged method is not dependent of any other methods, so it
        can be tested atomically.

        @author: Roy Nielsen
        """
        sig1 = "/etc/dds.txt"
        sig2 = "/var/log/dds.log"

        #####
        # Check for the existence of the first signature file, remove it if it
        # exists
        if os.path.exists(sig1):

            os.unlink(sig1)

            foundSig1 = True
        else:
            foundSig1 = False

        #####
        # Check for the existence of the second signature file, remove it if it
        # exists
        if os.path.exists(sig2):
            os.unlink(sig2)
            foundSig2 = True
        else:
            foundSig2 = False

        #####
        # Call the method
        self.rule.touch_imaged()

        #####
        # Check for the first file system signature
        success_a = os.path.isfile("/etc/dds.txt")
        self.logdispatch.log(LogPriority.DEBUG,
                             "Found first signature file...")
        self.assertTrue(success_a)

        #####
        # Check for the Second file system signature
        success_b = os.path.isfile("/var/log/dds.log")
        self.logdispatch.log(LogPriority.DEBUG,
                             "Found second signature file..")
        self.assertTrue(success_b)

        self.assertTrue(success_a and success_b)

        #####
        # If the files didn't exist at the beginning of the test, remove them.
        if not foundSig1:
            os.unlink(sig1)
        if not foundSig2:
            os.unlink(sig2)

    ###########################################################################

    def checkForSuccessfullInstallation(self):
        """
        Check for successfull test run.  Specifically what needs to have
        happened after a successfull run.  IE: must satisfy ALL conditions.

        @author: Roy Nielsen
        """
        #####
        # Check for existence of jamf binary
        success = os.path.isfile("/usr/local/bin/jamf")
        self.logdispatch.log(LogPriority.DEBUG, "Found the jamf binary..")
        self.assertTrue(success)

        #####
        # Check for the existence of the LANL Self Service.app
        success = os.path.isdir("/Applications/LANL Self Service.app")
        self.logdispatch.log(
            LogPriority.DEBUG,
            "Found result: " + str(success) + " Lanl Self Service.app")
        self.assertTrue(success)

        #####
        # Check for the first file system signature
        success = os.path.isfile("/etc/dds.txt")
        self.logdispatch.log(LogPriority.DEBUG, "Found first sig file...")
        self.assertTrue(success)

        #####
        # Check for the Second file system signature
        success = os.path.isfile("/var/log/dds.log")
        self.logdispatch.log(LogPriority.DEBUG, "Found second sig file...")
        self.assertTrue(success)

        #####
        # Check to make sure the "jamf recon" command works
        cmd = ["/usr/local/bin/jamf", "recon"]
        self.ch.executeCommand(cmd)
        return_code = self.ch.getReturnCode()
        self.logdispatch.log(
            LogPriority.DEBUG,
            "Return code from jamf " + " recon command: " + str(return_code))
        self.assertEqual(str(0), str(return_code))

    ###########################################################################

    def checkForBadInstallation(self):
        """
        Check for UNsuccessfull test run.  IE: must fail any of the following
        conditions.  Needs fuzzing applied, or variation on inputs to prove
        the variation works as expected.

        @Note: Running of the "/usr/local/bin/jamf recon" command is not
               executed in this test, as that functionality has already been
               tested.  The other variables need to be "fuzzed". IE, run
               every combination of the variables tested in this test.

        @author: Roy Nielsen
        """

        #####
        # Check if any of the following are false.  At least one must be false.
        success_a = os.path.isfile("/usr/local/bin/jamf")
        success_b = os.path.isdir("/Applications/LANL Self Service.app")
        success_c = os.path.isfile("/etc/dds.txt")
        success_d = os.path.isfile("/var/log/dds.log")

        #####
        # If any of these success parameters are false, the test fails
        self.assertTrue(
            success_a and success_b and success_c and success_d,
            "Could not find all files and directories " +
            "associated with a successful Casper installation")

        #####
        # Future testing needs to perform "fuzzing" - automated or auto
        # generated input testing
        # --
        # for every combination of inputs assert the correct outputs
        #
        # - at least one case is missing in this method - making sure to also
        #   test for the existence of the Jamf plist.
        #

    ###########################################################################

    def setConditionsForRule(self):
        '''Configure system for the unit test

        :param self: essential if you override this definition
        :returns: boolean - If successful True; If failure False
        @author: ekkehard j. koch

        '''
        success = True
        return success

    ###########################################################################

    def checkReportForRule(self, pCompliance, pRuleSuccess):
        '''check on whether report was correct

        :param self: essential if you override this definition
        :param pCompliance: the self.iscompliant value of rule
        :param pRuleSuccess: did report run successfully
        :returns: boolean - If successful True; If failure False
        @author: ekkehard j. koch

        '''
        self.logdispatch.log(LogPriority.DEBUG,
                             "pCompliance = " + str(pCompliance) + ".")
        self.logdispatch.log(LogPriority.DEBUG,
                             "pRuleSuccess = " + str(pRuleSuccess) + ".")

        success = True
        return success

    ###########################################################################

    def checkFixForRule(self, pRuleSuccess):
        '''check on whether fix was correct

        :param self: essential if you override this definition
        :param pRuleSuccess: did report run successfully
        :returns: boolean - If successful True; If failure False
        @author: ekkehard j. koch

        '''
        self.logdispatch.log(LogPriority.DEBUG,
                             "pRuleSuccess = " + str(pRuleSuccess) + ".")

        if pRuleSuccess:
            success = True
        else:
            success = False

        return success

    ###########################################################################

    def checkUndoForRule(self, pRuleSuccess):
        '''check on whether undo was correct

        :param self: essential if you override this definition
        :param pRuleSuccess: did report run successfully
        :returns: boolean - If successful True; If failure False
        @author: ekkehard j. koch

        '''
        self.logdispatch.log(LogPriority.DEBUG,
                             "pRuleSuccess = " + str(pRuleSuccess) + ".")

        if pRuleSuccess:
            success = True
        else:
            success = False

        return success

    ###########################################################################

    def removeJamfFramework(self):
        """
        Remove the jamf framework for setting initial conditions..

        @NOTE: There are many ways that a jamf install can be broken,
               This tests a clean uninstall.  Partial or broken installs
               are not covered in this test, however it may be a good idea
               to test for this in the future.

        @author: Roy Nielsen
        """
        success = False
        jamf_path = "/usr/local/bin/jamf"
        if os.path.exists(jamf_path):
            cmd = [jamf_path, "removeFramework"]

            self.ch.executeCommand(cmd)

            output = self.ch.getOutputString().split("\n")
            self.logdispatch.log(LogPriority.DEBUG, output)

            if self.ch.getReturnCode() == 0:
                success = True
        else:
            success = True
        return success
class zzzTestFrameworkMacPkgr(unittest.TestCase):
    """
    Class for testing the macpkgr.
    """
    @classmethod
    def setUpClass(self):
        """
        """
        self.macPackageName = "testStonixMacPkgr-0.0.3.pkg"
        self.reporoot = MACREPOROOT
        self.environ = Environment()
        self.logger = LogDispatcher(self.environ)
        self.pkgr = MacPkgr(self.environ, self.logger)
        if not self.environ.osfamily == "darwin":
            sys.exit(255)
        self.pkg_dirs = ["/tmp/testStonixMacPkgr-0.0.3/one/two/three/3.5", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/three", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two", \
                         "/tmp/testStonixMacPkgr-0.0.3/one", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/four/five", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/four", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/six/seven"]

        self.pkg_files = ["/tmp/testStonixMacPkgr-0.0.3/one/two/testfile1", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/two/four/five/testfile2", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/testfile3", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/testfile4", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/six/seven/testfile"]

        self.post_files = ["/tmp/testStonixMacPkgr-0.0.3/one/postfile2", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/two/three/3.5/postfile3"]

        self.post_dirs = ["/tmp/testStonixMacPkgr-0.0.3/one/six/6.5"]

        self.all_files = [self.pkg_files, self.post_files]
        self.all_dirs = [self.pkg_dirs, self.post_dirs]
        self.allowed_files_and_dirs = [self.pkg_dirs,
                                       self.pkg_dirs,
                                       self.post_dirs]
        self.ch = CommandHelper(self.logger)
        self.connection = Connectivity(self.logger)
        self.testDomain = "gov.lanl.testStonixMacPkgr.0.0.3.testStonixMacPkgr"

    @classmethod
    def tearDownClass(self):
        """
        Make sure the appropriate files are removed..
        """
        pass
    
    def test_inLinearFlow(self):
        """
        Run methods or functionality that requires order, ie a happens before b
        Like ensure a package is installed before testing if uninstall works.
        
        @author: Roy Nielsen
        """
        if not self.connection.isPageAvailable():
            self.logger.log(LogPriority.INFO, "This test fails without a " + \
                                              "properly configured Mac " + \
                                              "repository, so we are not " + \
                                              "running actual tests...")
        else:
            #####
            # Remove the package in case it is installed, so we have a sane, 
            # consistent starting point for the test.
            self.removeCompletePackage()
    
            #####
            # Install the package
            self.assertTrue(self.pkgr.installPackage(self.macPackageName),
                            "Problem with pkgr.installpackage...")        
            #####
            # Use the macpkgr method to check if the package is installed
            self.assertTrue(self.pkgr.checkInstall(self.macPackageName),
                            "Problem with pkgr.checkInstall...")
            
            #####
            # Manual check to see if the package is installed
            self.assertTrue(self.isInstalled(), "Problem with installation...")
            
            #####
            # Make sure it isn't a partial install...
            self.assertTrue(self.isFullInstall(), "Partial install...")
    
            #####
            # Remove the package, assert that it worked.                
            self.assertTrue(self.pkgr.removePackage(self.macPackageName),
                            "Problem removing package...")
            
            #####
            # Check that checkInstall returns the correct value
            self.assertFalse(self.pkgr.checkInstall(self.macPackageName),
                             "Problem with pkgr.checkinstall...")
    
            #####
            # Hand verify that self.pkgr.checkInstall worked.
            self.assertTrue(self.isMissing(), "Problem with package removal...")
            
            #####
            # Remove any presence of the package installed.
            self.removeCompletePackage()

        
    def testCheckInstall(self):
        """
        Test the checkInstall method.
        
        1 - make sure the test .pkg is NOT installed
        2 - download the package and check the md5
        3 - use custom installer command to install the package
        4 - call the checkInstall method
        
        @author: Roy Nielsen
        """
        if not self.connection.isPageAvailable():
            self.logger.log(LogPriority.INFO, "This test fails without a " + \
                                              "properly configured Mac " + \
                                              "repository, so we are not " + \
                                              "running actual tests...")
        else:
            #####
            # make sure the test .pkg is NOT installed
            self.pkgr.removePackage(self.macPackageName)
            
            #####
            # Test the checkInstall with the package removed
            self.assertFalse(self.pkgr.checkInstall(self.macPackageName))
            self.assertFalse(self.isInstalled())
            
            #####
            # Install the package
            self.pkgr.installPackage(self.macPackageName)
            
            #####
            # run checkInstall again
            self.assertTrue(self.pkgr.checkInstall(self.macPackageName))
            self.assertTrue(self.isInstalled())
        
    def testCheckAvailable(self):
        """
        Check if a package is available on the reporoot.
        
        Must have both the file AND the md5 checksum file on the server of the
        format:
        
        .<filename>.<UPPER-md5sum>
        
        Steps for this test:
        
        1 - set up self.pkgr.pkgUrl
        2 - run self.pkgr.downloadPackage
        3 - Make sure the checksum matches, otherwise there is a bad md5
            for the download, and the package should not be trusted, let alone
            installed.
        
        This covers two test cases -
        checkAvailable
        downloadPackage
        
        @author: Roy Nielsen
        """
        if not self.connection.isPageAvailable():
            self.logger.log(LogPriority.INFO, "This test fails without a " + \
                                              "properly configured Mac " + \
                                              "repository, so we are not " + \
                                              "running actual tests...")
        else:
            self.assertTrue(self.reporoot + self.macPackageName)
            self.pkgr.setPkgUrl(self.reporoot + self.macPackageName)
            self.pkgr.package = self.macPackageName
            self.assertTrue(self.pkgr.downloadPackage(), "Package: " + \
                            str(self.pkgr.getPkgUrl()) + " FAILED download...")
            
            self.assertTrue(self.pkgr.checkMd5(), "MD5 checksum didn't match - " + \
                       "package: " + str(self.pkgr.hashUrl) + " is NOT " + \
                       "available...")
                
    def testFindDomain(self):
        """
        Test the findDomain function.  The domain is required to do a reverse 
        lookup in the local client package receipt database.  It should find
        all the files that have been installed by the PACKAGE, not the 
        postflight.
        
        Will remove the test package if it exists, install the package then
        use the test package to make sure the package file list is accurate.
        
        @author: Roy Nielsen
        """
        if not self.connection.isPageAvailable():
            self.logger.log(LogPriority.INFO, "This test fails without a " + \
                                              "properly configured Mac " + \
                                              "repository, so we are not " + \
                                              "running actual tests...")
        else:
            #####
            # Make sure the package is installed
            self.pkgr.installPackage("testStonixMacPkgr-0.0.3.pkg")
            
            #####
            # Assert findDomain works properly when the package is installed
            self.assertEqual(self.testDomain, 
                             self.pkgr.findDomain("testStonixMacPkgr-0.0.3.pkg"))
        
    def testUnArchive(self):
        """
        Download a tar package with the test pkg in it.
        
        Will test doing a download and checksum of the following by downloading
        the file and doing a checksum, then unzipping the file, and check
        the internal filename:
        
        testStonixMacPkgr.zip
        
        @Note: *** Functionality needs approval ***
        
        @author: Roy Nielsen
        """
        pass
        
    def testCopyInstall(self):
        """
        Tests the copyInstall method.
        
        Will test by:
        
        Downloading the test .tar file with a .app in it, doing a checksum of
        the .tar file then performing a copyInstall.
        
        Will test by checking the existence of the .app being in the right 
        place.
        
        @author: Roy Nielsen
        """ 
        pass
        
    def testInstallPkg(self):
        """
        Tests the installPkg method.
        
        Will:
        Make sure the test pkg is not installed
        Download and checksum the file.
        install the .pkg with the installPkg method.
        
        @author: Roy Nielsen
        """
        pass
        
    def testIsMacPlatform(self):
        """
        Make sure we are on the Mac platform.
        
        @author: Roy Nielsen
        """
        if not self.connection.isPageAvailable():
            self.logger.log(LogPriority.INFO, "This test fails without a " + \
                                              "properly configured Mac " + \
                                              "repository, so we are not " + \
                                              "running actual tests...")
        else:
            self.assertTrue(self.environ.osfamily == "darwin", "Wrong OS...")
        
    def isFullInstall(self):
        """
        Make sure that all files and directories including those installed from
        the package and the postinstall script exist.
        
        @Note: In future, this should also do a receipt test as well.  This 
               would include getting the files from the receipt and checking
               for their existence and perhaps their permissions.
        
        @author: Roy Nielsen
        """

        files = self.doFilesExistTest(self.all_files)
        dirs = self.doDirsExist(self.all_dirs)
        
        if files and dirs:
            return True
        return False
    
    def isInstalled(self):
        """
        Test to make sure just the files and directories installed by the
        package are installed. Doesn't care about the files and directories
        installed by the postinstall script. 
        
        @author: Roy Nielsen
        """
        files = self.doFilesExistTest([self.pkg_files])
        dirs = self.doDirsExist([self.pkg_dirs])
        
        if files and dirs:
            return True
        return False

    def isMissing(self):
        """
        Test to make sure all the files have been removed that were Installed
        by the package.  Ignore, but note directories installed by the package
        that exist, as well as files and directories installed by the 
        postinstall script.
        
        @Note: In future, this test should check for a package receipt, and 
               make sure the files in the package receipt do not exist.  This
               is only valid for this package, as in the case of some software,
               like Adobe products, some of the files are shared libraries 
               between different products.
        
        @author: Roy Nielsen
        """
        removed = []
        exists = []
        
        #####
        # Cycle through each subset of files in the 
        for myfile in self.pkg_files:
            if os.path.isfile(myfile):
                self.logger.log(LogPriority.WARNING, "File: " + \
                                str(myfile) + " exists...")
                removed.append(False)
                exists.append(myfile)
        self.assertFalse(False in removed, "Some files exist: " + str(exists))
        
        #####
        # cycle through each set of directories in all_dirs
        for myset in self.allowed_files_and_dirs:
            #####
            # Cycle through each subset of files in the 
            for myfile in myset:
                if os.path.isdir(myfile):
                    self.logger.log(LogPriority.INFO, "Item: " + \
                                    str(myfile) + " exists...")
        if False in removed:
            return False
        return True

    def removeCompletePackage(self):
        """
        Remove all files, used to set the stage for install tests.
        
        @author:  Roy Nielsen
        """
        success = False
        try:
            testPath = "/tmp/testStonixMacPkgr-0.0.3"
            if os.path.exists(testPath):
                shutil.rmtree(testPath)
        except Exception, err:
            self.logger.log(LogPriority.INFO, "Test set already missing?")
            raise err
        else:
 def setUp(self):
     self.environ = Environment()
     self.logdispatcher = LogDispatcher(self.environ)
     self.conn = Connectivity(self.logdispatcher)
    def setUp(self):
        ''' '''

        self.environ = Environment()
        self.logdispatcher = LogDispatcher(self.environ)
        self.conn = Connectivity(self.logdispatcher, use_proxy=True)
 def setUp(self):
     self.environ = Environment()
     self.logdispatcher = LogDispatcher(self.environ)
     self.conn = Connectivity(self.logdispatcher)
    def setUpClass(self):
        """
        """
        self.environ = Environment()
        self.logger = LogDispatcher(self.environ)

        self.osfamily = self.environ.getosfamily()

        self.logger.log(LogPriority.DEBUG, "##################################")
        self.logger.log(LogPriority.DEBUG, "### OS Family: " + str(self.osfamily))
        self.logger.log(LogPriority.DEBUG, "##################################")

        self.libc = ctypes.CDLL("/usr/lib/libc.dylib")

        self.logger = LogDispatcher(self.environ)

        self.macPackageName = "testStonixMacPkgr-0.0.3.pkg"
        self.reporoot = MACREPOROOT

        #####
        # Create a class variable that houses the whole URL
        if self.reporoot.endswith("/"):
            self.pkgUrl = self.reporoot + self.macPackageName
        else:
            self.pkgUrl = self.reporoot + "/" + self.macPackageName

        message = "self.pkgUrl: " + str(self.pkgUrl)

        self.pkgr = MacPkgr(self.environ, self.logger)

        self.pkg_dirs = ["/tmp/testStonixMacPkgr-0.0.3/one/two/three/3.5", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/three", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two", \
                         "/tmp/testStonixMacPkgr-0.0.3/one", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/four/five", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two/four", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/two", \
                         "/tmp/testStonixMacPkgr-0.0.3/one/six/seven"]

        self.pkg_files = ["/tmp/testStonixMacPkgr-0.0.3/one/two/testfile1", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/two/four/five/testfile2", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/testfile3", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/testfile4", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/six/seven/testfile"]

        self.post_files = ["/tmp/testStonixMacPkgr-0.0.3/one/postfile2", \
                     "/tmp/testStonixMacPkgr-0.0.3/one/two/three/3.5/postfile3"]

        self.post_dirs = ["/tmp/testStonixMacPkgr-0.0.3/one/six/6.5"]

        self.all_files = [self.pkg_files, self.post_files]
        self.all_dirs = [self.pkg_dirs, self.post_dirs]
        self.allowed_files_and_dirs = [self.pkg_dirs,
                                       self.pkg_dirs,
                                       self.post_dirs]
        self.ch = CommandHelper(self.logger)
        self.connection = Connectivity(self.logger)
        self.testDomain = "gov.lanl.testStonixMacPkgr.0.0.3.testStonixMacPkgr"

    ############################################################################
    
        """