[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] More complete handling of tildes in paths; unit tests f...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv16439/lib/mixminion

Modified Files:
	ClientMain.py Config.py test.py 
Log Message:
More complete handling of tildes in paths; unit tests for _parseFilename

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- ClientMain.py	5 Jun 2003 05:24:23 -0000	1.87
+++ ClientMain.py	5 Jun 2003 05:48:38 -0000	1.88
@@ -880,7 +880,7 @@
     """
     ## Fields:
     # keyDir: The directory where we store our keys.
-    # keyring: DICT XXXX DOCDOC
+    # keyring: DICT DOCDOC
     # keyringPassword: The password for our encrypted keyfile
     ## Format:
     # We store keys in a file holding:
@@ -1314,7 +1314,7 @@
         self.config = conf
 
         # Make directories
-        userdir = os.path.expanduser(self.config['User']['UserDir'])
+        userdir = self.config['User']['UserDir']
         createPrivateDir(userdir)
         keyDir = os.path.join(userdir, "keys")
         self.keys = ClientKeyring(keyDir)
@@ -1903,7 +1903,7 @@
             else:
                 mixminion.Crypto.init_crypto(self.config)
 
-            userdir = os.path.expanduser(self.config['User']['UserDir'])
+            userdir = self.config['User']['UserDir']
             configureClientLock(os.path.join(userdir, "lock"))
         else:
             if self.wantLog:

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- Config.py	30 May 2003 03:07:56 -0000	1.45
+++ Config.py	5 Jun 2003 05:48:38 -0000	1.46
@@ -339,9 +339,8 @@
     return s
 
 def _parseFilename(s):
-    """DOCDOC"""
-    #XXXX004 testme
-    #XXXX004 use this more.
+    """Validation function.  Matches a filename, expanding tildes as
+       appropriate"""
     s = s.strip()
     if s[0] in "\"'":
         if s[-1] != s[0]:
@@ -705,14 +704,14 @@
     _syntax = {
         'Host' : { '__SECTION__' : ('ALLOW', None, None),
                    'ShredCommand': ('ALLOW', _parseCommand, None),
-                   'EntropySource': ('ALLOW', None, "/dev/urandom"),
+                   'EntropySource': ('ALLOW', _parseFilename, "/dev/urandom"),
                    'TrustedUser': ('ALLOW*', None, None),
                    },
         'DirectoryServers' :
                    { '__SECTION__' : ('REQUIRE', None, None),
                      'ServerURL' : ('ALLOW*', None, None),
                      'MaxSkew' : ('ALLOW', _parseInterval, "10 minutes") },
-        'User' : { 'UserDir' : ('ALLOW', None, "~/.mixminion" ) },
+        'User' : { 'UserDir' : ('ALLOW', _parseFilename, "~/.mixminion" ) },
         'Security' : { 'PathLength' : ('ALLOW', _parseInt, "8"),
                        'SURBAddress' : ('ALLOW', None, None),
                        'SURBPathLength' : ('ALLOW', _parseInt, "4"),

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- test.py	5 Jun 2003 05:24:23 -0000	1.116
+++ test.py	5 Jun 2003 05:48:38 -0000	1.117
@@ -3584,6 +3584,12 @@
         self.assertEquals(time.gmtime(tm)[:6], (2001,12,25,6,15,10))
         # nicknames
         self.assertEquals(C._parseNickname("Mrs.Premise"), "Mrs.Premise")
+        # Filenames
+        self.assertEquals(C._parseFilename(" ab/c/d"), "ab/c/d")
+        self.assertEquals(C._parseFilename("  ~/ab/c/d"),
+                          os.path.expanduser("~/ab/c/d"))
+        self.assertEquals(C._parseFilename(" 'ab/c d/d' "), "ab/c d/d")
+        self.assertEquals(C._parseFilename('  "ab/c d/d" '), "ab/c d/d")
 
         SC = mixminion.server.ServerConfig
         # Fractions
@@ -3599,6 +3605,7 @@
         self.assertEquals(SC._parseMixRule("binomialCottrell"),
                           "BinomialCottrellMixPool")
         self.assertEquals(SC._parseMixRule("TIMED"), "TimedMixPool")
+        
 
         ##
         # Now, try the failing cases.
@@ -3659,6 +3666,9 @@
         except ConfigError:
             # This is what we expect
             pass
+
+        # Filenames:
+        fails(C._parseFilename, " 'ab/cd")
 
         # IntervalSet validation
         def warns(mixInterval, retryList, self=self):