aboutsummaryrefslogtreecommitdiffstats
path: root/tests/report_tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-06-01 14:24:52 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-06-03 10:23:58 -0400
commit479e58fed6fcc1db66e3c1a6136dc89c8370f646 (patch)
treebec694575f399893d5fea46d8aae70fb431641a2 /tests/report_tests
parent55e77ad4c7e90ba14b10c5fdf18b65aa5d6b9cf8 (diff)
downloadsos-479e58fed6fcc1db66e3c1a6136dc89c8370f646.tar.gz
[tests] Add test for using `--encrypt-pass`
Adds two test cases for using `--encrypt-pass`; one with just the bare option and another in conjunction with `--clean` to ensure both can be used in the same execution. Resolves: #2566 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/report_tests')
-rw-r--r--tests/report_tests/encryption_tests.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/report_tests/encryption_tests.py b/tests/report_tests/encryption_tests.py
new file mode 100644
index 00000000..22c5669a
--- /dev/null
+++ b/tests/report_tests/encryption_tests.py
@@ -0,0 +1,51 @@
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+
+from avocado.utils import process
+from sos_tests import StageOneReportTest
+
+
+class EncryptedReportTest(StageOneReportTest):
+ """Tests the use of --encrypt-pass to ensure that the archive is
+ successfully encrypted.
+
+ :avocado: tags=stageone
+ """
+
+ encrypt_pass = 'sostest'
+ sos_cmd = "-o kernel --encrypt-pass %s" % encrypt_pass
+
+ def test_archive_gpg_encrypted(self):
+ self.assertOutputContains('/.*sosreport-.*tar.*\.gpg')
+ _cmd = "file %s" % self.encrypted_path
+ res = process.run(_cmd)
+ self.assertTrue("GPG symmetrically encrypted data" in res.stdout.decode())
+
+ def test_tarball_named_secure(self):
+ self.assertTrue('secured-' in self.encrypted_path)
+
+
+class EncryptedCleanedReportTest(EncryptedReportTest):
+ """Ensure that we can successfully both encrypt and clean a report in a
+ single execution
+
+ :avocado: tags=stageone
+ """
+
+ encrypt_pass = 'sostest'
+ sos_cmd = "-o host,networking --clean --encrypt-pass %s" % encrypt_pass
+
+ def test_hostname_obfuscated(self):
+ self.assertFileHasContent('/etc/hostname', 'host0')
+
+ def test_tarball_named_obfuscated(self):
+ self.assertTrue('obfuscated' in self.archive)
+
+ def test_ip_address_was_obfuscated(self):
+ self.assertFileNotHasContent('ip_addr', self.sysinfo['pre']['networking']['ip_addr'])