Merge "Expirer now quotes names when deleting"
This commit is contained in:
commit
6a06b59347
@ -13,6 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import urllib
|
||||||
from random import random
|
from random import random
|
||||||
from time import time
|
from time import time
|
||||||
from os.path import join
|
from os.path import join
|
||||||
@ -162,6 +163,7 @@ class ObjectExpirer(Daemon):
|
|||||||
:param timestamp: The timestamp the X-Delete-At value must match to
|
:param timestamp: The timestamp the X-Delete-At value must match to
|
||||||
perform the actual delete.
|
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)},
|
{'X-If-Delete-At': str(timestamp)},
|
||||||
(2, HTTP_NOT_FOUND, HTTP_PRECONDITION_FAILED))
|
(2, HTTP_NOT_FOUND, HTTP_PRECONDITION_FAILED))
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import urllib
|
||||||
from time import time
|
from time import time
|
||||||
from unittest import main, TestCase
|
from unittest import main, TestCase
|
||||||
from test.unit import FakeLogger
|
from test.unit import FakeLogger
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from swift.common import internal_client
|
from swift.common import internal_client
|
||||||
from swift.obj import expirer
|
from swift.obj import expirer
|
||||||
|
|
||||||
@ -512,5 +515,16 @@ class TestObjectExpirer(TestCase):
|
|||||||
pass
|
pass
|
||||||
self.assertEquals(503, exc.resp.status_int)
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user