| 1 |
#!/usr/bin/perl -w |
|---|
| 2 |
|
|---|
| 3 |
use strict; |
|---|
| 4 |
use Test::More 'no_plan'; |
|---|
| 5 |
$| = 1; |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
# =begin testing |
|---|
| 10 |
{ |
|---|
| 11 |
# Make sure Log::Log4perl loads |
|---|
| 12 |
BEGIN { use_ok('Log::Log4perl', qw(:nowarn)) |
|---|
| 13 |
or diag("Can't load Log::Log4perl package. Check to make sure the package library is correctly listed within the path."); |
|---|
| 14 |
|
|---|
| 15 |
# Suppress all logging messages, since we need clean output for unit testing. |
|---|
| 16 |
Log::Log4perl->init({ |
|---|
| 17 |
"log4perl.rootLogger" => "DEBUG, Buffer", |
|---|
| 18 |
"log4perl.appender.Buffer" => "Log::Log4perl::Appender::TestBuffer", |
|---|
| 19 |
"log4perl.appender.Buffer.min_level" => "fatal", |
|---|
| 20 |
"log4perl.appender.Buffer.layout" => "Log::Log4perl::Layout::PatternLayout", |
|---|
| 21 |
"log4perl.appender.Buffer.layout.ConversionPattern" => "%d{yyyy-MM-dd HH:mm:ss} %5p [%M] (%F:%L) - %m%n", |
|---|
| 22 |
}); |
|---|
| 23 |
} |
|---|
| 24 |
require_ok('Log::Log4perl'); |
|---|
| 25 |
use Log::Log4perl qw(:easy); |
|---|
| 26 |
|
|---|
| 27 |
# Make sure the module loads properly, with the exportable |
|---|
| 28 |
# functions shared. |
|---|
| 29 |
BEGIN { use_ok('HoneyClient::Util::Config', qw(getVar setVar)) |
|---|
| 30 |
or diag("Can't load HoneyClient::Util::Config package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| 31 |
require_ok('HoneyClient::Util::Config'); |
|---|
| 32 |
can_ok('HoneyClient::Util::Config', 'getVar'); |
|---|
| 33 |
can_ok('HoneyClient::Util::Config', 'setVar'); |
|---|
| 34 |
use HoneyClient::Util::Config qw(getVar setVar); |
|---|
| 35 |
|
|---|
| 36 |
# Suppress all logging messages, since we need clean output for unit testing. |
|---|
| 37 |
Log::Log4perl->init({ |
|---|
| 38 |
"log4perl.rootLogger" => "DEBUG, Buffer", |
|---|
| 39 |
"log4perl.appender.Buffer" => "Log::Log4perl::Appender::TestBuffer", |
|---|
| 40 |
"log4perl.appender.Buffer.min_level" => "fatal", |
|---|
| 41 |
"log4perl.appender.Buffer.layout" => "Log::Log4perl::Layout::PatternLayout", |
|---|
| 42 |
"log4perl.appender.Buffer.layout.ConversionPattern" => "%d{yyyy-MM-dd HH:mm:ss} %5p [%M] (%F:%L) - %m%n", |
|---|
| 43 |
}); |
|---|
| 44 |
|
|---|
| 45 |
# Make sure Data::Dumper loads |
|---|
| 46 |
BEGIN { use_ok('Data::Dumper') |
|---|
| 47 |
or diag("Can't load Data::Dumper package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| 48 |
require_ok('Data::Dumper'); |
|---|
| 49 |
use Data::Dumper; |
|---|
| 50 |
|
|---|
| 51 |
# Make sure Storable loads |
|---|
| 52 |
BEGIN { use_ok('Storable', qw(nfreeze thaw dclone)) |
|---|
| 53 |
or diag("Can't load Storable package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| 54 |
require_ok('Storable'); |
|---|
| 55 |
can_ok('Storable', 'nfreeze'); |
|---|
| 56 |
can_ok('Storable', 'thaw'); |
|---|
| 57 |
can_ok('Storable', 'dclone'); |
|---|
| 58 |
use Storable qw(nfreeze thaw dclone); |
|---|
| 59 |
|
|---|
| 60 |
# Make sure HoneyClient::Agent::Integrity::Registry loads |
|---|
| 61 |
#BEGIN { use_ok('HoneyClient::Agent::Integrity::Registry') |
|---|
| 62 |
# or diag("Can't load HoneyClient::Agent::Integrity::Registry package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| 63 |
#require_ok('HoneyClient::Agent::Integrity::Registry'); |
|---|
| 64 |
#use HoneyClient::Agent::Integrity::Registry; |
|---|
| 65 |
|
|---|
| 66 |
# Make sure HoneyClient::Agent::Integrity::Filesystem loads |
|---|
| 67 |
#BEGIN { use_ok('HoneyClient::Agent::Integrity::Filesystem') |
|---|
| 68 |
# or diag("Can't load HoneyClient::Agent::Integrity::Filesystem package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| 69 |
#require_ok('HoneyClient::Agent::Integrity::Filesystem'); |
|---|
| 70 |
#use HoneyClient::Agent::Integrity::Filesystem; |
|---|
| 71 |
|
|---|
| 72 |
# Make sure HoneyClient::Agent::Integrity loads. |
|---|
| 73 |
BEGIN { use_ok('HoneyClient::Agent::Integrity') or diag("Can't load HoneyClient::Agent::Integrity package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| 74 |
require_ok('HoneyClient::Agent::Integrity'); |
|---|
| 75 |
use HoneyClient::Agent::Integrity; |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
# =begin testing |
|---|
| 81 |
{ |
|---|
| 82 |
diag("These tests will create temporary files in /tmp. Be sure to cleanup this directory, if any of these tests fail."); |
|---|
| 83 |
|
|---|
| 84 |
# Create a generic Integrity object, with test state data. |
|---|
| 85 |
my $integrity = HoneyClient::Agent::Integrity->new(test => 1, bypass_baseline => 1); |
|---|
| 86 |
is($integrity->{test}, 1, "new(test => 1, bypass_baseline => 1)") or diag("The new() call failed."); |
|---|
| 87 |
isa_ok($integrity, 'HoneyClient::Agent::Integrity', "new(test => 1, bypass_baseline => 1)") or diag("The new() call failed."); |
|---|
| 88 |
|
|---|
| 89 |
diag("Performing baseline check of the system; this may take some time..."); |
|---|
| 90 |
|
|---|
| 91 |
# Perform baseline. |
|---|
| 92 |
$integrity = HoneyClient::Agent::Integrity->new(); |
|---|
| 93 |
isa_ok($integrity, 'HoneyClient::Agent::Integrity', "new()") or diag("The new() call failed."); |
|---|
| 94 |
$integrity->destroy(); |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
1; |
|---|