test_fingerprint_cmdline.py 690 B

123456789101112131415161718
  1. import subprocess
  2. from openleadr import utils
  3. import os
  4. import sys
  5. def test_fingerprint_cmdline():
  6. cert_path = os.path.join('certificates', 'dummy_ven.crt')
  7. with open(cert_path) as file:
  8. cert_str = file.read()
  9. fingerprint = utils.certificate_fingerprint(cert_str)
  10. if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
  11. executable = os.path.join(sys.prefix, 'bin', 'fingerprint')
  12. elif sys.platform.startswith('win'):
  13. executable = os.path.join(sys.prefix, 'Scripts', 'fingerprint.exe')
  14. result = subprocess.run([executable, cert_path], stdout=subprocess.PIPE)
  15. assert fingerprint == result.stdout.decode('utf-8').strip()