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, ex: raise ex
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, ex: raise ex
def test_bad_login(self): os.environ['SOFTHSM_CONF'] = softhsm_conf try: session = pk11._session(P11_MODULE, 0, "wrong") assert False, "We should have failed the last login" except PyKCS11Error, ex: assert ex.value == CKR_PIN_INCORRECT pass
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
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_bad_login(self): os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf try: session = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test?pin=wrong" % component_path['P11_MODULE']) assert False, "We should have failed the last login" except PyKCS11Error as ex: assert ex.value == CKR_PIN_INCORRECT pass
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, ex: raise ex
def test_bad_login(self): os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf try: session = pk11._session(component_path['P11_MODULE'], pk11_uri="pkcs11://%s/test?pin=wrong" % component_path['P11_MODULE']) assert False, "We should have failed the last login" except PyKCS11Error, ex: assert ex.value == CKR_PIN_INCORRECT pass
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 as ex: traceback.print_exc() raise ex finally: if session is not None: pk11._close_session(session)
def test_open_session(self): session = None try: os.environ['SOFTHSM_CONF'] = softhsm_conf os.environ['SOFTHSM2_CONF'] = softhsm_conf session = pk11._session(P11_MODULE, pk11_uri="pkcs11://%s/test?pin=secret1" % P11_MODULE) assert session is not None except Exception, ex: traceback.print_exc() raise ex
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
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 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() except Exception, ex: raise ex
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 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 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)