summaryrefslogtreecommitdiff
path: root/test/sysv-generator-test.py
diff options
context:
space:
mode:
authorFelipe Sateler <fsateler@debian.org>2015-06-27 21:00:32 -0300
committerFelipe Sateler <fsateler@debian.org>2015-06-29 16:07:49 -0300
commit264581a2f1599a27de577549dc75fccefef6a579 (patch)
tree164ac6c5d432d99cbcd753b39a43cd6c8dc76c02 /test/sysv-generator-test.py
parent2c09a745eba5f463e12b498a2f62a5036253c55c (diff)
sysv-generator: escape names when translating from sysv name
While the LSB suggests only [A-Za-z0-9], that doesn't prevent admins from doing the wrong thing. Lets not generate invalid names in that case.
Diffstat (limited to 'test/sysv-generator-test.py')
-rw-r--r--test/sysv-generator-test.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py
index af0493b9a8..23d6646bba 100644
--- a/test/sysv-generator-test.py
+++ b/test/sysv-generator-test.py
@@ -190,6 +190,15 @@ class SysvGeneratorTest(unittest.TestCase):
self.assert_enabled('foo.service', ['multi-user', 'graphical'])
self.assertNotIn('Overwriting', err)
+ def test_simple_escaped(self):
+ '''simple service without dependencies, that requires escaping the name'''
+
+ self.add_sysv('foo+', {})
+ self.add_sysv('foo-admin', {})
+ err, results = self.run_generator()
+ self.assertEqual(list(results), ['foo-admin.service', 'foo\\x2b.service'])
+ self.assertNotIn('Overwriting', err)
+
def test_simple_enabled_some(self):
'''simple service without dependencies, enabled in some runlevels'''
@@ -276,6 +285,16 @@ class SysvGeneratorTest(unittest.TestCase):
'foo.service')
self.assertNotIn('Overwriting', err)
+ def test_provides_escaped(self):
+ '''a script that Provides: a name that requires escaping'''
+
+ self.add_sysv('foo', {'Provides': 'foo foo+'})
+ err, results = self.run_generator()
+ self.assertEqual(list(results), ['foo.service'])
+ self.assertEqual(os.readlink(os.path.join(self.out_dir, 'foo\\x2b.service')),
+ 'foo.service')
+ self.assertNotIn('Overwriting', err)
+
def test_same_provides_in_multiple_scripts(self):
'''multiple init.d scripts provide the same name'''