Statistics
| Revision:

gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / dulwich / tests / compat / test_server.py @ 959

History | View | Annotate | Download (3.53 KB)

1
# test_server.py -- Compatibility tests for git server.
2
# Copyright (C) 2010 Google, Inc.
3
#
4
# Dulwich is dual-licensed under the Apache License, Version 2.0 and the GNU
5
# General Public License as public by the Free Software Foundation; version 2.0
6
# or (at your option) any later version. You can redistribute it and/or
7
# modify it under the terms of either of these two licenses.
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
#
15
# You should have received a copy of the licenses; if not, see
16
# <http://www.gnu.org/licenses/> for a copy of the GNU General Public License
17
# and <http://www.apache.org/licenses/LICENSE-2.0> for a copy of the Apache
18
# License, Version 2.0.
19
#
20

    
21
"""Compatibility tests between Dulwich and the cgit server.
22

23
Warning: these tests should be fairly stable, but when writing/debugging new
24
    tests, deadlocks may freeze the test process such that it cannot be
25
    Ctrl-C'ed. On POSIX systems, you can kill the tests with Ctrl-Z, "kill %".
26
"""
27

    
28
import threading
29
import os
30
import sys
31

    
32
from dulwich.server import (
33
    DictBackend,
34
    TCPGitServer,
35
    )
36
from dulwich.tests import skipIf
37
from dulwich.tests.compat.server_utils import (
38
    ServerTests,
39
    NoSideBand64kReceivePackHandler,
40
    )
41
from dulwich.tests.compat.utils import (
42
    CompatTestCase,
43
    require_git_version,
44
    )
45

    
46
@skipIf(sys.platform == 'win32', 'Broken on windows, with very long fail time.')
47
class GitServerTestCase(ServerTests, CompatTestCase):
48
    """Tests for client/server compatibility.
49

50
    This server test case does not use side-band-64k in git-receive-pack.
51
    """
52

    
53
    protocol = 'git'
54

    
55
    def _handlers(self):
56
        return {b'git-receive-pack': NoSideBand64kReceivePackHandler}
57

    
58
    def _check_server(self, dul_server):
59
        receive_pack_handler_cls = dul_server.handlers[b'git-receive-pack']
60
        caps = receive_pack_handler_cls.capabilities()
61
        self.assertFalse(b'side-band-64k' in caps)
62

    
63
    def _start_server(self, repo):
64
        backend = DictBackend({b'/': repo})
65
        dul_server = TCPGitServer(backend, b'localhost', 0,
66
                                  handlers=self._handlers())
67
        self._check_server(dul_server)
68
        self.addCleanup(dul_server.shutdown)
69
        self.addCleanup(dul_server.server_close)
70
        threading.Thread(target=dul_server.serve).start()
71
        self._server = dul_server
72
        _, port = self._server.socket.getsockname()
73
        return port
74

    
75

    
76
@skipIf(sys.platform == 'win32', 'Broken on windows, with very long fail time.')
77
class GitServerSideBand64kTestCase(GitServerTestCase):
78
    """Tests for client/server compatibility with side-band-64k support."""
79

    
80
    # side-band-64k in git-receive-pack was introduced in git 1.7.0.2
81
    min_git_version = (1, 7, 0, 2)
82

    
83
    def setUp(self):
84
        super(GitServerSideBand64kTestCase, self).setUp()
85
        # side-band-64k is broken in the widows client.
86
        # https://github.com/msysgit/git/issues/101
87
        # Fix has landed for the 1.9.3 release.
88
        if os.name == 'nt':
89
            require_git_version((1, 9, 3))
90

    
91

    
92
    def _handlers(self):
93
        return None  # default handlers include side-band-64k
94

    
95
    def _check_server(self, server):
96
        receive_pack_handler_cls = server.handlers[b'git-receive-pack']
97
        caps = receive_pack_handler_cls.capabilities()
98
        self.assertTrue(b'side-band-64k' in caps)