/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5557.1.7 by John Arbash Meinel
Merge in the bzr.dev 5582
1
# Copyright (C) 2007, 2009, 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
import bzrlib
23
from bzrlib import osutils
24
from bzrlib.tests import (
25
    TestCaseInTempDir,
26
    TestSkipped,
27
    )
28
from bzrlib.transport.http import ca_bundle
29
30
31
class TestGetCAPath(TestCaseInTempDir):
32
33
    def setUp(self):
5570.3.10 by Vincent Ladeuil
Rework the http tests with overrideEnv.
34
        super(TestGetCAPath, self).setUp()
35
        self.overrideEnv('CURL_CA_BUNDLE', None)
36
        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
37
38
    def _make_file(self, in_dir='.'):
39
        fname = os.path.join(in_dir, 'curl-ca-bundle.crt')
40
        f = file(fname,'w')
41
        f.write('spam')
42
        f.close()
43
44
    def test_found_nothing(self):
45
        self.assertEqual('', ca_bundle.get_ca_path(use_cache=False))
46
47
    def test_env_var(self):
5570.3.10 by Vincent Ladeuil
Rework the http tests with overrideEnv.
48
        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
49
        self._make_file()
50
        self.assertEqual('foo.bar', ca_bundle.get_ca_path(use_cache=False))
51
52
    def test_in_path(self):
53
        if sys.platform != 'win32':
54
            raise TestSkipped('Searching in PATH implemented only for win32')
55
        os.mkdir('foo')
56
        in_dir = os.path.join(os.getcwd(), 'foo')
57
        self._make_file(in_dir=in_dir)
5570.3.10 by Vincent Ladeuil
Rework the http tests with overrideEnv.
58
        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
59
        shouldbe = os.path.join(in_dir, 'curl-ca-bundle.crt')
60
        self.assertEqual(shouldbe, ca_bundle.get_ca_path(use_cache=False))