From owner-svn-src-head@freebsd.org Sun Jun 17 17:31:20 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5885E10033D6; Sun, 17 Jun 2018 17:31:20 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 04DDF76D1D; Sun, 17 Jun 2018 17:31:20 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DAA1C185F8; Sun, 17 Jun 2018 17:31:19 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5HHVJwW023641; Sun, 17 Jun 2018 17:31:19 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5HHVHOA023626; Sun, 17 Jun 2018 17:31:17 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201806171731.w5HHVHOA023626@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 17 Jun 2018 17:31:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335290 - in head: etc/mtree usr.sbin/praudit usr.sbin/praudit/tests usr.sbin/praudit/tests/input X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in head: etc/mtree usr.sbin/praudit usr.sbin/praudit/tests usr.sbin/praudit/tests/input X-SVN-Commit-Revision: 335290 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2018 17:31:20 -0000 Author: asomers Date: Sun Jun 17 17:31:16 2018 New Revision: 335290 URL: https://svnweb.freebsd.org/changeset/base/335290 Log: praudit(1): add tests Submitted by: aniketp MFC after: 2 weeks X-MFC-With: 335287 Sponsored by: Google, Inc. (GSoC 2018) Differential Revision: https://reviews.freebsd.org/D15751 Added: head/usr.sbin/praudit/tests/ head/usr.sbin/praudit/tests/Makefile (contents, props changed) head/usr.sbin/praudit/tests/input/ head/usr.sbin/praudit/tests/input/corrupted (contents, props changed) head/usr.sbin/praudit/tests/input/del_comma (contents, props changed) head/usr.sbin/praudit/tests/input/del_underscore (contents, props changed) head/usr.sbin/praudit/tests/input/no_args (contents, props changed) head/usr.sbin/praudit/tests/input/numeric_form (contents, props changed) head/usr.sbin/praudit/tests/input/raw_form (contents, props changed) head/usr.sbin/praudit/tests/input/same_line (contents, props changed) head/usr.sbin/praudit/tests/input/short_form (contents, props changed) head/usr.sbin/praudit/tests/input/trail (contents, props changed) head/usr.sbin/praudit/tests/input/xml_form (contents, props changed) head/usr.sbin/praudit/tests/praudit_test.sh (contents, props changed) Modified: head/etc/mtree/BSD.tests.dist head/usr.sbin/praudit/Makefile Modified: head/etc/mtree/BSD.tests.dist ============================================================================== --- head/etc/mtree/BSD.tests.dist Sun Jun 17 17:28:27 2018 (r335289) +++ head/etc/mtree/BSD.tests.dist Sun Jun 17 17:31:16 2018 (r335290) @@ -1028,6 +1028,8 @@ .. nmtree .. + praudit + .. pw .. rpcbind Modified: head/usr.sbin/praudit/Makefile ============================================================================== --- head/usr.sbin/praudit/Makefile Sun Jun 17 17:28:27 2018 (r335289) +++ head/usr.sbin/praudit/Makefile Sun Jun 17 17:31:16 2018 (r335290) @@ -14,4 +14,7 @@ WARNS?= 3 LIBADD= bsm +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include Added: head/usr.sbin/praudit/tests/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/Makefile Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,23 @@ +# $FreeBSD$ + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/usr.sbin/praudit + +ATF_TESTS_SH= praudit_test + +${PACKAGE}FILES+= \ + input/trail \ + input/corrupted \ + input/del_comma \ + input/del_underscore \ + input/no_args \ + input/numeric_form \ + input/raw_form \ + input/same_line \ + input/short_form \ + input/xml_form + +TEST_METADATA+= timeout="10" + +.include Added: head/usr.sbin/praudit/tests/input/corrupted ============================================================================== Binary file. No diff available. Added: head/usr.sbin/praudit/tests/input/del_comma ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/input/del_comma Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,7 @@ +header,113,11,socket(2),0,Mon Jun 11 10:18:45 2018, + 380 msec +argument,1,0x1c,domain +argument,2,0x2,type +argument,3,0x0,protocol +subject,root,root,wheel,root,0,7053,4724,37636,10.0.2.2 +return,success,3 +trailer,113 Added: head/usr.sbin/praudit/tests/input/del_underscore ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/input/del_underscore Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,7 @@ +header_113_11_socket(2)_0_Mon Jun 11 10:18:45 2018_ + 380 msec +argument_1_0x1c_domain +argument_2_0x2_type +argument_3_0x0_protocol +subject_root_root_wheel_root_0_7053_4724_37636_10.0.2.2 +return_success_3 +trailer_113 Added: head/usr.sbin/praudit/tests/input/no_args ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/input/no_args Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,7 @@ +header,113,11,socket(2),0,Mon Jun 11 10:18:45 2018, + 380 msec +argument,1,0x1c,domain +argument,2,0x2,type +argument,3,0x0,protocol +subject,root,root,wheel,root,0,7053,4724,37636,10.0.2.2 +return,success,3 +trailer,113 Added: head/usr.sbin/praudit/tests/input/numeric_form ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/input/numeric_form Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,7 @@ +header,113,11,socket(2),0,Mon Jun 11 10:18:45 2018, + 380 msec +argument,1,0x1c,domain +argument,2,0x2,type +argument,3,0x0,protocol +subject,root,root,wheel,root,0,7053,4724,37636,10.0.2.2 +return,success,3 +trailer,113 Added: head/usr.sbin/praudit/tests/input/raw_form ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/input/raw_form Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,7 @@ +20,113,11,183,0,1528712325,380 +45,1,0x1c,domain +45,2,0x2,type +45,3,0x0,protocol +36,0,0,0,0,0,7053,4724,37636,10.0.2.2 +39,0,3 +19,113 Added: head/usr.sbin/praudit/tests/input/same_line ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/input/same_line Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1 @@ +header,113,11,socket(2),0,Mon Jun 11 10:18:45 2018, + 380 msec,argument,1,0x1c,domain,argument,2,0x2,type,argument,3,0x0,protocol,subject,root,root,wheel,root,0,7053,4724,37636,10.0.2.2,return,success,3,trailer,113, Added: head/usr.sbin/praudit/tests/input/short_form ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/input/short_form Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,7 @@ +header,113,11,AUE_SOCKET,0,Mon Jun 11 10:18:45 2018, + 380 msec +argument,1,0x1c,domain +argument,2,0x2,type +argument,3,0x0,protocol +subject,root,root,wheel,root,0,7053,4724,37636,10.0.2.2 +return,success,3 +trailer,113 Added: head/usr.sbin/praudit/tests/input/trail ============================================================================== Binary file. No diff available. Added: head/usr.sbin/praudit/tests/input/xml_form ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/input/xml_form Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,12 @@ + + + + + + + + + + + + Added: head/usr.sbin/praudit/tests/praudit_test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/praudit/tests/praudit_test.sh Sun Jun 17 17:31:16 2018 (r335290) @@ -0,0 +1,183 @@ +# +# Copyright (c) 2018 Aniket Pandey +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + + +atf_test_case praudit_delim_comma +praudit_delim_comma_head() +{ + atf_set "descr" "Verify that comma delimiter is present with -d ',' cmd" +} + +praudit_delim_comma_body() +{ + atf_check -o file:$(atf_get_srcdir)/del_comma \ + praudit -d "," $(atf_get_srcdir)/trail +} + + +atf_test_case praudit_delim_underscore +praudit_delim_underscore_head() +{ + atf_set "descr" "Verify that underscore delimiter is present with -d _" +} + +praudit_delim_underscore_body() +{ + atf_check -o file:$(atf_get_srcdir)/del_underscore \ + praudit -d "_" $(atf_get_srcdir)/trail +} + + +atf_test_case praudit_no_args +praudit_no_args_head() +{ + atf_set "descr" "Verify that praudit outputs default form without " \ + "any arguments" +} + +praudit_no_args_body() +{ + atf_check -o file:$(atf_get_srcdir)/no_args \ + praudit $(atf_get_srcdir)/trail +} + + +atf_test_case praudit_numeric_form +praudit_numeric_form_head() +{ + atf_set "descr" "Verify that praudit outputs the numeric form " \ + "with -n flag" +} + +praudit_numeric_form_body() +{ + atf_check -o file:$(atf_get_srcdir)/numeric_form \ + praudit -n $(atf_get_srcdir)/trail +} + + +atf_test_case praudit_raw_form +praudit_raw_form_head() +{ + atf_set "descr" "Verify that praudit outputs the raw form with -r flag" +} + +praudit_raw_form_body() +{ + atf_check -o file:$(atf_get_srcdir)/raw_form \ + praudit -r $(atf_get_srcdir)/trail +} + + +atf_test_case praudit_same_line +praudit_same_line_head() +{ + atf_set "descr" "Verify that praudit outputs the trail in the same " \ + "line with -l flag" +} + +praudit_same_line_body() +{ + atf_check -o file:$(atf_get_srcdir)/same_line \ + praudit -l $(atf_get_srcdir)/trail +} + + +atf_test_case praudit_short_form +praudit_short_form_head() +{ + atf_set "descr" "Verify that praudit outputs the short form " \ + "with -s flag" +} + +praudit_short_form_body() +{ + atf_check -o file:$(atf_get_srcdir)/short_form \ + praudit -s $(atf_get_srcdir)/trail +} + + +atf_test_case praudit_xml_form +praudit_xml_form_head() +{ + atf_set "descr" "Verify that praudit outputs the XML file with -x flag" +} + +praudit_xml_form_body() +{ + atf_check -o file:$(atf_get_srcdir)/xml_form \ + praudit -x $(atf_get_srcdir)/trail +} + + +atf_test_case praudit_sync_to_next_record +praudit_sync_to_next_record_head() +{ + atf_set "descr" "Verify that praudit(1) outputs the last few audit " \ + "records when the initial part of the trail is " \ + "corrputed." +} + +praudit_sync_to_next_record_body() +{ + # The 'corrupted' binary file contains some redundant + # binary symbols before the actual audit record. + # Since 'praudit -p' syncs to the next legitimate record, + # it would skip the corrupted part and print the desired + # audit record to STDOUT. + atf_check -o file:$(atf_get_srcdir)/no_args \ + praudit -p $(atf_get_srcdir)/corrupted +} + + +atf_test_case praudit_raw_short_exclusive +praudit_raw_short_exclusive_head() +{ + atf_set "descr" "Verify that praudit outputs usage message on stderr " \ + "when both raw and short options are specified" +} + +praudit_raw_short_exclusive_body() +{ + atf_check -s exit:1 -e match:"usage: praudit" \ + praudit -rs $(atf_get_srcdir)/trail +} + + +atf_init_test_cases() +{ + atf_add_test_case praudit_delim_comma + atf_add_test_case praudit_delim_underscore + atf_add_test_case praudit_no_args + atf_add_test_case praudit_numeric_form + atf_add_test_case praudit_raw_form + atf_add_test_case praudit_same_line + atf_add_test_case praudit_short_form + atf_add_test_case praudit_xml_form + atf_add_test_case praudit_sync_to_next_record + atf_add_test_case praudit_raw_short_exclusive +}