All of lore.kernel.org
 help / color / mirror / Atom feed
From: Armin Kuster <akuster808@gmail.com>
To: yocto@yoctoproject.org
Subject: [meta-security][PATCH] samhain: add more tests and fix ret checks
Date: Wed,  8 May 2019 08:31:05 -0700	[thread overview]
Message-ID: <20190508153105.945-1-akuster808@gmail.com> (raw)

Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
 lib/oeqa/runtime/cases/samhain.py | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/lib/oeqa/runtime/cases/samhain.py b/lib/oeqa/runtime/cases/samhain.py
index e4bae7b..5043a38 100644
--- a/lib/oeqa/runtime/cases/samhain.py
+++ b/lib/oeqa/runtime/cases/samhain.py
@@ -1,6 +1,7 @@
 # Copyright (C) 2019 Armin Kuster <akuster808@gmail.com>
 #
 import re
+import os
 
 from oeqa.runtime.case import OERuntimeTestCase
 from oeqa.core.decorator.depends import OETestDepends
@@ -11,10 +12,32 @@ class SamhainTest(OERuntimeTestCase):
 
     @OEHasPackage(['samhain-standalone'])
     @OETestDepends(['ssh.SSHTest.test_ssh'])
-    def test_samhain_standalone_help(self):
+    def test_samhain_help(self):
+        machine = self.td.get('MACHINE', '')
+        status, output = self.target.run('echo "127.0.0.1 %s.localdomain  %s" >> /etc/hosts' % (machine, machine))
+        msg = ("samhain can't append hosts. "
+               'Status and output:%s and %s' % (status, output))
+        self.assertEqual(status, 0, msg = msg)
+
         status, output = self.target.run('samhain --help')
-        match = re.search('Please report bugs to support@la-samhna.de.', output)
+        msg = ('samhain command does not work as expected. '
+               'Status and output:%s and %s' % (status, output))
+        self.assertEqual(status, 0, msg = msg)
+
+    @OETestDepends(['samhain.SamhainTest.test_samhain_help'])
+    def test_samhain_init_db(self):
+        status, output = self.target.run('samhain -t init')
+        match = re.search('FAILED: 0 ', output)
+        if not match:
+            msg = ('samhain database init had an unexpected failure. '
+               'Status and output:%s and %s' % (status, output))
+            self.assertEqual(status, 0, msg = msg)
+
+    @OETestDepends(['samhain.SamhainTest.test_samhain_init_db'])
+    def test_samhain_db_check(self):
+        status, output = self.target.run('samhain -t check')
+        match = re.search('FAILED: 0 ', output)
         if not match:
-            msg = ('samhain-standalone command does not work as expected. '
+            msg = ('samhain errors found in db. '
                'Status and output:%s and %s' % (status, output))
-            self.assertEqual(status, 1, msg = msg)
+            self.assertEqual(status, 0, msg = msg)
-- 
2.17.1



                 reply	other threads:[~2019-05-08 15:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190508153105.945-1-akuster808@gmail.com \
    --to=akuster808@gmail.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.