bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2007, 2009, 2010, 2011 Canonical Ltd
|
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
16 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
17 |
"""Testing of breezy.transport.http.ca_bundle module"""
|
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
18 |
|
19 |
import os |
|
20 |
import sys |
|
21 |
||
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
22 |
from . import ( |
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
23 |
TestCaseInTempDir, |
24 |
TestSkipped, |
|
25 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
26 |
from ..transport.http import ca_bundle |
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
27 |
|
28 |
||
29 |
class TestGetCAPath(TestCaseInTempDir): |
|
30 |
||
31 |
def setUp(self): |
|
5570.3.10
by Vincent Ladeuil
Rework the http tests with overrideEnv. |
32 |
super(TestGetCAPath, self).setUp() |
33 |
self.overrideEnv('CURL_CA_BUNDLE', None) |
|
34 |
self.overrideEnv('PATH', None) |
|
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
35 |
|
36 |
def _make_file(self, in_dir='.'): |
|
37 |
fname = os.path.join(in_dir, 'curl-ca-bundle.crt') |
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
38 |
with open(fname, 'w') as f: |
39 |
f.write('spam') |
|
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
40 |
|
41 |
def test_found_nothing(self): |
|
42 |
self.assertEqual('', ca_bundle.get_ca_path(use_cache=False)) |
|
43 |
||
44 |
def test_env_var(self): |
|
5570.3.10
by Vincent Ladeuil
Rework the http tests with overrideEnv. |
45 |
self.overrideEnv('CURL_CA_BUNDLE', 'foo.bar') |
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
46 |
self._make_file() |
47 |
self.assertEqual('foo.bar', ca_bundle.get_ca_path(use_cache=False)) |
|
48 |
||
49 |
def test_in_path(self): |
|
50 |
if sys.platform != 'win32': |
|
51 |
raise TestSkipped('Searching in PATH implemented only for win32') |
|
52 |
os.mkdir('foo') |
|
6619.3.26
by Martin
Fix fallout from 2to3 getcwdu transformation and other test uses |
53 |
in_dir = os.path.join(self.test_dir, 'foo') |
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
54 |
self._make_file(in_dir=in_dir) |
5570.3.10
by Vincent Ladeuil
Rework the http tests with overrideEnv. |
55 |
self.overrideEnv('PATH', in_dir) |
2298.5.1
by Alexander Belchenko
Bugfix #82086: Searching location of CA bundle for PyCurl in env variable (CURL_CA_BUNDLE), and on win32 along the PATH |
56 |
shouldbe = os.path.join(in_dir, 'curl-ca-bundle.crt') |
57 |
self.assertEqual(shouldbe, ca_bundle.get_ca_path(use_cache=False)) |