* Created Get->uuid to generate random UUIDs via 'uuidgen'.
* Created Storage->read_mode that returns the standard 4-digit mode of a directory or file.
* Created System->stop_daemon to stop daemons.
* Altered Template->get to take fully defined path names.
* Altered Template->skin to use the 'set' parameter (as documented) instead of 'skin'. Also made it so that a skin could be set even if the skin directory doesn't exist via the new 'fatal' parameter.
Signed-off-by: Digimer <digimer@alteeve.ca>
is($mode,"4755","Verifying that 'Storage->change_mode' was able to change the mode of the test file (including setting the setuid and setgid sticky bits).");
is($directory_mode,"0757","Verifying that 'Storage->create_directory' created a directory with the requested mode.");
is($directory_user_name,$use_user,"Verifying that 'Storage->create_directory' created a directory with the requested owner.");
is($directory_group_name,$use_group,"Verifying that 'Storage->create_directory' created a directory with the requested group.");
# read_config
$an->data->{foo}{bar}{a}="test";
is($an->Storage->read_config({file=>"AN/test.conf"}),0,"Verifying that 'Storage->read_config' successfully found 'AN/test.conf'.");
is($an->Storage->read_config({file=>""}),1,"Verifying that 'Storage->read_config' returns '1' when called without a 'file' parameter being set.");
is($an->Storage->read_config({file=>"AN/moo.conf"}),2,"Verifying that 'Storage->read_config' returns '2' when the non-existent 'AN/moo.conf' is passed.");
cmp_ok($an->data->{foo}{bar}{a},'eq','I am "a"',"Verifying that 'AN/test.conf's 'foo::bar::a' overwrote an earlier set value.");
cmp_ok($an->data->{foo}{bar}{b},'eq','I am "b", split with tabs and having trailing spaces.',"Verifying that 'AN/test.conf's 'foo::bar::b' has whitespaces removed as expected.");
cmp_ok($an->data->{foo}{baz}{1},'eq','This is \'1\' with no spaces',"Verifying that 'AN/test.conf's 'foo::baz::1' parsed without spaces around '='.");
cmp_ok($an->data->{foo}{baz}{2},'eq','I had a $dollar = sign and split with tabs.',"Verifying that 'AN/test.conf's 'foo::baz::2' had no trouble with a '\$' and '=' characters in the string.");
# read_file was tested earlier.
# read_mode was tested earlier.
# search_directories
my$array1=$an->Storage->search_directories;
my$array1=$an->Storage->search_directories;
my$a1_count=@{$array1};
my$a1_count=@{$array1};
cmp_ok($a1_count,'>',0,"Verifying that Storage->search_directories has at least one entry. Found: [$a1_count] directories.");
cmp_ok($a1_count,'>',0,"Verifying that Storage->search_directories has at least one entry. Found: [$a1_count] directories.");
cmp_ok($a2_count,'==',2,"Verifying that Storage->search_directories now has 2 entries from a passed in CSV, testing that the list changed and a fake directory was dropped.");
cmp_ok($a2_count,'==',2,"Verifying that Storage->search_directories now has 2 entries from a passed in CSV, testing that the list changed and a fake directory was dropped.");
cmp_ok($a3_count,'==',3,"Verifying that Storage->search_directories now has 3 entries from a passed in array reference, verifying that the list changed again.");
cmp_ok($a3_count,'==',3,"Verifying that Storage->search_directories now has 3 entries from a passed in array reference, verifying that the list changed again.");
cmp_ok($a4_count,'==',$a1_count,"Verifying that Storage->search_directories has the original number of directories: [$a4_count] after being called with an invalid 'directories' parameter, showing that it reset properly.");
cmp_ok($a4_count,'==',$a1_count,"Verifying that Storage->search_directories has the original number of directories: [$a4_count] after being called with an invalid 'directories' parameter, showing that it reset properly.");
is($test2_template,"This is test template #2. It has a replacement: [boo!].\n","Verifying that 'Template->get' was able to read a test template with a variable insertion.");
is($an->Template->skin,"alteeve","Verifying that 'Template->skin' is initially set to 'alteeve'.");
$an->Template->skin({fatal=>0,set=>"test"});# We disable fatal because there may be no skin directory yet.
is($an->Template->skin,"test","Verifying that 'Template->skin' was changed to 'test'.");
$an->Template->skin({fatal=>0,set=>"alteeve"});
is($an->Template->skin,"alteeve","Verifying that 'Template->skin' was changed back to 'alteeve'.");
# Clean up
unlink$test_template_file;
### AN::Tools::Validate tests
# is_ipv4
is($an->Validate->is_ipv4({ip=>"0.0.0.0"}),"1","Verifying that 'Validate->is_ipv4' recognizes '0.0.0.0' as a valid IP address.");
is($an->Validate->is_ipv4({ip=>"255.255.255.255"}),"1","Verifying that 'Validate->is_ipv4' recognizes '255.255.255.255' as a valid IP address.");
is($an->Validate->is_ipv4({ip=>"256.255.255.255"}),"0","Verifying that 'Validate->is_ipv4' recognizes '256.255.255.255' as an invalid IP address.");
is($an->Validate->is_ipv4({ip=>"alteeve.com"}),"0","Verifying that 'Validate->is_ipv4' recognizes 'alteeve.com' as an invalid IP address.");
is($an->Validate->is_ipv4({ip=>"::1"}),"0","Verifying that 'Validate->is_ipv4' recognizes '::1' as an invalid IP address.");
is($bad_path,"#!not_found!#","Verifying that Storage->find properly returned '#!not_found!#' for a non-existed file.");
# Config file read tests.
$an->data->{foo}{bar}{a}="test";
is($an->Storage->read_config({file=>"AN/test.conf"}),0,"Verifying that 'Storage->read_config' successfully found 'AN/test.conf'.");
is($an->Storage->read_config({file=>""}),1,"Verifying that 'Storage->read_config' returns '1' when called without a 'file' parameter being set.");
is($an->Storage->read_config({file=>"AN/moo.conf"}),2,"Verifying that 'Storage->read_config' returns '2' when the non-existent 'AN/moo.conf' is passed.");
cmp_ok($an->data->{foo}{bar}{a},'eq','I am "a"',"Verifying that 'AN/test.conf's 'foo::bar::a' overwrote an earlier set value.");
cmp_ok($an->data->{foo}{bar}{b},'eq','I am "b", split with tabs and having trailing spaces.',"Verifying that 'AN/test.conf's 'foo::bar::b' has whitespaces removed as expected.");
cmp_ok($an->data->{foo}{baz}{1},'eq','This is \'1\' with no spaces',"Verifying that 'AN/test.conf's 'foo::baz::1' parsed without spaces around '='.");
cmp_ok($an->data->{foo}{baz}{2},'eq','I had a $dollar = sign and split with tabs.',"Verifying that 'AN/test.conf's 'foo::baz::2' had no trouble with a '\$' and '=' characters in the string.");
my$output=$an->System->call({shell_call=>$an->data->{path}{exe}{systemctl}." status ".$daemon.".service; ".$an->data->{path}{exe}{'echo'}." return_code:\$?"});
my$output=$an->System->call({shell_call=>$an->data->{path}{exe}{systemctl}." status ".$say_daemon."; ".$an->data->{path}{exe}{'echo'}." return_code:\$?"});
@ -50,7 +50,7 @@ It also has replacement variables: [#!variable!first!#] and [#!variable!second!#
<keyname="log_0028">Successfully read the words file: [#!variable!file!#].</key>
<keyname="log_0028">Successfully read the words file: [#!variable!file!#].</key>
<keyname="log_0029"><![CDATA[[ Error ] - Storage->find() failed to find: [#!variable!file!#].]]></key>
<keyname="log_0029"><![CDATA[[ Error ] - Storage->find() failed to find: [#!variable!file!#].]]></key>
<keyname="log_0030"><![CDATA[[ Warning ] - Template->skin() was asked to set the skin: [#!variable!set!#], but the source directory: [#!variable!skin_directory!#] doesn't exist. Ignoring.]]></key>
<keyname="log_0030"><![CDATA[[ Warning ] - Template->skin() was asked to set the skin: [#!variable!set!#], but the source directory: [#!variable!skin_directory!#] doesn't exist. Ignoring.]]></key>
<keyname="log_0031"><![CDATA[[ Warning ] - Storage->search_directories() was passed the array: [#!variable!array!#], but it wasn't actually an array. Using \@INC + path::directories::tools + \$ENV{'PATH'} for the list of directories to search instead.]]></key>
<keyname="log_0031"><![CDATA[[ Warning ] - Storage->search_directories() was passed the array: [#!variable!array!#], but it wasn't actually an array. Using @INC + path::directories::tools + \$ENV{'PATH'} for the list of directories to search instead.]]></key>
<keyname="log_0032"><![CDATA[[ Warning ] - Words->read()' called without a file name to read.]]></key>
<keyname="log_0032"><![CDATA[[ Warning ] - Words->read()' called without a file name to read.]]></key>
<keyname="log_0033"><![CDATA[[ Warning ] - Words->read()' asked to read: [#!variable!file!#] which was not found.]]></key>
<keyname="log_0033"><![CDATA[[ Warning ] - Words->read()' asked to read: [#!variable!file!#] which was not found.]]></key>
<keyname="log_0034"><![CDATA[[ Warning ] - AN::Tools::Words->read()' asked to read: [#!variable!file!#] which was not readable by: [#!variable!user!#] (uid/euid: [#!variable!uid!#]).]]></key>
<keyname="log_0034"><![CDATA[[ Warning ] - AN::Tools::Words->read()' asked to read: [#!variable!file!#] which was not readable by: [#!variable!user!#] (uid/euid: [#!variable!uid!#]).]]></key>
@ -69,6 +69,9 @@ It also has replacement variables: [#!variable!first!#] and [#!variable!second!#
<keyname="log_0047"><![CDATA[[ Error ] - The module Log->level() was passed an invalid log level: [#!variable!set!#]. Only '0', '1', '2', '3' or '4' are valid.]]></key>
<keyname="log_0047"><![CDATA[[ Error ] - The module Log->level() was passed an invalid log level: [#!variable!set!#]. Only '0', '1', '2', '3' or '4' are valid.]]></key>
<keyname="log_0048"><![CDATA[[ Warning ] - Testing of AN::Tools is beginning. This will generate warnings and alerts and are not a concern.]]></key>
<keyname="log_0048"><![CDATA[[ Warning ] - Testing of AN::Tools is beginning. This will generate warnings and alerts and are not a concern.]]></key>
<keyname="log_0049"><![CDATA[[ Warning ] - Testing of AN::Tools is complete.]]></key>
<keyname="log_0049"><![CDATA[[ Warning ] - Testing of AN::Tools is complete.]]></key>
<keyname="log_0050"><![CDATA[[ Error ] - The module Storage->read_mode() was called without a 'target' parameter, or the parameter was empty.]]></key>
<keyname="log_0051"><![CDATA[[ Error ] - The module Storage->change_owner() was asked to change the ownership of: [#!variable!target!#] which doesn't exist.]]></key>
<keyname="log_0052"><![CDATA[[ Error ] - The module Storage->copy_file() was called but the source file: [#!variable!source!#] doesn't exist.]]></key>
<!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. -->
<!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. -->