praudit_test.sh revision 335290
1335290Sasomers# 2335290Sasomers# Copyright (c) 2018 Aniket Pandey 3335290Sasomers# 4335290Sasomers# Redistribution and use in source and binary forms, with or without 5335290Sasomers# modification, are permitted provided that the following conditions 6335290Sasomers# are met: 7335290Sasomers# 1. Redistributions of source code must retain the above copyright 8335290Sasomers# notice, this list of conditions and the following disclaimer. 9335290Sasomers# 2. Redistributions in binary form must reproduce the above copyright 10335290Sasomers# notice, this list of conditions and the following disclaimer in the 11335290Sasomers# documentation and/or other materials provided with the distribution. 12335290Sasomers# 13335290Sasomers# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14335290Sasomers# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15335290Sasomers# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16335290Sasomers# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17335290Sasomers# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18335290Sasomers# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19335290Sasomers# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20335290Sasomers# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21335290Sasomers# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22335290Sasomers# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23335290Sasomers# SUCH DAMAGE. 24335290Sasomers# 25335290Sasomers# $FreeBSD: head/usr.sbin/praudit/tests/praudit_test.sh 335290 2018-06-17 17:31:16Z asomers $ 26335290Sasomers# 27335290Sasomers 28335290Sasomers 29335290Sasomersatf_test_case praudit_delim_comma 30335290Sasomerspraudit_delim_comma_head() 31335290Sasomers{ 32335290Sasomers atf_set "descr" "Verify that comma delimiter is present with -d ',' cmd" 33335290Sasomers} 34335290Sasomers 35335290Sasomerspraudit_delim_comma_body() 36335290Sasomers{ 37335290Sasomers atf_check -o file:$(atf_get_srcdir)/del_comma \ 38335290Sasomers praudit -d "," $(atf_get_srcdir)/trail 39335290Sasomers} 40335290Sasomers 41335290Sasomers 42335290Sasomersatf_test_case praudit_delim_underscore 43335290Sasomerspraudit_delim_underscore_head() 44335290Sasomers{ 45335290Sasomers atf_set "descr" "Verify that underscore delimiter is present with -d _" 46335290Sasomers} 47335290Sasomers 48335290Sasomerspraudit_delim_underscore_body() 49335290Sasomers{ 50335290Sasomers atf_check -o file:$(atf_get_srcdir)/del_underscore \ 51335290Sasomers praudit -d "_" $(atf_get_srcdir)/trail 52335290Sasomers} 53335290Sasomers 54335290Sasomers 55335290Sasomersatf_test_case praudit_no_args 56335290Sasomerspraudit_no_args_head() 57335290Sasomers{ 58335290Sasomers atf_set "descr" "Verify that praudit outputs default form without " \ 59335290Sasomers "any arguments" 60335290Sasomers} 61335290Sasomers 62335290Sasomerspraudit_no_args_body() 63335290Sasomers{ 64335290Sasomers atf_check -o file:$(atf_get_srcdir)/no_args \ 65335290Sasomers praudit $(atf_get_srcdir)/trail 66335290Sasomers} 67335290Sasomers 68335290Sasomers 69335290Sasomersatf_test_case praudit_numeric_form 70335290Sasomerspraudit_numeric_form_head() 71335290Sasomers{ 72335290Sasomers atf_set "descr" "Verify that praudit outputs the numeric form " \ 73335290Sasomers "with -n flag" 74335290Sasomers} 75335290Sasomers 76335290Sasomerspraudit_numeric_form_body() 77335290Sasomers{ 78335290Sasomers atf_check -o file:$(atf_get_srcdir)/numeric_form \ 79335290Sasomers praudit -n $(atf_get_srcdir)/trail 80335290Sasomers} 81335290Sasomers 82335290Sasomers 83335290Sasomersatf_test_case praudit_raw_form 84335290Sasomerspraudit_raw_form_head() 85335290Sasomers{ 86335290Sasomers atf_set "descr" "Verify that praudit outputs the raw form with -r flag" 87335290Sasomers} 88335290Sasomers 89335290Sasomerspraudit_raw_form_body() 90335290Sasomers{ 91335290Sasomers atf_check -o file:$(atf_get_srcdir)/raw_form \ 92335290Sasomers praudit -r $(atf_get_srcdir)/trail 93335290Sasomers} 94335290Sasomers 95335290Sasomers 96335290Sasomersatf_test_case praudit_same_line 97335290Sasomerspraudit_same_line_head() 98335290Sasomers{ 99335290Sasomers atf_set "descr" "Verify that praudit outputs the trail in the same " \ 100335290Sasomers "line with -l flag" 101335290Sasomers} 102335290Sasomers 103335290Sasomerspraudit_same_line_body() 104335290Sasomers{ 105335290Sasomers atf_check -o file:$(atf_get_srcdir)/same_line \ 106335290Sasomers praudit -l $(atf_get_srcdir)/trail 107335290Sasomers} 108335290Sasomers 109335290Sasomers 110335290Sasomersatf_test_case praudit_short_form 111335290Sasomerspraudit_short_form_head() 112335290Sasomers{ 113335290Sasomers atf_set "descr" "Verify that praudit outputs the short form " \ 114335290Sasomers "with -s flag" 115335290Sasomers} 116335290Sasomers 117335290Sasomerspraudit_short_form_body() 118335290Sasomers{ 119335290Sasomers atf_check -o file:$(atf_get_srcdir)/short_form \ 120335290Sasomers praudit -s $(atf_get_srcdir)/trail 121335290Sasomers} 122335290Sasomers 123335290Sasomers 124335290Sasomersatf_test_case praudit_xml_form 125335290Sasomerspraudit_xml_form_head() 126335290Sasomers{ 127335290Sasomers atf_set "descr" "Verify that praudit outputs the XML file with -x flag" 128335290Sasomers} 129335290Sasomers 130335290Sasomerspraudit_xml_form_body() 131335290Sasomers{ 132335290Sasomers atf_check -o file:$(atf_get_srcdir)/xml_form \ 133335290Sasomers praudit -x $(atf_get_srcdir)/trail 134335290Sasomers} 135335290Sasomers 136335290Sasomers 137335290Sasomersatf_test_case praudit_sync_to_next_record 138335290Sasomerspraudit_sync_to_next_record_head() 139335290Sasomers{ 140335290Sasomers atf_set "descr" "Verify that praudit(1) outputs the last few audit " \ 141335290Sasomers "records when the initial part of the trail is " \ 142335290Sasomers "corrputed." 143335290Sasomers} 144335290Sasomers 145335290Sasomerspraudit_sync_to_next_record_body() 146335290Sasomers{ 147335290Sasomers # The 'corrupted' binary file contains some redundant 148335290Sasomers # binary symbols before the actual audit record. 149335290Sasomers # Since 'praudit -p' syncs to the next legitimate record, 150335290Sasomers # it would skip the corrupted part and print the desired 151335290Sasomers # audit record to STDOUT. 152335290Sasomers atf_check -o file:$(atf_get_srcdir)/no_args \ 153335290Sasomers praudit -p $(atf_get_srcdir)/corrupted 154335290Sasomers} 155335290Sasomers 156335290Sasomers 157335290Sasomersatf_test_case praudit_raw_short_exclusive 158335290Sasomerspraudit_raw_short_exclusive_head() 159335290Sasomers{ 160335290Sasomers atf_set "descr" "Verify that praudit outputs usage message on stderr " \ 161335290Sasomers "when both raw and short options are specified" 162335290Sasomers} 163335290Sasomers 164335290Sasomerspraudit_raw_short_exclusive_body() 165335290Sasomers{ 166335290Sasomers atf_check -s exit:1 -e match:"usage: praudit" \ 167335290Sasomers praudit -rs $(atf_get_srcdir)/trail 168335290Sasomers} 169335290Sasomers 170335290Sasomers 171335290Sasomersatf_init_test_cases() 172335290Sasomers{ 173335290Sasomers atf_add_test_case praudit_delim_comma 174335290Sasomers atf_add_test_case praudit_delim_underscore 175335290Sasomers atf_add_test_case praudit_no_args 176335290Sasomers atf_add_test_case praudit_numeric_form 177335290Sasomers atf_add_test_case praudit_raw_form 178335290Sasomers atf_add_test_case praudit_same_line 179335290Sasomers atf_add_test_case praudit_short_form 180335290Sasomers atf_add_test_case praudit_xml_form 181335290Sasomers atf_add_test_case praudit_sync_to_next_record 182335290Sasomers atf_add_test_case praudit_raw_short_exclusive 183335290Sasomers} 184