Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Changes
via the remote host to a third party.
* Added new `libssh2` error codes under `ssh2.error_codes`, equivalent Python exceptions under `ssh2.exceptions`
and updated error code handling for all functions.
* Removed deprecated `libssh2` `ssh2.channel.Channel` functions `receive_window_adjust`, `handle_extended_data`
and `ignore_extended_data`.
* Removed deprecated `libssh2` `ssh2.session.Session` functions `startup`, `scp_recv` and `scp_send`.


Packaging
Expand Down
63 changes: 0 additions & 63 deletions ci/integration_tests/test_session.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from unittest.mock import MagicMock
import os
import socket
from unittest import skipUnless

from ssh2.channel import Channel
from ssh2.error_codes import LIBSSH2_ERROR_EAGAIN
Expand Down Expand Up @@ -104,8 +103,6 @@ def test_failed_pkey_auth(self):
self.user, 'EVEN MORE FAKE FILE',
publickey='FAKE FILE')

@skipUnless(hasattr(Session, 'scp_recv2'),
"Function not supported by libssh2")
def test_scp_recv2(self):
self.assertEqual(self._auth(), 0)
test_data = b"data"
Expand All @@ -132,66 +129,6 @@ def test_scp_recv2(self):
os.unlink(remote_filename)
self.assertRaises(SCPProtocolError, self.session.scp_recv2, remote_filename)

def test_scp_recv(self):
self.assertEqual(self._auth(), 0)
test_data = b"data"
remote_filename = os.sep.join([os.path.dirname(__file__),
"remote_test_file"])
with open(remote_filename, 'wb') as fh:
fh.write(test_data)
try:
(file_chan, fileinfo) = self.session.scp_recv(remote_filename)
except TypeError:
os.unlink(remote_filename)
raise
try:
total = 0
size, data = file_chan.read(size=fileinfo.st_size)
total += size
while total < fileinfo.st_size:
total += size
size, data = file_chan.read()
self.assertEqual(total, fileinfo.st_size)
except Exception:
raise
finally:
os.unlink(remote_filename)
self.assertRaises(SCPProtocolError, self.session.scp_recv, remote_filename)

def test_scp_send(self):
self.assertEqual(self._auth(), 0)
test_data = b"data"
remote_filename = os.sep.join([os.path.dirname(__file__),
"remote_test_file"])
to_copy = os.sep.join([os.path.dirname(__file__),
"copied"])
with open(remote_filename, 'wb') as fh:
fh.write(test_data)
fileinfo = os.stat(remote_filename)
try:
chan = self.session.scp_send(
to_copy, fileinfo.st_mode & 777, fileinfo.st_size)
with open(remote_filename, 'rb') as local_fh:
for data in local_fh:
chan.write(data)
chan.send_eof()
chan.wait_eof()
chan.wait_closed()
self.assertEqual(os.stat(to_copy).st_size,
os.stat(remote_filename).st_size)
except Exception:
raise
finally:
os.unlink(remote_filename)
try:
os.unlink(to_copy)
except OSError:
pass
self.assertRaises(SCPProtocolError, self.session.scp_send,
'/cannot_write', 1 & 777, 1)

@skipUnless(hasattr(Session, 'scp_send64'),
"Function not supported by libssh2")
def test_scp_send64(self):
self.assertEqual(self._auth(), 0)
test_data = b"data"
Expand Down
17 changes: 0 additions & 17 deletions ssh2/c_ssh2.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ cdef extern from "libssh2.h" nogil:
const char *banner)
int libssh2_banner_set(LIBSSH2_SESSION *session,
const char *banner)
int libssh2_session_startup(LIBSSH2_SESSION *session, int sock)
int libssh2_session_handshake(LIBSSH2_SESSION *session,
libssh2_socket_t sock)
int libssh2_session_disconnect_ex(LIBSSH2_SESSION *session,
Expand Down Expand Up @@ -288,10 +287,6 @@ cdef extern from "libssh2.h" nogil:
unsigned long *read_avail,
unsigned long *window_size_initial)
unsigned long libssh2_channel_window_read(LIBSSH2_CHANNEL *channel)
unsigned long \
libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL *channel,
unsigned long adjustment,
unsigned char force)
int \
libssh2_channel_receive_window_adjust2(LIBSSH2_CHANNEL *channel,
unsigned long adjustment,
Expand All @@ -316,12 +311,8 @@ cdef extern from "libssh2.h" nogil:
void libssh2_session_set_timeout(LIBSSH2_SESSION* session,
long timeout)
long libssh2_session_get_timeout(LIBSSH2_SESSION* session)
void libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel,
int ignore_mode)
int libssh2_channel_handle_extended_data2(LIBSSH2_CHANNEL *channel,
int ignore_mode)
int libssh2_channel_ignore_extended_data(LIBSSH2_CHANNEL *channel,
int ignore)
int libssh2_channel_flush_ex(LIBSSH2_CHANNEL *channel,
int streamid)
int libssh2_channel_flush(LIBSSH2_CHANNEL *channel)
Expand All @@ -342,10 +333,6 @@ cdef extern from "libssh2.h" nogil:
int libssh2_channel_free(LIBSSH2_CHANNEL *channel)
int libssh2_channel_signal_ex(LIBSSH2_CHANNEL *channel, const char *signame, size_t signame_len)

# libssh2_scp_recv is DEPRECATED, do not use!
LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session,
const char *path,
struct_stat *sb)
# Use libssh2_scp_recv2 for large (> 2GB) file support on windows
LIBSSH2_CHANNEL *libssh2_scp_recv2(LIBSSH2_SESSION *session,
const char *path,
Expand All @@ -357,10 +344,6 @@ cdef extern from "libssh2.h" nogil:
LIBSSH2_CHANNEL *libssh2_scp_send64(
LIBSSH2_SESSION *session, const char *path, int mode,
libssh2_int64_t size, time_t mtime, time_t atime)
LIBSSH2_CHANNEL *libssh2_scp_send(
LIBSSH2_SESSION *session,
const char *path, int mode,
libssh2_int64_t size)
int libssh2_base64_decode(LIBSSH2_SESSION *session, char **dest,
unsigned int *dest_len,
const char *src, unsigned int src_len)
Expand Down
Loading