/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/ftp_server/medusa_based.py

  • Committer: Martin von Gagern
  • Date: 2010-04-20 08:47:38 UTC
  • mfrom: (5167 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5195.
  • Revision ID: martin.vgagern@gmx.net-20100420084738-ygymnqmdllzrhpfn
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
"""
17
17
FTP test server.
18
18
 
33
33
from bzrlib import (
34
34
    tests,
35
35
    trace,
36
 
    transport,
37
36
    )
 
37
from bzrlib.tests import test_server
38
38
 
39
39
 
40
40
class test_filesystem(medusa.filesys.os_filesystem):
126
126
    def cmd_size(self, line):
127
127
        """Return the size of a file
128
128
 
129
 
        This is overloaded to help the test suite determine if the 
 
129
        This is overloaded to help the test suite determine if the
130
130
        target is a directory.
131
131
        """
132
132
        filename = line[1]
136
136
            else:
137
137
                self.respond('550 "%s" is not a file' % (filename,))
138
138
        else:
139
 
            self.respond('213 %d' 
 
139
            self.respond('213 %d'
140
140
                % (self.filesystem.stat(filename)[stat.ST_SIZE]),)
141
141
 
142
142
    def cmd_mkd(self, line):
210
210
        trace.mutter('ftp_server %s: %s', type, message)
211
211
 
212
212
 
213
 
class FTPServer(transport.Server):
 
213
class FTPTestServer(test_server.TestServer):
214
214
    """Common code for FTP server facilities."""
215
215
 
 
216
    no_unicode_support = True
 
217
 
216
218
    def __init__(self):
217
219
        self._root = None
218
220
        self._ftp_server = None
233
235
        """This is used by medusa.ftp_server to log connections, etc."""
234
236
        self.logs.append(message)
235
237
 
236
 
    def setUp(self, vfs_server=None):
237
 
        from bzrlib.transport.local import LocalURLServer
238
 
        if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)):
 
238
    def start_server(self, vfs_server=None):
 
239
        if not (vfs_server is None or isinstance(vfs_server,
 
240
                                                 test_server.LocalURLServer)):
239
241
            raise AssertionError(
240
242
                "FTPServer currently assumes local transport, got %s" % vfs_server)
241
243
        self._root = os.getcwdu()
250
252
        # Don't let it loop forever, or handle an infinite number of requests.
251
253
        # In this case it will run for 1000s, or 10000 requests
252
254
        self._async_thread = threading.Thread(
253
 
                target=FTPServer._asyncore_loop_ignore_EBADF,
 
255
                target=FTPTestServer._asyncore_loop_ignore_EBADF,
254
256
                kwargs={'timeout':0.1, 'count':10000})
255
257
        self._async_thread.setDaemon(True)
256
258
        self._async_thread.start()
257
259
 
258
 
    def tearDown(self):
259
 
        """See bzrlib.transport.Server.tearDown."""
 
260
    def stop_server(self):
260
261
        self._ftp_server.close()
261
262
        asyncore.close_all()
262
263
        self._async_thread.join()
279
280
            if e.args[0] != errno.EBADF:
280
281
                raise
281
282
 
282
 
 
283
 
 
 
283
    def add_user(self, user, password):
 
284
        """Add a user with write access."""
 
285
        authorizer = server = self._ftp_server.authorizer
 
286
        authorizer.secured_user = user
 
287
        authorizer.secured_password = password
284
288