From 582af7cd9d4cfd119ee3e27177a0347b1c129f66 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 16 May 2017 17:58:07 -0700 Subject: [PATCH] name_check: better test maximum_length Previously, we were testing that a 254 (!?) character name would be valid when the maximum configured is 500. Now we'll test that 500 character names are valid. While we're at it, stop patching self.test_check. It was unnecessary, and we were doing it badly. Change-Id: Ia604fa7b809a97fbce176c82606af73cdb92828c --- test/unit/common/middleware/test_name_check.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/unit/common/middleware/test_name_check.py b/test/unit/common/middleware/test_name_check.py index eab187cc15..3637ac6b32 100644 --- a/test/unit/common/middleware/test_name_check.py +++ b/test/unit/common/middleware/test_name_check.py @@ -66,12 +66,10 @@ class TestNameCheckMiddleware(unittest.TestCase): def test_maximum_length_from_config(self): # test invalid length - orig_test_check = self.test_check - conf = {'maximum_length': "500"} - self.test_check = name_check.filter_factory(conf)(FakeApp()) - path = '/V1.0/a/c' + 'o' * (500 - 8) + app = name_check.filter_factory({'maximum_length': "500"})(FakeApp()) + path = '/V1.0/a/c/' + 'o' * (500 - 9) resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'} - ).get_response(self.test_check) + ).get_response(app) self.assertEqual( resp.body, ("Object/Container/Account name longer than the allowed " @@ -79,12 +77,11 @@ class TestNameCheckMiddleware(unittest.TestCase): self.assertEqual(resp.status_int, 400) # test valid length - path = '/V1.0/a/c' + 'o' * (MAX_LENGTH - 10) + path = '/V1.0/a/c/' + 'o' * (500 - 10) resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'} - ).get_response(self.test_check) + ).get_response(app) self.assertEqual(resp.status_int, 200) self.assertEqual(resp.body, 'OK') - self.test_check = orig_test_check def test_invalid_length(self): path = '/V1.0/' + 'c' * (MAX_LENGTH - 5)