def test_passcheck(): ''' This tests if we can check the password for a logged-in user. ''' try: os.remove('test-passcheck.authdb.sqlite') except Exception as e: pass try: os.remove('test-passcheck.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-passcheck.authdb.sqlite-wal') except Exception as e: pass get_test_authdb() # create the user user_payload = {'email':'*****@*****.**', 'password':'******'} user_created = actions.create_new_user( user_payload, override_authdb_path='sqlite:///test-passcheck.authdb.sqlite' ) assert user_created['success'] is True assert user_created['user_email'] == '*****@*****.**' assert ('User account created. Please verify your email address to log in.' in user_created['messages']) # create a new session token session_payload = { 'user_id':2, 'client_header':'Mozzarella Killerwhale', 'expires':datetime.utcnow()+timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json':{'pref_datasets_always_private':True} } # check creation of session session_token1 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-passcheck.authdb.sqlite' ) assert session_token1['success'] is True assert session_token1['session_token'] is not None # verify our email emailverify = ( actions.verify_user_email_address( {'email':user_payload['email'], 'user_id': user_created['user_id']}, override_authdb_path='sqlite:///test-passcheck.authdb.sqlite' ) ) assert emailverify['success'] is True assert emailverify['user_id'] == user_created['user_id'] assert emailverify['is_active'] is True assert emailverify['user_role'] == 'authenticated' # now make a new session token to simulate a logged-in user session_payload = { 'user_id':emailverify['user_id'], 'client_header':'Mozzarella Killerwhale', 'expires':datetime.utcnow()+timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json':{'pref_datasets_always_private':True} } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-passcheck.authdb.sqlite' ) assert session_token2['success'] is True assert session_token2['session_token'] is not None # # now run a password check # # correct password pass_check = actions.auth_password_check( {'session_token':session_token2['session_token'], 'password':user_payload['password']}, override_authdb_path='sqlite:///test-passcheck.authdb.sqlite', raiseonfail=True ) assert pass_check['success'] is True assert pass_check['user_id'] == emailverify['user_id'] # incorrect password pass_check = actions.auth_password_check( {'session_token':session_token2['session_token'], 'password':'******'}, override_authdb_path='sqlite:///test-passcheck.authdb.sqlite', raiseonfail=True ) assert pass_check['success'] is False assert pass_check['user_id'] is None currproc = mp.current_process() if getattr(currproc, 'table_meta', None): del currproc.table_meta if getattr(currproc, 'connection', None): currproc.connection.close() del currproc.connection if getattr(currproc, 'engine', None): currproc.engine.dispose() del currproc.engine try: os.remove('test-passcheck.authdb.sqlite') except Exception as e: pass try: os.remove('test-passcheck.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-passcheck.authdb.sqlite-wal') except Exception as e: pass
def test_login_timing(): '''This tests obfuscating the presence/absence of users based on password checks. This may fail randomly if the testing service is under load. ''' try: os.remove('test-timing.authdb.sqlite') except Exception as e: pass try: os.remove('test-timing.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-timing.authdb.sqlite-wal') except Exception as e: pass get_test_authdb() # create the user user_payload = { 'email': '*****@*****.**', 'password': '******' } user_created = actions.create_new_user( user_payload, override_authdb_path='sqlite:///test-timing.authdb.sqlite') assert user_created['success'] is True assert user_created['user_email'] == '*****@*****.**' assert ('User account created. Please verify your email address to log in.' in user_created['messages']) # create a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token1 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-timing.authdb.sqlite') assert session_token1['success'] is True assert session_token1['session_token'] is not None # try logging in now with correct password login = actions.auth_user_login( { 'session_token': session_token1['session_token'], 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-timing.authdb.sqlite') # this should fail because we haven't verified our email yet assert login['success'] is False # verify our email emailverify = (actions.verify_user_email_address( { 'email': user_payload['email'], 'user_id': user_created['user_id'] }, override_authdb_path='sqlite:///test-timing.authdb.sqlite')) assert emailverify['success'] is True assert emailverify['user_id'] == user_created['user_id'] assert emailverify['is_active'] is True assert emailverify['user_role'] == 'authenticated' # now make a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-timing.authdb.sqlite') assert session_token2['success'] is True assert session_token2['session_token'] is not None # and now try to log in again login = actions.auth_user_login( { 'session_token': session_token2['session_token'], 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-timing.authdb.sqlite') assert login['success'] is True # basic tests for timing attacks # incorrect passwords incorrect_timings = [] for _ in range(1000): # now make a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-timing.authdb.sqlite') start = time.time() actions.auth_user_login( { 'session_token': session_token2['session_token'], 'email': user_payload['email'], 'password': secrets.token_urlsafe(16) }, override_authdb_path='sqlite:///test-timing.authdb.sqlite') end = time.time() incorrect_timings.append(end - start) # correct passwords correct_timings = [] for _ in range(1000): # now make a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-timing.authdb.sqlite') start = time.time() actions.auth_user_login( { 'session_token': session_token2['session_token'], 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-timing.authdb.sqlite') end = time.time() correct_timings.append(end - start) # wronguser passwords wronguser_timings = [] for _ in range(1000): # now make a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-timing.authdb.sqlite') start = time.time() actions.auth_user_login( { 'session_token': session_token2['session_token'], 'email': secrets.token_urlsafe(16), 'password': secrets.token_urlsafe(16) }, override_authdb_path='sqlite:///test-timing.authdb.sqlite') end = time.time() wronguser_timings.append(end - start) # broken requests broken_timings = [] for _ in range(1000): # now make a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-timing.authdb.sqlite') start = time.time() actions.auth_user_login( { 'session_token': 'correcthorsebatterystaple', 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-timing.authdb.sqlite') end = time.time() broken_timings.append(end - start) correct_timings = np.array(correct_timings) incorrect_timings = np.array(incorrect_timings) broken_timings = np.array(broken_timings) wronguser_timings = np.array(wronguser_timings) correct_median = np.median(correct_timings) incorrect_median = np.median(incorrect_timings) broken_median = np.median(broken_timings) wronguser_median = np.median(wronguser_timings) # all timings should match within 7 milliseconds or so assert_allclose(correct_median, incorrect_median, atol=7.0e-3) assert_allclose(correct_median, broken_median, atol=7.0e-3) assert_allclose(correct_median, wronguser_median, atol=7.0e-3) currproc = mp.current_process() if getattr(currproc, 'table_meta', None): del currproc.table_meta if getattr(currproc, 'connection', None): currproc.connection.close() del currproc.connection if getattr(currproc, 'engine', None): currproc.engine.dispose() del currproc.engine try: os.remove('test-timing.authdb.sqlite') except Exception as e: pass try: os.remove('test-timing.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-timing.authdb.sqlite-wal') except Exception as e: pass
def test_sessions(): ''' This tests session token generation, readback, deletion, and expiry. ''' try: os.remove('test-creation.authdb.sqlite') except Exception as e: pass try: os.remove('test-creation.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-creation.authdb.sqlite-wal') except Exception as e: pass get_test_authdb() # session token payload session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.2.3.4', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation session_token1 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-creation.authdb.sqlite') assert session_token1['success'] is True assert session_token1['session_token'] is not None # check deletion deleted = actions.auth_session_delete( {'session_token': session_token1['session_token']}, override_authdb_path='sqlite:///test-creation.authdb.sqlite') assert deleted['success'] is True # check readback of deleted check = actions.auth_session_exists( {'session_token': session_token1['session_token']}, override_authdb_path='sqlite:///test-creation.authdb.sqlite') assert check['success'] is False # new session token payload session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.2.3.4', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-creation.authdb.sqlite') assert session_token2['success'] is True assert session_token2['session_token'] is not None assert session_token1['session_token'] != session_token2['session_token'] # get items for session_token check = actions.auth_session_exists( {'session_token': session_token2['session_token']}, override_authdb_path='sqlite:///test-creation.authdb.sqlite') assert check['success'] is True for key in ('user_id', 'full_name', 'email', 'email_verified', 'emailverify_sent_datetime', 'is_active', 'last_login_try', 'last_login_success', 'created_on', 'user_role', 'session_token', 'ip_address', 'client_header', 'created', 'expires', 'extra_info_json'): assert key in check['session_info'] assert check['session_info']['user_id'] == 2 assert check['session_info']['full_name'] is None assert check['session_info']['email'] == 'anonuser@localhost' assert check['session_info']['email_verified'] is True assert check['session_info']['is_active'] is True assert check['session_info']['last_login_try'] is None assert check['session_info']['last_login_success'] is None assert check['session_info']['user_role'] == 'anonymous' assert check['session_info']['session_token'] == session_token2[ 'session_token'] assert check['session_info']['ip_address'] == session_payload['ip_address'] assert check['session_info']['client_header'] == session_payload[ 'client_header'] assert check['session_info']['expires'] == session_payload['expires'] assert check['session_info']['extra_info_json'] == session_payload[ 'extra_info_json'] # new session token payload session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(seconds=5), 'ip_address': '1.2.3.4', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation session_token3 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-creation.authdb.sqlite') assert session_token3['success'] is True assert session_token3['session_token'] is not None assert session_token3['session_token'] != session_token2['session_token'] # check readback when expired time.sleep(10.0) check = actions.auth_session_exists( {'session_token': session_token3['session_token']}, override_authdb_path='sqlite:///test-creation.authdb.sqlite') assert check['success'] is False currproc = mp.current_process() if getattr(currproc, 'table_meta', None): del currproc.table_meta if getattr(currproc, 'connection', None): currproc.connection.close() del currproc.connection if getattr(currproc, 'engine', None): currproc.engine.dispose() del currproc.engine try: os.remove('test-creation.authdb.sqlite') except Exception as e: pass try: os.remove('test-creation.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-creation.authdb.sqlite-wal') except Exception as e: pass
def test_sessioninfo(): ''' This tests if we can add session info to a session dict. ''' try: os.remove('test-sessioninfo.authdb.sqlite') except Exception as e: pass try: os.remove('test-sessioninfo.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-sessioninfo.authdb.sqlite-wal') except Exception as e: pass get_test_authdb() # create the user user_payload = { 'email': '*****@*****.**', 'password': '******' } user_created = actions.create_new_user( user_payload, override_authdb_path='sqlite:///test-sessioninfo.authdb.sqlite') assert user_created['success'] is True assert user_created['user_email'] == '*****@*****.**' assert ('User account created. Please verify your email address to log in.' in user_created['messages']) # create a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token1 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-sessioninfo.authdb.sqlite') assert session_token1['success'] is True assert session_token1['session_token'] is not None # verify our email emailverify = (actions.verify_user_email_address( { 'email': user_payload['email'], 'user_id': user_created['user_id'] }, override_authdb_path='sqlite:///test-sessioninfo.authdb.sqlite')) assert emailverify['success'] is True assert emailverify['user_id'] == user_created['user_id'] assert emailverify['is_active'] is True assert emailverify['user_role'] == 'authenticated' # now make a new session token session_payload = { 'user_id': emailverify['user_id'], 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-sessioninfo.authdb.sqlite') assert session_token2['success'] is True assert session_token2['session_token'] is not None # # now try to add info to the session # session_info_added = actions.auth_session_set_extrainfo( { 'session_token': session_token2['session_token'], 'extra_info': { 'this': 'is', 'a': 'test' } }, override_authdb_path='sqlite:///test-sessioninfo.authdb.sqlite', raiseonfail=True) assert session_info_added['success'] is True assert isinstance(session_info_added['session_info']['extra_info_json'], dict) assert session_info_added['session_info']['extra_info_json'][ 'this'] == 'is' assert session_info_added['session_info']['extra_info_json']['a'] == 'test' # get back the new session info info_check = actions.auth_session_exists( {'session_token': session_token2['session_token']}, override_authdb_path='sqlite:///test-sessioninfo.authdb.sqlite') assert info_check['success'] is True assert isinstance(info_check['session_info']['extra_info_json'], dict) assert info_check['session_info']['extra_info_json']['this'] == 'is' assert info_check['session_info']['extra_info_json']['a'] == 'test' currproc = mp.current_process() if getattr(currproc, 'table_meta', None): del currproc.table_meta if getattr(currproc, 'connection', None): currproc.connection.close() del currproc.connection if getattr(currproc, 'engine', None): currproc.engine.dispose() del currproc.engine try: os.remove('test-sessioninfo.authdb.sqlite') except Exception as e: pass try: os.remove('test-sessioninfo.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-sessioninfo.authdb.sqlite-wal') except Exception as e: pass
def test_login(): ''' This tests if we can log in successfully or fail correctly. ''' try: os.remove('test-login.authdb.sqlite') except Exception as e: pass try: os.remove('test-login.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-login.authdb.sqlite-wal') except Exception as e: pass get_test_authdb() # create the user user_payload = { 'email': '*****@*****.**', 'password': '******' } user_created = actions.create_new_user( user_payload, override_authdb_path='sqlite:///test-login.authdb.sqlite') assert user_created['success'] is True assert user_created['user_email'] == '*****@*****.**' assert ('User account created. Please verify your email address to log in.' in user_created['messages']) # create a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token1 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-login.authdb.sqlite') assert session_token1['success'] is True assert session_token1['session_token'] is not None # try logging in now with correct password login = actions.auth_user_login( { 'session_token': session_token1['session_token'], 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-login.authdb.sqlite') # this should fail because we haven't verified our email yet assert login['success'] is False # verify our email emailverify = (actions.verify_user_email_address( { 'email': user_payload['email'], 'user_id': user_created['user_id'] }, override_authdb_path='sqlite:///test-login.authdb.sqlite')) assert emailverify['success'] is True assert emailverify['user_id'] == user_created['user_id'] assert emailverify['is_active'] is True assert emailverify['user_role'] == 'authenticated' # now make a new session token session_payload = { 'user_id': emailverify['user_id'], 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-login.authdb.sqlite') assert session_token2['success'] is True assert session_token2['session_token'] is not None # and now try to log in again login = actions.auth_user_login( { 'session_token': session_token2['session_token'], 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-login.authdb.sqlite') assert login['success'] is True # try logging in now with the wrong password login = actions.auth_user_login( { 'session_token': session_token2['session_token'], 'email': user_payload['email'], 'password': '******' }, override_authdb_path='sqlite:///test-login.authdb.sqlite') assert login['success'] is False # tests for no session token provided login = actions.auth_user_login( { 'session_token': 'correcthorsebatterystaple', 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-login.authdb.sqlite') assert login['success'] is False currproc = mp.current_process() if getattr(currproc, 'table_meta', None): del currproc.table_meta if getattr(currproc, 'connection', None): currproc.connection.close() del currproc.connection if getattr(currproc, 'engine', None): currproc.engine.dispose() del currproc.engine try: os.remove('test-login.authdb.sqlite') except Exception as e: pass try: os.remove('test-login.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-login.authdb.sqlite-wal') except Exception as e: pass
def test_login_logout(): ''' See if we can login and log out correctly. ''' try: os.remove('test-loginlogout.authdb.sqlite') except Exception as e: pass try: os.remove('test-loginlogout.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-loginlogout.authdb.sqlite-wal') except Exception as e: pass get_test_authdb() # create the user user_payload = { 'email': '*****@*****.**', 'password': '******' } user_created = actions.create_new_user( user_payload, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite') assert user_created['success'] is True assert user_created['user_email'] == '*****@*****.**' assert ('User account created. Please verify your email address to log in.' in user_created['messages']) # create a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token1 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite', raiseonfail=True) assert session_token1['success'] is True assert session_token1['session_token'] is not None # try logging in now with correct password login = actions.auth_user_login( { 'session_token': session_token1['session_token'], 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite', raiseonfail=True) # this should fail because we haven't verified our email yet assert login['success'] is False # verify our email emailverify = (actions.verify_user_email_address( { 'email': user_payload['email'], 'user_id': user_created['user_id'] }, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite', raiseonfail=True)) assert emailverify['success'] is True assert emailverify['user_id'] == user_created['user_id'] assert emailverify['is_active'] is True assert emailverify['user_role'] == 'authenticated' # now make a new session token session_payload = { 'user_id': 2, 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } } # check creation of session session_token2 = actions.auth_session_new( session_payload, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite', raiseonfail=True) assert session_token2['success'] is True assert session_token2['session_token'] is not None # and now try to log in again login = actions.auth_user_login( { 'session_token': session_token2['session_token'], 'email': user_payload['email'], 'password': user_payload['password'] }, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite', raiseonfail=True) assert login['success'] is True # make sure the session token we used to log in is gone # check if our session was deleted correctly session_still_exists = actions.auth_session_exists( {'session_token': session_token2['session_token']}, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite') assert session_still_exists['success'] is False # start a new session with this user's user ID authenticated_session_token = actions.auth_session_new( { 'user_id': login['user_id'], 'client_header': 'Mozzarella Killerwhale', 'expires': datetime.utcnow() + timedelta(hours=1), 'ip_address': '1.1.1.1', 'extra_info_json': { 'pref_datasets_always_private': True } }, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite', raiseonfail=True) # now see if we can log out logged_out = actions.auth_user_logout( { 'session_token': authenticated_session_token['session_token'], 'user_id': login['user_id'] }, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite', raiseonfail=True) assert logged_out['success'] is True # check if our session was deleted correctly session_still_exists = actions.auth_session_exists( {'session_token': authenticated_session_token}, override_authdb_path='sqlite:///test-loginlogout.authdb.sqlite', raiseonfail=True) assert session_still_exists['success'] is False currproc = mp.current_process() if getattr(currproc, 'table_meta', None): del currproc.table_meta if getattr(currproc, 'connection', None): currproc.connection.close() del currproc.connection if getattr(currproc, 'engine', None): currproc.engine.dispose() del currproc.engine try: os.remove('test-loginlogout.authdb.sqlite') except Exception as e: pass try: os.remove('test-loginlogout.authdb.sqlite-shm') except Exception as e: pass try: os.remove('test-loginlogout.authdb.sqlite-wal') except Exception as e: pass