From 8118056a244ca74d16380ad26a70e3da40e7e401 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 9 Nov 2012 11:21:40 +0900 Subject: connect page merged into regvalidation. Flow nearly working with fake provider, except for authentication. --- src/leap/util/web.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/leap/util/web.py (limited to 'src/leap/util/web.py') diff --git a/src/leap/util/web.py b/src/leap/util/web.py new file mode 100644 index 00000000..6ddf4b21 --- /dev/null +++ b/src/leap/util/web.py @@ -0,0 +1,18 @@ +""" +web related utilities +""" + + +def get_https_domain_and_port(full_domain): + """ + returns a tuple with domain and port + from a full_domain string that can + contain a colon + """ + domain_split = full_domain.split(':') + _len = len(domain_split) + if _len == 1: + domain, port = full_domain, 443 + if _len == 2: + domain, port = domain_split + return domain, port -- cgit v1.2.3 From 8fd77ba036cb78c81939bbfce312b12cdc90d881 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 9 Nov 2012 18:13:32 +0900 Subject: working version of the fake provider. wizard can now be completely tested against this. --- src/leap/util/web.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/leap/util/web.py') diff --git a/src/leap/util/web.py b/src/leap/util/web.py index 6ddf4b21..b2aef058 100644 --- a/src/leap/util/web.py +++ b/src/leap/util/web.py @@ -3,16 +3,37 @@ web related utilities """ +class UsageError(Exception): + """ """ + + def get_https_domain_and_port(full_domain): """ returns a tuple with domain and port from a full_domain string that can contain a colon """ + if full_domain is None: + return None, None + + https_sch = "https://" + http_sch = "http://" + + if full_domain.startswith(https_sch): + full_domain = full_domain.lstrip(https_sch) + elif full_domain.startswith(http_sch): + raise UsageError( + "cannot be called with a domain " + "that begins with 'http://'") + domain_split = full_domain.split(':') _len = len(domain_split) if _len == 1: domain, port = full_domain, 443 - if _len == 2: + elif _len == 2: domain, port = domain_split + else: + raise UsageError( + "must be called with one only parameter" + "in the form domain[:port]") return domain, port -- cgit v1.2.3 From 490cde9c33039c2c5b16d929d6f8bb8e8f06f430 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 5 Dec 2012 23:50:08 +0900 Subject: tests for firstrun/wizard --- src/leap/util/web.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/leap/util/web.py') diff --git a/src/leap/util/web.py b/src/leap/util/web.py index b2aef058..15de0561 100644 --- a/src/leap/util/web.py +++ b/src/leap/util/web.py @@ -13,6 +13,7 @@ def get_https_domain_and_port(full_domain): from a full_domain string that can contain a colon """ + full_domain = unicode(full_domain) if full_domain is None: return None, None -- cgit v1.2.3