summaryrefslogtreecommitdiff
path: root/src/leap/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/gui')
-rw-r--r--src/leap/gui/firstrun/__init__.py5
-rw-r--r--src/leap/gui/firstrun/connect.py (renamed from src/leap/gui/firstrun/regvalidation.py)56
-rw-r--r--src/leap/gui/firstrun/intro.py2
-rw-r--r--src/leap/gui/firstrun/providersetup.py47
-rw-r--r--src/leap/gui/firstrun/register.py18
-rwxr-xr-xsrc/leap/gui/firstrun/wizard.py4
-rw-r--r--src/leap/gui/progress.py7
-rw-r--r--src/leap/gui/tests/test_firstrun_login.py2
-rw-r--r--src/leap/gui/tests/test_firstrun_register.py2
-rw-r--r--src/leap/gui/tests/test_firstrun_wizard.py4
10 files changed, 65 insertions, 82 deletions
diff --git a/src/leap/gui/firstrun/__init__.py b/src/leap/gui/firstrun/__init__.py
index d380b75a..2a523d6a 100644
--- a/src/leap/gui/firstrun/__init__.py
+++ b/src/leap/gui/firstrun/__init__.py
@@ -6,6 +6,7 @@ except ValueError:
pass
import intro
+import connect
import last
import login
import mixins
@@ -13,10 +14,10 @@ import providerinfo
import providerselect
import providersetup
import register
-import regvalidation
__all__ = [
'intro',
+ 'connect',
'last',
'login',
'mixins',
@@ -24,4 +25,4 @@ __all__ = [
'providerselect',
'providersetup',
'register',
- 'regvalidation'] # ,'wizard']
+ ] # ,'wizard']
diff --git a/src/leap/gui/firstrun/regvalidation.py b/src/leap/gui/firstrun/connect.py
index 6135a290..b7688380 100644
--- a/src/leap/gui/firstrun/regvalidation.py
+++ b/src/leap/gui/firstrun/connect.py
@@ -2,15 +2,7 @@
Provider Setup Validation Page,
used in First Run Wizard
"""
-# XXX This page is called regvalidation
-# but it's implementing functionality in the former
-# connect page.
-# We should remame it to connect again, when we integrate
-# the login branch of the wizard.
-
import logging
-#import json
-#import socket
from PyQt4 import QtGui
@@ -25,11 +17,11 @@ from leap.gui.constants import APP_LOGO
logger = logging.getLogger(__name__)
-class RegisterUserValidationPage(ValidationPage):
+class ConnectionPage(ValidationPage):
def __init__(self, parent=None):
- super(RegisterUserValidationPage, self).__init__(parent)
- self.current_page = "signupvalidation"
+ super(ConnectionPage, self).__init__(parent)
+ self.current_page = "connect"
title = self.tr("Connecting...")
# XXX uh... really?
@@ -52,32 +44,31 @@ class RegisterUserValidationPage(ValidationPage):
wizard = self.wizard()
full_domain = self.field('provider_domain')
domain, port = get_https_domain_and_port(full_domain)
- _domain = u"%s:%s" % (domain, port) if port != 443 else unicode(domain)
- # FIXME #BUG 638 FIXME FIXME FIXME
- verify = False # !!!!!!!!!!!!!!!!
- # FIXME #BUG 638 FIXME FIXME FIXME
+ pconfig = wizard.eipconfigchecker(domain=domain)
+ # this should be persisted...
+ pconfig.defaultprovider.load()
+ pconfig.set_api_domain()
+
+ pCertChecker = wizard.providercertchecker(
+ domain=domain)
+ pCertChecker.set_api_domain(pconfig.apidomain)
###########################################
# Set Credentials.
# username and password are in different fields
# if they were stored in log_in or sign_up pages.
- is_signup = self.field("is_signup")
+ from_login = wizard.from_login
unamek_base = 'userName'
passwk_base = 'userPassword'
- unamek = 'login_%s' % unamek_base if not is_signup else unamek_base
- passwk = 'login_%s' % passwk_base if not is_signup else passwk_base
+ unamek = 'login_%s' % unamek_base if from_login else unamek_base
+ passwk = 'login_%s' % passwk_base if from_login else passwk_base
username = self.field(unamek)
password = self.field(passwk)
credentials = username, password
- eipconfigchecker = wizard.eipconfigchecker(domain=_domain)
- #XXX change for _domain (sanitized)
- pCertChecker = wizard.providercertchecker(
- domain=full_domain)
-
yield(("head_sentinel", 0), lambda: None)
##################################################
@@ -85,8 +76,7 @@ class RegisterUserValidationPage(ValidationPage):
##################################################
def fetcheipconf():
try:
- eipconfigchecker.fetch_eip_service_config(
- domain=full_domain)
+ pconfig.fetch_eip_service_config()
# XXX get specific exception
except Exception as exc:
@@ -102,8 +92,7 @@ class RegisterUserValidationPage(ValidationPage):
def fetcheipcert():
try:
downloaded = pCertChecker.download_new_client_cert(
- credentials=credentials,
- verify=verify)
+ credentials=credentials)
if not downloaded:
logger.error('Could not download client cert.')
return False
@@ -111,6 +100,9 @@ class RegisterUserValidationPage(ValidationPage):
except auth.SRPAuthenticationError as exc:
return self.fail(self.tr(
"Authentication error: %s" % exc.message))
+
+ except Exception as exc:
+ return self.fail(exc.message)
else:
return True
@@ -182,8 +174,8 @@ class RegisterUserValidationPage(ValidationPage):
called after _do_checks has finished
(connected to checker thread finished signal)
"""
- is_signup = self.field("is_signup")
- prevpage = "signup" if is_signup else "login"
+ from_login = self.wizard().from_login
+ prevpage = "login" if from_login else "signup"
wizard = self.wizard()
if self.errors:
@@ -200,11 +192,11 @@ class RegisterUserValidationPage(ValidationPage):
def nextId(self):
wizard = self.wizard()
- if not wizard:
- return
+ #if not wizard:
+ #return
return wizard.get_page_index('lastpage')
def initializePage(self):
- super(RegisterUserValidationPage, self).initializePage()
+ super(ConnectionPage, self).initializePage()
self.set_undone()
self.completeChanged.emit()
diff --git a/src/leap/gui/firstrun/intro.py b/src/leap/gui/firstrun/intro.py
index 0a7484e2..0425b764 100644
--- a/src/leap/gui/firstrun/intro.py
+++ b/src/leap/gui/firstrun/intro.py
@@ -50,7 +50,7 @@ class IntroPage(QtGui.QWizardPage):
layout.addWidget(radiobuttonGroup)
self.setLayout(layout)
- self.registerField('is_signup', self.sign_up)
+ #self.registerField('is_signup', self.sign_up)
def validatePage(self):
return True
diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py
index 1a362794..981e3214 100644
--- a/src/leap/gui/firstrun/providersetup.py
+++ b/src/leap/gui/firstrun/providersetup.py
@@ -4,6 +4,8 @@ used if First Run Wizard
"""
import logging
+import requests
+
from PyQt4 import QtGui
from leap.base import exceptions as baseexceptions
@@ -20,8 +22,8 @@ class ProviderSetupValidationPage(ValidationPage):
self.current_page = "providersetupvalidation"
# XXX needed anymore?
- is_signup = self.field("is_signup")
- self.is_signup = is_signup
+ #is_signup = self.field("is_signup")
+ #self.is_signup = is_signup
self.setTitle(self.tr("Provider setup"))
self.setSubTitle(
@@ -110,26 +112,15 @@ class ProviderSetupValidationPage(ValidationPage):
#########################
def validatecacert():
- pass
- #api_uri = pconfig.get('api_uri', None)
- #try:
- #api_cert_verified = pCertChecker.verify_api_https(api_uri)
- #except requests.exceptions.SSLError as exc:
- #logger.error('BUG #638. %s' % exc.message)
- # XXX RAISE! See #638
- # bypassing until the hostname is fixed.
- # We probably should raise yet-another-warning
- # here saying user that the hostname "XX.XX.XX.XX' does not
- # match 'foo.bar.baz'
- #api_cert_verified = True
-
- #if not api_cert_verified:
- # XXX update validationMsg
- # should catch exception
- #return False
-
- #???
- #ca_cert_path = checker.ca_cert_path
+ api_uri = pconfig.get('api_uri', None)
+ try:
+ pCertChecker.verify_api_https(api_uri)
+ except requests.exceptions.SSLError as exc:
+ return self.fail("Validation Error")
+ except Exception as exc:
+ return self.fail(exc.msg)
+ else:
+ return True
yield((self.tr('Validating api certificate'), 90), validatecacert)
@@ -141,8 +132,8 @@ class ProviderSetupValidationPage(ValidationPage):
called after _do_checks has finished
(connected to checker thread finished signal)
"""
- prevpage = "providerselection" if self.is_signup else "login"
wizard = self.wizard()
+ prevpage = "login" if wizard.from_login else "providerselection"
if self.errors:
logger.debug('going back with errors')
@@ -158,14 +149,12 @@ class ProviderSetupValidationPage(ValidationPage):
def nextId(self):
wizard = self.wizard()
- if not wizard:
- return
- is_signup = self.field('is_signup')
- if is_signup is True:
- next_ = 'signup'
- if is_signup is False:
+ from_login = wizard.from_login
+ if from_login:
# XXX bad name. change to connect again.
next_ = 'signupvalidation'
+ else:
+ next_ = 'signup'
return wizard.get_page_index(next_)
def initializePage(self):
diff --git a/src/leap/gui/firstrun/register.py b/src/leap/gui/firstrun/register.py
index b04638e0..741b9267 100644
--- a/src/leap/gui/firstrun/register.py
+++ b/src/leap/gui/firstrun/register.py
@@ -224,11 +224,17 @@ class RegisterUserPage(InlineValidationPage, UserFormMixIn):
generator that yields actual checks
that are executed in a separate thread
"""
+ wizard = self.wizard()
+
provider = self.field('provider_domain')
username = self.userNameLineEdit.text()
password = self.userPasswordLineEdit.text()
password2 = self.userPassword2LineEdit.text()
+ pconfig = wizard.eipconfigchecker(domain=provider)
+ pconfig.defaultprovider.load()
+ pconfig.set_api_domain()
+
def checkpass():
# we better have here
# some call to a password checker...
@@ -263,14 +269,11 @@ class RegisterUserPage(InlineValidationPage, UserFormMixIn):
self, "showStepsFrame")
def register():
- # XXX FIXME!
- verify = False
signup = auth.LeapSRPRegister(
schema="https",
- provider=provider,
- verify=verify)
- #import ipdb;ipdb.set_trace()
+ provider=pconfig.apidomain,
+ verify=pconfig.cacert)
try:
ok, req = signup.register_user(
username, password)
@@ -381,7 +384,4 @@ class RegisterUserPage(InlineValidationPage, UserFormMixIn):
def nextId(self):
wizard = self.wizard()
- #if not wizard:
- #return
- # XXX this should be called connect
- return wizard.get_page_index('signupvalidation')
+ return wizard.get_page_index('connect')
diff --git a/src/leap/gui/firstrun/wizard.py b/src/leap/gui/firstrun/wizard.py
index 408d4597..427f9df8 100755
--- a/src/leap/gui/firstrun/wizard.py
+++ b/src/leap/gui/firstrun/wizard.py
@@ -59,8 +59,8 @@ def get_pages_dict():
('providersetupvalidation',
firstrun.providersetup.ProviderSetupValidationPage),
('signup', firstrun.register.RegisterUserPage),
- ('signupvalidation',
- firstrun.regvalidation.RegisterUserValidationPage),
+ ('connect',
+ firstrun.connect.ConnectionPage),
('lastpage', firstrun.last.LastPage)
))
diff --git a/src/leap/gui/progress.py b/src/leap/gui/progress.py
index ffea80de..ca4f6cc3 100644
--- a/src/leap/gui/progress.py
+++ b/src/leap/gui/progress.py
@@ -118,11 +118,12 @@ class StepsTableWidget(QtGui.QTableWidget):
self.setSelectionMode(
QtGui.QAbstractItemView.NoSelection)
width = self.width()
+
# WTF? Here init width is 100...
# but on populating is 456... :(
+ #logger.debug('init table. width=%s' % width)
# XXX do we need this initial?
- logger.debug('init table. width=%s' % width)
self.horizontalHeader().resizeSection(0, width * 0.7)
# this disables the table grid.
@@ -286,7 +287,7 @@ class WithStepsMixIn(object):
pagename = getattr(self, 'prev_page', None)
if pagename is None: # pragma: no cover
return
- logger.debug('cleaning wizard errors for %s' % pagename)
+ #logger.debug('cleaning wizard errors for %s' % pagename)
self.wizard().set_validation_error(pagename, None)
def populateStepsTable(self):
@@ -318,7 +319,7 @@ class WithStepsMixIn(object):
table = self.stepsTableWidget
FIRST_COLUMN_PERCENT = 0.70
width = table.width()
- logger.debug('populate table. width=%s' % width)
+ #logger.debug('populate table. width=%s' % width)
table.horizontalHeader().resizeSection(0, width * FIRST_COLUMN_PERCENT)
def set_item_icon(self, img=ICON_CHECKMARK, current=True):
diff --git a/src/leap/gui/tests/test_firstrun_login.py b/src/leap/gui/tests/test_firstrun_login.py
index fa800c23..6c45b8ef 100644
--- a/src/leap/gui/tests/test_firstrun_login.py
+++ b/src/leap/gui/tests/test_firstrun_login.py
@@ -100,7 +100,7 @@ class RegisterUserPageUITestCase(qunittest.TestCase):
pages = OrderedDict((
(self.pagename, TestPage),
('providersetupvalidation',
- firstrun.regvalidation.RegisterUserValidationPage)))
+ firstrun.connect.ConnectionPage)))
self.wizard = firstrun.wizard.FirstRunWizard(None, pages_dict=pages)
self.page = self.wizard.page(self.wizard.get_page_index(self.pagename))
diff --git a/src/leap/gui/tests/test_firstrun_register.py b/src/leap/gui/tests/test_firstrun_register.py
index 3447fe9d..d3be8897 100644
--- a/src/leap/gui/tests/test_firstrun_register.py
+++ b/src/leap/gui/tests/test_firstrun_register.py
@@ -113,7 +113,7 @@ class RegisterUserPageUITestCase(qunittest.TestCase):
pages = OrderedDict((
(self.pagename, TestPage),
('signupvalidation',
- firstrun.regvalidation.RegisterUserValidationPage)))
+ firstrun.connect.ConnectionPage)))
self.wizard = firstrun.wizard.FirstRunWizard(None, pages_dict=pages)
self.page = self.wizard.page(self.wizard.get_page_index(self.pagename))
diff --git a/src/leap/gui/tests/test_firstrun_wizard.py b/src/leap/gui/tests/test_firstrun_wizard.py
index d51e9945..b6c34000 100644
--- a/src/leap/gui/tests/test_firstrun_wizard.py
+++ b/src/leap/gui/tests/test_firstrun_wizard.py
@@ -29,8 +29,8 @@ PAGES_DICT = dict((
('providersetupvalidation',
firstrun.providersetup.ProviderSetupValidationPage),
('signup', firstrun.register.RegisterUserPage),
- ('signupvalidation',
- firstrun.regvalidation.RegisterUserValidationPage),
+ ('connect',
+ firstrun.connect.ConnectionPage),
('lastpage', firstrun.last.LastPage)
))