def test_open_session_no_pin(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf session = pk11._session(P11_MODULE, 0) assert session is not None except Exception as ex: traceback.print_exc() raise ex finally: if session is not None: pk11._close_session(session)
def test_open_session_no_pin(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf session = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test" % component_path['P11_MODULE']) assert session is not None except Exception as ex: traceback.print_exc() raise ex finally: if session is not None: pk11._close_session(session)
def test_find_key(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf session = pk11._session(P11_MODULE, 0, "secret1") key, cert = pk11._find_key(session, "test") assert key is not None assert cert is not None assert cert.strip() == open(signer_cert_pem).read().strip() except Exception as ex: raise ex finally: if session is not None: pk11._close_session(session)
def test_find_key(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf session = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test?pin=secret1" % component_path['P11_MODULE']) key, cert = pk11._find_key(session, "test") assert key is not None assert cert is not None assert cert.strip() == open(signer_cert_pem).read().strip().encode('utf-8') except Exception as ex: raise ex finally: if session is not None: pk11._close_session(session)
def test_two_sessions(self): session1 = None session2 = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf session1 = pk11._session(P11_MODULE, 0, "secret1") session2 = pk11._session(P11_MODULE, 0, "secret1") assert session1 != session2 assert session1 is not None assert session2 is not None except Exception as ex: raise ex finally: if session1 is not None: pk11._close_session(session1) if session2 is not None: pk11._close_session(session2)
def test_two_sessions(self): session1 = None session2 = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf session1 = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test?pin=secret1" % component_path['P11_MODULE']) session2 = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test?pin=secret1" % component_path['P11_MODULE']) assert session1 != session2 assert session1 is not None assert session2 is not None except Exception as ex: raise ex finally: if session1 is not None: pk11._close_session(session1) if session2 is not None: pk11._close_session(session2)
def test_find_key(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf session = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test?pin=secret1" % component_path['P11_MODULE']) key, cert = pk11._find_key(session, "test") assert key is not None assert cert is not None assert cert.strip() == open(signer_cert_pem).read().strip().encode( 'utf-8') except Exception as ex: raise ex finally: if session is not None: pk11._close_session(session)
"SoftHSM PKCS11 module not installed") def test_open_session(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf session = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test?pin=secret1" % component_path['P11_MODULE']) assert session is not None except Exception, ex: traceback.print_exc() raise ex finally: if session is not None: pk11._close_session(session) @unittest.skipIf(component_path['P11_MODULE'] is None, "SoftHSM PKCS11 module not installed") def test_open_session_no_pin(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf session = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test" % component_path['P11_MODULE']) assert session is not None except Exception, ex: traceback.print_exc() raise ex
self.cases = load_test_data('data/signverify') @unittest.skipIf(P11_MODULE is None, "SoftHSM PKCS11 module not installed") def test_open_session(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf session = pk11._session(P11_MODULE, 0, "secret1") assert session is not None except Exception, ex: traceback.print_exc() raise ex finally: if session is not None: pk11._close_session(session) @unittest.skipIf(P11_MODULE is None, "SoftHSM PKCS11 module not installed") def test_open_session_no_pin(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf session = pk11._session(P11_MODULE, 0) assert session is not None except Exception, ex: traceback.print_exc() raise ex finally: if session is not None: pk11._close_session(session)