Full coverage for view validateService

This commit is contained in:
Valentin Samir
2016-06-28 18:57:56 +02:00
parent 6d610d5aa6
commit 44acd005ee
3 changed files with 207 additions and 9 deletions

View File

@ -148,6 +148,7 @@ def gen_saml_id():
class PGTUrlHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""A simple http server that return 200 on GET and store GET parameters. Used in unit tests"""
PARAMS = {}
def do_GET(self):
@ -162,10 +163,10 @@ class PGTUrlHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def log_message(self, *args):
return
@staticmethod
def run():
@classmethod
def run(cls):
server_class = BaseHTTPServer.HTTPServer
httpd = server_class(("127.0.0.1", 0), PGTUrlHandler)
httpd = server_class(("127.0.0.1", 0), cls)
(host, port) = httpd.socket.getsockname()
def lauch():
@ -178,6 +179,15 @@ class PGTUrlHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return (httpd_thread, host, port)
class PGTUrlHandler404(PGTUrlHandler):
"""A simple http server that always return 404 not found. Used in unit tests"""
def do_GET(self):
self.send_response(404)
self.send_header(b"Content-type", "text/plain")
self.end_headers()
self.wfile.write(b"error 404 not found")
class LdapHashUserPassword(object):
"""Please see https://tools.ietf.org/id/draft-stroeder-hashed-userpassword-values-01.html"""