Newer
Older
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("ics-ans-role-java-and-oracle-jdk8")
ORACLE_JDK8_VERSION = "191"
JAVA8_HOME = "/opt/java/jdk1.8.0_{}".format(ORACLE_JDK8_VERSION)
def test_java_version(host):
cmd = host.run("{}/bin/java -version 2>&1".format(JAVA8_HOME))
assert 'java version "1.8.0_{}"'.format(ORACLE_JDK8_VERSION) in cmd.stdout
def test_java8_home(host):
assert cmd.stdout.strip() == JAVA8_HOME
def test_jce_policy(host):
cmd = host.run(
"{}/bin/jrunscript -e 'exit (javax.crypto.Cipher.getMaxAllowedKeyLength(\"RC5\") >= 256);'".format(
JAVA8_HOME
)
)
# The previous command returns 1, if the Unlimited Cryptography is available, 0 otherwise
assert cmd.rc == 1
def test_secure_random_source(host):
java_security = host.file("{}/jre/lib/security/java.security".format(JAVA8_HOME))
assert not java_security.contains("securerandom.source=file:/dev/random")
assert java_security.contains("securerandom.source=file:/dev/urandom")