File: test_extensions.sh

package info (click to toggle)
openscap 1.4.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 125,116 kB
  • sloc: xml: 527,136; ansic: 91,867; sh: 19,831; python: 2,531; perl: 444; makefile: 49
file content (56 lines) | stat: -rwxr-xr-x 1,397 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash

# Copyright 2018 Red Hat Inc., Durham, North Carolina.
# All Rights Reserved.
#
# OpenScap XCCDF Module Test Suite.
#
# Authors:
#      Peter Vrabec <pvrabec@redhat.com>
#      Alexander Scheel <ascheel@redhat.com>

. $builddir/tests/test_common.sh

# Test cases.

function test_known_extension {
	local INPUT=$1

	output=$(bash $builddir/run $builddir/utils/oscap xccdf eval $srcdir/$INPUT 2>&1)
	has_warning=$(echo "$output" | grep -i "Skipping rule")

	return $([ "x$has_warning" == "x" ])
}



function test_malformed_extension {
	local INPUT=$1

	output=$(bash $builddir/run $builddir/utils/oscap xccdf eval $srcdir/$INPUT 2>&1)
	has_warning=$(echo "$output" | grep -i "Skipping rule that uses OVAL")

	return $([ "x$has_warning" != "x" ])
}


function test_unknown_extension {
	local INPUT=$1

	output=$(bash $builddir/run $builddir/utils/oscap xccdf eval $srcdir/$INPUT 2>&1)
	has_warning=$(echo "$output" | grep -i "Skipping rule that requires")

	return $([ "x$has_warning" != "x" ])
}

# Testing.

test_init "test_xccdf_check_extensions.log"

if [ -z ${CUSTOM_OSCAP+x} ] ; then
    test_run "known check extension" test_known_extension test_known_extensions.xml
    test_run "malformed check extension" test_malformed_extension test_malformed_extensions.xml
    test_run "unknown check extension" test_unknown_extension test_proprietary_extensions.xml
fi

test_exit