Browse Source

Add test for fingerprint utility

Signed-off-by: Stan Janssen <stan.janssen@elaad.nl>
Stan Janssen 4 years ago
parent
commit
856432b6e2
1 changed files with 18 additions and 0 deletions
  1. 18 0
      test/test_fingerprint_cmdline.py

+ 18 - 0
test/test_fingerprint_cmdline.py

@@ -0,0 +1,18 @@
+import subprocess
+from openleadr import utils
+import os
+import sys
+
+def test_fingerprint_cmdline():
+    cert_path = os.path.join('certificates', 'dummy_ven.crt')
+    with open(cert_path) as file:
+        cert_str = file.read()
+    fingerprint = utils.certificate_fingerprint(cert_str)
+
+    if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
+        executable = os.path.join(sys.prefix, 'bin', 'fingerprint')
+    elif sys.platform.startswith('win'):
+        executable = os.path.join(sys.prefix, 'Scripts', 'fingerprint.exe')
+    result = subprocess.run([executable, cert_path], stdout=subprocess.PIPE)
+
+    assert fingerprint == result.stdout.decode('utf-8').strip()