change account_autocreate to default to true
"account_autocreate = true" is more common than the default false setting. This patch is to make "account_autocreate = true" as default setting. Change-Id: I7dec8d43ab7ffcd5bdd0ddb87733f5a9a39c81ec Closes-bug: #1629711
This commit is contained in:
@@ -998,7 +998,7 @@ user may create and delete accounts; if 'false' no one, even authorized, can. Th
|
||||
is false.
|
||||
.IP \fBaccount_autocreate\fR
|
||||
If set to 'true' authorized accounts that do not yet exist within the Swift cluster
|
||||
will be automatically created. The default is set to false.
|
||||
will be automatically created. The default is set to true.
|
||||
.IP \fBauto_create_account_prefix\fR
|
||||
Prefix used when automatically creating accounts. The default is '.'.
|
||||
.IP \fBmax_containers_per_account\fR
|
||||
|
||||
@@ -1887,10 +1887,10 @@ error_suppression_limit 10 Error count to consider
|
||||
node error limited
|
||||
allow_account_management false Whether account PUTs and DELETEs
|
||||
are even callable
|
||||
account_autocreate false If set to 'true' authorized
|
||||
account_autocreate true If set to 'false' authorized
|
||||
accounts that do not yet exist
|
||||
within the Swift cluster will
|
||||
be automatically created.
|
||||
not be automatically created.
|
||||
max_containers_per_account 0 If set to a positive value,
|
||||
trying to create a container
|
||||
when the account already has at
|
||||
|
||||
@@ -144,9 +144,9 @@ use = egg:swift#proxy
|
||||
# 'false' no one, even authorized, can.
|
||||
# allow_account_management = false
|
||||
#
|
||||
# If set to 'true' authorized accounts that do not yet exist within the Swift
|
||||
# cluster will be automatically created.
|
||||
# account_autocreate = false
|
||||
# If set to 'false', authorized accounts that do not yet exist within the Swift
|
||||
# cluster will not be automatically created.
|
||||
# account_autocreate = true
|
||||
#
|
||||
# If set to a positive value, trying to create a container when the account
|
||||
# already has at least this maximum containers will result in a 403 Forbidden.
|
||||
|
||||
@@ -209,7 +209,7 @@ class Application(object):
|
||||
mimetypes.init(mimetypes.knownfiles +
|
||||
[os.path.join(swift_dir, 'mime.types')])
|
||||
self.account_autocreate = \
|
||||
config_true_value(conf.get('account_autocreate', 'no'))
|
||||
config_true_value(conf.get('account_autocreate', 'true'))
|
||||
self.auto_create_account_prefix = (
|
||||
conf.get('auto_create_account_prefix') or '.')
|
||||
self.expiring_objects_account = self.auto_create_account_prefix + \
|
||||
|
||||
@@ -299,6 +299,7 @@ class TestAccountController(unittest.TestCase):
|
||||
self._assert_responses('DELETE', DELETE_TEST_CASES)
|
||||
|
||||
def test_response_code_for_POST(self):
|
||||
self.app.account_autocreate = False
|
||||
POST_TEST_CASES = [
|
||||
((204, 204, 204), 204),
|
||||
((204, 204, 404), 204),
|
||||
@@ -312,6 +313,8 @@ class TestAccountController(unittest.TestCase):
|
||||
((503, 503, 503), 503)
|
||||
]
|
||||
self._assert_responses('POST', POST_TEST_CASES)
|
||||
# set accout_autocreate back to default value
|
||||
self.app.account_autocreate = True
|
||||
|
||||
|
||||
@patch_policies(
|
||||
@@ -365,6 +368,7 @@ class TestAccountController4Replicas(TestAccountController):
|
||||
self._assert_responses('DELETE', DELETE_TEST_CASES)
|
||||
|
||||
def test_response_code_for_POST(self):
|
||||
self.app.account_autocreate = False
|
||||
POST_TEST_CASES = [
|
||||
((204, 204, 204, 204), 204),
|
||||
((204, 204, 204, 404), 204),
|
||||
@@ -383,6 +387,8 @@ class TestAccountController4Replicas(TestAccountController):
|
||||
((503, 503, 503, 503), 503)
|
||||
]
|
||||
self._assert_responses('POST', POST_TEST_CASES)
|
||||
# set accout_autocreate back to default value
|
||||
self.app.account_autocreate = True
|
||||
|
||||
|
||||
@patch_policies([StoragePolicy(0, 'zero', True, object_ring=FakeRing())])
|
||||
|
||||
@@ -351,6 +351,7 @@ class TestController(unittest.TestCase):
|
||||
# tests if 404 is cached and used
|
||||
def test_account_info_404(self):
|
||||
with save_globals():
|
||||
self.controller.app.account_autocreate = False
|
||||
set_http_connect(404, 404, 404)
|
||||
partition, nodes, count = \
|
||||
self.controller.account_info(self.account, self.request)
|
||||
@@ -7643,7 +7644,7 @@ class TestContainerController(unittest.TestCase):
|
||||
test_status_map((200, 404, 404, 500), 404, 404, 200)
|
||||
# return 503, don't cache container
|
||||
test_status_map((200, 500, 500, 500), 503, None, 200)
|
||||
self.assertFalse(self.app.account_autocreate)
|
||||
self.app.account_autocreate = False
|
||||
|
||||
# return 404 (as account is not found) and don't cache container
|
||||
test_status_map((404, 404, 404), 404, None, 404)
|
||||
@@ -7727,7 +7728,7 @@ class TestContainerController(unittest.TestCase):
|
||||
test_status_map((200, 201, 201, 500), 201, missing_container=True)
|
||||
test_status_map((200, 204, 404, 404), 404, missing_container=True)
|
||||
test_status_map((200, 204, 500, 404), 503, missing_container=True)
|
||||
self.assertFalse(self.app.account_autocreate)
|
||||
self.app.account_autocreate = False
|
||||
test_status_map((404, 404, 404), 404, missing_container=True)
|
||||
self.app.account_autocreate = True
|
||||
# fail to retrieve account info
|
||||
@@ -7826,9 +7827,8 @@ class TestContainerController(unittest.TestCase):
|
||||
test_status_map((200, 201, 201, 500), 201, missing_container=True)
|
||||
test_status_map((200, 204, 404, 404), 404, missing_container=True)
|
||||
test_status_map((200, 204, 500, 404), 503, missing_container=True)
|
||||
self.assertFalse(self.app.account_autocreate)
|
||||
test_status_map((404, 404, 404), 404, missing_container=True)
|
||||
self.app.account_autocreate = True
|
||||
self.app.account_autocreate = False
|
||||
test_status_map((404, 404, 404), 404, missing_container=True)
|
||||
|
||||
def test_PUT_max_containers_per_account(self):
|
||||
@@ -8295,7 +8295,8 @@ class TestContainerController(unittest.TestCase):
|
||||
def _do_test(method):
|
||||
with save_globals():
|
||||
swift.proxy.controllers.Controller.account_info = account_info
|
||||
app = proxy_server.Application(None, FakeMemcache(),
|
||||
app = proxy_server.Application({"account_autocreate": "false"},
|
||||
FakeMemcache(),
|
||||
account_ring=FakeRing(),
|
||||
container_ring=FakeRing())
|
||||
set_http_connect(201, 201, 201)
|
||||
@@ -8334,7 +8335,8 @@ class TestContainerController(unittest.TestCase):
|
||||
def _do_test(method):
|
||||
with save_globals():
|
||||
swift.proxy.controllers.Controller.account_info = account_info
|
||||
app = proxy_server.Application(None, FakeMemcache(),
|
||||
app = proxy_server.Application({"account_autocreate": "false"},
|
||||
FakeMemcache(),
|
||||
account_ring=FakeRing(),
|
||||
container_ring=FakeRing())
|
||||
set_http_connect(201, 201, 201)
|
||||
@@ -8786,6 +8788,7 @@ class TestAccountController(unittest.TestCase):
|
||||
def test_GET(self):
|
||||
with save_globals():
|
||||
controller = proxy_server.AccountController(self.app, 'a')
|
||||
self.app.account_autocreate = False
|
||||
# GET returns after the first successful call to an Account Server
|
||||
self.assert_status_map(controller.GET, (200,), 200, 200)
|
||||
self.assert_status_map(controller.GET, (503, 200), 200, 200)
|
||||
@@ -8809,7 +8812,7 @@ class TestAccountController(unittest.TestCase):
|
||||
with save_globals():
|
||||
controller = proxy_server.AccountController(self.app, 'a')
|
||||
self.app.memcache = FakeMemcacheReturnsNone()
|
||||
self.assertFalse(self.app.account_autocreate)
|
||||
self.app.account_autocreate = False
|
||||
# Repeat the test for autocreate = False and 404 by all
|
||||
self.assert_status_map(controller.GET,
|
||||
(404, 404, 404), 404)
|
||||
@@ -8857,6 +8860,7 @@ class TestAccountController(unittest.TestCase):
|
||||
# Same behaviour as GET
|
||||
with save_globals():
|
||||
controller = proxy_server.AccountController(self.app, 'a')
|
||||
self.app.account_autocreate = False
|
||||
self.assert_status_map(controller.HEAD, (200,), 200, 200)
|
||||
self.assert_status_map(controller.HEAD, (503, 200), 200, 200)
|
||||
self.assert_status_map(controller.HEAD, (503, 503, 200), 200, 200)
|
||||
@@ -8876,7 +8880,7 @@ class TestAccountController(unittest.TestCase):
|
||||
with save_globals():
|
||||
controller = proxy_server.AccountController(self.app, 'a')
|
||||
self.app.memcache = FakeMemcacheReturnsNone()
|
||||
self.assertFalse(self.app.account_autocreate)
|
||||
self.app.account_autocreate = False
|
||||
self.assert_status_map(controller.HEAD,
|
||||
(404, 404, 404), 404)
|
||||
controller.app.account_autocreate = True
|
||||
@@ -8893,7 +8897,7 @@ class TestAccountController(unittest.TestCase):
|
||||
controller = proxy_server.AccountController(self.app, 'a')
|
||||
self.app.memcache = FakeMemcacheReturnsNone()
|
||||
# first test with autocreate being False
|
||||
self.assertFalse(self.app.account_autocreate)
|
||||
self.app.account_autocreate = False
|
||||
self.assert_status_map(controller.POST,
|
||||
(404, 404, 404), 404)
|
||||
# next turn it on and test account being created than updated
|
||||
@@ -8915,7 +8919,7 @@ class TestAccountController(unittest.TestCase):
|
||||
controller = proxy_server.AccountController(self.app, 'a')
|
||||
self.app.memcache = FakeMemcacheReturnsNone()
|
||||
# first test with autocreate being False
|
||||
self.assertFalse(self.app.account_autocreate)
|
||||
self.app.account_autocreate = False
|
||||
self.assert_status_map(controller.POST,
|
||||
(404, 404, 404), 404)
|
||||
# next turn it on and test account being created than updated
|
||||
@@ -9592,7 +9596,7 @@ class TestSwiftInfo(unittest.TestCase):
|
||||
constraints.MAX_OBJECT_NAME_LENGTH)
|
||||
self.assertIn('strict_cors_mode', si)
|
||||
self.assertFalse(si['allow_account_management'])
|
||||
self.assertFalse(si['account_autocreate'])
|
||||
self.assertTrue(si['account_autocreate'])
|
||||
# This setting is by default excluded by disallowed_sections
|
||||
self.assertEqual(si['valid_api_versions'],
|
||||
constraints.VALID_API_VERSIONS)
|
||||
|
||||
Reference in New Issue
Block a user