Ignore:
Timestamp:
31/05/06 17:03:55 (14 years ago)
Author:
spascoe
Message:

Python code can read an authorisation message from the client.

Test cases confirm message passing client->server->python is working.

File:
1 edited

Legend:

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

    r1074 r1075  
    1616BBFTP = glob('%s/src/bbftp-client*/bbftpc/bbftp' % HOME)[0] 
    1717DATADIR = '%s/test/data' % HOME 
     18NDG_MESSAGE_LEN = 256 
     19 
    1820sys.path.append(BUILDDIR) 
    1921import bbftpd 
    2022         
    21 class AuthContext(object): 
     23class AuthzContext: 
     24    def __init__(self, version_msg, user): 
     25        self.version = version_msg 
     26        self.username = user 
     27 
     28class AuthContext: 
    2229    def authorise(self): 
    23         # Return a dummy authzContext 
    24         return AuthzContext("JoeBloggs") 
     30        # Read the auth version message 
     31        msg = bbftpd.recv(NDG_MESSAGE_LEN) 
     32        # Trim to first '\0' 
     33        x = msg.find('\0') 
     34        if x: 
     35            msg = msg[:x] 
    2536 
    26 class AuthzContext(object): 
    27     def __init__(self, username): 
    28         self.username = username 
     37        syslog.syslog(syslog.LOG_DEBUG, 'AuthContext received Auth message: %s' % msg) 
     38         
     39        return AuthzContext(msg, "TestCaseUser") 
    2940 
    3041class EmbeddedServerTestCase(unittest.TestCase): 
     
    6273        lines = self._readSyslog() 
    6374        self.assert_(self._findLines(['.*Getting new bbftp connexion.*', 
    64                                       '.*Received auth message: NDG-bbFTP.*', 
     75                                      '.*AuthContext received Auth message: NDG-bbFTP.*', 
    6576                                      r'.*Authz: MSG_LIST_V2 .*/test/data/\*.*', 
    66                                       r'.*User JoeBloggs disconnected.*'], lines)) 
     77                                      r'.*User TestCaseUser disconnected.*'], lines)) 
    6778 
    6879 
     
    8495        # Check syslog 
    8596        lines = self._readSyslog() 
    86         self.assert_(self._findLines(['.*Authz: RETR .*/foo', '.*GET JoeBloggs .*/foo.*'], lines)) 
     97        self.assert_(self._findLines(['.*Authz: RETR .*/foo', '.*GET TestCaseUser .*/foo.*'], lines)) 
    8798 
    8899    def testStore(self): 
     
    107118        # Check syslog 
    108119        lines = self._readSyslog() 
    109         self.assert_(self._findLines(['.*Authz: STORE .*/new_bar', '.*PUT JoeBloggs .*/new_bar.*'], lines)) 
     120        self.assert_(self._findLines(['.*Authz: STORE .*/new_bar', '.*PUT TestCaseUser .*/new_bar.*'], lines)) 
    110121 
    111122 
Note: See TracChangeset for help on using the changeset viewer.