r58053 - in /branches/upstream/libdbix-class-encodedcolumn-perl/current: ./ lib/DBIx/Class/ t/ t/lib/DigestTest/ t/lib/DigestTest/Schema/ t/var/
ansgar-guest at users.alioth.debian.org
ansgar-guest at users.alioth.debian.org
Wed May 19 10:43:08 UTC 2010
Author: ansgar-guest
Date: Wed May 19 10:42:55 2010
New Revision: 58053
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=58053
Log:
[svn-upgrade] Integrating new upstream version, libdbix-class-encodedcolumn-perl (0.00009)
Added:
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/bcrypt.t
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/class_level_encoders.t
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/digest_sha.t
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Bcrypt.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/PGP.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/SHA.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Whirlpool.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/pubring.gpg (with props)
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/secring.gpg (with props)
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/open_pgp.t
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/whirlpool.t
Removed:
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/01load.t
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/02digest.t
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/03crosstable_leak.t
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/TableA.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/TableB.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Test.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/pubring.gpg
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/secring.gpg
Modified:
branches/upstream/libdbix-class-encodedcolumn-perl/current/Changes
branches/upstream/libdbix-class-encodedcolumn-perl/current/MANIFEST
branches/upstream/libdbix-class-encodedcolumn-perl/current/META.yml
branches/upstream/libdbix-class-encodedcolumn-perl/current/Makefile.PL
branches/upstream/libdbix-class-encodedcolumn-perl/current/lib/DBIx/Class/EncodedColumn.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema.pm
branches/upstream/libdbix-class-encodedcolumn-perl/current/t/var/DigestTest-Schema-1.x-SQLite.sql
Modified: branches/upstream/libdbix-class-encodedcolumn-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/Changes?rev=58053&op=diff
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/Changes (original)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/Changes Wed May 19 10:42:55 2010
@@ -1,3 +1,5 @@
+0.00009 2010-05-17
+ - Rewritten test suite
0.00008 2010-04-30
- Fix packaging bug.
0.00007 2010-04-29
Modified: branches/upstream/libdbix-class-encodedcolumn-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/MANIFEST?rev=58053&op=diff
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/MANIFEST (original)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/MANIFEST Wed May 19 10:42:55 2010
@@ -15,13 +15,16 @@
MANIFEST This list of files
META.yml
README
-t/01load.t
-t/02digest.t
-t/03crosstable_leak.t
+t/bcrypt.t
+t/class_level_encoders.t
+t/digest_sha.t
t/lib/DigestTest/Schema.pm
-t/lib/DigestTest/Schema/TableA.pm
-t/lib/DigestTest/Schema/TableB.pm
-t/lib/DigestTest/Schema/Test.pm
-t/pubring.gpg
-t/secring.gpg
+t/lib/DigestTest/Schema/Bcrypt.pm
+t/lib/DigestTest/Schema/PGP.pm
+t/lib/DigestTest/Schema/pubring.gpg
+t/lib/DigestTest/Schema/secring.gpg
+t/lib/DigestTest/Schema/SHA.pm
+t/lib/DigestTest/Schema/Whirlpool.pm
+t/open_pgp.t
t/var/DigestTest-Schema-1.x-SQLite.sql
+t/whirlpool.t
Modified: branches/upstream/libdbix-class-encodedcolumn-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/META.yml?rev=58053&op=diff
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/META.yml (original)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/META.yml Wed May 19 10:42:55 2010
@@ -4,7 +4,6 @@
- 'Guillermo Roditi (groditi) <groditi at cpan.org>'
build_requires:
DBD::SQLite: 0
- Digest::SHA: 0
Dir::Self: 0
ExtUtils::MakeMaker: 6.42
File::Spec: 0
@@ -29,4 +28,4 @@
resources:
license: http://dev.perl.org/licenses/
repository: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class-EncodedColumn
-version: 0.00008
+version: 0.00009
Modified: branches/upstream/libdbix-class-encodedcolumn-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/Makefile.PL?rev=58053&op=diff
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/Makefile.PL (original)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/Makefile.PL Wed May 19 10:42:55 2010
@@ -19,27 +19,6 @@
test_requires 'DBD::SQLite';
test_requires 'Dir::Self';
test_requires 'File::Temp';
-test_requires 'Digest::SHA';
test_requires 'File::Spec';
-#recommended modules
-feature 'Digest::MD5 Support?',
- -default => 1,
- 'Digest',
- 'Digest::MD5';
-
-feature 'Digest::SHA Support?',
- -default => 1,
- 'Digest',
- 'Digest::SHA';
-
-feature 'Blowfish Support?',
- -default => 1,
- 'Crypt::Eksblowfish::Bcrypt';
-
-feature 'Crypt::OpenPGP (gpg) Support?',
- -default => 1,
- 'Crypt::OpenPGP',
- 'Crypt::CAST5_PP';
-
WriteAll;
Modified: branches/upstream/libdbix-class-encodedcolumn-perl/current/lib/DBIx/Class/EncodedColumn.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/lib/DBIx/Class/EncodedColumn.pm?rev=58053&op=diff
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/lib/DBIx/Class/EncodedColumn.pm (original)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/lib/DBIx/Class/EncodedColumn.pm Wed May 19 10:42:55 2010
@@ -4,12 +4,12 @@
use warnings;
use base qw/DBIx::Class/;
-use Digest;
use Sub::Name;
__PACKAGE__->mk_classdata( '_column_encoders' );
-our $VERSION = '0.00008';
+our $VERSION = '0.00009';
+$VERSION = eval $VERSION;
sub register_column {
my $self = shift;
@@ -185,18 +185,26 @@
=head2 encode_class
-The class to use for encoding. available classes are:
-
-=over 4
-
-=item C<Crypt::Eksblowfish::Bcrypt> - uses L<DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt>
+The class to use for encoding. Available classes are:
+
+=over 4
+
+=item C<Crypt::Eksblowfish::Bcrypt> - uses
+L<DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt> and
+requires L<Crypt::Eksblowfish::Bcrypt> to be installed
=item C<Digest> - uses L<DBIx::Class::EncodedColumn::Digest>
+requires L<Digest> to be installed as well as the algorithm required
+(L<Digest::SHA>, L<Digest::Whirlpool>, etc)
+
+=item C<Crypt::OpenPGP> - L<DBIx::Class::EncodedColumn::Crypt::OpenPGP>
+and requires L<Crypt::OpenPGP> to be installed
=back
Please see the relevant class's documentation for information about the
-specific arguments accepted by each.
+specific arguments accepted by each and make sure you include the encoding
+algorithm (e.g. L<Crypt::OpenPGP>) in your application's requirements.
=head1 EXTENDED METHODS
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/bcrypt.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/bcrypt.t?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/bcrypt.t (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/bcrypt.t Wed May 19 10:42:55 2010
@@ -1,0 +1,41 @@
+
+use strict;
+use warnings;
+use Test::More;
+
+use Dir::Self;
+use File::Spec;
+use File::Temp 'tempdir';
+use lib File::Spec->catdir(__DIR__, 'lib');
+
+BEGIN {
+ if( eval 'require Crypt::Eksblowfish::Bcrypt' ){
+ plan tests => 7;
+ use_ok('DigestTest::Schema');
+ } else {
+ plan skip_all => 'Crypt::Eksblowfish::Bcrypt not available';
+ exit;
+ }
+}
+
+#1
+DigestTest::Schema->load_classes('Bcrypt');
+
+my $tmp = tempdir( CLEANUP => 1 );
+my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite');
+my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}");
+$schema->deploy({}, File::Spec->catdir(__DIR__, 'var'));
+
+my %create_values = (bcrypt_1 => 'test1', bcrypt_2 => 'test1');
+my $row = $schema->resultset('Bcrypt')->create( \%create_values );
+is( length($row->bcrypt_1), 60, 'correct length');
+is( length($row->bcrypt_2), 59, 'correct length');
+
+ok( $row->bcrypt_1_check('test1'));
+ok( $row->bcrypt_2_check('test1'));
+
+$row->bcrypt_1('test2');
+$row->bcrypt_2('test2');
+
+ok( $row->bcrypt_1_check('test2'));
+ok( $row->bcrypt_2_check('test2'));
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/class_level_encoders.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/class_level_encoders.t?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/class_level_encoders.t (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/class_level_encoders.t Wed May 19 10:42:55 2010
@@ -1,0 +1,53 @@
+
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN {
+ if( eval 'require Digest' && eval 'require Digest::SHA' ){
+ plan tests => 1;
+ } else {
+ plan skip_all => 'Digest::SHA not available';
+ exit;
+ }
+}
+
+{
+ package TestCorrectlySetClassData;
+ use base qw/DBIx::Class/;
+ __PACKAGE__->load_components(qw/EncodedColumn Core/);
+ __PACKAGE__->table('test_register_column');
+}
+
+TestCorrectlySetClassData->add_columns(
+ sha1_hex => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 40,
+ encode_column => 1,
+ encode_class => 'Digest',
+ encode_args => {
+ format => 'hex',
+ algorithm => 'SHA-1',
+ },
+ encode_check_method => 'check_sha1_hex',
+ },
+);
+my $encoders_1 = TestCorrectlySetClassData->_column_encoders;
+
+TestCorrectlySetClassData->add_columns(
+ sha1_b64 => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 27,
+ encode_column => 1,
+ encode_class => 'Digest',
+ encode_args => {
+ algorithm => 'SHA-1',
+ },
+ encode_check_method => 'check_sha1_b64',
+ },
+);
+my $encoders_2 = TestCorrectlySetClassData->_column_encoders;
+
+isnt($encoders_1, $encoders_2, 'register_column uses fresh ref for econders');
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/digest_sha.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/digest_sha.t?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/digest_sha.t (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/digest_sha.t Wed May 19 10:42:55 2010
@@ -1,0 +1,92 @@
+
+use strict;
+use warnings;
+use Test::More;
+
+use Dir::Self;
+use File::Spec;
+use File::Temp 'tempdir';
+use lib File::Spec->catdir(__DIR__, 'lib');
+
+use DigestTest::Schema;
+
+BEGIN {
+ if( eval 'require Digest' && eval 'require Digest::SHA' ){
+ plan tests => 25;
+ } else {
+ plan skip_all => 'Digest::SHA not available';
+ exit;
+ }
+}
+
+DigestTest::Schema->load_classes('SHA');
+
+my $tmp = tempdir( CLEANUP => 1 );
+my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite');
+my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}");
+$schema->deploy({}, File::Spec->catdir(__DIR__, 'var'));
+
+my $checks = {};
+for my $algorithm( qw/SHA-1 SHA-256/){
+ my $maker = Digest->new($algorithm);
+ my $encodings = $checks->{$algorithm} = {};
+ for my $encoding (qw/base64 hex/){
+ my $values = $encodings->{$encoding} = {};
+ my $encoding_method = $encoding eq 'binary' ? 'digest' :
+ ($encoding eq 'hex' ? 'hexdigest' : 'b64digest');
+ for my $value (qw/test1 test2/){
+ $maker->add($value);
+ $values->{$value} = $maker->$encoding_method;
+ }
+ }
+}
+
+
+my %create_values = map { $_ => 'test1' }
+ qw( dummy_col sha1_hex sha1_b64 sha256_hex sha256_b64 sha256_b64_salted );
+
+my $row = $schema->resultset('SHA')->create( \%create_values );
+is($row->dummy_col, 'test1','dummy on create');
+ok(!$row->can('check_dummy_col'), 'no "check_dummy_col" method');
+
+is($row->sha1_hex, $checks->{'SHA-1'}{hex}{test1}, 'hex sha1 on create');
+is($row->sha1_b64, $checks->{'SHA-1'}{base64}{test1}, 'b64 sha1 on create');
+is($row->sha256_hex, $checks->{'SHA-256'}{hex}{test1}, 'hex sha256 on create');
+is($row->sha256b64, $checks->{'SHA-256'}{base64}{test1},'b64 sha256 on create');
+is( length($row->sha256_b64_salted), 57, 'correct salted length');
+
+can_ok($row, qw/check_sha1_hex check_sha1_b64/);
+ok($row->check_sha1_hex('test1'),'Checking hex digest_check_method');
+ok($row->check_sha1_b64('test1'),'Checking b64 digest_check_method');
+ok($row->check_sha256_b64_salted('test1'), 'Checking salted digest_check_method');
+
+$row->sha1_hex('test2');
+is($row->sha1_hex, $checks->{'SHA-1'}{hex}{test2}, 'Checking accessor');
+
+$row->update({sha1_b64 => 'test2', dummy_col => 'test2'});
+is($row->sha1_b64, $checks->{'SHA-1'}{base64}{test2}, 'Checking update');
+is($row->dummy_col, 'test2', 'dummy on update');
+
+$row->set_column(sha256_hex => 'test2');
+is($row->sha256_hex, $checks->{'SHA-256'}{hex}{test2}, 'Checking set_column');
+
+$row->sha256b64('test2');
+is($row->sha256b64, $checks->{'SHA-256'}{base64}{test2}, 'custom accessor');
+
+$row->update;
+
+my $copy = $row->copy({sha256_b64 => 'test2'});
+is($copy->sha1_hex, $checks->{'SHA-1'}{hex}{test2}, 'hex sha1 on copy');
+is($copy->sha1_b64, $checks->{'SHA-1'}{base64}{test2}, 'b64 sha1 on copy');
+is($copy->sha256_hex, $checks->{'SHA-256'}{hex}{test2}, 'hex sha256 on copy');
+is($copy->sha256b64, $checks->{'SHA-256'}{base64}{test2},'b64 sha256 on copy');
+
+my $new = $schema->resultset('SHA')->new( \%create_values );
+is($new->sha1_hex, $checks->{'SHA-1'}{hex}{test1}, 'hex sha1 on new');
+is($new->sha1_b64, $checks->{'SHA-1'}{base64}{test1}, 'b64 sha1 on new');
+is($new->sha256_hex, $checks->{'SHA-256'}{hex}{test1}, 'hex sha256 on new');
+is($new->sha256b64, $checks->{'SHA-256'}{base64}{test1}, 'b64 sha256 on new');
+
+$row->sha1_hex(undef);
+$row->update;
+is($row->sha1_hex, undef, 'Check undef is passed through');
Modified: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema.pm?rev=58053&op=diff
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema.pm (original)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema.pm Wed May 19 10:42:55 2010
@@ -3,6 +3,4 @@
use base qw/DBIx::Class::Schema/;
-__PACKAGE__->load_classes(qw/Test TableA TableB/);
-
1;
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Bcrypt.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Bcrypt.pm?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Bcrypt.pm (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Bcrypt.pm Wed May 19 10:42:55 2010
@@ -1,0 +1,37 @@
+package # hide from PAUSE
+ DigestTest::Schema::Bcrypt;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components(qw/EncodedColumn Core/);
+__PACKAGE__->table('test_bcrypt');
+__PACKAGE__->add_columns(
+ id => {
+ data_type => 'int',
+ is_nullable => 0,
+ is_auto_increment => 1
+ },
+ bcrypt_1 => {
+ data_type => 'text',
+ is_nullable => 1,
+ size => 60,
+ encode_column => 1,
+ encode_class => 'Crypt::Eksblowfish::Bcrypt',
+ encode_check_method => 'bcrypt_1_check',
+ },
+ bcrypt_2 => {
+ data_type => 'text',
+ is_nullable => 1,
+ size => 59,
+ encode_column => 1,
+ encode_class => 'Crypt::Eksblowfish::Bcrypt',
+ encode_args => {key_nul => 0, cost => 6 },
+ encode_check_method => 'bcrypt_2_check',
+ },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/PGP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/PGP.pm?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/PGP.pm (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/PGP.pm Wed May 19 10:42:55 2010
@@ -1,0 +1,69 @@
+package # hide from PAUSE
+ DigestTest::Schema::PGP;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class/;
+use Dir::Self;
+use File::Spec;
+
+my $pgp_conf = {
+ SecRing => File::Spec->catdir(__DIR__,'secring.gpg'),
+ PubRing => File::Spec->catdir(__DIR__,'pubring.gpg'),
+};
+
+__PACKAGE__->load_components(qw/EncodedColumn Core/);
+__PACKAGE__->table('test_pgp');
+__PACKAGE__->add_columns(
+ id => {
+ data_type => 'int',
+ is_nullable => 0,
+ is_auto_increment => 1
+ },
+ dummy_col => {
+ data_type => 'char',
+ size => 43,
+ encode_column => 0,
+ encode_class => 'Digest',
+ encode_check_method => 'check_dummy_col',
+ },
+ pgp_col_passphrase => {
+ data_type => 'text',
+ is_nullable => 1,
+ encode_column => 1,
+ encode_class => 'Crypt::OpenPGP',
+ encode_args => {
+ passphrase => 'Secret Words',
+ armour => 1
+ },
+ encode_check_method => 'decrypt_pgp_passphrase',
+ },
+ pgp_col_key => {
+ data_type => 'text',
+ is_nullable => 1,
+ encode_column => 1,
+ encode_class => 'Crypt::OpenPGP',
+ encode_args => {
+ recipient => '1B8924AA',
+ pgp_args => $pgp_conf,
+ armour => 1
+ },
+ encode_check_method => 'decrypt_pgp_key',
+ },
+ pgp_col_key_ps => {
+ data_type => 'text',
+ is_nullable => 1,
+ encode_column => 1,
+ encode_class => 'Crypt::OpenPGP',
+ encode_args => {
+ recipient => '7BEF6294',
+ pgp_args => $pgp_conf,
+ armour => 1
+ },
+ encode_check_method => 'decrypt_pgp_key_ps',
+ },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/SHA.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/SHA.pm?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/SHA.pm (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/SHA.pm Wed May 19 10:42:55 2010
@@ -1,0 +1,75 @@
+package # hide from PAUSE
+ DigestTest::Schema::SHA;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components(qw/EncodedColumn Core/);
+__PACKAGE__->table('test_sha');
+__PACKAGE__->add_columns(
+ id => {
+ data_type => 'int',
+ is_nullable => 0,
+ is_auto_increment => 1
+ },
+ dummy_col => {
+ data_type => 'char',
+ size => 43,
+ encode_column => 0,
+ encode_class => 'Digest',
+ encode_check_method => 'check_dummy_col',
+ },
+ sha1_hex => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 40,
+ encode_column => 1,
+ encode_class => 'Digest',
+ encode_args => {
+ format => 'hex',
+ algorithm => 'SHA-1',
+ },
+ encode_check_method => 'check_sha1_hex',
+ },
+ sha1_b64 => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 27,
+ encode_column => 1,
+ encode_class => 'Digest',
+ encode_args => {
+ algorithm => 'SHA-1',
+ },
+ encode_check_method => 'check_sha1_b64',
+ },
+ sha256_hex => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 64,
+ encode_column => 1,
+ encode_class => 'Digest',
+ encode_args => { format => 'hex',},
+ },
+ sha256_b64 => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 43,
+ accessor => 'sha256b64',
+ encode_column => 1,
+ encode_class => 'Digest',
+ },
+ sha256_b64_salted => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 57,
+ encode_column => 1,
+ encode_class => 'Digest',
+ encode_check_method => 'check_sha256_b64_salted',
+ encode_args => {salt_length => 14}
+ },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Whirlpool.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Whirlpool.pm?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Whirlpool.pm (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/Whirlpool.pm Wed May 19 10:42:55 2010
@@ -1,0 +1,43 @@
+package # hide from PAUSE
+ DigestTest::Schema::Whirlpool;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components(qw/EncodedColumn Core/);
+__PACKAGE__->table('test_whirlpool');
+__PACKAGE__->add_columns(
+ id => {
+ data_type => 'int',
+ is_nullable => 0,
+ is_auto_increment => 1
+ },
+ whirlpool_hex => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 128,
+ encode_column => 1,
+ encode_class => 'Digest',
+ encode_args => {
+ format => 'hex',
+ algorithm => 'Whirlpool',
+ },
+ encode_check_method => 'check_whirlpool_hex',
+ },
+ whirlpool_b64 => {
+ data_type => 'char',
+ is_nullable => 1,
+ size => 86,
+ encode_column => 1,
+ encode_class => 'Digest',
+ encode_args => {
+ algorithm => 'Whirlpool',
+ },
+ encode_check_method => 'check_whirlpool_b64',
+ },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/pubring.gpg
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/pubring.gpg?rev=58053&op=file
==============================================================================
Binary file - no diff available.
Propchange: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/pubring.gpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/secring.gpg
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/secring.gpg?rev=58053&op=file
==============================================================================
Binary file - no diff available.
Propchange: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/lib/DigestTest/Schema/secring.gpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/open_pgp.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/open_pgp.t?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/open_pgp.t (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/open_pgp.t Wed May 19 10:42:55 2010
@@ -1,0 +1,56 @@
+
+use strict;
+use warnings;
+use Test::More;
+
+use Dir::Self;
+use File::Spec;
+use File::Temp 'tempdir';
+use lib File::Spec->catdir(__DIR__, 'lib');
+use DigestTest::Schema;
+
+BEGIN {
+ if( eval 'require Crypt::OpenPGP' ){
+ plan tests => 6;
+ } else {
+ plan skip_all => 'Crypt::OpenPGP not available';
+ exit;
+ }
+}
+
+#1
+DigestTest::Schema->load_classes('PGP');
+
+my $tmp = tempdir( CLEANUP => 1 );
+my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite');
+my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}");
+$schema->deploy({}, File::Spec->catdir(__DIR__, 'var'));
+
+my $row = $schema->resultset('PGP')->create( {
+ dummy_col => 'Dummy Column',
+ pgp_col_passphrase => 'Test Encrypted Column with Passphrase',
+ pgp_col_key => 'Test Encrypted Column with Key Exchange',
+ pgp_col_key_ps => 'Test Encrypted Column with Key Exchange + Pass',
+} );
+
+like($row->pgp_col_passphrase, qr/BEGIN PGP MESSAGE/, 'Passphrase encrypted');
+like($row->pgp_col_key, qr/BEGIN PGP MESSAGE/, 'Key encrypted');
+like($row->pgp_col_key_ps, qr/BEGIN PGP MESSAGE/, 'Key+Passphrase encrypted');
+
+is(
+ $row->decrypt_pgp_passphrase('Secret Words'),
+ 'Test Encrypted Column with Passphrase',
+ 'Passphrase decryption/encryption'
+);
+
+is(
+ $row->decrypt_pgp_key,
+ 'Test Encrypted Column with Key Exchange',
+ 'Key Exchange decryption/encryption'
+);
+
+is(
+ $row->decrypt_pgp_key_ps('Secret Words'),
+ 'Test Encrypted Column with Key Exchange + Pass',
+ 'Secured Key Exchange decryption/encryption'
+);
Modified: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/var/DigestTest-Schema-1.x-SQLite.sql
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/var/DigestTest-Schema-1.x-SQLite.sql?rev=58053&op=diff
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/var/DigestTest-Schema-1.x-SQLite.sql (original)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/var/DigestTest-Schema-1.x-SQLite.sql Wed May 19 10:42:55 2010
@@ -1,40 +1,51 @@
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Thu Apr 29 20:08:54 2010
+-- Created on Mon May 17 13:22:05 2010
--
BEGIN TRANSACTION;
--
--- Table: tablea
+-- Table: test_bcrypt
--
-CREATE TABLE tablea (
+CREATE TABLE test_bcrypt (
id INTEGER PRIMARY KEY NOT NULL,
- conflicting_name char(43) NOT NULL
+ bcrypt_1 text,
+ bcrypt_2 text
);
--
--- Table: tableb
+-- Table: test_pgp
--
-CREATE TABLE tableb (
+CREATE TABLE test_pgp (
id INTEGER PRIMARY KEY NOT NULL,
- conflicting_name char(43) NOT NULL
+ dummy_col char(43) NOT NULL,
+ pgp_col_passphrase text,
+ pgp_col_key text,
+ pgp_col_key_ps text
);
--
--- Table: test
+-- Table: test_sha
--
-CREATE TABLE test (
+CREATE TABLE test_sha (
id INTEGER PRIMARY KEY NOT NULL,
dummy_col char(43) NOT NULL,
sha1_hex char(40),
sha1_b64 char(27),
sha256_hex char(64),
sha256_b64 char(43),
- sha256_b64_salted char(57),
- bcrypt_1 text,
- bcrypt_2 text
+ sha256_b64_salted char(57)
+);
+
+--
+-- Table: test_whirlpool
+--
+CREATE TABLE test_whirlpool (
+ id INTEGER PRIMARY KEY NOT NULL,
+ whirlpool_hex char(128),
+ whirlpool_b64 char(86)
);
COMMIT;
Added: branches/upstream/libdbix-class-encodedcolumn-perl/current/t/whirlpool.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbix-class-encodedcolumn-perl/current/t/whirlpool.t?rev=58053&op=file
==============================================================================
--- branches/upstream/libdbix-class-encodedcolumn-perl/current/t/whirlpool.t (added)
+++ branches/upstream/libdbix-class-encodedcolumn-perl/current/t/whirlpool.t Wed May 19 10:42:55 2010
@@ -1,0 +1,57 @@
+
+use strict;
+use warnings;
+use Test::More;
+
+use Dir::Self;
+use File::Spec;
+use File::Temp 'tempdir';
+use lib File::Spec->catdir(__DIR__, 'lib');
+use DigestTest::Schema;
+
+BEGIN {
+ if( eval 'require Digest; 1' && eval 'require Digest::Whirlpool; 1' ){
+ plan tests => 7;
+ } else {
+ plan skip_all => 'Digest::Whirlpool not available';
+ exit;
+ }
+}
+
+#1
+DigestTest::Schema->load_classes('Whirlpool');
+
+my $tmp = tempdir( CLEANUP => 1 );
+my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite');
+my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}");
+$schema->deploy({}, File::Spec->catdir(__DIR__, 'var'));
+
+my $checks = {};
+for my $algorithm( qw/Whirlpool/){
+ my $maker = Digest->new($algorithm);
+ my $encodings = $checks->{$algorithm} = {};
+ for my $encoding (qw/base64 hex/){
+ my $values = $encodings->{$encoding} = {};
+ my $encoding_method = $encoding eq 'binary' ? 'digest' :
+ ($encoding eq 'hex' ? 'hexdigest' : 'b64digest');
+ for my $value (qw/test1 test2/){
+ $maker->reset()->add($value);
+ $values->{$value} = $maker->$encoding_method;
+ }
+ }
+}
+
+my %create_values = (whirlpool_hex => 'test1', whirlpool_b64 => 'test1');
+my $row = $schema->resultset('Whirlpool')->create( \%create_values );
+is( $row->whirlpool_hex, $checks->{'Whirlpool'}{hex}{test1}, 'Whirlpool hex');
+is( $row->whirlpool_b64, $checks->{'Whirlpool'}{base64}{test1}, 'Whirlpool b64');
+
+can_ok( $row, qw/check_whirlpool_hex check_whirlpool_b64/ );
+ok( $row->check_whirlpool_hex('test1'), 'Checking hex digest_check_method for Whirlpool');
+ok( $row->check_whirlpool_b64('test1'), 'Checking b64 digest_check_method for Whirlpool');
+
+$row->whirlpool_hex('test2');
+is( $row->whirlpool_hex, $checks->{'Whirlpool'}{hex}{test2}, 'Checking accessor (Whirlpool)');
+
+$row->update({ whirlpool_b64 => 'test2' });
+is( $row->whirlpool_b64, $checks->{'Whirlpool'}{base64}{test2}, 'Checking Update (Whirlpool)');
More information about the Pkg-perl-cvs-commits
mailing list