Skip to content

Commit 8d541d9

Browse files
authored
Merge pull request #1457 from evgenyz/test_password_probe_offline
Add "offline" mode test for the password OVAL probe
2 parents 5871766 + a662645 commit 8d541d9

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

tests/probes/password/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
if(ENABLE_PROBES_UNIX)
22
add_oscap_test("test_probes_password.sh")
3+
add_oscap_test("test_probes_password_offline.sh")
34
endif()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2009 Red Hat Inc., Durham, North Carolina.
4+
# All Rights Reserved.
5+
#
6+
# OpenScap Probes Test Suite.
7+
#
8+
# Created on: Nov 30, 2009
9+
#
10+
# Authors:
11+
# Peter Vrabec, <[email protected]>
12+
# David Niemoller
13+
# Ondrej Moris, <[email protected]>
14+
# Evgenii Kolesnikov, <[email protected]>
15+
16+
. $builddir/tests/test_common.sh
17+
18+
# Test Cases.
19+
20+
function test_probes_password {
21+
22+
probecheck "password" || return 255
23+
24+
local ret_val=0;
25+
local DF="${srcdir}/test_probes_password_offline.xml"
26+
local RF="results.xml"
27+
28+
[ -f $RF ] && rm -f $RF
29+
30+
tmpdir=$(mktemp -t -d "test_password.XXXXXX")
31+
set_chroot_offline_test_mode "$tmpdir"
32+
33+
$OSCAP oval eval --results $RF $DF
34+
35+
unset_chroot_offline_test_mode
36+
rm -rf $tempdir
37+
38+
if [ -f $RF ]; then
39+
result=$RF
40+
assert_exists 1 'oval_results/results/system/tests/test[@test_id="oval:1:tst:1"][@result="not applicable"]'
41+
ret_val=$?
42+
else
43+
ret_val=1
44+
fi
45+
46+
return $ret_val
47+
}
48+
49+
# Testing.
50+
51+
test_init
52+
53+
test_run "test_probes_password_offline" test_probes_password
54+
55+
test_exit
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0"?>
2+
<oval_definitions xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ind-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:unix-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:lin-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd">
3+
<generator>
4+
<oval:product_name>password</oval:product_name>
5+
<oval:product_version>1.0</oval:product_version>
6+
<oval:schema_version>5.4</oval:schema_version>
7+
<oval:timestamp>2008-03-31T00:00:00-00:00</oval:timestamp>
8+
</generator>
9+
<definitions>
10+
<definition class="compliance" version="1" id="oval:1:def:1"> <!-- comment="true" -->
11+
<metadata>
12+
<title></title>
13+
<description></description>
14+
</metadata>
15+
<criteria>
16+
<criteria operator="AND">
17+
<criterion test_ref="oval:1:tst:1"/>
18+
</criteria>
19+
</criteria>
20+
</definition>
21+
</definitions>
22+
23+
<tests>
24+
<password_test version="1" id="oval:1:tst:1" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix">
25+
<object object_ref="oval:1:obj:1"/>
26+
<state state_ref="oval:1:ste:1"/>
27+
</password_test>
28+
</tests>
29+
30+
<objects>
31+
<password_object version="1" id="oval:1:obj:1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix">
32+
<username>root</username>
33+
</password_object>
34+
</objects>
35+
36+
<states>
37+
<password_state version="1" id="oval:1:ste:1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix">
38+
<username>root</username>
39+
<password>x</password>
40+
<user_id datatype="int">0</user_id>
41+
<group_id datatype="int">0</group_id>
42+
<gcos>root</gcos>
43+
<home_dir>/root</home_dir>
44+
<login_shell>/bin/bash</login_shell>
45+
</password_state>
46+
</states>
47+
48+
</oval_definitions>

0 commit comments

Comments
 (0)