Ignore:
Timestamp:
01/06/06 15:18:02 (13 years ago)
Author:
spascoe
Message:

Implemented full client-server handshake. A version message is now
exchanged client->server then server->client. These messages are logged
in debug mode. Message passing is implemented in Python on the server (at the
moment this is only implemented within test/test_embedded.py).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/test/test_bbftpd.py

    r1064 r1077  
    1111from glob import glob 
    1212import re, tempfile 
     13 
     14 
    1315 
    1416class ExtendedAPITestCase(unittest.TestCase): 
     
    5759        self.assert_(self._findLines(['.*Starting bbftpd in background mode'], lines)) 
    5860 
     61    def testHandshake(self): 
     62        """Connect with client in verbose mode and test Auth handhsake is received. 
     63        """ 
     64 
     65        self._startServer() 
     66        pid = self._getServerPid() 
     67 
     68        fh = self._runClient('dir .', debug=True) 
     69        output = fh.read() 
     70 
     71        self._stopServer(pid) 
     72 
     73        self.assert_(self._findLines(['Received Auth handshake: NDG-Delivery-server %s' % self.VERSION], output)) 
     74 
     75        lines = self._readSyslog() 
     76        self.assert_(self._findLines(['.*Received auth message: NDG-Delivery-client %s.*' % self.VERSION], lines)) 
     77 
     78 
    5979    def testDir(self): 
    6080        """Try connecting the client and listing a directory. 
     
    6484        pid = self._getServerPid() 
    6585 
    66         fh = self._runClient('-e "dir %s"' % self.DATADIR) 
     86        fh = self._runClient('dir %s' % self.DATADIR) 
    6787        output = fh.read() 
    6888 
     
    7494        lines = self._readSyslog() 
    7595        self.assert_(self._findLines(['.*Getting new bbftp connexion.*', 
    76                                       '.*Received auth message: NDG-bbFTP.*', 
    7796                                      r'.*Authz: MSG_LIST_V2 .*/test/data/\*.*', 
    7897                                      r'.*User  disconnected.*'], lines)) 
     
    86105 
    87106        tmp = tempfile.mktemp('test_bbftpd') 
    88         fh = self._runClient('-e "get %s/foo %s"' % (self.DATADIR, tmp)) 
     107        fh = self._runClient('get %s/foo %s' % (self.DATADIR, tmp)) 
    89108 
    90109        # Check the client output 
     
    112131        dest = '%s/new_bar' % (self.DATADIR) 
    113132        os.system('cp %s %s' % (src, dest)) 
    114         fh = self._runClient('-e "put %s %s"' % (src, dest)) 
     133        fh = self._runClient('put %s %s' % (src, dest)) 
    115134 
    116135        # Check the client output 
     
    147166        else: 
    148167            raise RuntimeError, 'Cannot find test data directory' 
     168        self.VERSION = open('%s/VERSION' % self.HOME).read() 
     169 
    149170 
    150171    def _startServer(self): 
     
    192213        return ''.join(filtered_log) 
    193214 
    194     def _runClient(self, *args): 
    195         """Run the client with th -m option and return a file handle of the output. 
    196         """ 
    197         fh = os.popen('%s -m -u testcase %s localhost' % (self.BBFTP, ' '.join(args))) 
     215    def _runClient(self, cmd, debug=False, user="testcase"): 
     216        """Run the client. 
     217        """ 
     218 
     219        if debug: 
     220            f = "-d" 
     221        else: 
     222            f = "-m" 
     223         
     224        fh = os.popen('%s %s -u %s -e %s localhost' % (self.BBFTP, f, user, repr(cmd))) 
    198225        return fh 
    199226 
Note: See TracChangeset for help on using the changeset viewer.