| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright 2018 Red Hat Inc., Durham, North Carolina. |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # OpenSCAP Test Suite |
| 7 | # |
| 8 | # Authors: |
| 9 | # Jan Černý <[email protected]> |
| 10 | |
| 11 | . $builddir/tests/test_common.sh |
| 12 | |
| 13 | set -e -o pipefail |
| 14 | |
| 15 | function test_offline_mode_system_info_offline { |
| 16 | # This test is dependent on /etc/os-release being present, so skip this test if it doesn't exist. |
| 17 | [ -f "/etc/os-release" ] || return 255 |
| 18 | |
| 19 | temp_dir="$(mktemp -d)" |
| 20 | |
| 21 | ln -s /etc $temp_dir |
| 22 | |
| 23 | result="$(mktemp)" |
| 24 | |
| 25 | set_chroot_offline_test_mode "$temp_dir" |
| 26 | |
| 27 | $OSCAP oval eval --results $result $srcdir/test_probes_system_info.oval.xml |
| 28 | |
| 29 | unset_chroot_offline_test_mode |
| 30 | |
| 31 | [ -s "$result" ] |
| 32 | |
| 33 | . /etc/os-release |
| 34 | |
| 35 | case $(uname) in |
| 36 | FreeBSD) |
| 37 | HOSTNAME=`grep hostname= /etc/rc.conf | cut -d '"' -f 2` |
| 38 | ;; |
| 39 | *) |
| 40 | HOSTNAME=`cat /etc/hostname` |
| 41 | ;; |
| 42 | esac |
| 43 | |
| 44 | assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_info' |
| 45 | assert_exists 1 "/oval_results/results/system/oval_system_characteristics/system_info/os_name[text()=\"${NAME}\"]" |
| 46 | assert_exists 1 "/oval_results/results/system/oval_system_characteristics/system_info/os_version[text()=\"${VERSION}\"]" |
| 47 | assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_info/architecture[text()="Unknown"]' |
| 48 | assert_exists 1 "/oval_results/results/system/oval_system_characteristics/system_info/primary_host_name[text()=\"${HOSTNAME}\"]" |
| 49 | |
| 50 | assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_info/interfaces' |
| 51 | # Getting network interfaces information from the guest is not implemented, |
| 52 | # check if there are no interfaces from the host |
| 53 | assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_info/interfaces/interface' |
| 54 | |
| 55 | rm -rf "$temp_dir" |
| 56 | rm -f "$result" |
| 57 | } |
| 58 | |
| 59 | test_run "test_offline_mode_system_info_offline" test_offline_mode_system_info_offline |