Example #1
0
    def test_filter_files(self):
        from pysvn import wc_notify_action as wcna
        from pysvn import Revision
        from core.controllers.auto_update.auto_update import os
        client = self.client
        override(os.path, 'isdir').expects(dontcare()).returns(False)
        set_count(exactly=2)
        ## Stop recording. Play!
        self.replay()
        # Call client's callback function several times
        f1 = '/path/to/file/foo.py'
        ev = {'action': wcna.update_delete,
               'error': None, 'mime_type': None, 'path': f1,
               'revision': Revision(pysvn.opt_revision_kind.number, 11)}
        client._register(ev)

        f2 = '/path/to/file/foo2.py'        
        ev2 = {'action': wcna.update_update,
               'error': None, 'mime_type': None,
               'path': f2,
               'revision': Revision(pysvn.opt_revision_kind.number, 11)}
        client._register(ev2)
        
        expected_res = SVNFilesList([(f1, FILE_DEL), (f2, FILE_UPD)])
        self.assertEquals(expected_res, 
            client._filter_files(filterbyactions=w3afSVNClient.UPD_ACTIONS))
        ## Verify ##
        self.verify()
Example #2
0
    def test_filter_files(self):
        from pysvn import wc_notify_action as wcna
        from pysvn import Revision

        os = get_autoupdate_os_module()
        client = self.client
        override(os.path, "isdir").expects(dontcare()).returns(False)
        set_count(exactly=2)
        ## Stop recording. Play!
        self.replay()
        # Call client's callback function several times
        f1 = "/path/to/file/foo.py"
        ev = {
            "action": wcna.update_delete,
            "error": None,
            "mime_type": None,
            "path": f1,
            "revision": Revision(pysvn.opt_revision_kind.number, 11),
        }
        client._register(ev)

        f2 = "/path/to/file/foo2.py"
        ev2 = {
            "action": wcna.update_update,
            "error": None,
            "mime_type": None,
            "path": f2,
            "revision": Revision(pysvn.opt_revision_kind.number, 11),
        }
        client._register(ev2)

        expected_res = SVNFilesList([(f1, FILE_DEL), (f2, FILE_UPD)])
        self.assertEquals(expected_res, client._filter_files(filterbyactions=w3afSVNClient.UPD_ACTIONS))
        ## Verify ##
        self.verify()
    def test_discover_eq_routes(self):
        # Start recording
        plugininst = self.plugininst
        override(plugininst, '_has_permission').expects().returns(True)
        method(self.fuzz_req, 'getURL').expects().returns(self.test_url)
        # HTTPS try
        self._call_traceroute('host.tld', 443, self.tracedict)
        # HTTP try
        self._call_traceroute('host.tld', 80, self.tracedict)
        # Output Manager. It must not be called!
        ommock = self.mock(hvshsdist.om)
        ommock.out
        set_count(exactly=0)
        
        ## Stop Recording.Time to Play! ##
        self.replay()
        res = plugininst.discover(self.fuzz_req)
        self.assertEquals(res, [])

        ## Verify ##
        self.verify()
    def test_discover_override_port(self):
        plugininst = self.plugininst
        override(plugininst, '_has_permission').expects().returns(True)
        method(self.fuzz_req, 'getURL').expects().returns('https://host.tld:4444')
        # HTTPS try
        self._call_traceroute('host.tld', 4444, self.tracedict)
        # HTTP try
        tracedict = copy.deepcopy(self.tracedict)
        tracedict['localhost'][3] = ('200.200.0.0', False) # Set diff hop
        self._call_traceroute('host.tld', 80, tracedict)
        # Mock output manager. Ensure that is called with the proper desc.
        override(hvshsdist.om.out, 'information').expects(expr(lambda x: x.find('host.tld:4444') != -1))
        set_count(exactly=1)

        ## Stop Recording.Time to Play! ##
        self.replay()
        res = plugininst.discover(self.fuzz_req)
        self.assertEquals(res, [])

        ## Verify ##
        self.verify()