Commit 8505ee49 authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify assertions.

parent 7a339758
...@@ -55,7 +55,7 @@ class FakeCallAndRead: ...@@ -55,7 +55,7 @@ class FakeCallAndRead:
argument_list[3] = 'ip/%s' % netmask argument_list[3] = 'ip/%s' % netmask
elif argument_list[:3] == ['ip', 'addr', 'list']: elif argument_list[:3] == ['ip', 'addr', 'list']:
retval = 0, str(INTERFACE_DICT) retval = 0, str(INTERFACE_DICT)
self.external_command_list.append(argument_list) self.external_command_list.append(' '.join(argument_list))
return retval return retval
class LoggableWrapper: class LoggableWrapper:
...@@ -221,10 +221,10 @@ class TestComputer(SlapformatMixin): ...@@ -221,10 +221,10 @@ class TestComputer(SlapformatMixin):
"chmod('/software_root', 493)"], "chmod('/software_root', 493)"],
self.test_result.bucket) self.test_result.bucket)
self.assertEqual([ self.assertEqual([
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
['groupadd', 'slapsoft'], 'groupadd slapsoft',
['useradd', '-d', '/software_root', '-g', 'slapsoft', '-s', 'useradd -d /software_root -g slapsoft -s /bin/false slapsoft'
'/bin/false', 'slapsoft']], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
def test_construct_empty_prepared_no_alter_user(self): def test_construct_empty_prepared_no_alter_user(self):
...@@ -239,7 +239,7 @@ class TestComputer(SlapformatMixin): ...@@ -239,7 +239,7 @@ class TestComputer(SlapformatMixin):
"chmod('/software_root', 493)"], "chmod('/software_root', 493)"],
self.test_result.bucket) self.test_result.bucket)
self.assertEqual([ self.assertEqual([
['ip', 'addr', 'list', 'bridge'],], 'ip addr list bridge',],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
def test_construct_empty_prepared_no_alter_network(self): def test_construct_empty_prepared_no_alter_network(self):
...@@ -255,10 +255,10 @@ class TestComputer(SlapformatMixin): ...@@ -255,10 +255,10 @@ class TestComputer(SlapformatMixin):
"chmod('/software_root', 493)"], "chmod('/software_root', 493)"],
self.test_result.bucket) self.test_result.bucket)
self.assertEqual([ self.assertEqual([
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
['groupadd', 'slapsoft'], 'groupadd slapsoft',
['useradd', '-d', '/software_root', '-g', 'slapsoft', '-s', 'useradd -d /software_root -g slapsoft -s /bin/false slapsoft'
'/bin/false', 'slapsoft']], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
def test_construct_empty_prepared_no_alter_network_user(self): def test_construct_empty_prepared_no_alter_network_user(self):
...@@ -273,7 +273,7 @@ class TestComputer(SlapformatMixin): ...@@ -273,7 +273,7 @@ class TestComputer(SlapformatMixin):
"chmod('/software_root', 493)"], "chmod('/software_root', 493)"],
self.test_result.bucket) self.test_result.bucket)
self.assertEqual([ self.assertEqual([
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -305,20 +305,19 @@ class TestComputer(SlapformatMixin): ...@@ -305,20 +305,19 @@ class TestComputer(SlapformatMixin):
], ],
self.test_result.bucket) self.test_result.bucket)
self.assertEqual([ self.assertEqual([
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
['groupadd', 'slapsoft'], 'groupadd slapsoft',
['useradd', '-d', '/software_root', '-g', 'slapsoft', '-s', 'useradd -d /software_root -g slapsoft -s /bin/false slapsoft',
'/bin/false', 'slapsoft'], ['groupadd', 'testuser'], 'groupadd testuser',
['useradd', '-d', '/instance_root/partition', '-g', 'testuser', '-s', 'useradd -d /instance_root/partition -g testuser -s /bin/false -G slapsoft testuser',
'/bin/false', '-G', 'slapsoft', 'testuser'], 'tunctl -t tap -u testuser',
['tunctl', '-t', 'tap', '-u', 'testuser'], 'ip link set tap up',
['ip', 'link', 'set', 'tap', 'up'], 'brctl show',
['brctl', 'show'], 'brctl addif bridge tap',
['brctl', 'addif', 'bridge', 'tap'], 'ip addr add ip/255.255.255.255 dev bridge',
['ip', 'addr', 'add', 'ip/255.255.255.255', 'dev', 'bridge'], 'ip addr list bridge',
['ip', 'addr', 'list', 'bridge'], 'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge',
['ip', 'addr', 'add', 'ip/ffff:ffff:ffff:ffff::', 'dev', 'bridge'], 'ip addr list bridge',
['ip', 'addr', 'list', 'bridge'],
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -348,15 +347,15 @@ class TestComputer(SlapformatMixin): ...@@ -348,15 +347,15 @@ class TestComputer(SlapformatMixin):
], ],
self.test_result.bucket) self.test_result.bucket)
self.assertEqual([ self.assertEqual([
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
['tunctl', '-t', 'tap', '-u', 'root'], 'tunctl -t tap -u root',
['ip', 'link', 'set', 'tap', 'up'], 'ip link set tap up',
['brctl', 'show'], 'brctl show',
['brctl', 'addif', 'bridge', 'tap'], 'brctl addif bridge tap',
['ip', 'addr', 'add', 'ip/255.255.255.255', 'dev', 'bridge'], 'ip addr add ip/255.255.255.255 dev bridge',
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
['ip', 'addr', 'add', 'ip/ffff:ffff:ffff:ffff::', 'dev', 'bridge'], 'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge',
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -388,16 +387,15 @@ class TestComputer(SlapformatMixin): ...@@ -388,16 +387,15 @@ class TestComputer(SlapformatMixin):
], ],
self.test_result.bucket) self.test_result.bucket)
self.assertEqual([ self.assertEqual([
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
['groupadd', 'slapsoft'], 'groupadd slapsoft',
['useradd', '-d', '/software_root', '-g', 'slapsoft', '-s', 'useradd -d /software_root -g slapsoft -s /bin/false slapsoft',
'/bin/false', 'slapsoft'], ['groupadd', 'testuser'], 'groupadd testuser',
['useradd', '-d', '/instance_root/partition', '-g', 'testuser', '-s', 'useradd -d /instance_root/partition -g testuser -s /bin/false -G slapsoft testuser',
'/bin/false', '-G', 'slapsoft', 'testuser'], 'ip addr add ip/255.255.255.255 dev bridge',
['ip', 'addr', 'add', 'ip/255.255.255.255', 'dev', 'bridge'], 'ip addr list bridge',
['ip', 'addr', 'list', 'bridge'], 'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge',
['ip', 'addr', 'add', 'ip/ffff:ffff:ffff:ffff::', 'dev', 'bridge'], 'ip addr list bridge',
['ip', 'addr', 'list', 'bridge'],
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -427,11 +425,11 @@ class TestComputer(SlapformatMixin): ...@@ -427,11 +425,11 @@ class TestComputer(SlapformatMixin):
], ],
self.test_result.bucket) self.test_result.bucket)
self.assertEqual([ self.assertEqual([
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
['ip', 'addr', 'add', 'ip/255.255.255.255', 'dev', 'bridge'], 'ip addr add ip/255.255.255.255 dev bridge',
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
['ip', 'addr', 'add', 'ip/ffff:ffff:ffff:ffff::', 'dev', 'bridge'], 'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge',
['ip', 'addr', 'list', 'bridge'], 'ip addr list bridge',
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -466,11 +464,10 @@ class TestUser(SlapformatMixin): ...@@ -466,11 +464,10 @@ class TestUser(SlapformatMixin):
user.setPath('/doesnotexistsyet') user.setPath('/doesnotexistsyet')
user.create() user.create()
self.assertEqual( self.assertEqual([
[ 'groupadd doesnotexistsyet',
['groupadd', 'doesnotexistsyet'], 'useradd -d /doesnotexistsyet -g doesnotexistsyet -s /bin/false '\
['useradd', '-d', '/doesnotexistsyet', '-g', 'doesnotexistsyet', '-s', 'doesnotexistsyet'
'/bin/false', 'doesnotexistsyet']
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -480,12 +477,10 @@ class TestUser(SlapformatMixin): ...@@ -480,12 +477,10 @@ class TestUser(SlapformatMixin):
user.setPath('/doesnotexistsyet') user.setPath('/doesnotexistsyet')
user.create() user.create()
self.assertEqual( self.assertEqual([
[ 'groupadd doesnotexistsyet',
['groupadd', 'doesnotexistsyet'], 'useradd -d /doesnotexistsyet -g doesnotexistsyet -s /bin/false -G '\
['useradd', '-d', '/doesnotexistsyet', '-g', 'doesnotexistsyet', '-s', 'additionalgroup1,additionalgroup2 doesnotexistsyet'
'/bin/false', '-G', 'additionalgroup1,additionalgroup2',
'doesnotexistsyet']
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -496,10 +491,8 @@ class TestUser(SlapformatMixin): ...@@ -496,10 +491,8 @@ class TestUser(SlapformatMixin):
user.setPath('/testuser') user.setPath('/testuser')
user.create() user.create()
self.assertEqual( self.assertEqual([
[ 'useradd -d /testuser -g testuser -s /bin/false testuser'
['useradd', '-d', '/testuser', '-g', 'testuser', '-s', '/bin/false',
'testuser']
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -511,11 +504,10 @@ class TestUser(SlapformatMixin): ...@@ -511,11 +504,10 @@ class TestUser(SlapformatMixin):
user.setPath('/testuser') user.setPath('/testuser')
user.create() user.create()
self.assertEqual( self.assertEqual([
[ 'groupadd testuser',
['groupadd', 'testuser'], 'usermod -d /testuser -g testuser -s /bin/false -G '\
['usermod', '-d', '/testuser', '-g', 'testuser', '-s', '/bin/false', 'additionalgroup1,additionalgroup2 testuser'
'-G', 'additionalgroup1,additionalgroup2', 'testuser']
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -526,11 +518,9 @@ class TestUser(SlapformatMixin): ...@@ -526,11 +518,9 @@ class TestUser(SlapformatMixin):
user.setPath('/testuser') user.setPath('/testuser')
user.create() user.create()
self.assertEqual( self.assertEqual([
[ 'groupadd testuser',
['groupadd', 'testuser'], 'usermod -d /testuser -g testuser -s /bin/false testuser'
['usermod', '-d', '/testuser', '-g', 'testuser', '-s', '/bin/false',
'testuser']
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
...@@ -543,10 +533,8 @@ class TestUser(SlapformatMixin): ...@@ -543,10 +533,8 @@ class TestUser(SlapformatMixin):
user.setPath('/testuser') user.setPath('/testuser')
user.create() user.create()
self.assertEqual( self.assertEqual([
[ 'usermod -d /testuser -g testuser -s /bin/false testuser'
['usermod', '-d', '/testuser', '-g', 'testuser', '-s', '/bin/false',
'testuser']
], ],
self.fakeCallAndRead.external_command_list) self.fakeCallAndRead.external_command_list)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment