Add support for Hash Prefix
A new configuration parameter is added to /etc/swift/swift.conf [swift-hash] swift_hash_path_prefix = 'random unique string' New installations are advised to set this parameter to a random secret, which would not be disclosed ouside the organization. The same secret needs to be used by all swift servers of the same cluster. Existing installations should set this parameter to an empty string (the default) DocImpact Fixes: Bug #1157454 Change-Id: I63b10d0b7d6dd3f74e0f10bb41b5f240fa03578a
This commit is contained in:
@@ -135,6 +135,7 @@ class TestObjectReplicator(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
utils.HASH_PATH_SUFFIX = 'endcap'
|
||||
utils.HASH_PATH_PREFIX = ''
|
||||
# Setup a test ring (stolen from common/test_ring.py)
|
||||
self.testdir = tempfile.mkdtemp()
|
||||
self.devices = os.path.join(self.testdir, 'node')
|
||||
|
||||
@@ -383,6 +383,7 @@ class TestObjectController(unittest.TestCase):
|
||||
def setUp(self):
|
||||
""" Set up for testing swift.object_server.ObjectController """
|
||||
utils.HASH_PATH_SUFFIX = 'endcap'
|
||||
utils.HASH_PATH_PREFIX = 'startcap'
|
||||
self.testdir = \
|
||||
os.path.join(mkdtemp(), 'tmp_test_object_server_ObjectController')
|
||||
mkdirs(os.path.join(self.testdir, 'sda1', 'tmp'))
|
||||
@@ -1808,6 +1809,8 @@ class TestObjectController(unittest.TestCase):
|
||||
'x-trans-id': '-'}})
|
||||
|
||||
def test_async_update_saves_on_exception(self):
|
||||
_prefix = utils.HASH_PATH_PREFIX
|
||||
utils.HASH_PATH_PREFIX = ''
|
||||
|
||||
def fake_http_connect(*args):
|
||||
raise Exception('test')
|
||||
@@ -1820,6 +1823,7 @@ class TestObjectController(unittest.TestCase):
|
||||
{'x-timestamp': '1', 'x-out': 'set'}, 'sda1')
|
||||
finally:
|
||||
object_server.http_connect = orig_http_connect
|
||||
utils.HASH_PATH_PREFIX = _prefix
|
||||
self.assertEquals(
|
||||
pickle.load(open(os.path.join(self.testdir, 'sda1',
|
||||
'async_pending', 'a83',
|
||||
@@ -1828,6 +1832,8 @@ class TestObjectController(unittest.TestCase):
|
||||
'container': 'c', 'obj': 'o', 'op': 'PUT'})
|
||||
|
||||
def test_async_update_saves_on_non_2xx(self):
|
||||
_prefix = utils.HASH_PATH_PREFIX
|
||||
utils.HASH_PATH_PREFIX = ''
|
||||
|
||||
def fake_http_connect(status):
|
||||
|
||||
@@ -1860,6 +1866,7 @@ class TestObjectController(unittest.TestCase):
|
||||
'op': 'PUT'})
|
||||
finally:
|
||||
object_server.http_connect = orig_http_connect
|
||||
utils.HASH_PATH_PREFIX = _prefix
|
||||
|
||||
def test_async_update_does_not_save_on_2xx(self):
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class TestObjectUpdater(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
utils.HASH_PATH_SUFFIX = 'endcap'
|
||||
utils.HASH_PATH_PREFIX = ''
|
||||
self.testdir = os.path.join(os.path.dirname(__file__),
|
||||
'object_updater')
|
||||
rmtree(self.testdir, ignore_errors=1)
|
||||
|
||||
Reference in New Issue
Block a user