1
#!/usr/bin/perl -I../lib
5
use Test::Simple tests => 8;
7
use Mail::DKIM::Signer;
8
use Mail::DKIM::DkSignature;
10
# The main purpose of this set of tests is to ensure that I am aware
11
# whenever a change in my code causes the generated signature to change
12
# for DomainKeys signatures. Generally this should never occur for a
13
# change in DomainKeys code. (In contrast to DKIM, where the generated
14
# signature gets included in the signature, so any changes to the format
15
# of the signature will cause the hash to change.)
22
if ($sig_args{Headers} && $sig_args{Headers} eq "*")
24
$sig_args{Headers} = $signer->headers;
26
$signer->add_signature(Mail::DKIM::DkSignature->new(%sig_args));
29
my $tdir = -f "t/test.key" ? "t" : ".";
30
my $keyfile = "$tdir/test.key";
31
my $sample_email = <<END_OF_SAMPLE;
32
From: jason <jlong\@messiah.edu>
34
Comment: what is a comment
36
this is a sample message
38
$sample_email =~ s/\n/\015\012/gs;
40
sub sign_sample_using_args
43
Algorithm => "rsa-sha1",
45
Domain => "messiah.edu",
48
my $dkim = Mail::DKIM::Signer->new(
52
$dkim->PRINT($sample_email);
55
my $signature = $dkim->signature;
61
$signature = sign_sample_using_args(
64
ok($signature, "signature() works");
65
print "# " . $signature->as_string . "\n";
66
ok($signature->data =~ /^TL93PzPvedAijHChCAt/, "got expected signature");
69
$signature = sign_sample_using_args(
73
ok($signature, "signature() works");
74
print "# " . $signature->as_string . "\n";
75
ok($signature->data =~ /^n\+qfVkhQPch80atOC7/, "got expected signature");
77
$signature = sign_sample_using_args(
80
ok($signature, "signature() works");
81
print "# " . $signature->as_string . "\n";
82
ok($signature->data =~ /^JWzIzvCZBIYnoMebzKU/, "got expected signature");
85
$signature = sign_sample_using_args(
89
ok($signature, "signature() works");
90
print "# " . $signature->as_string . "\n";
91
ok($signature->data =~ /^fkDC8iF/, "got expected signature");