Ignore:
Timestamp:
06/06/06 15:01:09 (14 years ago)
Author:
spascoe
Message:

Python code on the server will now receive the private string from the
client. This is the basic requirement for doing bbftp authentication
within python.

Slightly higher level message passing functions ndg_message_send/recv are now
bound to python callbacks bbftpd.send and bbftpd.recv.

File:
1 edited

Legend:

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

    r1077 r1100  
    3232    def authorise(self): 
    3333        # Read the auth version message 
    34         msg = bbftpd.recv(NDG_MESSAGE_LEN) 
     34        msg = bbftpd.recv() 
    3535        # Trim to first '\0' 
    3636        x = msg.find('\0') 
     
    4343        msg = NDG_HANDSHAKE + '\0' * (NDG_MESSAGE_LEN - len(NDG_HANDSHAKE)) 
    4444        bbftpd.send(msg) 
    45              
     45 
     46        # Get privatestr 
     47        privatestr = bbftpd.recv() 
     48        # Trim to first '\0' 
     49        x = privatestr.find('\0') 
     50        if x: 
     51            privatestr = privatestr[:x] 
     52        syslog.syslog(syslog.LOG_DEBUG, "AuthContext received privatestr: %s" % privatestr) 
     53 
    4654        return AuthzContext(msg, "TestCaseUser") 
    4755 
     
    6472    def testStartup(self): 
    6573        lines = self._readSyslog() 
     74        # Give syslog time to flush it's logs. 
     75        time.sleep(1) 
    6676        self.assert_(self._findLines(['.*Starting bbftpd'], lines)) 
    6777 
     
    8090        lines = self._readSyslog() 
    8191        self.assert_(self._findLines(['.*Getting new bbftp connexion.*', 
    82                                       '.*AuthContext received Auth message: NDG-Delivery-client %s' % VERSION, 
    8392                                      r'.*Authz: MSG_LIST_V2 .*/test/data/\*.*', 
    8493                                      r'.*User TestCaseUser disconnected.*'], lines)) 
    8594 
     95 
     96    def testHandshake(self): 
     97        """Verify handshake messages are exchanged. 
     98        """ 
     99 
     100        fh = self._runClient("dir .", debug=True) 
     101        output = fh.read() 
     102 
     103        self.assert_(self._findLines(['Received Auth handshake: NDG-Delivery-server %s' % VERSION], output)) 
     104 
     105        lines = self._readSyslog() 
     106        self.assert_(self._findLines(['.*AuthContext received Auth message: NDG-Delivery-client %s' % VERSION], lines)) 
     107 
     108    def testPrivateStr(self): 
     109        """Verify the private string is sent to server. 
     110        """ 
     111 
     112        fh = self._runClient("dir .", privatestr="testPrivateStr") 
     113        output = fh.read() 
     114 
     115        lines = self._readSyslog() 
     116        self.assert_(self._findLines(['.*AuthContext received privatestr: testPrivateStr'], lines)) 
    86117 
    87118    def testRetr(self): 
     
    133164    def _startServer(self): 
    134165        # Start the server and store it's PID 
    135         self.pid = bbftpd.run(AuthContext(), ['-l', 'DEBUG']) 
     166        self.authContext = AuthContext() 
     167        self.pid = bbftpd.run(self.authContext, ['-l', 'DEBUG']) 
    136168 
    137169    def _stopServer(self): 
     
    142174 
    143175 
    144     def _runClient(self, cmd, debug=False, user="testcase"): 
     176    def _runClient(self, cmd, debug=False, user="testcase", privatestr=None): 
    145177        """Run the client. 
    146178        """ 
     
    150182        else: 
    151183            f = "-m" 
    152          
    153         fh = os.popen('%s %s -u %s -e %s localhost' % (BBFTP, f, user, repr(cmd))) 
     184 
     185        if privatestr == None: 
     186            p = "" 
     187        else: 
     188            p = "-P %s" % repr(privatestr) 
     189         
     190        fh = os.popen('%s %s %s -u %s -e %s localhost' % (BBFTP, f, p, user, repr(cmd))) 
    154191        return fh 
    155192 
Note: See TracChangeset for help on using the changeset viewer.