[apt-proxy-devel] r648 - trunk/apt_proxy/test

Chris Halls halls at alioth.debian.org
Tue Apr 17 21:53:11 UTC 2007


Author: halls
Date: Tue Apr 17 21:53:10 2007
New Revision: 648

Modified:
   trunk/apt_proxy/test/test_requests.py
Log:
* Add decompressors to tests, and unmark as todo
* Add test for valid /../ in path


Modified: trunk/apt_proxy/test/test_requests.py
==============================================================================
--- trunk/apt_proxy/test/test_requests.py	(original)
+++ trunk/apt_proxy/test/test_requests.py	Tue Apr 17 21:53:10 2007
@@ -37,10 +37,18 @@
     class containing test data for a request
     """
     def __init__(self, filename, expectedResponse, if_modified_since=None, expectedSize=None, filePath=None, abortTransfer=False):
-        self.filename = filename
+        """
+        Initialise data for client testing
+        @param filename Name of file to be sent in request from apt client
+        @param expectedResponse HTTP response expected from apt-proxy
+        @param expectedSize Size of file that should be sent back to client. See also filePath
+        @param filePath Path to source file - used to automatically calculate expectedSize instead of supplying expectedSize directly
+        @param abortTransfer Close connection before transfer is complete to test error handling
+        """
+        self.filename = filename 
         self.expectedResponse = expectedResponse
         self.if_modified_since = if_modified_since
-        self.filePath = filePath
+        self.filePath = filePath # Path to source file, used to calculate expected size
         self.abortTransfer = abortTransfer
 
         if expectedSize is not None:
@@ -310,7 +318,7 @@
         backend_uri = self.protocol + "://127.0.0.1:" + str(self.port)
         if self.uriSuffix:
             backend_uri += '/' + self.uriSuffix
-        config = ("dynamic_backends=off\n" +
+        config = ("dynamic_backends=off\nuse_experimental_decompressors=on\n" +
                   "[test_data]\n" +
                   "backends=" + str(backend_uri))
         TestRequestHelper.setUp(self, config)
@@ -396,12 +404,10 @@
         filename = self.calcFilePaths(self.packagesTestFile)[0][1:] # Remove leading '/' from path
         backend = self.factory.getBackend(self.backendName)
         self.assertEquals(backend.get_packages_db().packages.get_files(), [filename])
-    testPackagesGzFile.todo = "Need to test this"
 
     def testPackagesBz2File(self):
         return self.downloadFile(self.packagesTestFile+'.bz2').addCallback(self.PackagesUncompressed)
     testPackagesBz2File.timeout = 2
-    testPackagesBz2File.todo = "Need to test this code"
 
     def testNotModifiedGreater(self):
         "Check http not modified is sent for new file"
@@ -545,7 +551,7 @@
 
     def testTilde(self):
         return self.downloadFiles('/packages/tilde~test.txt')
-    testTilde.timeout = 10
+    testTilde.timeout = 2
 
     def testConnectionRefused(self):
         self.server.stop()
@@ -584,6 +590,14 @@
         dl = defer.DeferredList([d1,d2])
         dl.chainDeferred(self.testResult)
         
+    def testDotDot(self):
+        "Check path containing /../"
+        #filename, sourcepath, destpath = self.getFilePaths('/packages/apt_0.0.1_test.deb')
+        #return self.doRequest(uriData(filename, http.OK, filePath = os.path.normpath(destpath)))
+        filename, sourcepath, destpath = self.getFilePaths('/packages/apt_0.0.1_test.deb')
+        return self.doRequest(uriData(filename.replace('/','/foo/../'), http.OK, filePath=sourcepath, abortTransfer=True))
+    testDotDot.timeout = 2
+        
     #def testTimeout(self):
         #pass
     #testTimeout.todo = True



More information about the apt-proxy-devel mailing list