Expirer now quotes names when deleting

Change-Id: I5c615c6f32967510f09b783b1ba7089119f1d8bd
This commit is contained in:
gholt 2013-04-15 22:12:23 +00:00
parent 59f6779603
commit c354db2158
2 changed files with 17 additions and 1 deletions

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import urllib
from random import random
from time import time
from os.path import join
@ -162,6 +163,7 @@ class ObjectExpirer(Daemon):
:param timestamp: The timestamp the X-Delete-At value must match to
perform the actual delete.
"""
self.swift.make_request('DELETE', '/v1/%s' % actual_obj.lstrip('/'),
path = '/v1/' + urllib.quote(actual_obj.lstrip('/'))
self.swift.make_request('DELETE', path,
{'X-If-Delete-At': str(timestamp)},
(2, HTTP_NOT_FOUND, HTTP_PRECONDITION_FAILED))

View File

@ -13,10 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import urllib
from time import time
from unittest import main, TestCase
from test.unit import FakeLogger
import mock
from swift.common import internal_client
from swift.obj import expirer
@ -512,5 +515,16 @@ class TestObjectExpirer(TestCase):
pass
self.assertEquals(503, exc.resp.status_int)
def test_delete_actual_object_quotes(self):
name = 'this name should get quoted'
timestamp = '1366063156.863045'
x = expirer.ObjectExpirer({})
x.swift.make_request = mock.MagicMock()
x.delete_actual_object(name, timestamp)
x.swift.make_request.assert_called_once()
self.assertEquals(x.swift.make_request.call_args[0][1],
'/v1/' + urllib.quote(name))
if __name__ == '__main__':
main()