[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] seek to the beginning after writing the temp file, since that is probably what users expect



commit 744617d8928cf097d9f1f0c0ae3b0b136895bffb
Author: Ximin Luo <infinity0@xxxxxxx>
Date:   Sat Nov 9 14:45:37 2013 +0000

    seek to the beginning after writing the temp file, since that is probably what users expect
---
 flashproxy/keys.py           |    1 +
 flashproxy/test/test_keys.py |    3 +++
 2 files changed, 4 insertions(+)

diff --git a/flashproxy/keys.py b/flashproxy/keys.py
index 28b4406..ff27448 100644
--- a/flashproxy/keys.py
+++ b/flashproxy/keys.py
@@ -77,6 +77,7 @@ class temp_cert(object):
         self.fd = tempfile.NamedTemporaryFile(prefix="fp-cert-temp-", suffix=".crt", delete=True)
         self.fd.write(certdata)
         self.fd.flush()
+        self.fd.seek(0)
 
     def __enter__(self):
         return self.fd
diff --git a/flashproxy/test/test_keys.py b/flashproxy/test/test_keys.py
index 00b82a7..15c4449 100644
--- a/flashproxy/test/test_keys.py
+++ b/flashproxy/test/test_keys.py
@@ -4,11 +4,14 @@ import unittest
 from flashproxy.keys import PIN_GOOGLE_CA_CERT, PIN_GOOGLE_PUBKEY_SHA1, check_certificate_pin, temp_cert
 
 class TempCertTest(unittest.TestCase):
+
     def test_temp_cert_success(self):
         fn = None
         with temp_cert(PIN_GOOGLE_CA_CERT) as ca_file:
             fn = ca_file.name
             self.assertTrue(os.path.exists(fn))
+            lines = ca_file.readlines()
+            self.assertIn("-----BEGIN CERTIFICATE-----\n", lines)
         self.assertFalse(os.path.exists(fn))
 
     def test_temp_cert_raise(self):

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits