From 1ab0617598d22a0d1cc64a727f1053ef16010d49 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 4 Oct 2012 05:27:36 +0900 Subject: manual test --- src/leap/gui/tests/integration/fake_user_signup.py | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/leap/gui/tests/integration/fake_user_signup.py (limited to 'src/leap/gui/tests/integration') diff --git a/src/leap/gui/tests/integration/fake_user_signup.py b/src/leap/gui/tests/integration/fake_user_signup.py new file mode 100644 index 00000000..5c2dea5f --- /dev/null +++ b/src/leap/gui/tests/integration/fake_user_signup.py @@ -0,0 +1,76 @@ +""" +simple server to test registration and +authentication + +To test: + +curl -d login=python_test_user -d password_salt=54321\ + -d password_verifier=12341234 \ + http://localhost:8000/users.json + +""" +from BaseHTTPServer import HTTPServer +from BaseHTTPServer import BaseHTTPRequestHandler +import cgi +import urlparse + +HOST = "localhost" +PORT = 8000 + +LOGIN_ERROR = """{"errors":{"login":["has already been taken"]}}""" + + +class request_handler(BaseHTTPRequestHandler): + responses = { + '/': ['ok\n'], + '/users.json': ['ok\n'] + } + + def do_GET(self): + path = urlparse.urlparse(self.path) + message = '\n'.join( + self.responses.get( + path.path, None)) + self.send_response(200) + self.end_headers() + self.wfile.write(message) + + def do_POST(self): + form = cgi.FieldStorage( + fp=self.rfile, + headers=self.headers, + environ={'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': self.headers['Content-Type'], + }) + data = dict( + (key, form[key].value) for key in form.keys()) + path = urlparse.urlparse(self.path) + message = '\n'.join( + self.responses.get( + path.path, None)) + + login = data.get('login', None) + password_salt = data.get('password_salt', None) + password_verifier = data.get('password_verifier', None) + + ok = True if ( + login == "python_test_user" and + password_salt == "54321" and + password_verifier == "12341234") else False + + if ok: + self.send_response(200) + self.end_headers() + self.wfile.write(message) + + else: + self.send_response(500) + self.end_headers() + self.wfile.write(LOGIN_ERROR) + + +if __name__ == "__main__": + server = HTTPServer((HOST, PORT), request_handler) + server.serve_forever() + + -- cgit v1.2.3 From c06d7e25649cc76dfe7418a520dc823270a3191f Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 01:59:06 +0900 Subject: add user registration to wizard validation still a bit fragile but there it is. --- src/leap/gui/tests/integration/fake_user_signup.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/leap/gui/tests/integration') diff --git a/src/leap/gui/tests/integration/fake_user_signup.py b/src/leap/gui/tests/integration/fake_user_signup.py index 5c2dea5f..ee8e6ead 100644 --- a/src/leap/gui/tests/integration/fake_user_signup.py +++ b/src/leap/gui/tests/integration/fake_user_signup.py @@ -50,14 +50,10 @@ class request_handler(BaseHTTPRequestHandler): path.path, None)) login = data.get('login', None) - password_salt = data.get('password_salt', None) - password_verifier = data.get('password_verifier', None) - - ok = True if ( - login == "python_test_user" and - password_salt == "54321" and - password_verifier == "12341234") else False + #password_salt = data.get('password_salt', None) + #password_verifier = data.get('password_verifier', None) + ok = True if (login == "python_test_user") else False if ok: self.send_response(200) self.end_headers() -- cgit v1.2.3 From 0576427f697fa631d8f5cc2fc596c60bce38dda3 Mon Sep 17 00:00:00 2001 From: kali Date: Sat, 6 Oct 2012 01:51:51 +0900 Subject: pep8 --- src/leap/gui/tests/integration/fake_user_signup.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/leap/gui/tests/integration') diff --git a/src/leap/gui/tests/integration/fake_user_signup.py b/src/leap/gui/tests/integration/fake_user_signup.py index ee8e6ead..e46ff349 100644 --- a/src/leap/gui/tests/integration/fake_user_signup.py +++ b/src/leap/gui/tests/integration/fake_user_signup.py @@ -68,5 +68,3 @@ class request_handler(BaseHTTPRequestHandler): if __name__ == "__main__": server = HTTPServer((HOST, PORT), request_handler) server.serve_forever() - - -- cgit v1.2.3 From 8a594577660d78a4f0f9d3c5f5902dff3911e010 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 8 Oct 2012 05:53:16 +0900 Subject: catch timeout and specify kind of signup error --- src/leap/gui/tests/integration/fake_user_signup.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/leap/gui/tests/integration') diff --git a/src/leap/gui/tests/integration/fake_user_signup.py b/src/leap/gui/tests/integration/fake_user_signup.py index e46ff349..12f18966 100644 --- a/src/leap/gui/tests/integration/fake_user_signup.py +++ b/src/leap/gui/tests/integration/fake_user_signup.py @@ -23,7 +23,8 @@ LOGIN_ERROR = """{"errors":{"login":["has already been taken"]}}""" class request_handler(BaseHTTPRequestHandler): responses = { '/': ['ok\n'], - '/users.json': ['ok\n'] + '/users.json': ['ok\n'], + '/timeout': ['ok\n'] } def do_GET(self): @@ -47,12 +48,21 @@ class request_handler(BaseHTTPRequestHandler): path = urlparse.urlparse(self.path) message = '\n'.join( self.responses.get( - path.path, None)) + path.path, '')) login = data.get('login', None) #password_salt = data.get('password_salt', None) #password_verifier = data.get('password_verifier', None) + if path.geturl() == "/timeout": + print 'timeout' + self.send_response(200) + self.end_headers() + self.wfile.write(message) + import time + time.sleep(10) + return + ok = True if (login == "python_test_user") else False if ok: self.send_response(200) -- cgit v1.2.3