From e92191306587335ad0aab3a3b9dffef21765e17b Mon Sep 17 00:00:00 2001 From: Clay Gerrard Date: Mon, 19 Aug 2019 11:06:20 -0500 Subject: [PATCH] Rename symlink method Related-Change-Id: I179ea6180d31146bb947061c69b1807c59529ac8 Change-Id: I770ea1be25e339e5ce4341b532a1fff9e1373152 --- swift/common/middleware/symlink.py | 4 ++-- test/unit/common/middleware/test_symlink.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/swift/common/middleware/symlink.py b/swift/common/middleware/symlink.py index c5e727e4f5..a23aa4fd4f 100644 --- a/swift/common/middleware/symlink.py +++ b/swift/common/middleware/symlink.py @@ -229,7 +229,7 @@ TGT_BYTES_SYSMETA_SYMLINK_HDR = \ get_sys_meta_prefix('object') + 'symlink-target-bytes' -def _check_symlink_header(req): +def _validate_and_prep_request_headers(req): """ Validate that the value from x-symlink-target header is well formatted and that the x-symlink-target-etag header (if present) does not contain @@ -561,7 +561,7 @@ class SymlinkObjectContext(WSGIContext): request=req, content_type='text/plain') - symlink_target_path, etag = _check_symlink_header(req) + symlink_target_path, etag = _validate_and_prep_request_headers(req) if etag: resp = self._validate_etag_and_update_sysmeta( req, symlink_target_path, etag) diff --git a/test/unit/common/middleware/test_symlink.py b/test/unit/common/middleware/test_symlink.py index 359e82a19e..d37dd69b7f 100644 --- a/test/unit/common/middleware/test_symlink.py +++ b/test/unit/common/middleware/test_symlink.py @@ -653,11 +653,11 @@ class TestSymlinkMiddleware(TestSymlinkMiddlewareBase): status, headers, body = self.call_sym(req) self.assertEqual(status, '404 Not Found') - def test_check_symlink_header(self): + def test_validate_and_prep_request_headers(self): def do_test(headers): req = Request.blank('/v1/a/c/o', method='PUT', headers=headers) - symlink._check_symlink_header(req) + symlink._validate_and_prep_request_headers(req) # normal cases do_test({'X-Symlink-Target': 'c1/o1'}) @@ -682,12 +682,12 @@ class TestSymlinkMiddleware(TestSymlinkMiddlewareBase): {'X-Symlink-Target': 'cont/obj', 'X-Symlink-Target-Account': swob.wsgi_quote(target)}) - def test_check_symlink_header_invalid_format(self): + def test_validate_and_prep_request_headers_invalid_format(self): def do_test(headers, status, err_msg): req = Request.blank('/v1/a/c/o', method='PUT', headers=headers) with self.assertRaises(swob.HTTPException) as cm: - symlink._check_symlink_header(req) + symlink._validate_and_prep_request_headers(req) self.assertEqual(cm.exception.status, status) self.assertEqual(cm.exception.body, err_msg) @@ -747,11 +747,11 @@ class TestSymlinkMiddleware(TestSymlinkMiddlewareBase): '412 Precondition Failed', b'Account name cannot contain slashes') - def test_check_symlink_header_points_to_itself(self): + def test_validate_and_prep_request_headers_points_to_itself(self): req = Request.blank('/v1/a/c/o', method='PUT', headers={'X-Symlink-Target': 'c/o'}) with self.assertRaises(swob.HTTPException) as cm: - symlink._check_symlink_header(req) + symlink._validate_and_prep_request_headers(req) self.assertEqual(cm.exception.status, '400 Bad Request') self.assertEqual(cm.exception.body, b'Symlink cannot target itself') @@ -760,7 +760,7 @@ class TestSymlinkMiddleware(TestSymlinkMiddlewareBase): headers={'X-Symlink-Target': 'c/o', 'X-Symlink-Target-Account': 'a'}) with self.assertRaises(swob.HTTPException) as cm: - symlink._check_symlink_header(req) + symlink._validate_and_prep_request_headers(req) self.assertEqual(cm.exception.status, '400 Bad Request') self.assertEqual(cm.exception.body, b'Symlink cannot target itself') @@ -768,7 +768,7 @@ class TestSymlinkMiddleware(TestSymlinkMiddlewareBase): req = Request.blank('/v1/a/c/o', method='PUT', headers={'X-Symlink-Target': 'c/o', 'X-Symlink-Target-Account': 'a1'}) - symlink._check_symlink_header(req) + symlink._validate_and_prep_request_headers(req) def test_symloop_max_config(self): self.app = FakeSwift()