b725e5f10e6031cf0781c8593fe854b2046a3bae
Marco Ricci Change the author e-mail ad...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py   1) # SPDX-FileCopyrightText: 2024 Marco Ricci <software@the13thletter.info>
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py             2) #
tests/test_ssh_agent_client.py             3) # SPDX-License-Identifier: MIT
tests/test_ssh_agent_client.py             4) 
tests/test_ssh_agent_client.py             5) """Test OpenSSH key loading and signing."""
tests/test_ssh_agent_client.py             6) 
tests/test_ssh_agent_client.py             7) from __future__ import annotations
tests/test_ssh_agent_client.py             8) 
tests/test_ssh_agent_client.py             9) import base64
tests/test_ssh_agent_client.py            10) import io
tests/test_ssh_agent_client.py            11) import socket
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            12) from typing import TYPE_CHECKING
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            13) 
tests/test_ssh_agent_client.py            14) import click
tests/test_ssh_agent_client.py            15) import click.testing
Marco Ricci Add hypothesis-based tests...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py  16) import hypothesis
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            17) import pytest
Marco Ricci Add hypothesis-based tests...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py  18) from hypothesis import strategies
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            19) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            20) import tests
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py  21) from derivepassphrase import _types, cli, ssh_agent, vault
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            22) 
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            23) if TYPE_CHECKING:
Marco Ricci Fix awkward parametrization...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py  24)     from collections.abc import Iterable
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            25) 
Marco Ricci Add missing tests for `SSHA...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py  26)     from typing_extensions import Any, Buffer
Marco Ricci Add hypothesis-based tests...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py  27) 
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            28) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            29) class TestStaticFunctionality:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            30)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py            31)         ['public_key', 'public_key_data'],
tests/test_ssh_agent_client.py            32)         [
tests/test_ssh_agent_client.py            33)             (val['public_key'], val['public_key_data'])
tests/test_ssh_agent_client.py            34)             for val in tests.SUPPORTED_KEYS.values()
tests/test_ssh_agent_client.py            35)         ],
tests/test_ssh_agent_client.py            36)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            37)     def test_100_key_decoding(
tests/test_ssh_agent_client.py            38)         self, public_key: bytes, public_key_data: bytes
tests/test_ssh_agent_client.py            39)     ) -> None:
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py            40)         keydata = base64.b64decode(public_key.split(None, 2)[1])
tests/test_ssh_agent_client.py            41)         assert (
tests/test_ssh_agent_client.py            42)             keydata == public_key_data
tests/test_ssh_agent_client.py            43)         ), "recorded public key data doesn't match"
tests/test_ssh_agent_client.py            44) 
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py  45)     @pytest.mark.parametrize(
tests/test_derivepassphrase_ssh_agent.py  46)         ['line', 'env_name', 'value'],
tests/test_derivepassphrase_ssh_agent.py  47)         [
tests/test_derivepassphrase_ssh_agent.py  48)             (
tests/test_derivepassphrase_ssh_agent.py  49)                 'SSH_AUTH_SOCK=/tmp/pageant.user/pageant.27170; export SSH_AUTH_SOCK;',  # noqa: E501
tests/test_derivepassphrase_ssh_agent.py  50)                 'SSH_AUTH_SOCK',
tests/test_derivepassphrase_ssh_agent.py  51)                 '/tmp/pageant.user/pageant.27170',
tests/test_derivepassphrase_ssh_agent.py  52)             ),
tests/test_derivepassphrase_ssh_agent.py  53)             (
tests/test_derivepassphrase_ssh_agent.py  54)                 'SSH_AUTH_SOCK=/tmp/ssh-3CSTC1W5M22A/agent.27270; export SSH_AUTH_SOCK;',  # noqa: E501
tests/test_derivepassphrase_ssh_agent.py  55)                 'SSH_AUTH_SOCK',
tests/test_derivepassphrase_ssh_agent.py  56)                 '/tmp/ssh-3CSTC1W5M22A/agent.27270',
tests/test_derivepassphrase_ssh_agent.py  57)             ),
tests/test_derivepassphrase_ssh_agent.py  58)             (
tests/test_derivepassphrase_ssh_agent.py  59)                 'SSH_AUTH_SOCK=/tmp/pageant.user/pageant.27170; export SSH_AUTH_SOCK',  # noqa: E501
tests/test_derivepassphrase_ssh_agent.py  60)                 'SSH_AUTH_SOCK',
tests/test_derivepassphrase_ssh_agent.py  61)                 '/tmp/pageant.user/pageant.27170',
tests/test_derivepassphrase_ssh_agent.py  62)             ),
tests/test_derivepassphrase_ssh_agent.py  63)             (
tests/test_derivepassphrase_ssh_agent.py  64)                 'export SSH_AUTH_SOCK=/tmp/ssh-3CSTC1W5M22A/agent.27270;',
tests/test_derivepassphrase_ssh_agent.py  65)                 'SSH_AUTH_SOCK',
tests/test_derivepassphrase_ssh_agent.py  66)                 '/tmp/ssh-3CSTC1W5M22A/agent.27270',
tests/test_derivepassphrase_ssh_agent.py  67)             ),
tests/test_derivepassphrase_ssh_agent.py  68)             (
tests/test_derivepassphrase_ssh_agent.py  69)                 'export SSH_AUTH_SOCK=/tmp/pageant.user/pageant.27170',
tests/test_derivepassphrase_ssh_agent.py  70)                 'SSH_AUTH_SOCK',
tests/test_derivepassphrase_ssh_agent.py  71)                 '/tmp/pageant.user/pageant.27170',
tests/test_derivepassphrase_ssh_agent.py  72)             ),
tests/test_derivepassphrase_ssh_agent.py  73)             (
tests/test_derivepassphrase_ssh_agent.py  74)                 'SSH_AGENT_PID=27170; export SSH_AGENT_PID;',
tests/test_derivepassphrase_ssh_agent.py  75)                 'SSH_AGENT_PID',
tests/test_derivepassphrase_ssh_agent.py  76)                 '27170',
tests/test_derivepassphrase_ssh_agent.py  77)             ),
tests/test_derivepassphrase_ssh_agent.py  78)             (
tests/test_derivepassphrase_ssh_agent.py  79)                 'SSH_AGENT_PID=27170; export SSH_AGENT_PID',
tests/test_derivepassphrase_ssh_agent.py  80)                 'SSH_AGENT_PID',
tests/test_derivepassphrase_ssh_agent.py  81)                 '27170',
tests/test_derivepassphrase_ssh_agent.py  82)             ),
tests/test_derivepassphrase_ssh_agent.py  83)             ('export SSH_AGENT_PID=27170;', 'SSH_AGENT_PID', '27170'),
tests/test_derivepassphrase_ssh_agent.py  84)             ('export SSH_AGENT_PID=27170', 'SSH_AGENT_PID', '27170'),
tests/test_derivepassphrase_ssh_agent.py  85)             (
tests/test_derivepassphrase_ssh_agent.py  86)                 'export VARIABLE=value; export OTHER_VARIABLE=other_value;',
tests/test_derivepassphrase_ssh_agent.py  87)                 'VARIABLE',
tests/test_derivepassphrase_ssh_agent.py  88)                 None,
tests/test_derivepassphrase_ssh_agent.py  89)             ),
tests/test_derivepassphrase_ssh_agent.py  90)             (
tests/test_derivepassphrase_ssh_agent.py  91)                 'VARIABLE=value',
tests/test_derivepassphrase_ssh_agent.py  92)                 'VARIABLE',
tests/test_derivepassphrase_ssh_agent.py  93)                 None,
tests/test_derivepassphrase_ssh_agent.py  94)             ),
tests/test_derivepassphrase_ssh_agent.py  95)         ],
tests/test_derivepassphrase_ssh_agent.py  96)     )
tests/test_derivepassphrase_ssh_agent.py  97)     def test_190_sh_export_line_parsing(
tests/test_derivepassphrase_ssh_agent.py  98)         self, line: str, env_name: str, value: str | None
tests/test_derivepassphrase_ssh_agent.py  99)     ) -> None:
tests/test_derivepassphrase_ssh_agent.py 100)         if value is not None:
tests/test_derivepassphrase_ssh_agent.py 101)             assert tests.parse_sh_export_line(line, env_name=env_name) == value
tests/test_derivepassphrase_ssh_agent.py 102)         else:
tests/test_derivepassphrase_ssh_agent.py 103)             with pytest.raises(ValueError, match='Cannot parse sh line:'):
tests/test_derivepassphrase_ssh_agent.py 104)                 tests.parse_sh_export_line(line, env_name=env_name)
tests/test_derivepassphrase_ssh_agent.py 105) 
Marco Ricci Clean up testing machinery...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 106)     def test_200_constructor_no_running_agent(
Marco Ricci Fail gracefully if UNIX dom...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 107)         self,
tests/test_derivepassphrase_ssh_agent.py 108)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_ssh_agent.py 109)         skip_if_no_af_unix_support: None,
Marco Ricci Clean up testing machinery...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 110)     ) -> None:
Marco Ricci Fail gracefully if UNIX dom...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 111)         del skip_if_no_af_unix_support
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           112)         monkeypatch.delenv('SSH_AUTH_SOCK', raising=False)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           113)         with pytest.raises(
tests/test_ssh_agent_client.py           114)             KeyError, match='SSH_AUTH_SOCK environment variable'
tests/test_ssh_agent_client.py           115)         ):
Marco Ricci Fail gracefully if UNIX dom...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 116)             ssh_agent.SSHAgentClient()
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           117) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           118)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           119)         ['input', 'expected'],
tests/test_ssh_agent_client.py           120)         [
tests/test_ssh_agent_client.py           121)             (16777216, b'\x01\x00\x00\x00'),
tests/test_ssh_agent_client.py           122)         ],
tests/test_ssh_agent_client.py           123)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           124)     def test_210_uint32(self, input: int, expected: bytes | bytearray) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 125)         uint32 = ssh_agent.SSHAgentClient.uint32
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           126)         assert uint32(input) == expected
tests/test_ssh_agent_client.py           127) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           128)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           129)         ['input', 'expected'],
tests/test_ssh_agent_client.py           130)         [
tests/test_ssh_agent_client.py           131)             (b'ssh-rsa', b'\x00\x00\x00\x07ssh-rsa'),
tests/test_ssh_agent_client.py           132)             (b'ssh-ed25519', b'\x00\x00\x00\x0bssh-ed25519'),
tests/test_ssh_agent_client.py           133)             (
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 134)                 ssh_agent.SSHAgentClient.string(b'ssh-ed25519'),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           135)                 b'\x00\x00\x00\x0f\x00\x00\x00\x0bssh-ed25519',
tests/test_ssh_agent_client.py           136)             ),
tests/test_ssh_agent_client.py           137)         ],
tests/test_ssh_agent_client.py           138)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           139)     def test_211_string(
tests/test_ssh_agent_client.py           140)         self, input: bytes | bytearray, expected: bytes | bytearray
tests/test_ssh_agent_client.py           141)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 142)         string = ssh_agent.SSHAgentClient.string
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           143)         assert bytes(string(input)) == expected
tests/test_ssh_agent_client.py           144) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           145)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           146)         ['input', 'expected'],
tests/test_ssh_agent_client.py           147)         [
tests/test_ssh_agent_client.py           148)             (b'\x00\x00\x00\x07ssh-rsa', b'ssh-rsa'),
tests/test_ssh_agent_client.py           149)             (
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 150)                 ssh_agent.SSHAgentClient.string(b'ssh-ed25519'),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           151)                 b'ssh-ed25519',
tests/test_ssh_agent_client.py           152)             ),
tests/test_ssh_agent_client.py           153)         ],
tests/test_ssh_agent_client.py           154)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           155)     def test_212_unstring(
tests/test_ssh_agent_client.py           156)         self, input: bytes | bytearray, expected: bytes | bytearray
tests/test_ssh_agent_client.py           157)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 158)         unstring = ssh_agent.SSHAgentClient.unstring
tests/test_derivepassphrase_ssh_agent.py 159)         unstring_prefix = ssh_agent.SSHAgentClient.unstring_prefix
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           160)         assert bytes(unstring(input)) == expected
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           161)         assert tuple(bytes(x) for x in unstring_prefix(input)) == (
tests/test_ssh_agent_client.py           162)             expected,
tests/test_ssh_agent_client.py           163)             b'',
tests/test_ssh_agent_client.py           164)         )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           165) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           166)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           167)         ['value', 'exc_type', 'exc_pattern'],
tests/test_ssh_agent_client.py           168)         [
tests/test_ssh_agent_client.py           169)             (10000000000000000, OverflowError, 'int too big to convert'),
tests/test_ssh_agent_client.py           170)             (-1, OverflowError, "can't convert negative int to unsigned"),
tests/test_ssh_agent_client.py           171)         ],
tests/test_ssh_agent_client.py           172)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           173)     def test_310_uint32_exceptions(
tests/test_ssh_agent_client.py           174)         self, value: int, exc_type: type[Exception], exc_pattern: str
tests/test_ssh_agent_client.py           175)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 176)         uint32 = ssh_agent.SSHAgentClient.uint32
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           177)         with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           178)             uint32(value)
tests/test_ssh_agent_client.py           179) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           180)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           181)         ['input', 'exc_type', 'exc_pattern'],
tests/test_ssh_agent_client.py           182)         [
tests/test_ssh_agent_client.py           183)             ('some string', TypeError, 'invalid payload type'),
tests/test_ssh_agent_client.py           184)         ],
tests/test_ssh_agent_client.py           185)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           186)     def test_311_string_exceptions(
tests/test_ssh_agent_client.py           187)         self, input: Any, exc_type: type[Exception], exc_pattern: str
tests/test_ssh_agent_client.py           188)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 189)         string = ssh_agent.SSHAgentClient.string
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           190)         with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           191)             string(input)
tests/test_ssh_agent_client.py           192) 
tests/test_ssh_agent_client.py           193)     @pytest.mark.parametrize(
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           194)         ['input', 'exc_type', 'exc_pattern', 'has_trailer', 'parts'],
tests/test_ssh_agent_client.py           195)         [
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           196)             (b'ssh', ValueError, 'malformed SSH byte string', False, None),
tests/test_ssh_agent_client.py           197)             (
tests/test_ssh_agent_client.py           198)                 b'\x00\x00\x00\x08ssh-rsa',
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           199)                 ValueError,
tests/test_ssh_agent_client.py           200)                 'malformed SSH byte string',
tests/test_ssh_agent_client.py           201)                 False,
tests/test_ssh_agent_client.py           202)                 None,
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           203)             ),
tests/test_ssh_agent_client.py           204)             (
tests/test_ssh_agent_client.py           205)                 b'\x00\x00\x00\x04XXX trailing text',
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           206)                 ValueError,
tests/test_ssh_agent_client.py           207)                 'malformed SSH byte string',
tests/test_ssh_agent_client.py           208)                 True,
tests/test_ssh_agent_client.py           209)                 (b'XXX ', b'trailing text'),
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           210)             ),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           211)         ],
tests/test_ssh_agent_client.py           212)     )
tests/test_ssh_agent_client.py           213)     def test_312_unstring_exceptions(
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           214)         self,
tests/test_ssh_agent_client.py           215)         input: bytes | bytearray,
tests/test_ssh_agent_client.py           216)         exc_type: type[Exception],
tests/test_ssh_agent_client.py           217)         exc_pattern: str,
tests/test_ssh_agent_client.py           218)         has_trailer: bool,
tests/test_ssh_agent_client.py           219)         parts: tuple[bytes | bytearray, bytes | bytearray] | None,
tests/test_ssh_agent_client.py           220)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 221)         unstring = ssh_agent.SSHAgentClient.unstring
tests/test_derivepassphrase_ssh_agent.py 222)         unstring_prefix = ssh_agent.SSHAgentClient.unstring_prefix
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           223)         with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           224)             unstring(input)
tests/test_ssh_agent_client.py           225)         if has_trailer:
tests/test_ssh_agent_client.py           226)             assert tuple(bytes(x) for x in unstring_prefix(input)) == parts
tests/test_ssh_agent_client.py           227)         else:
tests/test_ssh_agent_client.py           228)             with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           229)                 unstring_prefix(input)
tests/test_ssh_agent_client.py           230) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           231) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           232) class TestAgentInteraction:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           233)     @pytest.mark.parametrize(
Marco Ricci Simplify some SSH agent key...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 234)         'data_dict',
tests/test_derivepassphrase_ssh_agent.py 235)         list(tests.SUPPORTED_KEYS.values()),
tests/test_derivepassphrase_ssh_agent.py 236)         ids=tests.SUPPORTED_KEYS.keys(),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           237)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           238)     def test_200_sign_data_via_agent(
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 239)         self,
tests/test_derivepassphrase_ssh_agent.py 240)         ssh_agent_client_with_test_keys_loaded: ssh_agent.SSHAgentClient,
tests/test_derivepassphrase_ssh_agent.py 241)         data_dict: tests.SSHTestKey,
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           242)     ) -> None:
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 243)         client = ssh_agent_client_with_test_keys_loaded
tests/test_derivepassphrase_ssh_agent.py 244)         key_comment_pairs = {bytes(k): bytes(c) for k, c in client.list_keys()}
tests/test_derivepassphrase_ssh_agent.py 245)         public_key_data = data_dict['public_key_data']
tests/test_derivepassphrase_ssh_agent.py 246)         expected_signature = data_dict['expected_signature']
tests/test_derivepassphrase_ssh_agent.py 247)         derived_passphrase = data_dict['derived_passphrase']
tests/test_derivepassphrase_ssh_agent.py 248)         if public_key_data not in key_comment_pairs:  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 249)             pytest.skip('prerequisite SSH key not loaded')
tests/test_derivepassphrase_ssh_agent.py 250)         signature = bytes(
tests/test_derivepassphrase_ssh_agent.py 251)             client.sign(payload=vault.Vault._UUID, key=public_key_data)
tests/test_derivepassphrase_ssh_agent.py 252)         )
tests/test_derivepassphrase_ssh_agent.py 253)         assert signature == expected_signature, 'SSH signature mismatch'
tests/test_derivepassphrase_ssh_agent.py 254)         signature2 = bytes(
tests/test_derivepassphrase_ssh_agent.py 255)             client.sign(payload=vault.Vault._UUID, key=public_key_data)
tests/test_derivepassphrase_ssh_agent.py 256)         )
tests/test_derivepassphrase_ssh_agent.py 257)         assert signature2 == expected_signature, 'SSH signature mismatch'
tests/test_derivepassphrase_ssh_agent.py 258)         assert (
Marco Ricci Publish polished `is_suitab...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 259)             vault.Vault.phrase_from_key(public_key_data, conn=client)
tests/test_derivepassphrase_ssh_agent.py 260)             == derived_passphrase
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 261)         ), 'SSH signature mismatch'
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           262) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           263)     @pytest.mark.parametrize(
Marco Ricci Simplify some SSH agent key...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 264)         'data_dict',
tests/test_derivepassphrase_ssh_agent.py 265)         list(tests.UNSUITABLE_KEYS.values()),
tests/test_derivepassphrase_ssh_agent.py 266)         ids=tests.UNSUITABLE_KEYS.keys(),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           267)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           268)     def test_201_sign_data_via_agent_unsupported(
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 269)         self,
tests/test_derivepassphrase_ssh_agent.py 270)         ssh_agent_client_with_test_keys_loaded: ssh_agent.SSHAgentClient,
tests/test_derivepassphrase_ssh_agent.py 271)         data_dict: tests.SSHTestKey,
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           272)     ) -> None:
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 273)         client = ssh_agent_client_with_test_keys_loaded
tests/test_derivepassphrase_ssh_agent.py 274)         key_comment_pairs = {bytes(k): bytes(c) for k, c in client.list_keys()}
tests/test_derivepassphrase_ssh_agent.py 275)         public_key_data = data_dict['public_key_data']
tests/test_derivepassphrase_ssh_agent.py 276)         _ = data_dict['expected_signature']
tests/test_derivepassphrase_ssh_agent.py 277)         if public_key_data not in key_comment_pairs:  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 278)             pytest.skip('prerequisite SSH key not loaded')
Marco Ricci Publish polished `is_suitab...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 279)         assert not vault.Vault.is_suitable_ssh_key(
tests/test_derivepassphrase_ssh_agent.py 280)             public_key_data, client=None
tests/test_derivepassphrase_ssh_agent.py 281)         ), 'Expected key to be unsuitable in general'
tests/test_derivepassphrase_ssh_agent.py 282)         if vault.Vault.is_suitable_ssh_key(public_key_data, client=client):
tests/test_derivepassphrase_ssh_agent.py 283)             pytest.skip('agent automatically ensures key is suitable')
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 284)         with pytest.raises(ValueError, match='unsuitable SSH key'):
Marco Ricci Publish polished `is_suitab...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 285)             vault.Vault.phrase_from_key(public_key_data, conn=client)
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           286) 
Marco Ricci Fix awkward parametrization...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 287)     @pytest.mark.parametrize(
tests/test_derivepassphrase_ssh_agent.py 288)         ['key', 'single'],
tests/test_derivepassphrase_ssh_agent.py 289)         [
tests/test_derivepassphrase_ssh_agent.py 290)             (value['public_key_data'], False)
tests/test_derivepassphrase_ssh_agent.py 291)             for value in tests.SUPPORTED_KEYS.values()
tests/test_derivepassphrase_ssh_agent.py 292)         ]
tests/test_derivepassphrase_ssh_agent.py 293)         + [(tests.list_keys_singleton()[0].key, True)],
tests/test_derivepassphrase_ssh_agent.py 294)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           295)     def test_210_ssh_key_selector(
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 296)         self,
tests/test_derivepassphrase_ssh_agent.py 297)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Fix test suite to actually...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 298)         ssh_agent_client_with_test_keys_loaded: ssh_agent.SSHAgentClient,
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 299)         key: bytes,
tests/test_derivepassphrase_ssh_agent.py 300)         single: bool,
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           301)     ) -> None:
Marco Ricci Fix test suite to actually...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 302)         client = ssh_agent_client_with_test_keys_loaded
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 303) 
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           304)         def key_is_suitable(key: bytes) -> bool:
Marco Ricci Publish polished `is_suitab...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 305)             always = {
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           306)                 v['public_key_data'] for v in tests.SUPPORTED_KEYS.values()
tests/test_ssh_agent_client.py           307)             }
Marco Ricci Publish polished `is_suitab...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 308)             dsa = {
tests/test_derivepassphrase_ssh_agent.py 309)                 v['public_key_data']
tests/test_derivepassphrase_ssh_agent.py 310)                 for k, v in tests.UNSUITABLE_KEYS.items()
tests/test_derivepassphrase_ssh_agent.py 311)                 if k.startswith(('dsa', 'ecdsa'))
tests/test_derivepassphrase_ssh_agent.py 312)             }
tests/test_derivepassphrase_ssh_agent.py 313)             return key in always or (
tests/test_derivepassphrase_ssh_agent.py 314)                 client.has_deterministic_dsa_signatures() and key in dsa
tests/test_derivepassphrase_ssh_agent.py 315)             )
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           316) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           317)         if single:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           318)             monkeypatch.setattr(
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 319)                 ssh_agent.SSHAgentClient,
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           320)                 'list_keys',
tests/test_ssh_agent_client.py           321)                 tests.list_keys_singleton,
tests/test_ssh_agent_client.py           322)             )
tests/test_ssh_agent_client.py           323)             keys = [
tests/test_ssh_agent_client.py           324)                 pair.key
tests/test_ssh_agent_client.py           325)                 for pair in tests.list_keys_singleton()
tests/test_ssh_agent_client.py           326)                 if key_is_suitable(pair.key)
tests/test_ssh_agent_client.py           327)             ]
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           328)             index = '1'
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           329)             text = 'Use this key? yes\n'
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           330)         else:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           331)             monkeypatch.setattr(
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 332)                 ssh_agent.SSHAgentClient, 'list_keys', tests.list_keys
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           333)             )
tests/test_ssh_agent_client.py           334)             keys = [
tests/test_ssh_agent_client.py           335)                 pair.key
tests/test_ssh_agent_client.py           336)                 for pair in tests.list_keys()
tests/test_ssh_agent_client.py           337)                 if key_is_suitable(pair.key)
tests/test_ssh_agent_client.py           338)             ]
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           339)             index = str(1 + keys.index(key))
tests/test_ssh_agent_client.py           340)             n = len(keys)
tests/test_ssh_agent_client.py           341)             text = f'Your selection? (1-{n}, leave empty to abort): {index}\n'
tests/test_ssh_agent_client.py           342)         b64_key = base64.standard_b64encode(key).decode('ASCII')
tests/test_ssh_agent_client.py           343) 
tests/test_ssh_agent_client.py           344)         @click.command()
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           345)         def driver() -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 346)             key = cli._select_ssh_key()
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           347)             click.echo(base64.standard_b64encode(key).decode('ASCII'))
tests/test_ssh_agent_client.py           348) 
tests/test_ssh_agent_client.py           349)         runner = click.testing.CliRunner(mix_stderr=True)
Marco Ricci Clean up testing machinery...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 350)         _result = runner.invoke(
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           351)             driver,
tests/test_ssh_agent_client.py           352)             [],
tests/test_ssh_agent_client.py           353)             input=('yes\n' if single else f'{index}\n'),
tests/test_ssh_agent_client.py           354)             catch_exceptions=True,
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           355)         )
Marco Ricci Clean up testing machinery...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 356)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_ssh_agent.py 357)         for snippet in ('Suitable SSH keys:\n', text, f'\n{b64_key}\n'):
tests/test_derivepassphrase_ssh_agent.py 358)             assert result.clean_exit(output=snippet), 'expected clean exit'
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           359) 
Marco Ricci Clean up testing machinery...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 360)     def test_300_constructor_bad_running_agent(
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 361)         self,
tests/test_derivepassphrase_ssh_agent.py 362)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Let the `running_ssh_agent`...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 363)         running_ssh_agent: tests.RunningSSHAgentInfo,
Marco Ricci Clean up testing machinery...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 364)     ) -> None:
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 365)         with monkeypatch.context() as monkeypatch2:
Marco Ricci Let the `running_ssh_agent`...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 366)             monkeypatch2.setenv(
tests/test_derivepassphrase_ssh_agent.py 367)                 'SSH_AUTH_SOCK', running_ssh_agent.socket + '~'
tests/test_derivepassphrase_ssh_agent.py 368)             )
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 369)             sock = socket.socket(family=socket.AF_UNIX)
tests/test_derivepassphrase_ssh_agent.py 370)             with pytest.raises(OSError):  # noqa: PT011
tests/test_derivepassphrase_ssh_agent.py 371)                 ssh_agent.SSHAgentClient(socket=sock)
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           372) 
Marco Ricci Fail gracefully if UNIX dom...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 373)     def test_301_constructor_no_af_unix_support(
tests/test_derivepassphrase_ssh_agent.py 374)         self,
tests/test_derivepassphrase_ssh_agent.py 375)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_ssh_agent.py 376)     ) -> None:
tests/test_derivepassphrase_ssh_agent.py 377)         with monkeypatch.context() as monkeypatch2:
tests/test_derivepassphrase_ssh_agent.py 378)             monkeypatch2.setenv('SSH_AUTH_SOCK', "the value doesn't matter")
tests/test_derivepassphrase_ssh_agent.py 379)             monkeypatch2.delattr(socket, 'AF_UNIX', raising=False)
tests/test_derivepassphrase_ssh_agent.py 380)             with pytest.raises(
tests/test_derivepassphrase_ssh_agent.py 381)                 NotImplementedError,
tests/test_derivepassphrase_ssh_agent.py 382)                 match='UNIX domain sockets',
tests/test_derivepassphrase_ssh_agent.py 383)             ):
tests/test_derivepassphrase_ssh_agent.py 384)                 ssh_agent.SSHAgentClient()
tests/test_derivepassphrase_ssh_agent.py 385) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           386)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           387)         'response',
tests/test_ssh_agent_client.py           388)         [
tests/test_ssh_agent_client.py           389)             b'\x00\x00',
tests/test_ssh_agent_client.py           390)             b'\x00\x00\x00\x1f some bytes missing',
tests/test_ssh_agent_client.py           391)         ],
tests/test_ssh_agent_client.py           392)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           393)     def test_310_truncated_server_response(
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 394)         self,
tests/test_derivepassphrase_ssh_agent.py 395)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Let the `running_ssh_agent`...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 396)         running_ssh_agent: tests.RunningSSHAgentInfo,
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 397)         response: bytes,
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           398)     ) -> None:
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 399)         del running_ssh_agent
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 400)         client = ssh_agent.SSHAgentClient()
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           401)         response_stream = io.BytesIO(response)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           402) 
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           403)         class PseudoSocket:
tests/test_ssh_agent_client.py           404)             def sendall(self, *args: Any, **kwargs: Any) -> Any:  # noqa: ARG002
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           405)                 return None
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           406) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           407)             def recv(self, *args: Any, **kwargs: Any) -> Any:
tests/test_ssh_agent_client.py           408)                 return response_stream.read(*args, **kwargs)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           409) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           410)         pseudo_socket = PseudoSocket()
tests/test_ssh_agent_client.py           411)         monkeypatch.setattr(client, '_connection', pseudo_socket)
tests/test_ssh_agent_client.py           412)         with pytest.raises(EOFError):
tests/test_ssh_agent_client.py           413)             client.request(255, b'')
tests/test_ssh_agent_client.py           414) 
tests/test_ssh_agent_client.py           415)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           416)         ['response_code', 'response', 'exc_type', 'exc_pattern'],
tests/test_ssh_agent_client.py           417)         [
Marco Ricci Introduce TrailingDataError...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           418)             (
Marco Ricci Add a specific error class...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 419)                 _types.SSH_AGENT.FAILURE,
tests/test_derivepassphrase_ssh_agent.py 420)                 b'',
tests/test_derivepassphrase_ssh_agent.py 421)                 ssh_agent.SSHAgentFailedError,
tests/test_derivepassphrase_ssh_agent.py 422)                 'failed to complete the request',
tests/test_derivepassphrase_ssh_agent.py 423)             ),
tests/test_derivepassphrase_ssh_agent.py 424)             (
tests/test_derivepassphrase_ssh_agent.py 425)                 _types.SSH_AGENT.IDENTITIES_ANSWER,
tests/test_derivepassphrase_ssh_agent.py 426)                 b'\x00\x00\x00\x01',
tests/test_derivepassphrase_ssh_agent.py 427)                 EOFError,
tests/test_derivepassphrase_ssh_agent.py 428)                 'truncated response',
tests/test_derivepassphrase_ssh_agent.py 429)             ),
tests/test_derivepassphrase_ssh_agent.py 430)             (
tests/test_derivepassphrase_ssh_agent.py 431)                 _types.SSH_AGENT.IDENTITIES_ANSWER,
Marco Ricci Introduce TrailingDataError...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           432)                 b'\x00\x00\x00\x00abc',
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 433)                 ssh_agent.TrailingDataError,
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           434)                 'Overlong response',
Marco Ricci Introduce TrailingDataError...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           435)             ),
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           436)         ],
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           437)     )
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           438)     def test_320_list_keys_error_responses(
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           439)         self,
Marco Ricci Clean up testing machinery...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 440)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Let the `running_ssh_agent`...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 441)         running_ssh_agent: tests.RunningSSHAgentInfo,
Marco Ricci Add a specific error class...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 442)         response_code: _types.SSH_AGENT,
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           443)         response: bytes | bytearray,
tests/test_ssh_agent_client.py           444)         exc_type: type[Exception],
tests/test_ssh_agent_client.py           445)         exc_pattern: str,
tests/test_ssh_agent_client.py           446)     ) -> None:
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 447)         del running_ssh_agent
tests/test_derivepassphrase_ssh_agent.py 448) 
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 449)         passed_response_code = response_code
tests/test_derivepassphrase_ssh_agent.py 450) 
tests/test_derivepassphrase_ssh_agent.py 451)         def request(
tests/test_derivepassphrase_ssh_agent.py 452)             request_code: int | _types.SSH_AGENTC,
tests/test_derivepassphrase_ssh_agent.py 453)             payload: bytes | bytearray,
tests/test_derivepassphrase_ssh_agent.py 454)             /,
tests/test_derivepassphrase_ssh_agent.py 455)             *,
tests/test_derivepassphrase_ssh_agent.py 456)             response_code: Iterable[int | _types.SSH_AGENT]
tests/test_derivepassphrase_ssh_agent.py 457)             | int
tests/test_derivepassphrase_ssh_agent.py 458)             | _types.SSH_AGENT
tests/test_derivepassphrase_ssh_agent.py 459)             | None = None,
tests/test_derivepassphrase_ssh_agent.py 460)         ) -> tuple[int, bytes | bytearray] | bytes | bytearray:
tests/test_derivepassphrase_ssh_agent.py 461)             del request_code
tests/test_derivepassphrase_ssh_agent.py 462)             del payload
tests/test_derivepassphrase_ssh_agent.py 463)             if isinstance(  # pragma: no branch
Marco Ricci Add support for Python 3.9

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 464)                 response_code, (int, _types.SSH_AGENT)
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 465)             ):
tests/test_derivepassphrase_ssh_agent.py 466)                 response_code = frozenset({response_code})
tests/test_derivepassphrase_ssh_agent.py 467)             if response_code is not None:  # pragma: no branch
tests/test_derivepassphrase_ssh_agent.py 468)                 response_code = frozenset({
tests/test_derivepassphrase_ssh_agent.py 469)                     c if isinstance(c, int) else c.value for c in response_code
tests/test_derivepassphrase_ssh_agent.py 470)                 })
tests/test_derivepassphrase_ssh_agent.py 471) 
tests/test_derivepassphrase_ssh_agent.py 472)             if not response_code:  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 473)                 return (passed_response_code.value, response)
tests/test_derivepassphrase_ssh_agent.py 474)             if passed_response_code.value not in response_code:
tests/test_derivepassphrase_ssh_agent.py 475)                 raise ssh_agent.SSHAgentFailedError(
tests/test_derivepassphrase_ssh_agent.py 476)                     passed_response_code.value, response
tests/test_derivepassphrase_ssh_agent.py 477)                 )
tests/test_derivepassphrase_ssh_agent.py 478)             return response
tests/test_derivepassphrase_ssh_agent.py 479) 
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 480)         with monkeypatch.context() as monkeypatch2:
tests/test_derivepassphrase_ssh_agent.py 481)             client = ssh_agent.SSHAgentClient()
tests/test_derivepassphrase_ssh_agent.py 482)             monkeypatch2.setattr(client, 'request', request)
tests/test_derivepassphrase_ssh_agent.py 483)             with pytest.raises(exc_type, match=exc_pattern):
tests/test_derivepassphrase_ssh_agent.py 484)                 client.list_keys()
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           485) 
tests/test_ssh_agent_client.py           486)     @pytest.mark.parametrize(
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 487)         [
tests/test_derivepassphrase_ssh_agent.py 488)             'key',
tests/test_derivepassphrase_ssh_agent.py 489)             'check',
tests/test_derivepassphrase_ssh_agent.py 490)             'response_code',
tests/test_derivepassphrase_ssh_agent.py 491)             'response',
tests/test_derivepassphrase_ssh_agent.py 492)             'exc_type',
tests/test_derivepassphrase_ssh_agent.py 493)             'exc_pattern',
tests/test_derivepassphrase_ssh_agent.py 494)         ],
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           495)         [
tests/test_ssh_agent_client.py           496)             (
tests/test_ssh_agent_client.py           497)                 b'invalid-key',
tests/test_ssh_agent_client.py           498)                 True,
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 499)                 _types.SSH_AGENT.FAILURE,
tests/test_derivepassphrase_ssh_agent.py 500)                 b'',
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           501)                 KeyError,
tests/test_ssh_agent_client.py           502)                 'target SSH key not loaded into agent',
tests/test_ssh_agent_client.py           503)             ),
tests/test_ssh_agent_client.py           504)             (
tests/test_ssh_agent_client.py           505)                 tests.SUPPORTED_KEYS['ed25519']['public_key_data'],
tests/test_ssh_agent_client.py           506)                 True,
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 507)                 _types.SSH_AGENT.FAILURE,
tests/test_derivepassphrase_ssh_agent.py 508)                 b'',
Marco Ricci Add a specific error class...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_ssh_agent.py 509)                 ssh_agent.SSHAgentFailedError,
tests/test_derivepassphrase_ssh_agent.py 510)                 'failed to complete the request',
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           511)             ),
tests/test_ssh_agent_client.py           512)         ],
Marco Ricci Rename and regroup all test...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           513)     )
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           514)     def test_330_sign_error_responses(
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           515)         self,
Marco Ricci Clean up testing machinery...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 516)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Let the `running_ssh_agent`...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 517)         running_ssh_agent: tests.RunningSSHAgentInfo,
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           518)         key: bytes | bytearray,
tests/test_ssh_agent_client.py           519)         check: bool,
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 520)         response_code: _types.SSH_AGENT,
tests/test_derivepassphrase_ssh_agent.py 521)         response: bytes | bytearray,
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 5 months ago

