def test_connection_bad_credentials(): '''attempt connection to a non-existing server''' copts = SFTP_LOCAL.copy() copts['password'] = '******' with pytest.raises(pysftp.SSHException): with pysftp.Connection(**copts) as sftp: sftp.listdir()
def test_connection_ciphers_param(): '''test the ciphers parameter portion of the Connection''' ciphers = ('aes256-ctr', 'blowfish-cbc', 'aes256-cbc', 'arcfour256') copts = SFTP_LOCAL.copy() # don't sully the module level variable copts['ciphers'] = ciphers assert copts != SFTP_LOCAL with pysftp.Connection(**copts) as sftp: rslt = sftp.listdir() assert len(rslt) > 1
def test_depr_ciphers_param(): '''test deprecation warning for Connection cipher parameter''' warnings.simplefilter('always') copts = SFTP_LOCAL.copy() copts['ciphers'] = ('aes256-ctr', 'blowfish-cbc', 'aes256-cbc', 'arcfour256') with pytest.warns(DeprecationWarning): with pysftp.Connection(**copts) as sftp: sftp.listdir()
def test_active_ciphers(): '''test that method returns a tuple of strings, that show ciphers used''' ciphers = ('aes256-ctr', 'blowfish-cbc', 'aes256-cbc', 'arcfour256') copts = SFTP_LOCAL.copy() # don't sully the module level variable cnopts = pysftp.CnOpts() cnopts.ciphers = ciphers copts['cnopts'] = cnopts with pysftp.Connection(**copts) as sftp: local_cipher, remote_cipher = sftp.active_ciphers assert local_cipher in ciphers assert remote_cipher in ciphers
def test_compression_enabled(): '''test that compression=True results in compression enabled, assuming that the server supports compression''' copts = SFTP_LOCAL.copy() cnopts = pysftp.CnOpts() cnopts.compression = True copts['cnopts'] = cnopts with pysftp.Connection(**copts) as sftp: lcompress, rcompress = sftp.active_compression assert lcompress != 'none' assert rcompress != 'none'