diff --git a/mslib/msui/mscolab.py b/mslib/msui/mscolab.py index 33c3d0177..869bfe591 100644 --- a/mslib/msui/mscolab.py +++ b/mslib/msui/mscolab.py @@ -61,7 +61,7 @@ from PyQt5.QtWidgets import QDialog, QFileDialog, QMessageBox from PyQt5.QtGui import QPixmap -from mslib.utils.auth import get_password_from_keyring, save_password_to_keyring +from mslib.utils.auth import get_password_from_keyring, save_password_to_keyring, del_password_from_keyring from mslib.utils.verify_user_token import verify_user_token as _verify_user_token from mslib.utils.verify_waypoint_data import verify_waypoint_data from mslib.utils.qt import get_open_filename, get_save_filename, dropEvent, dragEnterEvent, show_popup @@ -936,6 +936,9 @@ def delete_own_account(self, _=None): if reply == QMessageBox.No: return try: + auth_name = config_loader(dataset="MSCOLAB_auth_user_name") + del_password_from_keyring(self.mscolab_server_url, self.email) + del_password_from_keyring(f"MSCOLAB_AUTH_{self.mscolab_server_url}", auth_name) response = self.conn.request_post("delete_own_account") except requests.exceptions.RequestException as ex: raise MSColabConnectionError(f"Some error occurred ({ex})! Please reconnect.") diff --git a/tests/_test_msui/test_mscolab.py b/tests/_test_msui/test_mscolab.py index 8b6c599fa..4e37b8ee5 100644 --- a/tests/_test_msui/test_mscolab.py +++ b/tests/_test_msui/test_mscolab.py @@ -892,10 +892,20 @@ def test_user_delete(self, mockmessage, qtbot): self._create_user(qtbot, "something", "something@something.org", "something") u_id = self.window.mscolab.user['id'] self.window.mscolab.open_profile_window() + # Uses 'TestKeyring' from conftest.py for verification. + assert self.url + "something@something.org" in mslib.utils.auth.keyring.get_keyring().passwords + assert "MSCOLAB_AUTH_" + self.url, "something@something.org" in mslib.utils.auth.keyring.get_keyring().passwords QtTest.QTest.mouseClick(self.window.mscolab.profile_dialog.deleteAccountBtn, QtCore.Qt.LeftButton) assert self.window.listOperationsMSC.model().rowCount() == 0 assert self.window.usernameLabel.isVisible() is False assert self.window.connectBtn.isVisible() is True + assert ( + self.url + "something@something.org" + not in mslib.utils.auth.keyring.get_keyring().passwords + ) + assert "MSCOLAB_AUTH_" + self.url, "something@something.org" not in ( + mslib.utils.auth.keyring.get_keyring().passwords + ) with self.app.app_context(): assert User.query.filter_by(emailid='something').count() == 0 assert Permission.query.filter_by(u_id=u_id).count() == 0