Skip to content

Commit

Permalink
Add a CTest test for shorthand_to_oval.py
Browse files Browse the repository at this point in the history
This is a simple end-to-end test for utils/shorthand_to_oval.py
  • Loading branch information
jan-cerny committed Jan 25, 2023
1 parent 8dcf357 commit 5e6ca9e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ add_test(
)
set_tests_properties("stable-profile-ids" PROPERTIES LABELS quick)

add_test(
NAME "shorthand-to-oval"
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/utils/shorthand_to_oval.py" "${CMAKE_CURRENT_SOURCE_DIR}/data/utils/shorthand_oval.xml" "${CMAKE_CURRENT_BINARY_DIR}/oval.xml"
)
set_tests_properties("shorthand-to-oval" PROPERTIES LABELS quick)

add_test(
NAME "stable-profiles"
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/test_profile_stability.py" "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/data/profile_stability"
Expand Down
22 changes: 22 additions & 0 deletions tests/data/utils/shorthand_oval.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<def-group>
<definition class="compliance" id="no_empty_passwords" version="1">
<metadata>
<title>Prevent Login to Accounts With Empty Password</title>
<affected family="unix">
<platform>multi_platform_all</platform>
</affected>
<description>The file /etc/pam.d/system-auth should not contain the nullok option</description>
</metadata>
<criteria>
<criterion comment="make sure the nullok option is not used in /etc/pam.d/system-auth" test_ref="test_no_empty_passwords"/>
</criteria>
</definition>
<ind:textfilecontent54_test check="all" check_existence="none_exist" version="1" id="test_no_empty_passwords" comment="make sure nullok is not used in /etc/pam.d/system-auth">
<ind:object object_ref="object_no_empty_passwords"/>
</ind:textfilecontent54_test>
<ind:textfilecontent54_object id="object_no_empty_passwords" version="1">
<ind:filepath operation="pattern match">^/etc/pam.d/(system|password)-auth$</ind:filepath>
<ind:pattern operation="pattern match">^[^#]*\bnullok\b.*$</ind:pattern>
<ind:instance datatype="int">1</ind:instance>
</ind:textfilecontent54_object>
</def-group>

0 comments on commit 5e6ca9e

Please sign in to comment.