Commits

Toby Inkster  committed 52ed29b Draft

better test cases

  • Participants
  • Parent commits 9896179

Comments (0)

Files changed (2)

File t/02decrypt.t

-use Test::More tests => 3;
+use utf8;
+use Test::More tests => 5;
 use RDF::Crypt;
 
-my $D = RDF::Crypt::Decrypter->new_from_string(<<'PRIVATEKEY');
------BEGIN RSA PRIVATE KEY-----
-MIIEogIBAAKCAQEAyT/S/MwLJYVMBEEmc7IQszS5nxdu0iaTlshg7iXlQG9ue8ep
-u01THS+lhE66YnuK4YFiTrrpEKMyNo0xBz7n2o4fXkhXy/NTSGrTdAN8mLmVdyeX
-R0otY+u6XdI1DLHjNwfSLd8BBhMXJefbBlM51hZ8biKNBIS8f2P7wGEzQrm+HZkI
-gM8clVU8GvwDE/cwuRd7ZJvX7YT27g5EJCKFbpVvY07sO7qVQ7XEc5ItAfMNq/HO
-c7xZLTiNoThxIK/HldZnB/kf2pI0r3LqBQyMXCKZMr4sbfEopaNeI0oLjLnzW1X9
-fFJmXD0J3Ub9OdfSEB/etfL+Nmzbxkj/GhtQ1QIDAQABAoIBAHL8+sris0O/BA4y
-Q4w7o/shFyZltzZwQEgZOfkYwgKtKM2k6cBRkDnO7Z3JdgmrWVE8IjWl6mFNPfWZ
-evgO418ncZjncPLhlyZ7k1JoY5rH/zTT9EYRhhnfqN7Oqu0T/yWEXH1FPEqCQemw
-rp7Qku1Wb8ZmC3kXdrS7Ji9n2mg2wM7xNf9nboxtYSleFGmnhuJcyp3OyvFUrIKJ
-gwNstNC/nZb1ZrGKvIjcQ+HXzqVQamPu1z9JASyYcGFRJmcRlBvgCGsCn8T1dHze
-sdy9n8tpq10A2dUad/Im9vbxPXpa0OK/L1/m4Fy619KIRw3tAgdT/NJoTDJn2bY/
-Ndyt+UkCgYEA9Z75YcbL8foGDehQhyOvVEQBhsmU57QPUwTNfPVbJkrbI3M2y2jh
-US0dAbOaAJXkzEVVNgLnNREzxtjx88NXWGJjPjwf74JVPzPWppBrp0C5q1quEevr
-fOxg3dLvyiCM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==';
-
 my @strings;
+push @strings, '';
 push @strings, 'Testing: 1, 2, 3';
 push @strings, 'Hello world';
 push @strings, 'This is a very, very, very, very, very, very, very, very, very, ' .
 	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
 	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
 	'very, very, very, very, very, very long string. A lot more than 512 bits.';
+push @strings, 'Schloß';
 
-for (my $i=0; $i<3; $i++)
-{
-	my $decrypted = $D->decrypt_text( $crypts[$i] );
-	is($decrypted, $strings[$i], "String test $i worked.");
-}
+my $key = Crypt::OpenSSL::RSA->generate_key(512);
+my $E   = RDF::Crypt::Encrypter->new_from_string($key->get_public_key_string);
+my $D   = RDF::Crypt::Decrypter->new_from_string($key->get_private_key_string);
+
+is(
+	$D->decrypt_text( $E->encrypt_text($_) ),
+	$_,
+) for @strings;
+

File t/03verify.t

+use utf8;
+use Test::More tests => 10;
+use RDF::Crypt;
+
+my @strings;
+push @strings, '';
+push @strings, 'Testing: 1, 2, 3';
+push @strings, 'Hello world';
+push @strings, 'This is a very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very, very, very, very, very, very, very, ' .
+	'very, very, very, very, very, very long string. A lot more than 512 bits.';
+push @strings, 'Schloß';
+
+my $key = Crypt::OpenSSL::RSA->generate_key(1024);
+my $V   = RDF::Crypt::Verifier->new_from_string($key->get_public_key_string);
+my $S   = RDF::Crypt::Signer->new_from_string($key->get_private_key_string);
+
+ok(
+	$V->verify_text($_, $S->sign_text($_)),
+) for @strings;
+
+ok(
+	not $V->verify_text($_, uc $S->sign_text($_)),
+) for @strings;