tests/test_ssh_agent_client.py           522)         exc_type: type[Exception],
tests/test_ssh_agent_client.py           523)         exc_pattern: str,
tests/test_ssh_agent_client.py           524)     ) -> None:
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 525)         del running_ssh_agent
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 526)         passed_response_code = response_code
tests/test_derivepassphrase_ssh_agent.py 527) 
tests/test_derivepassphrase_ssh_agent.py 528)         def request(
tests/test_derivepassphrase_ssh_agent.py 529)             request_code: int | _types.SSH_AGENTC,
tests/test_derivepassphrase_ssh_agent.py 530)             payload: bytes | bytearray,
tests/test_derivepassphrase_ssh_agent.py 531)             /,
tests/test_derivepassphrase_ssh_agent.py 532)             *,
tests/test_derivepassphrase_ssh_agent.py 533)             response_code: Iterable[int | _types.SSH_AGENT]
tests/test_derivepassphrase_ssh_agent.py 534)             | int
tests/test_derivepassphrase_ssh_agent.py 535)             | _types.SSH_AGENT
tests/test_derivepassphrase_ssh_agent.py 536)             | None = None,
tests/test_derivepassphrase_ssh_agent.py 537)         ) -> tuple[int, bytes | bytearray] | bytes | bytearray:
tests/test_derivepassphrase_ssh_agent.py 538)             del request_code
tests/test_derivepassphrase_ssh_agent.py 539)             del payload
tests/test_derivepassphrase_ssh_agent.py 540)             if isinstance(  # pragma: no branch
Marco Ricci Add support for Python 3.9

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 541)                 response_code, (int, _types.SSH_AGENT)
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 542)             ):
tests/test_derivepassphrase_ssh_agent.py 543)                 response_code = frozenset({response_code})
tests/test_derivepassphrase_ssh_agent.py 544)             if response_code is not None:  # pragma: no branch
tests/test_derivepassphrase_ssh_agent.py 545)                 response_code = frozenset({
tests/test_derivepassphrase_ssh_agent.py 546)                     c if isinstance(c, int) else c.value for c in response_code
tests/test_derivepassphrase_ssh_agent.py 547)                 })
tests/test_derivepassphrase_ssh_agent.py 548) 
tests/test_derivepassphrase_ssh_agent.py 549)             if not response_code:  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 550)                 return (passed_response_code.value, response)
tests/test_derivepassphrase_ssh_agent.py 551)             if (
tests/test_derivepassphrase_ssh_agent.py 552)                 passed_response_code.value not in response_code
tests/test_derivepassphrase_ssh_agent.py 553)             ):  # pragma: no branch
tests/test_derivepassphrase_ssh_agent.py 554)                 raise ssh_agent.SSHAgentFailedError(
tests/test_derivepassphrase_ssh_agent.py 555)                     passed_response_code.value, response
tests/test_derivepassphrase_ssh_agent.py 556)                 )
tests/test_derivepassphrase_ssh_agent.py 557)             return response  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 558) 
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 559)         with monkeypatch.context() as monkeypatch2:
tests/test_derivepassphrase_ssh_agent.py 560)             client = ssh_agent.SSHAgentClient()
tests/test_derivepassphrase_ssh_agent.py 561)             monkeypatch2.setattr(client, 'request', request)
tests/test_derivepassphrase_ssh_agent.py 562)             KeyCommentPair = _types.KeyCommentPair  # noqa: N806
tests/test_derivepassphrase_ssh_agent.py 563)             loaded_keys = [
tests/test_derivepassphrase_ssh_agent.py 564)                 KeyCommentPair(v['public_key_data'], b'no comment')
tests/test_derivepassphrase_ssh_agent.py 565)                 for v in tests.SUPPORTED_KEYS.values()
tests/test_derivepassphrase_ssh_agent.py 566)             ]
tests/test_derivepassphrase_ssh_agent.py 567)             monkeypatch2.setattr(client, 'list_keys', lambda: loaded_keys)
tests/test_derivepassphrase_ssh_agent.py 568)             with pytest.raises(exc_type, match=exc_pattern):
tests/test_derivepassphrase_ssh_agent.py 569)                 client.sign(key, b'abc', check_if_key_loaded=check)
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 570) 
tests/test_derivepassphrase_ssh_agent.py 571)     @pytest.mark.parametrize(
tests/test_derivepassphrase_ssh_agent.py 572)         ['request_code', 'response_code', 'exc_type', 'exc_pattern'],
tests/test_derivepassphrase_ssh_agent.py 573)         [
tests/test_derivepassphrase_ssh_agent.py 574)             (
tests/test_derivepassphrase_ssh_agent.py 575)                 _types.SSH_AGENTC.REQUEST_IDENTITIES,
tests/test_derivepassphrase_ssh_agent.py 576)                 _types.SSH_AGENT.SUCCESS,
tests/test_derivepassphrase_ssh_agent.py 577)                 ssh_agent.SSHAgentFailedError,
tests/test_derivepassphrase_ssh_agent.py 578)                 f'[Code {_types.SSH_AGENT.IDENTITIES_ANSWER.value}]',
tests/test_derivepassphrase_ssh_agent.py 579)             ),
tests/test_derivepassphrase_ssh_agent.py 580)         ],
tests/test_derivepassphrase_ssh_agent.py 581)     )
tests/test_derivepassphrase_ssh_agent.py 582)     def test_340_request_error_responses(
tests/test_derivepassphrase_ssh_agent.py 583)         self,
Marco Ricci Let the `running_ssh_agent`...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 584)         running_ssh_agent: tests.RunningSSHAgentInfo,
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 585)         request_code: _types.SSH_AGENTC,
tests/test_derivepassphrase_ssh_agent.py 586)         response_code: _types.SSH_AGENT,
tests/test_derivepassphrase_ssh_agent.py 587)         exc_type: type[Exception],
tests/test_derivepassphrase_ssh_agent.py 588)         exc_pattern: str,
tests/test_derivepassphrase_ssh_agent.py 589)     ) -> None:
Marco Ricci Add test fixture for manual...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 590)         del running_ssh_agent
tests/test_derivepassphrase_ssh_agent.py 591) 
Marco Ricci Support passing expected SS...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 592)         with (
tests/test_derivepassphrase_ssh_agent.py 593)             pytest.raises(exc_type, match=exc_pattern),
tests/test_derivepassphrase_ssh_agent.py 594)             ssh_agent.SSHAgentClient() as client,
tests/test_derivepassphrase_ssh_agent.py 595)         ):
tests/test_derivepassphrase_ssh_agent.py 596)             client.request(request_code, b'', response_code=response_code)
Marco Ricci Add hypothesis-based tests...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_ssh_agent.py 597) 
Marco Ricci Add missing tests for `SSHA...

Marco Ricci authored 3 weeks ago

tests/test_derivepassphrase_ssh_agent.py 598)     @pytest.mark.parametrize(
tests/test_derivepassphrase_ssh_agent.py 599)         'response_data',
tests/test_derivepassphrase_ssh_agent.py 600)         [
tests/test_derivepassphrase_ssh_agent.py 601)             b'\xde\xad\xbe\xef',
tests/test_derivepassphrase_ssh_agent.py 602)             b'\x00\x00\x00\x0fwrong extension',
tests/test_derivepassphrase_ssh_agent.py 603)             b'\x00\x00\x00\x05query\xde\xad\xbe\xef',
tests/test_derivepassphrase_ssh_agent.py 604)             b'\x00\x00\x00\x05query\x00\x00\x00\x04ext1\x00\x00',
tests/test_derivepassphrase_ssh_agent.py 605)         ],
tests/test_derivepassphrase_ssh_agent.py 606)     )
tests/test_derivepassphrase_ssh_agent.py 607)     def test_350_query_extensions_malformed_responses(
tests/test_derivepassphrase_ssh_agent.py 608)         self,
tests/test_derivepassphrase_ssh_agent.py 609)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_ssh_agent.py 610)         running_ssh_agent: tests.RunningSSHAgentInfo,
tests/test_derivepassphrase_ssh_agent.py 611)         response_data: bytes,
tests/test_derivepassphrase_ssh_agent.py 612)     ) -> None:
tests/test_derivepassphrase_ssh_agent.py 613)         del running_ssh_agent
tests/test_derivepassphrase_ssh_agent.py 614) 
tests/test_derivepassphrase_ssh_agent.py 615)         def request(
tests/test_derivepassphrase_ssh_agent.py 616)             code: int | _types.SSH_AGENTC,
tests/test_derivepassphrase_ssh_agent.py 617)             payload: Buffer,
tests/test_derivepassphrase_ssh_agent.py 618)             /,
tests/test_derivepassphrase_ssh_agent.py 619)             *,
tests/test_derivepassphrase_ssh_agent.py 620)             response_code: (
tests/test_derivepassphrase_ssh_agent.py 621)                 Iterable[_types.SSH_AGENT | int]
tests/test_derivepassphrase_ssh_agent.py 622)                 | _types.SSH_AGENT
tests/test_derivepassphrase_ssh_agent.py 623)                 | int
tests/test_derivepassphrase_ssh_agent.py 624)                 | None
tests/test_derivepassphrase_ssh_agent.py 625)             ) = None,
tests/test_derivepassphrase_ssh_agent.py 626)         ) -> tuple[int, bytes] | bytes:
tests/test_derivepassphrase_ssh_agent.py 627)             request_codes = {
tests/test_derivepassphrase_ssh_agent.py 628)                 _types.SSH_AGENTC.EXTENSION,
tests/test_derivepassphrase_ssh_agent.py 629)                 _types.SSH_AGENTC.EXTENSION.value,
tests/test_derivepassphrase_ssh_agent.py 630)             }
tests/test_derivepassphrase_ssh_agent.py 631)             assert code in request_codes
tests/test_derivepassphrase_ssh_agent.py 632)             response_codes = {
tests/test_derivepassphrase_ssh_agent.py 633)                 _types.SSH_AGENT.EXTENSION_RESPONSE,
tests/test_derivepassphrase_ssh_agent.py 634)                 _types.SSH_AGENT.EXTENSION_RESPONSE.value,
tests/test_derivepassphrase_ssh_agent.py 635)                 _types.SSH_AGENT.SUCCESS,
tests/test_derivepassphrase_ssh_agent.py 636)                 _types.SSH_AGENT.SUCCESS.value,
tests/test_derivepassphrase_ssh_agent.py 637)             }
tests/test_derivepassphrase_ssh_agent.py 638)             assert payload == b'\x00\x00\x00\x05query'
tests/test_derivepassphrase_ssh_agent.py 639)             if response_code is None:  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 640)                 return (
tests/test_derivepassphrase_ssh_agent.py 641)                     _types.SSH_AGENT.EXTENSION_RESPONSE.value,
tests/test_derivepassphrase_ssh_agent.py 642)                     response_data,
tests/test_derivepassphrase_ssh_agent.py 643)                 )
tests/test_derivepassphrase_ssh_agent.py 644)             if isinstance(  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 645)                 response_code, (_types.SSH_AGENT, int)
tests/test_derivepassphrase_ssh_agent.py 646)             ):
tests/test_derivepassphrase_ssh_agent.py 647)                 assert response_code in response_codes
tests/test_derivepassphrase_ssh_agent.py 648)                 return response_data
tests/test_derivepassphrase_ssh_agent.py 649)             for single_code in response_code:  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 650)                 assert single_code in response_codes
tests/test_derivepassphrase_ssh_agent.py 651)             return response_data  # pragma: no cover
tests/test_derivepassphrase_ssh_agent.py 652) 
tests/test_derivepassphrase_ssh_agent.py 653)         with (
tests/test_derivepassphrase_ssh_agent.py 654)             monkeypatch.context() as monkeypatch2,
tests/test_derivepassphrase_ssh_agent.py 655)             ssh_agent.SSHAgentClient() as client,
tests/test_derivepassphrase_ssh_agent.py 656)         ):
tests/test_derivepassphrase_ssh_agent.py 657)             monkeypatch2.setattr(client, 'request', request)
tests/test_derivepassphrase_ssh_agent.py 658)             with pytest.raises(
tests/test_derivepassphrase_ssh_agent.py 659)                 RuntimeError,
tests/test_derivepassphrase_ssh_agent.py 660)                 match='Malformed response|does not match request'
tests/test_derivepassphrase_ssh_agent.py 661)             ):
tests/test_derivepassphrase_ssh_agent.py 662)                 client.query_extensions()
tests/test_derivepassphrase_ssh_agent.py 663)