Changeset 2cb0581 in trunk


Ignore:
Timestamp:
2007-12-12T02:47:04Z (17 years ago)
Author:
Brian Warner <warner@…>
Branches:
master
Children:
38d1af7
Parents:
b085097
Message:

test_web.py: survive localdir/localfile= names with spaces. Should close #223

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/test/test_web.py

    rb085097 r2cb0581  
    445445
    446446    def test_GET_FILEURL_localfile(self):
    447         localfile = os.path.abspath("web/GET_FILEURL_localfile")
    448         url = self.public_url + "/foo/bar.txt?t=download&localfile=%s" % localfile
     447        localfile = os.path.abspath("web/GET_FILEURL_local file")
     448        url = (self.public_url + "/foo/bar.txt?t=download&localfile=%s" %
     449               urllib.quote(localfile))
    449450        fileutil.make_dirs("web")
    450451        d = self.GET(url)
     
    457458
    458459    def test_GET_FILEURL_localfile_disabled(self):
    459         localfile = os.path.abspath("web/GET_FILEURL_localfile_disabled")
    460         url = self.public_url + "/foo/bar.txt?t=download&localfile=%s" % localfile
     460        localfile = os.path.abspath("web/GET_FILEURL_local file_disabled")
     461        url = (self.public_url + "/foo/bar.txt?t=download&localfile=%s" %
     462               urllib.quote(localfile))
    461463        fileutil.make_dirs("web")
    462464        self.disable_local_access()
     
    473475        old_LOCALHOST = webish.LOCALHOST
    474476        webish.LOCALHOST = "127.0.0.2"
    475         localfile = os.path.abspath("web/GET_FILEURL_localfile_nonlocal")
     477        localfile = os.path.abspath("web/GET_FILEURL_local file_nonlocal")
    476478        fileutil.make_dirs("web")
    477479        d = self.GET(self.public_url + "/foo/bar.txt?t=download&localfile=%s"
    478                      % localfile)
     480                     % urllib.quote(localfile))
    479481        d.addBoth(self.shouldFail, error.Error, "localfile non-local",
    480482                  "403 Forbidden",
     
    493495        fileutil.make_dirs("web/nonabsolute")
    494496        d = self.GET(self.public_url + "/foo/bar.txt?t=download&localfile=%s"
    495                      % localfile)
     497                     % urllib.quote(localfile))
    496498        d.addBoth(self.shouldFail, error.Error, "localfile non-absolute",
    497499                  "403 Forbidden",
     
    503505
    504506    def test_PUT_NEWFILEURL_localfile(self):
    505         localfile = os.path.abspath("web/PUT_NEWFILEURL_localfile")
    506         url = self.public_url + "/foo/new.txt?t=upload&localfile=%s" % localfile
     507        localfile = os.path.abspath("web/PUT_NEWFILEURL_local file")
     508        url = (self.public_url + "/foo/new.txt?t=upload&localfile=%s" %
     509               urllib.quote(localfile))
    507510        fileutil.make_dirs("web")
    508511        f = open(localfile, "wb")
     
    517520
    518521    def test_PUT_NEWFILEURL_localfile_disabled(self):
    519         localfile = os.path.abspath("web/PUT_NEWFILEURL_localfile_disabled")
    520         url = self.public_url + "/foo/new.txt?t=upload&localfile=%s" % localfile
     522        localfile = os.path.abspath("web/PUT_NEWFILEURL_local file_disabled")
     523        url = (self.public_url + "/foo/new.txt?t=upload&localfile=%s" %
     524               urllib.quote(localfile))
    521525        fileutil.make_dirs("web")
    522526        f = open(localfile, "wb")
     
    531535
    532536    def test_PUT_NEWFILEURL_localfile_mkdirs(self):
    533         localfile = os.path.abspath("web/PUT_NEWFILEURL_localfile_mkdirs")
     537        localfile = os.path.abspath("web/PUT_NEWFILEURL_local file_mkdirs")
    534538        fileutil.make_dirs("web")
    535539        f = open(localfile, "wb")
     
    537541        f.close()
    538542        d = self.PUT(self.public_url + "/foo/newdir/new.txt?t=upload&localfile=%s"
    539                      % localfile, "")
     543                     % urllib.quote(localfile), "")
    540544        d.addCallback(self.failUnlessURIMatchesChild,
    541545                      self._foo_node, "newdir/new.txt")
     
    715719
    716720    def test_GET_DIRURL_localdir(self):
    717         localdir = os.path.abspath("web/GET_DIRURL_localdir")
     721        localdir = os.path.abspath("web/GET_DIRURL_local dir")
    718722        fileutil.make_dirs("web")
    719         d = self.GET(self.public_url + "/foo?t=download&localdir=%s" % localdir)
     723        d = self.GET(self.public_url + "/foo?t=download&localdir=%s" %
     724                     urllib.quote(localdir))
    720725        def _check(res):
    721726            barfile = os.path.join(localdir, "bar.txt")
     
    731736
    732737    def test_GET_DIRURL_localdir_disabled(self):
    733         localdir = os.path.abspath("web/GET_DIRURL_localdir_disabled")
     738        localdir = os.path.abspath("web/GET_DIRURL_local dir_disabled")
    734739        fileutil.make_dirs("web")
    735740        self.disable_local_access()
    736         d = self.GET(self.public_url + "/foo?t=download&localdir=%s" % localdir)
     741        d = self.GET(self.public_url + "/foo?t=download&localdir=%s" %
     742                     urllib.quote(localdir))
    737743        d.addBoth(self.shouldFail, error.Error, "localfile disabled",
    738744                  "403 Forbidden",
     
    741747
    742748    def test_GET_DIRURL_localdir_nonabsolute(self):
    743         localdir = "web/nonabsolute/dirpath"
     749        localdir = "web/nonabsolute/dir path"
    744750        fileutil.make_dirs("web/nonabsolute")
    745         d = self.GET(self.public_url + "/foo?t=download&localdir=%s" % localdir)
     751        d = self.GET(self.public_url + "/foo?t=download&localdir=%s" %
     752                     urllib.quote(localdir))
    746753        d.addBoth(self.shouldFail, error.Error, "localdir non-absolute",
    747754                  "403 Forbidden",
     
    811818
    812819    def test_PUT_NEWDIRURL_localdir(self):
    813         localdir = os.path.abspath("web/PUT_NEWDIRURL_localdir")
     820        localdir = os.path.abspath("web/PUT_NEWDIRURL_local dir")
    814821        # create some files there
    815822        fileutil.make_dirs(os.path.join(localdir, "one"))
     
    822829
    823830        d = self.PUT(self.public_url + "/newdir?t=upload&localdir=%s"
    824                      % localdir, "")
     831                     % urllib.quote(localdir), "")
    825832        pr = self.public_root
    826833        d.addCallback(lambda res: self.failUnlessNodeHasChild(pr, "newdir"))
     
    840847
    841848    def test_PUT_NEWDIRURL_localdir_disabled(self):
    842         localdir = os.path.abspath("web/PUT_NEWDIRURL_localdir_disabled")
     849        localdir = os.path.abspath("web/PUT_NEWDIRURL_local dir_disabled")
    843850        # create some files there
    844851        fileutil.make_dirs(os.path.join(localdir, "one"))
     
    852859        self.disable_local_access()
    853860        d = self.PUT(self.public_url + "/newdir?t=upload&localdir=%s"
    854                      % localdir, "")
     861                     % urllib.quote(localdir), "")
    855862        d.addBoth(self.shouldFail, error.Error, "localfile disabled",
    856863                  "403 Forbidden",
     
    859866
    860867    def test_PUT_NEWDIRURL_localdir_mkdirs(self):
    861         localdir = os.path.abspath("web/PUT_NEWDIRURL_localdir_mkdirs")
     868        localdir = os.path.abspath("web/PUT_NEWDIRURL_local dir_mkdirs")
    862869        # create some files there
    863870        fileutil.make_dirs(os.path.join(localdir, "one"))
     
    870877
    871878        d = self.PUT(self.public_url + "/foo/subdir/newdir?t=upload&localdir=%s"
    872                      % localdir,
     879                     % urllib.quote(localdir),
    873880                     "")
    874881        fn = self._foo_node
Note: See TracChangeset for help on using the changeset viewer.