- Timestamp:
- 11/24/25 15:17:00 (7 weeks ago)
- Branches:
- master
- Children:
- 2fd0536
- Parents:
- 376e21b
- Location:
- tests
- Files:
-
- 4 added
- 1 edited
-
conftest.py (modified) (2 diffs)
-
data/test.p12 (added)
-
data/testcert.pem (added)
-
data/testkey.pem (added)
-
test_signing.py (added)
Legend:
- Unmodified
- Added
- Removed
-
tests/conftest.py
r376e21b rd7499ca 1 1 # tests/stubs/single_choice_question.py 2 from dataclasses import dataclass, field 2 3 import pytest 4 import platform 5 from pathlib import Path 3 6 from datetime import datetime 4 from dataclasses import dataclass, field5 7 from typing import List 6 from flexoentity import FlexOID, FlexoEntity, EntityType, EntityState, Domain 8 from flexoentity import FlexOID, FlexoEntity, EntityType, EntityState, Domain, get_signing_backend, CertificateReference 9 7 10 8 11 @pytest.fixture … … 98 101 q._update_fingerprint() 99 102 return q 103 104 SYSTEM = platform.system() 105 106 107 # ───────────────────────────────────────────────────────────── 108 # Basic test data directory + PEM test files 109 # ───────────────────────────────────────────────────────────── 110 111 @pytest.fixture(scope="session") 112 def test_data_dir(): 113 return Path(__file__).parent / "data" 114 115 116 @pytest.fixture(scope="session") 117 def test_cert(test_data_dir): 118 return test_data_dir / "testcert.pem" 119 120 121 @pytest.fixture(scope="session") 122 def test_key(test_data_dir): 123 return test_data_dir / "testkey.pem" 124 125 126 # ───────────────────────────────────────────────────────────── 127 # CertificateReference fixtures for each platform 128 # ───────────────────────────────────────────────────────────── 129 130 @pytest.fixture(scope="session") 131 def cert_ref_linux(test_cert, test_key): 132 """Linux: Uses OpenSSL CMS with PEM cert + PEM private key.""" 133 return CertificateReference( 134 platform="LINUX", 135 identifier=str(test_cert), 136 private_key_path=str(test_key), 137 public_cert_path=str(test_cert), 138 ) 139 140 141 @pytest.fixture(scope="session") 142 def cert_ref_macos(test_cert): 143 """ 144 macOS: Uses Keychain identity with Common Name (CN). 145 The test cert must be imported into the login keychain with CN=FlexOSignerTest. 146 """ 147 return CertificateReference( 148 platform="MACOS", 149 identifier="FlexOSignerTest", 150 public_cert_path=str(test_cert), 151 ) 152 153 @pytest.fixture(scope="session") 154 def backend(test_cert, test_key): 155 """Return the correct backend for the current platform.""" 156 157 if SYSTEM == "Linux": 158 cert_ref = CertificateReference( 159 platform="LINUX", 160 identifier=str(test_cert), 161 private_key_path=str(test_key), 162 public_cert_path=str(test_cert), 163 ) 164 165 elif SYSTEM == "Darwin": 166 cert_ref = CertificateReference( 167 platform="MACOS", 168 identifier="FlexOSignerTest", 169 public_cert_path=str(test_cert), 170 ) 171 172 elif SYSTEM == "Windows": 173 pytest.skip("Windows signing tests not implemented yet") 174 175 else: 176 pytest.skip(f"Unsupported platform: {SYSTEM}") 177 178 try: 179 backend = get_signing_backend(cert_ref) 180 # sanity check: ensures cert exists and command is available 181 _ = backend.certificate_thumbprint 182 return backend 183 except Exception as e: 184 pytest.skip(f"Backend unavailable or misconfigured: {e}")
Note:
See TracChangeset
for help on using the changeset viewer.
