use path as resource id when missing RESELLER prefix
we don't have an id if RESELLER prefix is not in path. this causes an id to be autogenerated making each request a completely different resource id. this patch changes it so we just default to path as our id if one cannot be computed. Change-Id: I5775406a84b5f2ad0f95f366b7deca210d2f8e87 Closes-Bug: #1566940
This commit is contained in:
parent
db6dccbc6d
commit
0789e5e30c
@ -216,7 +216,7 @@ class Swift(object):
|
||||
# build object store details
|
||||
target = cadf_resource.Resource(
|
||||
typeURI='service/storage/object',
|
||||
id=account.partition(self.reseller_prefix)[2])
|
||||
id=account.partition(self.reseller_prefix)[2] or path)
|
||||
target.metadata = resource_metadata
|
||||
target.action = method.lower()
|
||||
|
||||
|
@ -317,7 +317,7 @@ class TestSwift(tests_base.TestCase):
|
||||
data = notify.call_args_list[0][0]
|
||||
self.assertEqual("account", data[2]['target']['id'])
|
||||
|
||||
def test_invalid_reseller_prefix(self):
|
||||
def test_incomplete_reseller_prefix(self):
|
||||
# Custom reseller prefix set, but without trailing underscore
|
||||
app = swift.Swift(
|
||||
FakeApp(), {'reseller_prefix': 'CUSTOM'})
|
||||
@ -329,6 +329,17 @@ class TestSwift(tests_base.TestCase):
|
||||
data = notify.call_args_list[0][0]
|
||||
self.assertEqual("account", data[2]['target']['id'])
|
||||
|
||||
def test_invalid_reseller_prefix(self):
|
||||
app = swift.Swift(
|
||||
FakeApp(), {'reseller_prefix': 'AUTH_'})
|
||||
req = FakeRequest('/1.0/admin/bucket',
|
||||
environ={'REQUEST_METHOD': 'GET'})
|
||||
with mock.patch('oslo_messaging.Notifier.info') as notify:
|
||||
list(app(req.environ, self.start_response))
|
||||
self.assertEqual(1, len(notify.call_args_list))
|
||||
data = notify.call_args_list[0][0]
|
||||
self.assertEqual("1.0/admin/bucket", data[2]['target']['id'])
|
||||
|
||||
def test_ignore_requests_from_project(self):
|
||||
app = swift.Swift(FakeApp(), {'ignore_projects': 'skip_proj'})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user