dulwich: workaround github SSH server in asyncssh vendor

- allow mismatched RSA signature algo names in initial
  SSH_MSG_USERAUTH_PK_OK response
- unit test overridden asyncssh publickey auth compatibility with
  github ssh server
This commit is contained in:
Peter Rowlands
2021-11-17 12:48:34 +02:00
committed by Ruslan Kuprieiev
parent 45c4e1998d
commit 25dca0b665
2 changed files with 71 additions and 0 deletions
+26
View File
@@ -594,3 +594,29 @@ def test_pygit_checkout_subdir(tmp_dir, scm, git):
with (tmp_dir / "dir").chdir():
git.checkout(rev)
assert not (tmp_dir / "dir" / "bar").exists()
@pytest.mark.parametrize(
"algorithm", [b"ssh-rsa", b"rsa-sha2-256", b"rsa-sha2-512"]
)
def test_dulwich_github_compat(mocker, algorithm):
from asyncssh.misc import ProtocolError
from dvc.scm.git.backend.dulwich.asyncssh_vendor import (
_process_public_key_ok_gh,
)
key_data = b"foo"
auth = mocker.Mock(
_keypair=mocker.Mock(algorithm=algorithm, public_data=key_data),
)
packet = mocker.Mock()
with pytest.raises(ProtocolError):
strings = iter((b"ed21556", key_data))
packet.get_string = lambda: next(strings)
_process_public_key_ok_gh(auth, None, None, packet)
strings = iter((b"ssh-rsa", key_data))
packet.get_string = lambda: next(strings)
_process_public_key_ok_gh(auth, None, None, packet)