source: mod_gnutls/test/tests/24_pkcs11_cert/hooks.py @ ff039b1

asyncioproxy-ticket
Last change on this file since ff039b1 was ff039b1, checked in by Fiona Klute <fiona.klute@…>, 23 months ago

Test suite: Replace softhsm.bash with Python code

With this all test scripts only call runtest.py.

  • Property mode set to 100644
File size: 635 bytes
Line 
1#!/usr/bin/python3
2import os
3import mgstest.softhsm
4from pathlib import Path
5from unittest import SkipTest
6
7def prepare_env():
8    if not mgstest.softhsm.find_softhsm_bin():
9        raise SkipTest('SoftHSM not found.')
10
11    db = 'authority/server/softhsm2.db'
12    softhsm_conf = mgstest.softhsm.tmp_softhsm_conf(db)
13    def cleanup():
14        print(f'Delete {softhsm_conf}')
15        Path(softhsm_conf).unlink()
16
17    try:
18        token = mgstest.softhsm.Token(config_file=softhsm_conf)
19        for key, value in token.test_env.items():
20            os.environ[key] = value
21    except:
22        cleanup()
23        raise
24
25    return cleanup
Note: See TracBrowser for help on using the repository browser.