blacklist some options for initdb instead of having big whitelist

This commit is contained in:
Alexander Kukushkin
2015-11-12 12:07:36 +01:00
parent f0a6c86caa
commit d39d297d92
2 changed files with 3 additions and 6 deletions
+2 -5
View File
@@ -169,11 +169,8 @@ class Postgresql:
@staticmethod
def initdb_allowed_option(name):
allowed_options = set(['auth', 'auth-host', 'auth-local', 'encoding', 'data-checksums',
'locale', 'lc-collate', 'lc-ctype', 'lc-messages', 'lc-monetary',
'lc-numeric', 'lc-time', 'text-search-config', 'xlogdir', 'debug', 'noclean'])
if name not in allowed_options:
raise Exception('{} option for initdb is unknown or not allowed'.format(name))
if name in ['pgdata', 'nosync', 'pwfile', 'sync-only']:
raise Exception('{} option for initdb is not allowed'.format(name))
return True
def get_initdb_options(self):
+1 -1
View File
@@ -190,7 +190,7 @@ class TestPostgresql(unittest.TestCase):
def test_get_initdb_options(self):
self.p.initdb_options = [{'encoding': 'UTF8'}, 'data-checksums']
self.assertEquals(self.p.get_initdb_options(), ['--encoding=UTF8', '--data-checksums'])
self.p.initdb_options = [{'foo': 'bar'}]
self.p.initdb_options = [{'pgdata': 'bar'}]
self.assertRaises(Exception, self.p.get_initdb_options)
self.p.initdb_options = [{'foo': 'bar', 1: 2}]
self.assertRaises(Exception, self.p.get_initdb_options)