diff options
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r-- | src/leap/bitmask/crypto/tests/test_srpauth.py | 34 | ||||
-rw-r--r-- | src/leap/bitmask/gui/loggerwindow.py | 23 | ||||
-rw-r--r-- | src/leap/bitmask/gui/mainwindow.py | 3 | ||||
-rw-r--r-- | src/leap/bitmask/gui/statuspanel.py | 2 | ||||
-rw-r--r-- | src/leap/bitmask/gui/twisted_main.py | 6 | ||||
-rw-r--r-- | src/leap/bitmask/gui/ui/loggerwindow.ui | 42 | ||||
-rw-r--r-- | src/leap/bitmask/gui/ui/mainwindow.ui | 7 | ||||
-rw-r--r-- | src/leap/bitmask/gui/ui/statuspanel.ui | 8 | ||||
-rw-r--r-- | src/leap/bitmask/gui/ui/wizard.ui | 36 | ||||
-rw-r--r-- | src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py | 30 |
10 files changed, 127 insertions, 64 deletions
diff --git a/src/leap/bitmask/crypto/tests/test_srpauth.py b/src/leap/bitmask/crypto/tests/test_srpauth.py index 043da15e..44cd6334 100644 --- a/src/leap/bitmask/crypto/tests/test_srpauth.py +++ b/src/leap/bitmask/crypto/tests/test_srpauth.py @@ -247,9 +247,9 @@ class SRPAuthTestCase(unittest.TestCase): def wrapper(_): with self.assertRaises(srpauth.SRPAuthUnknownUser): - with mock.patch('leap.util.request_helpers.get_content', - new=mock.create_autospec(get_content)) as \ - content: + with mock.patch( + 'leap.bitmask.util.request_helpers.get_content', + new=mock.create_autospec(get_content)) as content: content.return_value = ("{}", 0) self.auth_backend._start_authentication( @@ -264,9 +264,9 @@ class SRPAuthTestCase(unittest.TestCase): def wrapper(_): with self.assertRaises(srpauth.SRPAuthBadStatusCode): - with mock.patch('leap.util.request_helpers.get_content', - new=mock.create_autospec(get_content)) as \ - content: + with mock.patch( + 'leap.bitmask.util.request_helpers.get_content', + new=mock.create_autospec(get_content)) as content: content.return_value = ("{}", 0) self.auth_backend._start_authentication(None, @@ -281,9 +281,9 @@ class SRPAuthTestCase(unittest.TestCase): def wrapper(_): with self.assertRaises(srpauth.SRPAuthNoSalt): - with mock.patch('leap.util.request_helpers.get_content', - new=mock.create_autospec(get_content)) as \ - content: + with mock.patch( + 'leap.bitmask.util.request_helpers.get_content', + new=mock.create_autospec(get_content)) as content: content.return_value = ("{}", 0) self.auth_backend._start_authentication(None, @@ -298,9 +298,9 @@ class SRPAuthTestCase(unittest.TestCase): def wrapper(_): with self.assertRaises(srpauth.SRPAuthNoB): - with mock.patch('leap.util.request_helpers.get_content', - new=mock.create_autospec(get_content)) as \ - content: + with mock.patch( + 'leap.bitmask.util.request_helpers.get_content', + new=mock.create_autospec(get_content)) as content: content.return_value = ('{"salt": ""}', 0) self.auth_backend._start_authentication(None, @@ -317,7 +317,7 @@ class SRPAuthTestCase(unittest.TestCase): test_B = "67890" def wrapper(_): - with mock.patch('leap.util.request_helpers.get_content', + with mock.patch('leap.bitmask.util.request_helpers.get_content', new=mock.create_autospec(get_content)) as \ content: content.return_value = ('{"salt":"%s", "B":"%s"}' % (test_salt, @@ -395,7 +395,7 @@ class SRPAuthTestCase(unittest.TestCase): d = self._prepare_auth_challenge() def wrapper(salt_B): - with mock.patch('leap.util.request_helpers.get_content', + with mock.patch('leap.bitmask.util.request_helpers.get_content', new=mock.create_autospec(get_content)) as \ content: content.return_value = ("{", 0) @@ -421,7 +421,7 @@ class SRPAuthTestCase(unittest.TestCase): return_value=res) def wrapper(salt_B): - with mock.patch('leap.util.request_helpers.get_content', + with mock.patch('leap.bitmask.util.request_helpers.get_content', new=mock.create_autospec(get_content)) as \ content: content.return_value = ("", 0) @@ -445,7 +445,7 @@ class SRPAuthTestCase(unittest.TestCase): return_value=res) def wrapper(salt_B): - with mock.patch('leap.util.request_helpers.get_content', + with mock.patch('leap.bitmask.util.request_helpers.get_content', new=mock.create_autospec(get_content)) as \ content: content.return_value = ("[]", 0) @@ -469,7 +469,7 @@ class SRPAuthTestCase(unittest.TestCase): return_value=res) def wrapper(salt_B): - with mock.patch('leap.util.request_helpers.get_content', + with mock.patch('leap.bitmask.util.request_helpers.get_content', new=mock.create_autospec(get_content)) as \ content: content.return_value = ("{}", 0) diff --git a/src/leap/bitmask/gui/loggerwindow.py b/src/leap/bitmask/gui/loggerwindow.py index 981bf65d..9b4ba55d 100644 --- a/src/leap/bitmask/gui/loggerwindow.py +++ b/src/leap/bitmask/gui/loggerwindow.py @@ -56,6 +56,10 @@ class LoggerWindow(QtGui.QDialog): self.ui.btnWarning.toggled.connect(self._load_history), self.ui.btnError.toggled.connect(self._load_history), self.ui.btnCritical.toggled.connect(self._load_history) + self.ui.leFilterBy.textEdited.connect(self._filter_by) + self.ui.cbCaseInsensitive.stateChanged.connect(self._load_history) + + self._current_filter = "" # Load logging history and connect logger with the widget self._logging_handler = handler @@ -95,7 +99,14 @@ class LoggerWindow(QtGui.QDialog): close_tag = "</td></tr>" message = open_tag + message + close_tag - self.ui.txtLogHistory.append(message) + filter_by = self._current_filter + msg = message + if self.ui.cbCaseInsensitive.isChecked(): + msg = msg.upper() + filter_by = filter_by.upper() + + if msg.find(filter_by) != -1: + self.ui.txtLogHistory.append(message) def _load_history(self): """ @@ -120,6 +131,16 @@ class LoggerWindow(QtGui.QDialog): logging.CRITICAL: self.ui.btnCritical.isChecked() } + def _filter_by(self, text): + """ + Sets the text to use for filtering logs in the log window. + + :param text: the text to compare with the logs when filtering. + :type text: str + """ + self._current_filter = text + self._load_history() + def _save_log_to_file(self): """ Lets the user save the current log to a file diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index aa4baf56..b624988f 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -60,6 +60,7 @@ from leap.bitmask.services.eip.vpnlaunchers import EIPNoTunKextLoaded from leap.bitmask.util import __version__ as VERSION from leap.bitmask.util.keyring_helpers import has_keyring +from leap.bitmask.util.leap_log_handler import LeapLogHandler from leap.bitmask.services.mail.smtpconfig import SMTPConfig @@ -359,7 +360,6 @@ class MainWindow(QtGui.QMainWindow): :return: a logging handler or None :rtype: LeapLogHandler or None """ - from leap.util.leap_log_handler import LeapLogHandler leap_logger = logging.getLogger('leap') for h in leap_logger.handlers: if isinstance(h, LeapLogHandler): @@ -380,6 +380,7 @@ class MainWindow(QtGui.QMainWindow): leap_log_handler = self._get_leap_logging_handler() if leap_log_handler is None: logger.error('Leap logger handler not found') + return else: self._logger_window = LoggerWindow(handler=leap_log_handler) self._logger_window.setVisible( diff --git a/src/leap/bitmask/gui/statuspanel.py b/src/leap/bitmask/gui/statuspanel.py index 8f5427ad..eb731927 100644 --- a/src/leap/bitmask/gui/statuspanel.py +++ b/src/leap/bitmask/gui/statuspanel.py @@ -421,6 +421,8 @@ class StatusPanelWidget(QtGui.QWidget): self.set_eip_status(self.tr("Waiting to start...")) elif status == "ASSIGN_IP": self.set_eip_status(self.tr("Assigning IP")) + elif status == "RECONNECTING": + self.set_eip_status(self.tr("Reconnecting...")) elif status == "ALREADYRUNNING": # Put the following calls in Qt's event queue, otherwise # the UI won't update properly diff --git a/src/leap/bitmask/gui/twisted_main.py b/src/leap/bitmask/gui/twisted_main.py index c7add3ee..e11af7bd 100644 --- a/src/leap/bitmask/gui/twisted_main.py +++ b/src/leap/bitmask/gui/twisted_main.py @@ -53,8 +53,8 @@ def quit(app): :type app: QtCore.QApplication """ from twisted.internet import reactor - logger.debug('stopping twisted reactor') + logger.debug('Stopping twisted reactor') try: - reactor.stop() + reactor.callLater(0, reactor.stop) except error.ReactorNotRunning: - logger.debug('reactor not running') + logger.debug('Reactor not running') diff --git a/src/leap/bitmask/gui/ui/loggerwindow.ui b/src/leap/bitmask/gui/ui/loggerwindow.ui index b08428a9..3de786f7 100644 --- a/src/leap/bitmask/gui/ui/loggerwindow.ui +++ b/src/leap/bitmask/gui/ui/loggerwindow.ui @@ -14,14 +14,34 @@ <string>Logs</string> </property> <property name="windowIcon"> - <iconset resource="../../../../data/resources/mainwindow.qrc"> + <iconset resource="../../../../../data/resources/mainwindow.qrc"> <normaloff>:/images/mask-icon.png</normaloff>:/images/mask-icon.png</iconset> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="0" colspan="2"> + <item row="2" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Filter by:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="leFilterBy"/> + </item> + <item row="2" column="2"> + <widget class="QCheckBox" name="cbCaseInsensitive"> + <property name="text"> + <string>Case Insensitive</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="0" colspan="3"> <widget class="QTextBrowser" name="txtLogHistory"/> </item> - <item row="0" column="0" colspan="2"> + <item row="0" column="0" colspan="3"> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QPushButton" name="btnDebug"> @@ -29,7 +49,7 @@ <string>Debug</string> </property> <property name="icon"> - <iconset resource="../../../../data/resources/loggerwindow.qrc"> + <iconset resource="../../../../../data/resources/loggerwindow.qrc"> <normaloff>:/images/oxygen-icons/script-error.png</normaloff>:/images/oxygen-icons/script-error.png</iconset> </property> <property name="checkable"> @@ -49,7 +69,7 @@ <string>Info</string> </property> <property name="icon"> - <iconset resource="../../../../data/resources/loggerwindow.qrc"> + <iconset resource="../../../../../data/resources/loggerwindow.qrc"> <normaloff>:/images/oxygen-icons/dialog-information.png</normaloff>:/images/oxygen-icons/dialog-information.png</iconset> </property> <property name="checkable"> @@ -69,7 +89,7 @@ <string>Warning</string> </property> <property name="icon"> - <iconset resource="../../../../data/resources/loggerwindow.qrc"> + <iconset resource="../../../../../data/resources/loggerwindow.qrc"> <normaloff>:/images/oxygen-icons/dialog-warning.png</normaloff>:/images/oxygen-icons/dialog-warning.png</iconset> </property> <property name="checkable"> @@ -89,7 +109,7 @@ <string>Error</string> </property> <property name="icon"> - <iconset resource="../../../../data/resources/loggerwindow.qrc"> + <iconset resource="../../../../../data/resources/loggerwindow.qrc"> <normaloff>:/images/oxygen-icons/dialog-error.png</normaloff>:/images/oxygen-icons/dialog-error.png</iconset> </property> <property name="checkable"> @@ -109,7 +129,7 @@ <string>Critical</string> </property> <property name="icon"> - <iconset resource="../../../../data/resources/loggerwindow.qrc"> + <iconset resource="../../../../../data/resources/loggerwindow.qrc"> <normaloff>:/images/oxygen-icons/edit-bomb.png</normaloff>:/images/oxygen-icons/edit-bomb.png</iconset> </property> <property name="checkable"> @@ -129,7 +149,7 @@ <string>Save to file</string> </property> <property name="icon"> - <iconset resource="../../../../data/resources/loggerwindow.qrc"> + <iconset resource="../../../../../data/resources/loggerwindow.qrc"> <normaloff>:/images/oxygen-icons/document-save-as.png</normaloff>:/images/oxygen-icons/document-save-as.png</iconset> </property> </widget> @@ -148,8 +168,8 @@ <tabstop>txtLogHistory</tabstop> </tabstops> <resources> - <include location="../../../../data/resources/loggerwindow.qrc"/> - <include location="../../../../data/resources/mainwindow.qrc"/> + <include location="../../../../../data/resources/loggerwindow.qrc"/> + <include location="../../../../../data/resources/mainwindow.qrc"/> </resources> <connections/> </ui> diff --git a/src/leap/bitmask/gui/ui/mainwindow.ui b/src/leap/bitmask/gui/ui/mainwindow.ui index ecd3cbe9..9c4e6ff0 100644 --- a/src/leap/bitmask/gui/ui/mainwindow.ui +++ b/src/leap/bitmask/gui/ui/mainwindow.ui @@ -14,7 +14,7 @@ <string>Bitmask</string> </property> <property name="windowIcon"> - <iconset resource="../../../../data/resources/mainwindow.qrc"> + <iconset resource="../../../../../data/resources/mainwindow.qrc"> <normaloff>:/images/mask-icon.png</normaloff>:/images/mask-icon.png</iconset> </property> <property name="inputMethodHints"> @@ -166,7 +166,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/mask-launcher.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/mask-launcher.png</pixmap> </property> <property name="alignment"> <set>Qt::AlignCenter</set> @@ -308,8 +308,9 @@ </action> </widget> <resources> + <include location="../../../../../data/resources/mainwindow.qrc"/> + <include location="../../../../../data/resources/locale.qrc"/> <include location="../../../../data/resources/mainwindow.qrc"/> - <include location="../../../../data/resources/locale.qrc"/> </resources> <connections/> </ui> diff --git a/src/leap/bitmask/gui/ui/statuspanel.ui b/src/leap/bitmask/gui/ui/statuspanel.ui index 3482ac7c..39992e1a 100644 --- a/src/leap/bitmask/gui/ui/statuspanel.ui +++ b/src/leap/bitmask/gui/ui/statuspanel.ui @@ -114,7 +114,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/icons.qrc">:/images/light/64/network-eip-down.png</pixmap> + <pixmap resource="../../../../../data/resources/icons.qrc">:/images/light/64/network-eip-down.png</pixmap> </property> <property name="alignment"> <set>Qt::AlignCenter</set> @@ -135,7 +135,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/icons.qrc">:/images/light/16/down-arrow.png</pixmap> + <pixmap resource="../../../../../data/resources/icons.qrc">:/images/light/16/down-arrow.png</pixmap> </property> </widget> </item> @@ -192,7 +192,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/icons.qrc">:/images/light/16/up-arrow.png</pixmap> + <pixmap resource="../../../../../data/resources/icons.qrc">:/images/light/16/up-arrow.png</pixmap> </property> </widget> </item> @@ -283,7 +283,7 @@ </layout> </widget> <resources> - <include location="../../../../data/resources/icons.qrc"/> + <include location="../../../../../data/resources/icons.qrc"/> </resources> <connections/> </ui> diff --git a/src/leap/bitmask/gui/ui/wizard.ui b/src/leap/bitmask/gui/ui/wizard.ui index 5e0108dc..3b8f1215 100644 --- a/src/leap/bitmask/gui/ui/wizard.ui +++ b/src/leap/bitmask/gui/ui/wizard.ui @@ -7,14 +7,26 @@ <x>0</x> <y>0</y> <width>536</width> - <height>452</height> + <height>490</height> </rect> </property> + <property name="minimumSize"> + <size> + <width>536</width> + <height>490</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>536</width> + <height>490</height> + </size> + </property> <property name="windowTitle"> <string>Bitmask first run</string> </property> <property name="windowIcon"> - <iconset resource="../../../../data/resources/mainwindow.qrc"> + <iconset resource="../../../../../data/resources/mainwindow.qrc"> <normaloff>:/images/mask-icon.png</normaloff>:/images/mask-icon.png</iconset> </property> <property name="modal"> @@ -193,7 +205,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> </property> </widget> </item> @@ -215,7 +227,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> </property> </widget> </item> @@ -237,7 +249,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> </property> </widget> </item> @@ -486,7 +498,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> </property> </widget> </item> @@ -508,7 +520,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> </property> </widget> </item> @@ -551,7 +563,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/Emblem-question.png</pixmap> </property> </widget> </item> @@ -771,7 +783,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/mask-icon.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/mask-icon.png</pixmap> </property> </widget> </item> @@ -787,7 +799,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/Globe.png</pixmap> + <pixmap resource="../../../../../data/resources/mainwindow.qrc">:/images/Globe.png</pixmap> </property> </widget> </item> @@ -839,8 +851,8 @@ <tabstop>btnCheck</tabstop> </tabstops> <resources> - <include location="../../../../data/resources/mainwindow.qrc"/> - <include location="../../../../data/resources/locale.qrc"/> + <include location="../../../../../data/resources/mainwindow.qrc"/> + <include location="../../../../../data/resources/locale.qrc"/> </resources> <connections/> </ui> diff --git a/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py b/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py index 96ab53ce..93467d3a 100644 --- a/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py +++ b/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py @@ -421,8 +421,9 @@ class ProviderBootstrapperActiveTest(unittest.TestCase): self.pb._download_provider_info() self.assertTrue(ProviderConfig.save.called) - @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path', - lambda x: where('cacert.pem')) + @mock.patch( + 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path', + lambda x: where('cacert.pem')) def test_download_provider_info_not_modified(self): self._setup_provider_config_with("1", tempfile.mkdtemp()) self._setup_providerbootstrapper(True) @@ -439,8 +440,9 @@ class ProviderBootstrapperActiveTest(unittest.TestCase): # config, because it's new enough self.assertFalse(ProviderConfig.save.called) - @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path', - lambda x: where('cacert.pem')) + @mock.patch( + 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path', + lambda x: where('cacert.pem')) def test_download_provider_info_modified(self): self._setup_provider_config_with("1", tempfile.mkdtemp()) self._setup_providerbootstrapper(True) @@ -456,8 +458,9 @@ class ProviderBootstrapperActiveTest(unittest.TestCase): self.assertTrue(ProviderConfig.load.called) self.assertTrue(ProviderConfig.save.called) - @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path', - lambda x: where('cacert.pem')) + @mock.patch( + 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path', + lambda x: where('cacert.pem')) def test_download_provider_info_unsupported_api_raises(self): self._setup_provider_config_with("9999999", tempfile.mkdtemp()) self._setup_providerbootstrapper(False) @@ -469,8 +472,9 @@ class ProviderBootstrapperActiveTest(unittest.TestCase): with self.assertRaises(UnsupportedProviderAPI): self.pb._download_provider_info() - @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path', - lambda x: where('cacert.pem')) + @mock.patch( + 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path', + lambda x: where('cacert.pem')) def test_download_provider_info_unsupported_api(self): self._setup_provider_config_with(SupportedAPIs.SUPPORTED_APIS[0], tempfile.mkdtemp()) @@ -482,10 +486,12 @@ class ProviderBootstrapperActiveTest(unittest.TestCase): return_value="https://localhost:%s" % (self.https_port,)): self.pb._download_provider_info() - @mock.patch('leap.config.providerconfig.ProviderConfig.get_api_uri', - lambda x: 'api.uri') - @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path', - lambda x: '/cert/path') + @mock.patch( + 'leap.bitmask.config.providerconfig.ProviderConfig.get_api_uri', + lambda x: 'api.uri') + @mock.patch( + 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path', + lambda x: '/cert/path') def test_check_api_certificate_skips(self): self.pb._provider_config = ProviderConfig() self.pb._session.get = mock.MagicMock(return_value=Response()) |