From 00942c1431c551e0bded111271be9b69f5261d91 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 27 Feb 2012 15:05:45 +1300 Subject: Add upstream certificate lookup. This initiates a connection to the server to obtain certificate information to generate interception certificates. At the moment, the information used is the Common Name, and the list of Subject Alternative Names. --- test/test_utils.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'test/test_utils.py') diff --git a/test/test_utils.py b/test/test_utils.py index c2f81a7b..06366773 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -149,14 +149,16 @@ class udummy_cert(libpry.AutoTree): p = utils.dummy_cert( os.path.join(d, "foo"), cacert, - "foo.com" + "foo.com", + ["one.com", "two.com", "*.three.com"] ) assert os.path.exists(p) # Short-circuit assert utils.dummy_cert( os.path.join(d, "foo"), cacert, - "foo.com" + "foo.com", + [] ) def test_no_ca(self): @@ -164,7 +166,8 @@ class udummy_cert(libpry.AutoTree): p = utils.dummy_cert( d, None, - "foo.com" + "foo.com", + [] ) assert os.path.exists(p) @@ -255,7 +258,16 @@ class u_parse_size(libpry.AutoTree): libpry.raises(ValueError, utils.parse_size, "ak") +class uparse_text_cert(libpry.AutoTree): + def test_simple(self): + c = file("data/text_cert", "r").read() + cn, san = utils.parse_text_cert(c) + assert cn == "google.com" + assert len(san) == 436 + + tests = [ + uparse_text_cert(), uformat_timestamp(), uisBin(), uisXML(), -- cgit v1.2.3 From 2ba8296843fc83256e3e13a23529a915d73a2e2d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 27 Feb 2012 15:21:05 +1300 Subject: Better certificate parsing. --- test/test_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/test_utils.py') diff --git a/test/test_utils.py b/test/test_utils.py index 06366773..116abfe1 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -265,6 +265,12 @@ class uparse_text_cert(libpry.AutoTree): assert cn == "google.com" assert len(san) == 436 + c = file("data/text_cert_2", "r").read() + cn, san = utils.parse_text_cert(c) + assert cn == "www.inode.co.nz" + assert len(san) == 2 + + tests = [ uparse_text_cert(), -- cgit v1.2.3 From 764724748bf27466594be9755914ff25d52a66c5 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 27 Feb 2012 15:59:29 +1300 Subject: Fix cert generation harder. --- test/test_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/test_utils.py') diff --git a/test/test_utils.py b/test/test_utils.py index 116abfe1..9ad0f006 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -147,12 +147,14 @@ class udummy_cert(libpry.AutoTree): cacert = os.path.join(d, "foo/cert.cnf") assert utils.dummy_ca(cacert) p = utils.dummy_cert( - os.path.join(d, "foo"), + #os.path.join(d, "foo"), + "/tmp", cacert, "foo.com", ["one.com", "two.com", "*.three.com"] ) assert os.path.exists(p) + # Short-circuit assert utils.dummy_cert( os.path.join(d, "foo"), -- cgit v1.2.3 From 688faa9baa79750642ffbf4241bb166f594e4179 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 27 Feb 2012 20:34:47 +1300 Subject: Repair unit tests. --- test/test_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/test_utils.py') diff --git a/test/test_utils.py b/test/test_utils.py index 9ad0f006..79ddf53d 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -147,14 +147,13 @@ class udummy_cert(libpry.AutoTree): cacert = os.path.join(d, "foo/cert.cnf") assert utils.dummy_ca(cacert) p = utils.dummy_cert( - #os.path.join(d, "foo"), - "/tmp", + os.path.join(d, "foo"), cacert, "foo.com", ["one.com", "two.com", "*.three.com"] ) assert os.path.exists(p) - + # Short-circuit assert utils.dummy_cert( os.path.join(d, "foo"), -- cgit v1.2.3