コード例 #1
0
 def _parse_userauth_failure(self, m):
     authlist = m.get_list()
     partial = m.get_boolean()
     if partial:
         self._log(INFO, 'Authentication continues...')
         self._log(DEBUG, 'Methods: ' + str(authlist))
         self.transport.saved_exception = PartialAuthentication(authlist)
     elif self.auth_method not in authlist:
         for msg in (
             'Authentication type ({}) not permitted.'.format(
                 self.auth_method
             ),
             'Allowed methods: {}'.format(authlist),
         ):
             self._log(DEBUG, msg)
         self.transport.saved_exception = BadAuthenticationType(
             'Bad authentication type', authlist
         )
     else:
         self._log(
             INFO,
             'Authentication ({}) failed.'.format(self.auth_method)
         )
     self.authenticated = False
     self.username = None
     if self.auth_event is not None:
         self.auth_event.set()
コード例 #2
0
 def auth_none(username):
     raise BadAuthenticationType(
         "Bad authentication type",
         ["publickey", "keyboard-interactive", "password"],
     )
コード例 #3
0
 def auth_none(username):
     raise BadAuthenticationType("Bad authentication type", None)
コード例 #4
0
import pickle

import pytest

from paramiko import RSAKey
from paramiko.ssh_exception import (
    BadAuthenticationType,
    PartialAuthentication,
    ChannelException,
    BadHostKeyException,
    ProxyCommandFailure,
)


@pytest.mark.parametrize(['exc'], [
    (BadAuthenticationType("Bad authentication type", ["ok", "also-ok"]), ),
    (PartialAuthentication(["ok", "also-ok"]), ),
    (BadHostKeyException("myhost", RSAKey.generate(2048),
                         RSAKey.generate(2048)), ),
    (ProxyCommandFailure("nc servername 22", 1), ),
    (ChannelException(17, "whatever"), ),
])
def test_ssh_exception_strings(exc):
    assert isinstance(str(exc), str)
    assert isinstance(repr(exc), str)
    if type(exc) != BadHostKeyException:
        ne = pickle.loads(pickle.dumps(exc))
        assert type(ne) == type(exc)
コード例 #5
0
ファイル: test_ssh_exception.py プロジェクト: zdiai/Somsdiag
 def test_BadAuthenticationType(self):
     exc = BadAuthenticationType("Bad authentication type",
                                 ["ok", "also-ok"])
     expected = "Bad authentication type; allowed types: ['ok', 'also-ok']"
     assert str(exc) == expected