From 8645604c8e5285c5b5bec538a50d3b4f6b13c9a5 Mon Sep 17 00:00:00 2001 From: Matus Marhefka Date: Tue, 14 May 2019 15:38:50 +0200 Subject: [PATCH] Add test for DS session and SCAP 1.3 remote resources * Test for PR#1324 which verifies that DS session does not quit when SCAP 1.3 content contains remote component but `--fetch-remote-resources` option is not provided. The test is also extended to verify that scans utilizing SCAP 1.2 and 1.3 datastreams produce the same results. --- tests/DS/Makefile.am | 2 + .../remote_content_1.2.ds.xml | 87 ++++++++++++++++++ .../remote_content_1.3.ds.xml | 89 +++++++++++++++++++ tests/DS/test_ds.sh | 17 ++++ 4 files changed, 195 insertions(+) create mode 100644 tests/DS/ds_continue_without_remote_resources/remote_content_1.2.ds.xml create mode 100644 tests/DS/ds_continue_without_remote_resources/remote_content_1.3.ds.xml diff --git a/tests/DS/Makefile.am b/tests/DS/Makefile.am index 616f24d24..ea742386d 100644 --- a/tests/DS/Makefile.am +++ b/tests/DS/Makefile.am @@ -11,6 +11,8 @@ TESTS_ENVIRONMENT= \ TESTS = test_ds.sh EXTRA_DIST = test_ds.sh \ + ds_continue_without_remote_resources/remote_content_1.2.ds.xml \ + ds_continue_without_remote_resources/remote_content_1.3.ds.xml \ eval_invalid/sds.xml \ eval_invalid/sds-oval.xml \ eval_simple/sds.xml \ diff --git a/tests/DS/ds_continue_without_remote_resources/remote_content_1.2.ds.xml b/tests/DS/ds_continue_without_remote_resources/remote_content_1.2.ds.xml new file mode 100644 index 000000000..31d4fc770 --- /dev/null +++ b/tests/DS/ds_continue_without_remote_resources/remote_content_1.2.ds.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + 5.10 + 2009-01-12T10:41:00-05:00 + + + + + + PASS + pass + + + + + + + + + + + + + + + + oval:x:var:1 + + + + + + + + accepted + 1.0 + + + xccdf_test_profile + This profile is for testing. + + + + + test value + foo + 50 + 100 + + + This rule always pass + + + + + + This rule checks remote resource + + + + + + This rule always pass + + + + + + + diff --git a/tests/DS/ds_continue_without_remote_resources/remote_content_1.3.ds.xml b/tests/DS/ds_continue_without_remote_resources/remote_content_1.3.ds.xml new file mode 100644 index 000000000..3cf15f8df --- /dev/null +++ b/tests/DS/ds_continue_without_remote_resources/remote_content_1.3.ds.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + 5.11 + 2009-01-12T10:41:00-05:00 + + + + + + PASS + pass + + + + + + + + + + + + + + + + oval:x:var:1 + + + + + + + + accepted + 1.0 + + + xccdf_test_profile + This profile is for testing. + + + + + test value + foo + 50 + 100 + + + This rule always pass + + + + + + This rule checks remote resource + + + + + + This rule always pass + + + + + + + diff --git a/tests/DS/test_ds.sh b/tests/DS/test_ds.sh index 22cafe6c9..1383ad87a 100755 --- a/tests/DS/test_ds.sh +++ b/tests/DS/test_ds.sh @@ -414,6 +414,21 @@ function test_sds_tailoring { rm -f "$result" } +function test_ds_continue_without_remote_resources() { + local DS="${srcdir}/$1" + local PROFILE="$2" + local result=$(mktemp) + + $OSCAP xccdf eval --profile "$PROFILE" --results "$result" "$DS" + + assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-pass"]/result[text()="pass"]' + assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-remote_res"]/result[text()="notchecked"]' + assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-pass2"]/result[text()="pass"]' + + rm -f "$result" +} + + # Testing. test_init "test_ds.log" @@ -454,6 +469,8 @@ test_run "rds_split_simple" test_rds_split rds_split_simple report-request.xml r test_run "test_eval_complex" test_eval_complex test_run "sds_add_multiple_oval_twice_in_row" sds_add_multiple_twice +test_run "test_ds_1_2_continue_without_remote_resources" test_ds_continue_without_remote_resources ds_continue_without_remote_resources/remote_content_1.2.ds.xml xccdf_com.example.www_profile_test_remote_res +test_run "test_ds_1_3_continue_without_remote_resources" test_ds_continue_without_remote_resources ds_continue_without_remote_resources/remote_content_1.3.ds.xml xccdf_com.example.www_profile_test_remote_res test_exit