Ticket #4930: 4930-rnto-1.diff
| File 4930-rnto-1.diff, 2.8 KB (added by adiroiban, 11 months ago) |
|---|
-
twisted/test/test_ftp.py
81 81 self.dirPath = filepath.FilePath(self.directory) 82 82 83 83 # Start the server 84 p = portal.Portal(ftp.FTPRealm(self.directory)) 84 p = portal.Portal(ftp.FTPRealm( 85 anonymousRoot=self.directory, 86 userHome=self.directory, 87 )) 85 88 p.registerChecker(checkers.AllowAnonymousAccess(), 86 89 credentials.IAnonymous) 90 91 users_checker = checkers.InMemoryUsernamePasswordDatabaseDontUse() 92 self.username = "test-user" 93 self.password = "test-password" 94 users_checker.addUser(self.username, self.password) 95 p.registerChecker(users_checker, credentials.IUsernamePassword) 96 87 97 self.factory = ftp.FTPFactory(portal=p, 88 98 userAnonymous=self.userAnonymous) 89 99 port = reactor.listenTCP(0, self.factory, interface="127.0.0.1") … … 159 169 ['230 Anonymous login ok, access restrictions apply.'], 160 170 chainDeferred=d) 161 171 172 def _userLogin(self): 173 d = self.assertCommandResponse( 174 'USER %s' % (self.username), 175 ['331 Password required for %s.' % (self.username)]) 176 return self.assertCommandResponse( 177 'PASS %s' % (self.password), 178 ['230 User logged in, proceed'], 179 chainDeferred=d) 162 180 163 181 164 182 class FTPAnonymousTestCase(FTPServerTestCase): … … 348 366 chainDeferred=d) 349 367 return d 350 368 369 def testRNFRandRNTO(self): 370 # Create user home folder with a 'foo' file. 371 self.dirPath.child(self.username).createDirectory() 372 self.dirPath.child(self.username).child('foo').touch() 351 373 374 d = self._userLogin() 375 self.assertCommandResponse( 376 'RNFR foo', 377 ["350 Requested file action pending further information."], 378 chainDeferred=d) 379 self.assertCommandResponse( 380 'RNTO bar', 381 ["250 Requested File Action Completed OK"], 382 chainDeferred=d) 383 return d 384 385 def testRNFRwithoutRNTO(self): 386 d = self._anonymousLogin() 387 self.assertCommandResponse( 388 'RNFR foo', 389 ["350 Requested file action pending further information."], 390 chainDeferred=d) 391 self.assertCommandFailed( 392 'OTHER don-tcare', 393 ["503 Incorrect sequence of commands: RNTO required after RNFR"], 394 chainDeferred=d) 395 return d 396 352 397 def test_portRangeForwardError(self): 353 398 """ 354 399 Exceptions other than L{error.CannotListenError} which are raised by
