App-Spoor
view release on metacpan or search on metacpan
t/AccessEntryParser.t view on Meta::CPAN
\%parsed_log_entry_forward_added,
'Parses an access log entry - adding a forward'
);
is_deeply(
App::Spoor::AccessEntryParser::parse("$access_log_entry_forward_added\n"),
\%parsed_log_entry_forward_added,
'Parses an access log entry - adding a forward with a trailing newline'
);
my $access_log_entry_not_mailbox_level = '10.10.10.10 - foo [10/15/2018:17:47:27 -0000] ' .
'"POST /cpsess0248462691/webmail/paper_lantern/mail/doaddfwd.html HTTP/1.1" 200 0 "https://cp4.capefox.co:2096/" ' .
'"Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0" "s" "-" 2096';
my %parsed_log_entry_not_mailbox_level = (
type => 'access',
ip => '10.10.10.10',
credential => 'foo',
log_time => DateTime->new(
year => 2018,
month => 10,
day => 15,
hour => 17,
minute => 47,
second => 27,
time_zone => '-0000'
)->epoch(),
context => 'unrecognised',
event => 'unrecognised',
status => 'success'
);
is_deeply(
App::Spoor::AccessEntryParser::parse($access_log_entry_not_mailbox_level),
\%parsed_log_entry_not_mailbox_level,
'Parses an access log entry - not mailbox level'
);
is_deeply(
App::Spoor::AccessEntryParser::parse("$access_log_entry_not_mailbox_level\n"),
\%parsed_log_entry_not_mailbox_level,
'Parses an access log entry - not mailbox level with a trailing newline'
);
my $access_log_entry_incorrect_verb = '10.10.10.10 - rorymckinley%40blah.capefox.co [10/15/2018:17:47:27 -0000] ' .
'"GET /cpsess0248462691/webmail/paper_lantern/mail/doaddfwd.html HTTP/1.1" 200 0 "https://cp4.capefox.co:2096/" ' .
'"Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0" "s" "-" 2096';
my %parsed_log_entry_incorrect_verb = (
type => 'access',
ip => '10.10.10.10',
credential => 'rorymckinley@blah.capefox.co',
t/AccessEntryParser.t view on Meta::CPAN
\%parsed_forward_removed,
'Parses an access log entry - removing a forward'
);
is_deeply(
App::Spoor::AccessEntryParser::parse("$access_log_forward_removed\n"),
\%parsed_forward_removed,
'Parses an access log entry - removing a forward with a trailing newline'
);
my $access_log_forward_removed_not_mailbox = '10.10.10.10 - foobar [03/05/2019:10:38:37 -0000] ' .
'"GET /cpsess9858418447/webmail/paper_lantern/mail/dodelfwd.html?email=rorymckinley%40blah.capefox.co' .
'&emaildest=rorymckinley%2bcpanel%40gmail.com HTTP/1.1" 200 0 "https://cp6.capefox.co:2096/" ' .
'"Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 ' .
'Safari/537.36" "s" "-" 2096';
my %parsed_forward_removed_not_mailbox = (
type => 'access',
ip => '10.10.10.10',
credential => 'foobar',
log_time => DateTime->new(
year => 2019,
month => 3,
day => 5,
hour => 10,
minute => 38,
second => 37,
time_zone => '-0000'
)->epoch(),
context => 'unrecognised',
event => 'unrecognised',
status => 'success'
);
is_deeply(
App::Spoor::AccessEntryParser::parse($access_log_forward_removed_not_mailbox),
\%parsed_forward_removed_not_mailbox,
'Parses an access log entry - removing a forward not at mailbox level'
);
is_deeply(
App::Spoor::AccessEntryParser::parse("$access_log_forward_removed_not_mailbox\n"),
\%parsed_forward_removed_not_mailbox,
'Parses an access log entry - removing a forward not at mailbox level with a trailing newline - '
);
my $access_log_forward_removed_fail = '10.10.10.10 - rorymckinley%40blah.capefox.co [03/05/2019:10:38:37 -0000] ' .
'"GET /cpsess9858418447/webmail/paper_lantern/mail/dodelfwd.html?email=rorymckinley%40blah.capefox.co' .
'&emaildest=rorymckinley%2bcpanel%40gmail.com HTTP/1.1" 400 0 "https://cp6.capefox.co:2096/" ' .
'"Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 ' .
'Safari/537.36" "s" "-" 2096';
my %parsed_forward_removed_fail = (
xt/boilerplate.t view on Meta::CPAN
#!perl -T
use 5.006;
use strict;
use warnings;
use Test::More;
plan tests => 5;
sub not_in_file_ok {
my ($filename, %regex) = @_;
open( my $fh, '<', $filename )
or die "couldn't open $filename for reading: $!";
my %violated;
while (my $line = <$fh>) {
while (my ($desc, $regex) = each %regex) {
if ($line =~ $regex) {
push @{$violated{$desc}||=[]}, $.;
xt/boilerplate.t view on Meta::CPAN
if (%violated) {
fail("$filename contains boilerplate text");
diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
} else {
pass("$filename contains no boilerplate text");
}
}
sub module_boilerplate_ok {
my ($module) = @_;
not_in_file_ok($module =>
'the great new $MODULENAME' => qr/ - The great new /,
'boilerplate description' => qr/Quick summary of what the module/,
'stub function definition' => qr/function[12]/,
);
}
TODO: {
local $TODO = "Need to replace the boilerplate text";
not_in_file_ok(README =>
"The README is used..." => qr/The README is used/,
"'version information here'" => qr/to provide version information/,
);
not_in_file_ok(Changes =>
"placeholder date/time" => qr(Date/time)
);
module_boilerplate_ok('lib/App/Spoor.pm');
module_boilerplate_ok('lib/App/Spoor/AccessEntryParser.pm');
module_boilerplate_ok('lib/App/Spoor/LoginEntryParser.pm');
}
( run in 0.246 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )