import os import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ["MOLECULE_INVENTORY_FILE"] ).get_hosts("all") JAVA_VERSION = "13.0.1" JAVA_HOME = "/opt/java/jdk-{}".format(JAVA_VERSION) JAVAFX_VERSION = "13.0.1" PATH_TO_FX = "/opt/java/javafx-sdk-{}/lib".format(JAVAFX_VERSION) def test_java_version(host): cmd = host.run("java -version 2>&1") assert 'openjdk version "{}"'.format(JAVA_VERSION) in cmd.stdout def test_java_home(host): cmd = host.run(r'su -l -c "echo \$JAVA_HOME"') assert cmd.stdout.strip() == JAVA_HOME assert host.file(JAVA_HOME).exists def test_javafx_home(host): cmd = host.run(r'su -l -c "echo \$PATH_TO_FX"') assert cmd.stdout.strip() == PATH_TO_FX assert host.file(PATH_TO_FX).exists def test_jce_policy(host): cmd = host.run( "jrunscript -e 'exit (javax.crypto.Cipher.getMaxAllowedKeyLength(\"RC5\") >= 256);'" ) # 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("{}/conf/security/java.security".format(JAVA_HOME)) assert not java_security.contains("securerandom.source=file:/dev/random") assert java_security.contains("securerandom.source=file:/dev/urandom")