Ticket #2875: 2875-ftp-access-1.diff

File 2875-ftp-access-1.diff, 1.8 KB (added by adiroiban, 2 years ago)
  • twisted/test/test_ftp.py

     
    25892589        return self.assertFailure(d, ftp.FileNotFoundError) 
    25902590 
    25912591 
     2592    def test_accessNotAllowed(self): 
     2593        """ 
     2594        access should fail on a resource for which we can't list its content. 
     2595        """ 
     2596        path = 'foo' 
     2597        self.createDirectory(path) 
     2598        self.root.child(path).chmod(000) 
     2599        d = self.shell.access((path,)) 
     2600 
     2601        def revert_permissions(result_or_failure): 
     2602            """Folder permissions are reverted so that any clean function 
     2603            will be allowed to remove the folder. 
     2604            """ 
     2605            self.root.child(path).chmod(0700) 
     2606            self.root.child(path).remove() 
     2607            return result_or_failure 
     2608 
     2609        d.addBoth(revert_permissions) 
     2610        return self.assertFailure(d, ftp.PermissionDeniedError) 
     2611 
     2612    if not os.name == 'posix': 
     2613        test_accessNotAllowed.skip = "test_accessNotAllowed not supported" 
     2614 
    25922615    def test_openForReading(self): 
    25932616        """ 
    25942617        Check that openForReading returns an object providing C{ftp.IReadFile}. 
  • twisted/protocols/ftp.py

     
    16741674 
    16751675 
    16761676    def access(self, path): 
     1677        """ 
     1678        See L{IFTPShell.access}. 
     1679 
     1680        If path doesn't exists, it returns L{FileNotFoundError}. 
     1681        It checks path access by issuing a folder listing command. 
     1682        """  
    16771683        p = self._path(path) 
    16781684        if not p.exists(): 
    16791685            # Again, win32 doesn't report a sane error after, so let's fail