Centralize testing
This commit is contained in:
27
tests/integration/clients.py
Normal file
27
tests/integration/clients.py
Normal file
@ -0,0 +1,27 @@
|
||||
"""Client helpers."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||
|
||||
from sshecret.crypto import generate_private_key, generate_public_key_string
|
||||
|
||||
|
||||
@dataclass
|
||||
class ClientData:
|
||||
"""Test client."""
|
||||
|
||||
name: str
|
||||
private_key: rsa.RSAPrivateKey
|
||||
|
||||
@property
|
||||
def public_key(self) -> str:
|
||||
"""Return public key as string."""
|
||||
return generate_public_key_string(self.private_key.public_key())
|
||||
|
||||
|
||||
def create_test_client(name: str) -> ClientData:
|
||||
"""Create test client."""
|
||||
return ClientData(
|
||||
name=name,
|
||||
private_key=generate_private_key()
|
||||
)
|
||||
Reference in New Issue
Block a user