26973402aac5d216a66ae3fc8f2d7bcb0fd7ea89
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py             1) # SPDX-FileCopyrightText: 2024 Marco Ricci <m@the13thletter.info>
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 os
tests/test_ssh_agent_client.py            12) import socket
tests/test_ssh_agent_client.py            13) import subprocess
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py            15) 
tests/test_ssh_agent_client.py            16) import click
tests/test_ssh_agent_client.py            17) import click.testing
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            18) import pytest
tests/test_ssh_agent_client.py            19) from typing_extensions import Any
tests/test_ssh_agent_client.py            20) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py            21) import tests
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            24) if TYPE_CHECKING:
tests/test_ssh_agent_client.py            25)     from collections.abc import Iterator
tests/test_ssh_agent_client.py            26) 
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py            39)         keydata = base64.b64decode(public_key.split(None, 2)[1])
tests/test_ssh_agent_client.py            40)         assert (
tests/test_ssh_agent_client.py            41)             keydata == public_key_data
tests/test_ssh_agent_client.py            42)         ), "recorded public key data doesn't match"
tests/test_ssh_agent_client.py            43) 
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            44)     def test_200_constructor_no_running_agent(self, monkeypatch: Any) -> None:
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py            45)         monkeypatch.delenv('SSH_AUTH_SOCK', raising=False)
tests/test_ssh_agent_client.py            46)         sock = socket.socket(family=socket.AF_UNIX)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            47)         with pytest.raises(
tests/test_ssh_agent_client.py            48)             KeyError, match='SSH_AUTH_SOCK environment variable'
tests/test_ssh_agent_client.py            49)         ):
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py  50)             ssh_agent.SSHAgentClient(socket=sock)
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            52)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py            53)         ['input', 'expected'],
tests/test_ssh_agent_client.py            54)         [
tests/test_ssh_agent_client.py            55)             (16777216, b'\x01\x00\x00\x00'),
tests/test_ssh_agent_client.py            56)         ],
tests/test_ssh_agent_client.py            57)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            62)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py            63)         ['input', 'expected'],
tests/test_ssh_agent_client.py            64)         [
tests/test_ssh_agent_client.py            65)             (b'ssh-rsa', b'\x00\x00\x00\x07ssh-rsa'),
tests/test_ssh_agent_client.py            66)             (b'ssh-ed25519', b'\x00\x00\x00\x0bssh-ed25519'),
tests/test_ssh_agent_client.py            67)             (
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            69)                 b'\x00\x00\x00\x0f\x00\x00\x00\x0bssh-ed25519',
tests/test_ssh_agent_client.py            70)             ),
tests/test_ssh_agent_client.py            71)         ],
tests/test_ssh_agent_client.py            72)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            79)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py            80)         ['input', 'expected'],
tests/test_ssh_agent_client.py            81)         [
tests/test_ssh_agent_client.py            82)             (b'\x00\x00\x00\x07ssh-rsa', b'ssh-rsa'),
tests/test_ssh_agent_client.py            83)             (
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            85)                 b'ssh-ed25519',
tests/test_ssh_agent_client.py            86)             ),
tests/test_ssh_agent_client.py            87)         ],
tests/test_ssh_agent_client.py            88)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py            95)         assert tuple(bytes(x) for x in unstring_prefix(input)) == (
tests/test_ssh_agent_client.py            96)             expected,
tests/test_ssh_agent_client.py            97)             b'',
tests/test_ssh_agent_client.py            98)         )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           100)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           101)         ['value', 'exc_type', 'exc_pattern'],
tests/test_ssh_agent_client.py           102)         [
tests/test_ssh_agent_client.py           103)             (10000000000000000, OverflowError, 'int too big to convert'),
tests/test_ssh_agent_client.py           104)             (-1, OverflowError, "can't convert negative int to unsigned"),
tests/test_ssh_agent_client.py           105)         ],
tests/test_ssh_agent_client.py           106)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           111)         with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           112)             uint32(value)
tests/test_ssh_agent_client.py           113) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           114)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           115)         ['input', 'exc_type', 'exc_pattern'],
tests/test_ssh_agent_client.py           116)         [
tests/test_ssh_agent_client.py           117)             ('some string', TypeError, 'invalid payload type'),
tests/test_ssh_agent_client.py           118)         ],
tests/test_ssh_agent_client.py           119)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           124)         with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           125)             string(input)
tests/test_ssh_agent_client.py           126) 
tests/test_ssh_agent_client.py           127)     @pytest.mark.parametrize(
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           133)                 ValueError,
tests/test_ssh_agent_client.py           134)                 'malformed SSH byte string',
tests/test_ssh_agent_client.py           135)                 False,
tests/test_ssh_agent_client.py           136)                 None,
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           137)             ),
tests/test_ssh_agent_client.py           138)             (
tests/test_ssh_agent_client.py           139)                 b'\x00\x00\x00\x04XXX trailing text',
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           140)                 ValueError,
tests/test_ssh_agent_client.py           141)                 'malformed SSH byte string',
tests/test_ssh_agent_client.py           142)                 True,
tests/test_ssh_agent_client.py           143)                 (b'XXX ', b'trailing text'),
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           145)         ],
tests/test_ssh_agent_client.py           146)     )
tests/test_ssh_agent_client.py           147)     def test_312_unstring_exceptions(
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           148)         self,
tests/test_ssh_agent_client.py           149)         input: bytes | bytearray,
tests/test_ssh_agent_client.py           150)         exc_type: type[Exception],
tests/test_ssh_agent_client.py           151)         exc_pattern: str,
tests/test_ssh_agent_client.py           152)         has_trailer: bool,
tests/test_ssh_agent_client.py           153)         parts: tuple[bytes | bytearray, bytes | bytearray] | None,
tests/test_ssh_agent_client.py           154)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           157)         with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           158)             unstring(input)
tests/test_ssh_agent_client.py           159)         if has_trailer:
tests/test_ssh_agent_client.py           160)             assert tuple(bytes(x) for x in unstring_prefix(input)) == parts
tests/test_ssh_agent_client.py           161)         else:
tests/test_ssh_agent_client.py           162)             with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           163)                 unstring_prefix(input)
tests/test_ssh_agent_client.py           164) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           166) @tests.skip_if_no_agent
tests/test_ssh_agent_client.py           167) class TestAgentInteraction:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           168)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           169)         ['keytype', 'data_dict'], list(tests.SUPPORTED_KEYS.items())
tests/test_ssh_agent_client.py           170)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           171)     def test_200_sign_data_via_agent(
tests/test_ssh_agent_client.py           172)         self, keytype: str, data_dict: tests.SSHTestKey
tests/test_ssh_agent_client.py           173)     ) -> None:
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           174)         del keytype  # Unused.
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           175)         private_key = data_dict['private_key']
tests/test_ssh_agent_client.py           176)         try:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           177)             _ = subprocess.run(
tests/test_ssh_agent_client.py           178)                 ['ssh-add', '-t', '30', '-q', '-'],
tests/test_ssh_agent_client.py           179)                 input=private_key,
tests/test_ssh_agent_client.py           180)                 check=True,
tests/test_ssh_agent_client.py           181)                 capture_output=True,
tests/test_ssh_agent_client.py           182)             )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           183)         except subprocess.CalledProcessError as e:
tests/test_ssh_agent_client.py           184)             pytest.skip(
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           185)                 f'uploading test key: {e!r}, stdout={e.stdout!r}, '
tests/test_ssh_agent_client.py           186)                 f'stderr={e.stderr!r}'
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           187)             )
tests/test_ssh_agent_client.py           188)         else:
tests/test_ssh_agent_client.py           189)             try:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           191)             except OSError:  # pragma: no cover
tests/test_ssh_agent_client.py           192)                 pytest.skip('communication error with the SSH agent')
tests/test_ssh_agent_client.py           193)         with client:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           194)             key_comment_pairs = {
tests/test_ssh_agent_client.py           195)                 bytes(k): bytes(c) for k, c in client.list_keys()
tests/test_ssh_agent_client.py           196)             }
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           197)             public_key_data = data_dict['public_key_data']
tests/test_ssh_agent_client.py           198)             expected_signature = data_dict['expected_signature']
tests/test_ssh_agent_client.py           199)             derived_passphrase = data_dict['derived_passphrase']
tests/test_ssh_agent_client.py           200)             if public_key_data not in key_comment_pairs:  # pragma: no cover
tests/test_ssh_agent_client.py           201)                 pytest.skip('prerequisite SSH key not loaded')
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           202)             signature = bytes(
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 203)                 client.sign(payload=vault.Vault._UUID, key=public_key_data)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           205)             assert signature == expected_signature, 'SSH signature mismatch'
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           206)             signature2 = bytes(
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 207)                 client.sign(payload=vault.Vault._UUID, key=public_key_data)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           209)             assert signature2 == expected_signature, 'SSH signature mismatch'
tests/test_ssh_agent_client.py           210)             assert (
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 211)                 vault.Vault.phrase_from_key(public_key_data)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           212)                 == derived_passphrase
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           213)             ), 'SSH signature mismatch'
tests/test_ssh_agent_client.py           214) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           215)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           216)         ['keytype', 'data_dict'], list(tests.UNSUITABLE_KEYS.items())
tests/test_ssh_agent_client.py           217)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           218)     def test_201_sign_data_via_agent_unsupported(
tests/test_ssh_agent_client.py           219)         self, keytype: str, data_dict: tests.SSHTestKey
tests/test_ssh_agent_client.py           220)     ) -> None:
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           221)         del keytype  # Unused.
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           222)         private_key = data_dict['private_key']
tests/test_ssh_agent_client.py           223)         try:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           224)             _ = subprocess.run(
tests/test_ssh_agent_client.py           225)                 ['ssh-add', '-t', '30', '-q', '-'],
tests/test_ssh_agent_client.py           226)                 input=private_key,
tests/test_ssh_agent_client.py           227)                 check=True,
tests/test_ssh_agent_client.py           228)                 capture_output=True,
tests/test_ssh_agent_client.py           229)             )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           230)         except subprocess.CalledProcessError as e:  # pragma: no cover
tests/test_ssh_agent_client.py           231)             pytest.skip(
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           232)                 f'uploading test key: {e!r}, stdout={e.stdout!r}, '
tests/test_ssh_agent_client.py           233)                 f'stderr={e.stderr!r}'
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           234)             )
tests/test_ssh_agent_client.py           235)         else:
tests/test_ssh_agent_client.py           236)             try:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           238)             except OSError:  # pragma: no cover
tests/test_ssh_agent_client.py           239)                 pytest.skip('communication error with the SSH agent')
tests/test_ssh_agent_client.py           240)         with client:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           241)             key_comment_pairs = {
tests/test_ssh_agent_client.py           242)                 bytes(k): bytes(c) for k, c in client.list_keys()
tests/test_ssh_agent_client.py           243)             }
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           244)             public_key_data = data_dict['public_key_data']
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           245)             _ = data_dict['expected_signature']
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           246)             if public_key_data not in key_comment_pairs:  # pragma: no cover
tests/test_ssh_agent_client.py           247)                 pytest.skip('prerequisite SSH key not loaded')
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           248)             signature = bytes(
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 249)                 client.sign(payload=vault.Vault._UUID, key=public_key_data)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           250)             )
tests/test_ssh_agent_client.py           251)             signature2 = bytes(
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 252)                 client.sign(payload=vault.Vault._UUID, key=public_key_data)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           254)             assert signature != signature2, 'SSH signature repeatable?!'
tests/test_ssh_agent_client.py           255)             with pytest.raises(ValueError, match='unsuitable SSH key'):
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 256)                 vault.Vault.phrase_from_key(public_key_data)
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           257) 
tests/test_ssh_agent_client.py           258)     @staticmethod
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           259)     def _params() -> Iterator[tuple[bytes, bool]]:
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           260)         for value in tests.SUPPORTED_KEYS.values():
tests/test_ssh_agent_client.py           261)             key = value['public_key_data']
tests/test_ssh_agent_client.py           262)             yield (key, False)
tests/test_ssh_agent_client.py           263)         singleton_key = tests.list_keys_singleton()[0].key
tests/test_ssh_agent_client.py           264)         for value in tests.SUPPORTED_KEYS.values():
tests/test_ssh_agent_client.py           265)             key = value['public_key_data']
tests/test_ssh_agent_client.py           266)             if key == singleton_key:
tests/test_ssh_agent_client.py           267)                 yield (key, True)
tests/test_ssh_agent_client.py           268) 
tests/test_ssh_agent_client.py           269)     @pytest.mark.parametrize(['key', 'single'], list(_params()))
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           270)     def test_210_ssh_key_selector(
tests/test_ssh_agent_client.py           271)         self, monkeypatch: Any, key: bytes, single: bool
tests/test_ssh_agent_client.py           272)     ) -> None:
tests/test_ssh_agent_client.py           273)         def key_is_suitable(key: bytes) -> bool:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           274)             return key in {
tests/test_ssh_agent_client.py           275)                 v['public_key_data'] for v in tests.SUPPORTED_KEYS.values()
tests/test_ssh_agent_client.py           276)             }
tests/test_ssh_agent_client.py           277) 
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           281)                 'list_keys',
tests/test_ssh_agent_client.py           282)                 tests.list_keys_singleton,
tests/test_ssh_agent_client.py           283)             )
tests/test_ssh_agent_client.py           284)             keys = [
tests/test_ssh_agent_client.py           285)                 pair.key
tests/test_ssh_agent_client.py           286)                 for pair in tests.list_keys_singleton()
tests/test_ssh_agent_client.py           287)                 if key_is_suitable(pair.key)
tests/test_ssh_agent_client.py           288)             ]
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           294)             )
tests/test_ssh_agent_client.py           295)             keys = [
tests/test_ssh_agent_client.py           296)                 pair.key
tests/test_ssh_agent_client.py           297)                 for pair in tests.list_keys()
tests/test_ssh_agent_client.py           298)                 if key_is_suitable(pair.key)
tests/test_ssh_agent_client.py           299)             ]
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           308)             click.echo(base64.standard_b64encode(key).decode('ASCII'))
tests/test_ssh_agent_client.py           309) 
tests/test_ssh_agent_client.py           310)         runner = click.testing.CliRunner(mix_stderr=True)
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           311)         result = runner.invoke(
tests/test_ssh_agent_client.py           312)             driver,
tests/test_ssh_agent_client.py           313)             [],
tests/test_ssh_agent_client.py           314)             input=('yes\n' if single else f'{index}\n'),
tests/test_ssh_agent_client.py           315)             catch_exceptions=True,
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           317)         assert result.stdout.startswith(
tests/test_ssh_agent_client.py           318)             'Suitable SSH keys:\n'
tests/test_ssh_agent_client.py           319)         ), 'missing expected output'
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           320)         assert text in result.stdout, 'missing expected output'
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           321)         assert result.stdout.endswith(
tests/test_ssh_agent_client.py           322)             f'\n{b64_key}\n'
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           323)         ), 'missing expected output'
tests/test_ssh_agent_client.py           324)         assert result.exit_code == 0, 'driver program failed?!'
tests/test_ssh_agent_client.py           325) 
tests/test_ssh_agent_client.py           326)     del _params
tests/test_ssh_agent_client.py           327) 
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           328)     def test_300_constructor_bad_running_agent(self, monkeypatch: Any) -> None:
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           329)         monkeypatch.setenv('SSH_AUTH_SOCK', os.environ['SSH_AUTH_SOCK'] + '~')
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           330)         sock = socket.socket(family=socket.AF_UNIX)
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           331)         with pytest.raises(OSError):  # noqa: PT011
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 332)             ssh_agent.SSHAgentClient(socket=sock)
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           334)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           335)         'response',
tests/test_ssh_agent_client.py           336)         [
tests/test_ssh_agent_client.py           337)             b'\x00\x00',
tests/test_ssh_agent_client.py           338)             b'\x00\x00\x00\x1f some bytes missing',
tests/test_ssh_agent_client.py           339)         ],
tests/test_ssh_agent_client.py           340)     )
Marco Ricci Fix typing issues in mypy s...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           341)     def test_310_truncated_server_response(
tests/test_ssh_agent_client.py           342)         self, monkeypatch: Any, response: bytes
tests/test_ssh_agent_client.py           343)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           354)         pseudo_socket = PseudoSocket()
tests/test_ssh_agent_client.py           355)         monkeypatch.setattr(client, '_connection', pseudo_socket)
tests/test_ssh_agent_client.py           356)         with pytest.raises(EOFError):
tests/test_ssh_agent_client.py           357)             client.request(255, b'')
tests/test_ssh_agent_client.py           358) 
tests/test_ssh_agent_client.py           359)     @tests.skip_if_no_agent
tests/test_ssh_agent_client.py           360)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           361)         ['response_code', 'response', 'exc_type', 'exc_pattern'],
tests/test_ssh_agent_client.py           362)         [
tests/test_ssh_agent_client.py           363)             (255, b'', RuntimeError, 'error return from SSH agent:'),
tests/test_ssh_agent_client.py           364)             (12, b'\x00\x00\x00\x01', EOFError, 'truncated response'),
Marco Ricci Introduce TrailingDataError...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           365)             (
tests/test_ssh_agent_client.py           366)                 12,
tests/test_ssh_agent_client.py           367)                 b'\x00\x00\x00\x00abc',
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           374)         self,
tests/test_ssh_agent_client.py           375)         monkeypatch: Any,
tests/test_ssh_agent_client.py           376)         response_code: int,
tests/test_ssh_agent_client.py           377)         response: bytes | bytearray,
tests/test_ssh_agent_client.py           378)         exc_type: type[Exception],
tests/test_ssh_agent_client.py           379)         exc_pattern: str,
tests/test_ssh_agent_client.py           380)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 381)         client = ssh_agent.SSHAgentClient()
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           382)         monkeypatch.setattr(
tests/test_ssh_agent_client.py           383)             client,
tests/test_ssh_agent_client.py           384)             'request',
tests/test_ssh_agent_client.py           385)             lambda *a, **kw: (response_code, response),  # noqa: ARG005
tests/test_ssh_agent_client.py           386)         )
Marco Ricci Rename and regroup all test...

