diff options
author | Mika Pflüger <Mika Pflüger mika@mikapflueger.de> | 2015-02-01 21:20:19 +0100 |
---|---|---|
committer | Mika Pflüger <Mika Pflüger mika@mikapflueger.de> | 2015-02-01 21:20:19 +0100 |
commit | 65fb0980d01d928e60c246d361954b961296e67f (patch) | |
tree | 93cea4cbebf3b9c237dae93a37250df2e1e2cab1 /tests | |
parent | 4d968c22b56bf045dca6abd0da891b6db9724c9f (diff) |
Add support for posix-rename@openssh.com for the SFTP server side and fix tests accordingly.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stub_sftp.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/stub_sftp.py b/tests/stub_sftp.py index 24380ba1..a894c2ba 100644 --- a/tests/stub_sftp.py +++ b/tests/stub_sftp.py @@ -23,7 +23,7 @@ A stub SFTP server for loopback SFTP testing. import os import sys from paramiko import ServerInterface, SFTPServerInterface, SFTPServer, SFTPAttributes, \ - SFTPHandle, SFTP_OK, AUTH_SUCCESSFUL, OPEN_SUCCEEDED + SFTPHandle, SFTP_OK, SFTP_FAILURE, AUTH_SUCCESSFUL, OPEN_SUCCEEDED from paramiko.common import o666 @@ -139,12 +139,24 @@ class StubSFTPServer (SFTPServerInterface): def rename(self, oldpath, newpath): oldpath = self._realpath(oldpath) newpath = self._realpath(newpath) + if os.path.exists(newpath): + return SFTP_FAILURE try: os.rename(oldpath, newpath) except OSError as e: return SFTPServer.convert_errno(e.errno) return SFTP_OK + def posix_rename(self, oldpath, newpath): + oldpath = self._realpath(oldpath) + newpath = self._realpath(newpath) + try: + os.rename(oldpath, newpath) + except OSError as e: + return SFTPServer.convert_errno(e.errno) + return SFTP_OK + + def mkdir(self, path, attr): path = self._realpath(path) try: |