Apache2-AuthCookieDBI
view release on metacpan or search on metacpan
t/utils24.t view on Meta::CPAN
use strict;
use warnings;
use English qw(-no_match_vars);
use FindBin qw($Bin);
use lib "$Bin/mock_libs";
use Apache2::RequestRec; # from mocks
use Apache2::Const -compile => qw( AUTHZ_GRANTED AUTHZ_DENIED AUTHZ_DENIED_NO_USER AUTHZ_GENERAL_ERROR);
use Crypt::CBC; # from mocks
use Digest::MD5 qw( md5_hex ); # from mocks
use Digest::SHA;
use Data::Dumper;
use Mock::Tieable;
use Test::More tests => 72;
use constant CLASS_UNDER_TEST => 'Apache2_4::AuthCookieDBI';
use constant EMPTY_STRING => q{};
use constant TRUE => 1;
use_ok(CLASS_UNDER_TEST);
test_authen_cred();
test_check_password();
test_defined_or_empty();
test_decrypt_session_key();
test_encrypt_session_key();
test_dir_config_var();
test_authen_ses_key();
test_get_cipher_for_type();
test_group();
test__dbi_connect();
test_get_crypted_password();
test_user_is_active();
test__get_new_session();
exit;
sub set_up {
my $auth_name = shift;
my $mock_config = shift || _mock_config_for_auth_name($auth_name);
my $r = Apache2::RequestRec->new(
auth_name => $auth_name,
mock_config => $mock_config
); # from mock_libs
return $r;
}
sub _mock_config_for_auth_name {
my ($auth_name) = @_;
my %mock_config = (
"${auth_name}DBI_DSN" => 'test_DBI_DSN',
"${auth_name}DBI_User" => 'test_DBI_User',
"${auth_name}DBI_Password" => 'test_DBI_Password',
"${auth_name}DBI_SecretKey" => 'test_DBI_SecretKey',
"${auth_name}DBI_PasswordField" => 'test_DBI_PasswordField',
"${auth_name}DBI_UsersTable" => 'test_DBI_Userstable',
"${auth_name}DBI_UserField" => 'test_DBI_UserField',
"${auth_name}DBI_UserActiveField" => EMPTY_STRING,
);
return \%mock_config;
}
sub test_authen_cred {
my $auth_name = 'testing_authen_cred';
my $secret_key = 'test secret key';
my $mock_config = {
( run in 0.604 second using v1.01-cache-2.11-cpan-39bf76dae61 )