Skip to content

Commit

Permalink
fix tests with minimal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasertl committed Dec 27, 2024
1 parent 4c51ab3 commit b206c44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.12"
- "3.13"

steps:
Expand Down Expand Up @@ -51,6 +50,7 @@ jobs:
run: |
env
softhsm2-util --version
openssl version
- name: Initialize token
run: softhsm2-util --init-token --free --label $PKCS11_TOKEN_LABEL --pin $PKCS11_TOKEN_PIN --so-pin $PKCS11_TOKEN_SO_PIN
Expand Down
23 changes: 16 additions & 7 deletions tests/test_x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import base64
import datetime
import subprocess
import tempfile

from asn1crypto import pem
from asn1crypto.csr import CertificationRequest, CertificationRequestInfo
Expand Down Expand Up @@ -223,13 +224,21 @@ def test_self_sign_certificate(self):
}
)

# Pipe our certificate to OpenSSL to verify it
with subprocess.Popen(
(OPENSSL, "verify"), stdin=subprocess.PIPE, stdout=subprocess.DEVNULL
) as proc:
proc.stdin.write(pem.armor("CERTIFICATE", cert.dump()))
proc.stdin.close()
self.assertEqual(proc.wait(), 0)
pem_cert = pem.armor("CERTIFICATE", cert.dump())

with tempfile.NamedTemporaryFile() as pem_file:
pem_file.write(pem_cert)
pem_file.flush()

# Pipe our certificate to OpenSSL to verify it
with subprocess.Popen(
(OPENSSL, "verify", "-CAfile", pem_file.name),
stdin=subprocess.PIPE,
stdout=subprocess.DEVNULL,
) as proc:
proc.stdin.write(pem.armor("CERTIFICATE", cert.dump()))
proc.stdin.close()
self.assertEqual(proc.wait(), 0)

@Only.openssl
@requires(Mechanism.RSA_PKCS_KEY_PAIR_GEN, Mechanism.SHA1_RSA_PKCS)
Expand Down

0 comments on commit b206c44

Please sign in to comment.