summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py11
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestEncryption.py24
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py19
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDecisions.py8
-rwxr-xr-xtestsuite/before_install.sh14
-rwxr-xr-xtestsuite/install.sh10
6 files changed, 62 insertions, 24 deletions
diff --git a/testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py b/testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py
index 0c059b5f3..0e9e3a141 100644
--- a/testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py
+++ b/testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py
@@ -17,6 +17,14 @@ while path != "/":
path = os.path.dirname(path)
from common import *
+# try to find true
+if os.path.exists("/bin/true"):
+ TRUE = "/bin/true"
+elif os.path.exists("/usr/bin/true"):
+ TRUE = "/usr/bin/true"
+else:
+ TRUE = None
+
class TestTool(Bcfg2TestCase):
test_obj = Tool
@@ -69,10 +77,11 @@ class TestTool(Bcfg2TestCase):
["/test"] + [e.get("name") for e in important])
t.getSupportedEntries.assert_called_with()
+ @skipIf(TRUE is None, "/bin/true or equivalent not found")
def test__check_execs(self):
t = self.get_obj()
if t.__execs__ == []:
- t.__execs__.append("/bin/true")
+ t.__execs__.append(TRUE)
@patch("os.stat")
def inner(mock_stat):
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestEncryption.py b/testsuite/Testsrc/Testlib/TestServer/TestEncryption.py
index cfb0c023b..3da323262 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestEncryption.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestEncryption.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import os
import sys
-from Bcfg2.Compat import b64decode
+from Bcfg2.Compat import b64decode, b64encode
from mock import Mock, MagicMock, patch
# add all parent testsuite directories to sys.path to allow (most)
@@ -125,10 +125,28 @@ baz
passwd,
"also bogus"]))
- # test with no good passphrase given nor in config
+ # test with no good passphrase given nor in config. we use
+ # something that isn't a valid ciphertext here since a
+ # ciphertext encrypted with one key may be technically
+ # decryptable with a different key, although it will decrypt
+ # to gibberish. nonetheless, it doesn't raise the requisite
+ # EVPError, so the test fails.
self.assertRaises(EVPError,
bruteforce_decrypt,
- crypted, passphrases=["bogus", "also bogus"])
+ b64encode("not an actual ciphertext!"),
+ passphrases=["bogus", "also bogus"])
+
+ # test with no good passphrase given nor in config. this
+ # version of the test uses a valid ciphertext, and looks for
+ # *either* EVPError or a failed decrypt.
+ try:
+ plaintext = bruteforce_decrypt(crypted,
+ passphrases=["bogus", "also bogus"])
+ if plaintext == passwd:
+ self.fail("Successfully decrypted ciphertext with wrong key")
+ except EVPError:
+ # success!
+ pass
# test with good passphrase in config file
Bcfg2.Options.setup.passphrases = dict(bogus="bogus",
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
index 1f8449bb6..37beaa26c 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
@@ -1121,6 +1121,25 @@ class TestInfoXML(TestStructFile):
self.assertTrue(inc("Path", name="/etc/bar.conf", negate="true"))
self.assertTrue(inc("Path", name="/etc/bar.conf", negate="tRUe"))
+ def test_include_element_altsrc(self):
+ ix = self.get_obj()
+ metadata = Mock()
+ entry = lxml.etree.Element("Path", name="/etc/bar.conf",
+ realname="/etc/foo.conf")
+ inc = lambda tag, **attrs: \
+ ix._include_element(lxml.etree.Element(tag, **attrs),
+ metadata, entry)
+
+ self.assertFalse(inc("Path", name="/etc/bar.conf"))
+ self.assertFalse(inc("Path", name="/etc/foo.conf", negate="true"))
+ self.assertFalse(inc("Path", name="/etc/foo.conf", negate="tRuE"))
+ self.assertTrue(inc("Path", name="/etc/foo.conf"))
+ self.assertTrue(inc("Path", name="/etc/foo.conf", negate="false"))
+ self.assertTrue(inc("Path", name="/etc/foo.conf", negate="faLSe"))
+ self.assertTrue(inc("Path", name="/etc/bar.conf", negate="true"))
+ self.assertTrue(inc("Path", name="/etc/bar.conf", negate="tRUe"))
+
+
def test_BindEntry(self):
ix = self.get_obj()
entry = lxml.etree.Element("Path", name=self.path)
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDecisions.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDecisions.py
index 537ceb4ff..8b4df8abb 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDecisions.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDecisions.py
@@ -52,9 +52,9 @@ class TestDecisions(TestPlugin, TestDecision):
metadata = Mock()
self.assertEqual(d.GetDecisions(metadata, "whitelist"),
- d.whitelist.get_decision.return_value)
- d.whitelist.get_decision.assert_called_with(metadata)
+ d.whitelist.get_decisions.return_value)
+ d.whitelist.get_decisions.assert_called_with(metadata)
self.assertEqual(d.GetDecisions(metadata, "blacklist"),
- d.blacklist.get_decision.return_value)
- d.blacklist.get_decision.assert_called_with(metadata)
+ d.blacklist.get_decisions.return_value)
+ d.blacklist.get_decisions.assert_called_with(metadata)
diff --git a/testsuite/before_install.sh b/testsuite/before_install.sh
deleted file mode 100755
index 2c80036cd..000000000
--- a/testsuite/before_install.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash -ex
-
-# before_install script for Travis-CI
-
-PYVER=$(python -c 'import sys;print(".".join(str(v) for v in sys.version_info[0:2]))')
-
-sudo apt-get update -qq
-sudo apt-get install -qq swig libxml2-utils
-if [[ "$WITH_OPTIONAL_DEPS" == "yes" ]]; then
- if [[ ${PYVER:0:1} == "2" ]]; then
- sudo apt-get install -y yum libaugeas0 augeas-lenses libacl1-dev \
- libssl-dev
- fi
-fi
diff --git a/testsuite/install.sh b/testsuite/install.sh
index 6f36d4bef..bbbd9ae76 100755
--- a/testsuite/install.sh
+++ b/testsuite/install.sh
@@ -2,7 +2,10 @@
# install script for Travis-CI
-pip install -r testsuite/requirements.txt --use-mirrors
+sudo apt-get update -qq
+sudo apt-get install swig libxml2-utils
+
+pip install -r testsuite/requirements.txt
PYVER=$(python -c 'import sys;print(".".join(str(v) for v in sys.version_info[0:2]))')
@@ -11,7 +14,10 @@ if [[ ${PYVER:0:1} == "2" && $PYVER != "2.7" ]]; then
fi
if [[ "$WITH_OPTIONAL_DEPS" == "yes" ]]; then
- pip install --use-mirrors PyYAML pyinotify boto pylibacl 'django<1.5' Jinja2
+ sudo apt-get install -y yum libaugeas0 augeas-lenses libacl1-dev libssl-dev
+
+ pip install --use-mirrors PyYAML pyinotify boto pylibacl 'django<1.5' \
+ Jinja2
easy_install https://fedorahosted.org/released/python-augeas/python-augeas-0.4.1.tar.gz
if [[ ${PYVER:0:1} == "2" ]]; then
# django supports py3k, but South doesn't, and the django bits