blob: 659724d0aa2e3852819e6b60dbf4ccfcb36a9ad7 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001# Copyright (C) 2019 Armin Kuster <akuster808@gmail.com>
2#
3import re
4
5from oeqa.runtime.case import OERuntimeTestCase
6from oeqa.core.decorator.depends import OETestDepends
7from oeqa.runtime.decorator.package import OEHasPackage
8
9
10class TripwireTest(OERuntimeTestCase):
11
12 @OEHasPackage(['tripwire'])
13 @OETestDepends(['ssh.SSHTest.test_ssh'])
14 def test_tripwire_help(self):
15 status, output = self.target.run('tripwire --help')
16 msg = ('tripwire command does not work as expected. '
17 'Status and output:%s and %s' % (status, output))
18 self.assertEqual(status, 8, msg = msg)
19
20 @OETestDepends(['tripwire.TripwireTest.test_tripwire_help'])
21 def test_tripwire_twinstall(self):
22 status, output = self.target.run('/etc/tripwire/twinstall.sh')
23 match = re.search('The database was successfully generated.', output)
24 if not match:
25 msg = ('/etc/tripwire/twinstall.sh failed. '
26 'Status and output:%s and %s' % (status, output))
27 self.assertEqual(status, 0, msg = msg)
28
29 @OETestDepends(['tripwire.TripwireTest.test_tripwire_twinstall'])
30 def test_tripwire_twadmin(self):
31 status, output = self.target.run('twadmin --create-cfgfile --cfgfile /etc/tripwire/twcfg.enc --site-keyfile /etc/tripwire/site.key -Q tripwire /etc/tripwire/twcfg.txt')
32 status, output = self.target.run('twadmin --create-polfile --cfgfile /etc/tripwire/twcfg.enc --polfile /etc/tripwire/twpol.enc --site-keyfile /etc/tripwire/site.key -Q tripwire /etc/tripwire/twpol.txt')
33 match = re.search('Wrote policy file: /etc/tripwire/twpol.enc', output)
34 if not match:
35 msg = ('twadmin --create-profile ; failed. '
36 'Status and output:%s and %s' % (status, output))
37 self.assertEqual(status, 0, msg = msg)
38
39 @OETestDepends(['tripwire.TripwireTest.test_tripwire_twadmin'])
40 def test_tripwire_init(self):
41 status, hostname = self.target.run('hostname')
42 status, output = self.target.run('tripwire --init --cfgfile /etc/tripwire/twcfg.enc --polfile /etc/tripwire/tw.pol --site-keyfile /etc/tripwire/site.key --local-keyfile /etc/tripwire/%s-local.key -P tripwire' % hostname)
43 match = re.search('The database was successfully generated.', output)
44 if not match:
45 msg = ('tripwire --init; Failed for host: %s. '
46 'Status and output:%s and %s' % (hostname, status, output))
47 self.assertEqual(status, 0, msg = msg)