Marco Ricci authored 4 months ago

tests/test_ssh_agent_client.py           387)         with pytest.raises(exc_type, match=exc_pattern):
tests/test_ssh_agent_client.py           388)             client.list_keys()
tests/test_ssh_agent_client.py           389) 
tests/test_ssh_agent_client.py           390)     @tests.skip_if_no_agent
tests/test_ssh_agent_client.py           391)     @pytest.mark.parametrize(
tests/test_ssh_agent_client.py           392)         ['key', 'check', 'response', 'exc_type', 'exc_pattern'],
tests/test_ssh_agent_client.py           393)         [
tests/test_ssh_agent_client.py           394)             (
tests/test_ssh_agent_client.py           395)                 b'invalid-key',
tests/test_ssh_agent_client.py           396)                 True,
tests/test_ssh_agent_client.py           397)                 (255, b''),
tests/test_ssh_agent_client.py           398)                 KeyError,
tests/test_ssh_agent_client.py           399)                 'target SSH key not loaded into agent',
tests/test_ssh_agent_client.py           400)             ),
tests/test_ssh_agent_client.py           401)             (
tests/test_ssh_agent_client.py           402)                 tests.SUPPORTED_KEYS['ed25519']['public_key_data'],
tests/test_ssh_agent_client.py           403)                 True,
tests/test_ssh_agent_client.py           404)                 (255, b''),
tests/test_ssh_agent_client.py           405)                 RuntimeError,
tests/test_ssh_agent_client.py           406)                 'signing data failed:',
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           411)         self,
tests/test_ssh_agent_client.py           412)         monkeypatch: Any,
tests/test_ssh_agent_client.py           413)         key: bytes | bytearray,
tests/test_ssh_agent_client.py           414)         check: bool,
tests/test_ssh_agent_client.py           415)         response: tuple[int, bytes | bytearray],
tests/test_ssh_agent_client.py           416)         exc_type: type[Exception],
tests/test_ssh_agent_client.py           417)         exc_pattern: str,
tests/test_ssh_agent_client.py           418)     ) -> None:
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 419)         client = ssh_agent.SSHAgentClient()
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           420)         monkeypatch.setattr(client, 'request', lambda a, b: response)  # noqa: ARG005
Marco Ricci Move `sequin` and `ssh_agen...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_ssh_agent.py 421)         KeyCommentPair = ssh_agent.types.KeyCommentPair  # noqa: N806
Marco Ricci Reformat everything with ruff

Marco Ricci authored 3 months ago

tests/test_ssh_agent_client.py           422)         loaded_keys = [
tests/test_ssh_agent_client.py           423)             KeyCommentPair(v['public_key_data'], b'no comment')
tests/test_ssh_agent_client.py           424)             for v in tests.SUPPORTED_KEYS.values()
tests/test_ssh_agent_client.py           425)         ]