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_embedded.py

    r1075 r1077  
    1616BBFTP = glob('%s/src/bbftp-client*/bbftpc/bbftp' % HOME)[0] 
    1717DATADIR = '%s/test/data' % HOME 
     18VERSION = open('%s/VERSION' % HOME).read() 
    1819NDG_MESSAGE_LEN = 256 
     20 
     21NDG_HANDSHAKE = "NDG-Delivery-server %s" % VERSION 
    1922 
    2023sys.path.append(BUILDDIR) 
     
    3639 
    3740        syslog.syslog(syslog.LOG_DEBUG, 'AuthContext received Auth message: %s' % msg) 
    38          
     41 
     42        # Send the response 
     43        msg = NDG_HANDSHAKE + '\0' * (NDG_MESSAGE_LEN - len(NDG_HANDSHAKE)) 
     44        bbftpd.send(msg) 
     45             
    3946        return AuthzContext(msg, "TestCaseUser") 
    4047 
     
    6471 
    6572 
    66         fh = self._runClient('-e "dir %s"' % DATADIR) 
     73        fh = self._runClient("dir %s" % DATADIR) 
    6774        output = fh.read() 
    6875 
     
    7380        lines = self._readSyslog() 
    7481        self.assert_(self._findLines(['.*Getting new bbftp connexion.*', 
    75                                       '.*AuthContext received Auth message: NDG-bbFTP.*', 
     82                                      '.*AuthContext received Auth message: NDG-Delivery-client %s' % VERSION, 
    7683                                      r'.*Authz: MSG_LIST_V2 .*/test/data/\*.*', 
    7784                                      r'.*User TestCaseUser disconnected.*'], lines)) 
     
    8390 
    8491        tmp = tempfile.mktemp('test_bbftpd') 
    85         fh = self._runClient('-e "get %s/foo %s"' % (DATADIR, tmp)) 
     92        fh = self._runClient("get %s/foo %s" % (DATADIR, tmp)) 
    8693 
    8794        # Check the client output 
     
    105112        dest = '%s/new_bar' % (DATADIR) 
    106113        os.system('cp %s %s' % (src, dest)) 
    107         fh = self._runClient('-e "put %s %s"' % (src, dest)) 
     114        fh = self._runClient("put %s %s" % (src, dest)) 
    108115 
    109116        # Check the client output 
     
    134141        syslog.syslog(syslog.LOG_DEBUG, 'Stopping server') 
    135142 
    136     def _runClient(self, *args): 
    137         """Run the client with th -m option and return a file handle of the output. 
     143 
     144    def _runClient(self, cmd, debug=False, user="testcase"): 
     145        """Run the client. 
    138146        """ 
    139         fh = os.popen('%s -m -u testcase %s localhost' % (BBFTP, ' '.join(args))) 
     147 
     148        if debug: 
     149            f = "-d" 
     150        else: 
     151            f = "-m" 
     152         
     153        fh = os.popen('%s %s -u %s -e %s localhost' % (BBFTP, f, user, repr(cmd))) 
    140154        return fh 
     155 
    141156 
    142157    def _readSyslog(self, logfile="/var/log/bbftpd/bbftpd.log"): 
Note: See TracChangeset for help on using the changeset viewer.