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 |
|
17 |
"""Testing of bzrlib.transport.http.ca_bundle module"""
|
|
18 |
||
19 |
import os |
|
20 |
import sys |
|
21 |
||
22 |
from bzrlib.tests import ( |
|
23 |
TestCaseInTempDir, |
|
24 |
TestSkipped, |
|
25 |
)
|
|
26 |
from bzrlib.transport.http import ca_bundle |
|
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') |
|
38 |
f = file(fname,'w') |
|
39 |
f.write('spam') |
|
40 |
f.close() |
|
41 |
||
42 |
def test_found_nothing(self): |
|
43 |
self.assertEqual('', ca_bundle.get_ca_path(use_cache=False)) |
|
44 |
||
45 |
def test_env_var(self): |
|
5570.3.10
by Vincent Ladeuil
Rework the http tests with overrideEnv. |
46 |
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 |
47 |
self._make_file() |
48 |
self.assertEqual('foo.bar', ca_bundle.get_ca_path(use_cache=False)) |
|
49 |
||
50 |
def test_in_path(self): |
|
51 |
if sys.platform != 'win32': |
|
52 |
raise TestSkipped('Searching in PATH implemented only for win32') |
|
53 |
os.mkdir('foo') |
|
54 |
in_dir = os.path.join(os.getcwd(), 'foo') |
|
55 |
self._make_file(in_dir=in_dir) |
|
5570.3.10
by Vincent Ladeuil
Rework the http tests with overrideEnv. |
56 |
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 |
57 |
shouldbe = os.path.join(in_dir, 'curl-ca-bundle.crt') |
58 |
self.assertEqual(shouldbe, ca_bundle.get_ca_path(use_cache=False)) |