Skip to content

Commit

Permalink
move allowed_signers from compat into package
Browse files Browse the repository at this point in the history
  • Loading branch information
castedo committed Jan 7, 2025
1 parent 5f92001 commit 2f17d4b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 1 addition & 2 deletions compat/ssh_keygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from typing import BinaryIO

from sshsig import InvalidSignature, check_signature, verify

from .allowed_signers import load_for_git_allowed_signers_file
from sshsig.allowed_signers import load_for_git_allowed_signers_file


def cli_subcmd_check_novalidate(
Expand Down
8 changes: 6 additions & 2 deletions compat/allowed_signers.py → sshsig/allowed_signers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# (c) 2024 E. Castedo Ellerman <[email protected]>
# Released under the MIT License (https://spdx.org/licenses/MIT)

"""Parsing of the ssh-keygen allowed signers format."""

from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, TextIO

from sshsig import PublicKey
from .ssh_public_key import PublicKey


if TYPE_CHECKING:
Expand Down Expand Up @@ -171,7 +173,9 @@ def load_for_git_allowed_signers_file(file: TextIO | Path) -> Iterable[PublicKey
return for_git_allowed_keys(load_allowed_signers_file(file))


def save_for_git_allowed_signers_file(src: set[PublicKey], out: Path | TextIO) -> None:
def save_for_git_allowed_signers_file(
src: Iterable[PublicKey], out: Path | TextIO
) -> None:
"""Save keys for git to "allowed signers" format per ssh-keygen."""

if isinstance(out, Path):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_allowed_signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from unittest import TestCase

from sshsig import PublicKey

from compat.allowed_signers import AllowedSigner, load_allowed_signers_file
from sshsig.allowed_signers import AllowedSigner, load_allowed_signers_file


TESTDATA_DIR = Path(__file__).parent.parent / "testdata"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sshsig.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from unittest import TestCase

from sshsig import sshsig
from sshsig.allowed_signers import load_for_git_allowed_signers_file

from compat import ssh_keygen
from compat.allowed_signers import load_for_git_allowed_signers_file


TESTDATA_DIR = Path(__file__).parent.parent / "testdata"
Expand Down

0 comments on commit 2f17d4b

Please sign in to comment.