ParallelSSH/ssh-python

📦 Errors when running tests during RPM build

major opened this issue · 2 comments

major commented

I'm working to package ssh-python in Fedora Linux and I'm able to build the RPM well with the documentation provided in the repository. Thanks for that!

However, as part of the RPM build, I am trying to run the tests with pytest. I'm getting some errors that I haven't been able to debug quite yet:

__________________________ ChannelTest.test_exit_code __________________________

self = <tests.test_channel.ChannelTest testMethod=test_exit_code>

    def test_exit_code(self):
>       self._auth()

tests/test_channel.py:117: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/base_case.py:89: in _auth
    self.session.userauth_publickey(self.pkey), 0)
ssh/session.pyx:430: in ssh.session.Session.userauth_publickey
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   ssh.exceptions.AuthenticationDenied: b"Access denied for 'publickey'. Authentication that can continue: publickey,password,keyboard-interactive"

ssh/utils.pyx:109: AuthenticationDenied

I've looked through the circle ci YAML in the repo to see if I am missing a step somewhere, but I have not found any missing steps yet. I'm running the tests using /usr/bin/pytest tests.

Thanks for any help you can provide here! 🫂

Hi there,

Thanks for the interest.

The tests in the repository are integration tests performed on Circle CI. No support is offered for running them outside this repository's CI, nor is it necessary.

Now test suite fails in 4 units

Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-ssh-python-1.0.0-9.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-ssh-python-1.0.0-9.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/ssh-python-1.0.0
collected 49 items

tests/test_channel.py .........                                          [ 18%]
tests/test_connector.py .                                                [ 20%]
tests/test_event.py ...                                                  [ 26%]
tests/test_keytypes.py ...                                               [ 32%]
tests/test_session.py .......F......                                     [ 61%]
tests/test_sftp.py .F.F..............F                                   [100%]

=================================== FAILURES ===================================
__________________________ SessionTest.test_key_auth ___________________________

self = <tests.test_session.SessionTest testMethod=test_key_auth>

    def test_key_auth(self):
        self.assertEqual(self.session.connect(), 0)
>       self.assertRaises(KeyImportError, import_pubkey_file, self.user_key)
E       AssertionError: KeyImportError not raised by import_pubkey_file

tests/test_session.py:112: AssertionError
____________________________ SFTPTest.test_fstatvfs ____________________________

self = <tests.test_sftp.SFTPTest testMethod=test_fstatvfs>

    def test_fstatvfs(self):
        self._auth()
        sftp = self.session.sftp_init()
        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:
            with sftp.open(remote_filename, 0, 0) as fh:
                vfs = fh.fstatvfs()
                self.assertTrue(vfs is not None)
>               self.assertTrue(vfs.f_files > 0)
E               AssertionError: False is not true

tests/test_sftp.py:339: AssertionError
____________________ SFTPTest.test_handle_open_nonblocking _____________________

self = <tests.test_sftp.SFTPTest testMethod=test_handle_open_nonblocking>

    def test_handle_open_nonblocking(self):
        self._auth()
        sftp = self.session.sftp_init()
        self.session.set_blocking(False)
>       fh = sftp.open('.', 0, 0)

tests/test_sftp.py:367:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   raise SFTPHandleError(ssh_get_error(self.session._session))
E   ssh.exceptions.SFTPHandleError: b''

ssh/sftp.pyx:135: SFTPHandleError
____________________________ SFTPTest.test_statvfs _____________________________

self = <tests.test_sftp.SFTPTest testMethod=test_statvfs>

    def test_statvfs(self):
        self._auth()
        sftp = self.session.sftp_init()
        vfs = sftp.statvfs('.')
        self.assertTrue(vfs is not None)
>       self.assertTrue(vfs.f_files > 0)
E       AssertionError: False is not true

tests/test_sftp.py:323: AssertionError
=========================== short test summary info ============================
FAILED tests/test_session.py::SessionTest::test_key_auth - AssertionError: Ke...
FAILED tests/test_sftp.py::SFTPTest::test_fstatvfs - AssertionError: False is...
FAILED tests/test_sftp.py::SFTPTest::test_handle_open_nonblocking - ssh.excep...
FAILED tests/test_sftp.py::SFTPTest::test_statvfs - AssertionError: False is ...
========================= 4 failed, 45 passed in 8.58s =========================

Really .. it would be good to make pytest test suite useable outside CI env.