From f07dfa202d98c0e9500b71a0040db32183a8106e Mon Sep 17 00:00:00 2001 From: zheng yin Date: Fri, 23 Sep 2016 18:07:28 +0800 Subject: [PATCH] Add test_PUT/DELETE_bad_timestamp in obj/test_server It has valid_timestamp() to check timestamps in /POST/PUT/DELETE methods. It has test_POST_bad_timestamps in Post, but it has no test_PUT/DELETE_bad_timestamps int PUT/DELETE. Therefore,I add them Change-Id: Ib531f3b7819c1c8dc69a7b51d990581bf1e24dab --- test/unit/obj/test_server.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py index 4807ccf01f..db20c41f5e 100755 --- a/test/unit/obj/test_server.py +++ b/test/unit/obj/test_server.py @@ -1068,6 +1068,13 @@ class TestObjectController(unittest.TestCase): resp = req.get_response(self.object_controller) self.assertEqual(resp.status_int, 400) + def test_PUT_bad_timestamp(self): + req = Request.blank( + '/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + headers={'X-Timestamp': 'bad'}) + resp = req.get_response(self.object_controller) + self.assertEqual(resp.status_int, 400) + def test_PUT_no_content_type(self): req = Request.blank( '/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, @@ -3639,6 +3646,13 @@ class TestObjectController(unittest.TestCase): self.assertTrue(os.path.isfile(ts_1003_file)) self.assertEqual(len(os.listdir(os.path.dirname(ts_1003_file))), 1) + def test_DELETE_bad_timestamp(self): + req = Request.blank( + '/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}, + headers={'X-Timestamp': 'bad'}) + resp = req.get_response(self.object_controller) + self.assertEqual(resp.status_int, 400) + def test_DELETE_succeeds_with_later_POST(self): t_put = next(self.ts).internal req = Request.blank('/sda1/p/a/c/o',