Egg-Release-Authorize

 view release on metacpan or  search on metacpan

t/08_crypt_cbc.t  view on Meta::CPAN

use Test::More;
use lib qw( ../lib ./lib );
use Egg::Helper;
use UNIVERSAL::require;

unless ( Cache::FileCache->require ) {
	plan skip_all=> "Cache::FileCache is not installed."
} else {
	unless ( Crypt::CBC->require ) {
		plan skip_all=> "Crypt::CBC is not installed."
	} else {
		test();
	}
}

sub test {

my $ciper= Crypt::Blowfish->require ? 'Blowfish'
         : Crypt::DES->require      ? 'DES'
         : Crypt::Camellia->require ? 'Camellia'
         : Crypt::Rabbit->require   ? 'Rabbit'
         : Crypt::Twofish2->require ? 'Twofish2'
         : return do {
	plan skip_all=> "The Ciper module is not installed.";
  };

plan tests=> 39;

my $tool= Egg::Helper->helper_tools;

my $project= 'Vtest';
my $path   = $tool->helper_tempdir. "/$project";
my $psw    = '%test%';
my $key    = '12345678';
my $salt   = '';
my $passwd = do {
	my $cbc= Crypt::CBC->new({
	  cipher         => $ciper,
	  key            => $key,
	  iv             => '$KJh#(}q',
	  padding        => 'standard',
	  prepend_iv     => 0,
	  regenerate_key => 1,
	  });
	$cbc->encrypt_hex($psw. $salt);
  };

$tool->helper_create_files(
  [ $tool->helper_yaml_load( join('', <DATA>)) ],
  { path => $path, salt=> $salt, cipher=> $ciper, key=> $key, passwd=> $passwd },
  );

my $e= Egg::Helper->run( Vtest => {
#  vtest_plugins=> [qw/ -Debug /],
  vtest_root   => $path,
  vtest_config => { MODEL=> ['Auth'] },
  });

ok $e->is_model('auth'), q{$e->is_model('auth')};
ok $e->is_model('a_test'), q{$e->is_model('a_test')};

ok my $s= $e->model('a_test'), q{$s= $e->model('a_test')};
is $s, $e->model('auth'), q{$s, $e->model('auth')};

isa_ok $s, 'Vtest::Model::Auth::Test';
isa_ok $s, 'Egg::Model::Auth::Session::FileCache';
isa_ok $s, 'Egg::Model::Auth::Bind::Cookie';
isa_ok $s, 'Egg::Model::Auth::Base';
isa_ok $s, 'Egg::Base';
isa_ok $s, 'Egg::Component';
isa_ok $s, 'Egg::Component::Base';

ok my $a= $s->api, q{my $a= $s->api};
isa_ok $a, 'Vtest::Model::Auth::Test::API::File';
isa_ok $a, 'Egg::Model::Auth::Crypt::CBC';
isa_ok $a, 'Egg::Model::Auth::Base::API';
isa_ok $a, 'Egg::Component::Base';

$e->helper_create_dir($e->path_to('cache'));



( run in 0.777 second using v1.01-cache-2.11-cpan-f4a522933cf )