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
This commit is contained in:
zheng yin 2016-09-23 18:07:28 +08:00
parent 937bc73a72
commit f07dfa202d

View File

@ -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',