dkim 0.1.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +20 -0
- data/.gitignore +1 -0
- data/Appraisals +7 -0
- data/CHANGELOG.md +28 -3
- data/Gemfile +5 -1
- data/README.md +52 -61
- data/Rakefile +12 -0
- data/bin/dkimsign.rb +0 -0
- data/dkim.gemspec +5 -0
- data/gemfiles/mail_2.6.gemfile +11 -0
- data/gemfiles/mail_2.7.gemfile +11 -0
- data/lib/dkim/canonicalized_headers.rb +26 -0
- data/lib/dkim/dkim_header.rb +21 -12
- data/lib/dkim/encodings/base64.rb +12 -0
- data/lib/dkim/encodings/dkim_quoted_printable.rb +19 -0
- data/lib/dkim/encodings/plain_text.rb +8 -0
- data/lib/dkim/encodings.rb +3 -0
- data/lib/dkim/header.rb +7 -0
- data/lib/dkim/interceptor.rb +13 -1
- data/lib/dkim/options.rb +84 -0
- data/lib/dkim/signed_mail.rb +31 -56
- data/lib/dkim/tag_value_list.rb +28 -0
- data/lib/dkim/version.rb +1 -1
- data/lib/dkim.rb +4 -8
- data/lib/mail/dkim_field.rb +4 -4
- data/test/dkim/canonicalization_test.rb +80 -0
- data/test/dkim/canonicalized_headers_test.rb +51 -0
- data/test/dkim/dkim_header_test.rb +43 -0
- data/test/dkim/encodings_test.rb +24 -0
- data/test/dkim/interceptor_test.rb +129 -0
- data/test/dkim/options_test.rb +40 -0
- data/test/dkim/signed_mail_test.rb +112 -0
- data/test/dkim/tag_value_list_test.rb +28 -0
- data/test/test_helper.rb +36 -4
- metadata +95 -18
- data/lib/dkim/header_list.rb +0 -19
- data/test/canonicalization_test.rb +0 -78
@@ -0,0 +1,112 @@
|
|
1
|
+
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
module Dkim
|
5
|
+
class SignedMailTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@mail = EXAMPLEEMAIL.dup
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_defaults
|
11
|
+
signed_mail = SignedMail.new(@mail, :time => Time.at(1234567890))
|
12
|
+
dkim_header = signed_mail.dkim_header.list
|
13
|
+
|
14
|
+
assert_equal 'rsa-sha256', dkim_header['a']
|
15
|
+
assert_equal 'brisbane', dkim_header['s']
|
16
|
+
assert_equal 'example.com', dkim_header['d']
|
17
|
+
assert_equal 'relaxed/relaxed', dkim_header['c']
|
18
|
+
assert_equal 'dns/txt', dkim_header['q']
|
19
|
+
assert_equal 'from:to:subject:date:message-id', dkim_header['h']
|
20
|
+
|
21
|
+
# bh value from RFC 6376
|
22
|
+
assert_equal '2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=', dkim_header['bh']
|
23
|
+
assert_equal 'dQOeSpGJTfSbX4hPGGsy4ipcNAzC/33K7XaEXkjBneJJhv6MczHkJNsfmXeYESNIh5WVTuvE5IbnDPBVFrL+b3GKiLiyp/vlKO2NJViX4dLnKT/GdxjJh06ljZcYjUA+PorHvMwdu+cDsCffN8A7IhfVdsFruQr3vFPD0JyJ9XU=', dkim_header['b']
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_overrides
|
27
|
+
options = {
|
28
|
+
:domain => 'example.org',
|
29
|
+
:selector => 'sidney',
|
30
|
+
:time => Time.now,
|
31
|
+
:signing_algorithm => 'rsa-sha1',
|
32
|
+
:header_canonicalization => 'simple',
|
33
|
+
:body_canonicalization => 'simple',
|
34
|
+
:time => Time.at(1234567890)
|
35
|
+
}
|
36
|
+
signed_mail = SignedMail.new(@mail, options)
|
37
|
+
dkim_header = signed_mail.dkim_header.list
|
38
|
+
|
39
|
+
assert_equal 'rsa-sha1', dkim_header['a']
|
40
|
+
assert_equal 'sidney', dkim_header['s']
|
41
|
+
assert_equal 'example.org', dkim_header['d']
|
42
|
+
assert_equal 'simple/simple', dkim_header['c']
|
43
|
+
assert_equal 'dns/txt', dkim_header['q']
|
44
|
+
assert_equal "from:to:subject:date:message-id", dkim_header['h']
|
45
|
+
assert_equal 'yk6W9pJJilr5MMgeEdSd7J3IaJI=', dkim_header['bh']
|
46
|
+
assert_equal 't+dk4yxTI2ByZxxRzkwhZhM4WzTZjGWHiWnS2t4pg7oT7fAIlMrfihJ/CIvGmYqYv4lbq4LStHqHx9TmEgxrkjLevHtuqhxkN55xJ2vA2QzTzFi2fMDZ4fFqWy4QtvlLjBAhevG+LXpmjPYec1cyeMlHlPAthq5+RNi6NHErJiM=', dkim_header['b']
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_expire
|
50
|
+
options = {
|
51
|
+
:time => Time.at(1234567890),
|
52
|
+
:expire => Time.at(1234567990)
|
53
|
+
}
|
54
|
+
signed_mail = SignedMail.new(@mail, options)
|
55
|
+
dkim_header = signed_mail.dkim_header.list
|
56
|
+
|
57
|
+
assert_equal 1234567990, dkim_header['x']
|
58
|
+
assert_equal '2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=', dkim_header['bh']
|
59
|
+
assert_equal 'dn2Y5rSXQNRBy904vwpvri6xcmlrwKDmDX4XtBgyABQw9jLTulgD/G61TeyqinwgaHiatQaYt4pnpzYQGMaCCg7MepkkpZAR4IggAnHo/qB4JRx5OYBslKCCwpeb70YOPdukVopEnaCoUfkCGJ5vvu3xXG1N+ajKWqYiZ0n4z+o=', dkim_header['b']
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_identity
|
63
|
+
options = {
|
64
|
+
:domain => 'example.org',
|
65
|
+
:selector => 'sidney',
|
66
|
+
:identity => '@example.org',
|
67
|
+
:time => Time.at(1234567890)
|
68
|
+
}
|
69
|
+
signed_mail = SignedMail.new(@mail, options)
|
70
|
+
dkim_header = signed_mail.dkim_header.list
|
71
|
+
|
72
|
+
assert_equal '@example.org', dkim_header['i']
|
73
|
+
assert_equal '2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=', dkim_header['bh']
|
74
|
+
assert_equal 'dCiulbJTD+GCCItMij1IU/RO0+q73afdjmrCWV5Qu7BIT5Kbp5Oi3jqCzj/v8Juks2/L6GBSXZia3aZprNVZX0szt8RnwC9NJx9WhcjN2RPz4Zf5F1jJivCN+PtaIWA3i3Ki/DR1q+RuNPgs7T1KKMo3Ih5uHubZIsMwRzbQBc0=', dkim_header['b']
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_empty_body_hashes
|
78
|
+
@mail = @mail.split("\n\n").first + "\n\n"
|
79
|
+
|
80
|
+
# the following are from RFC 6376 section 3.4.3 and 3.4.4
|
81
|
+
[
|
82
|
+
# [bh, options]
|
83
|
+
['uoq1oCgLlTqpdDX/iUbLy7J1Wic=', {:body_canonicalization => 'simple', :signing_algorithm => 'rsa-sha1' }],
|
84
|
+
['frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN/XKdLCPjaYaY=', {:body_canonicalization => 'simple', :signing_algorithm => 'rsa-sha256'}],
|
85
|
+
['2jmj7l5rSw0yVb/vlWAYkK/YBwk=', {:body_canonicalization => 'relaxed', :signing_algorithm => 'rsa-sha1' }],
|
86
|
+
['47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', {:body_canonicalization => 'relaxed', :signing_algorithm => 'rsa-sha256'}],
|
87
|
+
].each do |body_hash, options|
|
88
|
+
signed_mail = SignedMail.new(@mail, options)
|
89
|
+
dkim_header = signed_mail.dkim_header.list
|
90
|
+
|
91
|
+
assert_equal body_hash, dkim_header['bh']
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_multiple_instances_of_header
|
96
|
+
@mail = <<-eos
|
97
|
+
Received: <A>
|
98
|
+
Received: <B>
|
99
|
+
Received: <C>
|
100
|
+
|
101
|
+
eos
|
102
|
+
|
103
|
+
signed_mail = SignedMail.new(@mail, :header_canonicalization => 'simple', :signable_headers => Dkim::DefaultHeaders + ['Received'])
|
104
|
+
|
105
|
+
assert_equal "received:received:received", signed_mail.dkim_header['h']
|
106
|
+
|
107
|
+
headers = signed_mail.canonical_header
|
108
|
+
assert_equal "Received: <C>\r\nReceived: <B>\r\nReceived: <A>\r\n", headers.to_s
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
module Dkim
|
5
|
+
class TagValueListTest < Minitest::Test
|
6
|
+
def test_replacement
|
7
|
+
@list = TagValueList.new
|
8
|
+
|
9
|
+
@list['a'] = '1'
|
10
|
+
@list['b'] = '2'
|
11
|
+
@list['c'] = '3'
|
12
|
+
assert_equal 'a=1; b=2; c=3', @list.to_s
|
13
|
+
|
14
|
+
@list['b'] = '4'
|
15
|
+
assert_equal 'a=1; b=4; c=3', @list.to_s
|
16
|
+
end
|
17
|
+
def test_correct_format
|
18
|
+
@list = TagValueList.new
|
19
|
+
|
20
|
+
@list['b'] = '2'
|
21
|
+
@list['a'] = '1'
|
22
|
+
@list['c'] = '!@#$%^'
|
23
|
+
|
24
|
+
assert_equal 'b=2; a=1; c=!@#$%^', @list.to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'minitest/autorun'
|
3
5
|
require 'dkim'
|
4
6
|
|
5
7
|
class String
|
6
|
-
# Parse the format used in
|
8
|
+
# Parse the format used in RFC 6376
|
7
9
|
#
|
8
10
|
# In the following examples, actual whitespace is used only for
|
9
11
|
# clarity. The actual input and output text is designated using
|
@@ -23,7 +25,37 @@ class String
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
# examples used in
|
27
|
-
|
28
|
+
# examples used in RFC 6376
|
29
|
+
EXAMPLEEMAIL = %{
|
30
|
+
From: Joe SixPack <IIVyTowbcT@www.brandonchecketts.com>
|
31
|
+
To: Suzie Q <suzie@shopping.example.net>
|
32
|
+
Subject: Is dinner ready?
|
33
|
+
Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT)
|
34
|
+
Message-ID: <20030712040037.46341.5F8J@football.example.com>
|
35
|
+
|
36
|
+
Hi.
|
28
37
|
|
38
|
+
We lost the game. Are you hungry yet?
|
39
|
+
|
40
|
+
Joe.}.gsub(/\A\n/,'')
|
41
|
+
|
42
|
+
Dkim::domain = 'example.com'
|
43
|
+
Dkim::selector = 'brisbane'
|
44
|
+
Dkim::private_key = %{
|
45
|
+
-----BEGIN RSA PRIVATE KEY-----
|
46
|
+
MIICXwIBAAKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYtIxN2SnFC
|
47
|
+
jxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/RtdC2UzJ1lWT947qR+Rcac2gb
|
48
|
+
to/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB
|
49
|
+
AoGBALmn+XwWk7akvkUlqb+dOxyLB9i5VBVfje89Teolwc9YJT36BGN/l4e0l6QX
|
50
|
+
/1//6DWUTB3KI6wFcm7TWJcxbS0tcKZX7FsJvUz1SbQnkS54DJck1EZO/BLa5ckJ
|
51
|
+
gAYIaqlA9C0ZwM6i58lLlPadX/rtHb7pWzeNcZHjKrjM461ZAkEA+itss2nRlmyO
|
52
|
+
n1/5yDyCluST4dQfO8kAB3toSEVc7DeFeDhnC1mZdjASZNvdHS4gbLIA1hUGEF9m
|
53
|
+
3hKsGUMMPwJBAPW5v/U+AWTADFCS22t72NUurgzeAbzb1HWMqO4y4+9Hpjk5wvL/
|
54
|
+
eVYizyuce3/fGke7aRYw/ADKygMJdW8H/OcCQQDz5OQb4j2QDpPZc0Nc4QlbvMsj
|
55
|
+
7p7otWRO5xRa6SzXqqV3+F0VpqvDmshEBkoCydaYwc2o6WQ5EBmExeV8124XAkEA
|
56
|
+
qZzGsIxVP+sEVRWZmW6KNFSdVUpk3qzK0Tz/WjQMe5z0UunY9Ax9/4PVhp/j61bf
|
57
|
+
eAYXunajbBSOLlx4D+TunwJBANkPI5S9iylsbLs6NkaMHV6k5ioHBBmgCak95JGX
|
58
|
+
GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc=
|
59
|
+
-----END RSA PRIVATE KEY-----
|
60
|
+
}
|
29
61
|
|
metadata
CHANGED
@@ -1,16 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dkim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Hawthorn
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
11
|
+
date: 2021-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mail
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
14
69
|
description: gem for adding DKIM signatures to email messages
|
15
70
|
email:
|
16
71
|
- john.hawthorn@gmail.com
|
@@ -19,49 +74,71 @@ executables:
|
|
19
74
|
extensions: []
|
20
75
|
extra_rdoc_files: []
|
21
76
|
files:
|
22
|
-
- .
|
77
|
+
- ".github/workflows/test.yml"
|
78
|
+
- ".gitignore"
|
79
|
+
- Appraisals
|
23
80
|
- CHANGELOG.md
|
24
81
|
- Gemfile
|
25
82
|
- README.md
|
26
83
|
- Rakefile
|
27
84
|
- bin/dkimsign.rb
|
28
85
|
- dkim.gemspec
|
86
|
+
- gemfiles/mail_2.6.gemfile
|
87
|
+
- gemfiles/mail_2.7.gemfile
|
29
88
|
- lib/dkim.rb
|
30
89
|
- lib/dkim/body.rb
|
31
90
|
- lib/dkim/canonicalizable.rb
|
91
|
+
- lib/dkim/canonicalized_headers.rb
|
32
92
|
- lib/dkim/dkim_header.rb
|
93
|
+
- lib/dkim/encodings.rb
|
94
|
+
- lib/dkim/encodings/base64.rb
|
95
|
+
- lib/dkim/encodings/dkim_quoted_printable.rb
|
96
|
+
- lib/dkim/encodings/plain_text.rb
|
33
97
|
- lib/dkim/header.rb
|
34
|
-
- lib/dkim/header_list.rb
|
35
98
|
- lib/dkim/interceptor.rb
|
99
|
+
- lib/dkim/options.rb
|
36
100
|
- lib/dkim/signed_mail.rb
|
101
|
+
- lib/dkim/tag_value_list.rb
|
37
102
|
- lib/dkim/version.rb
|
38
103
|
- lib/mail/dkim_field.rb
|
39
|
-
- test/canonicalization_test.rb
|
104
|
+
- test/dkim/canonicalization_test.rb
|
105
|
+
- test/dkim/canonicalized_headers_test.rb
|
106
|
+
- test/dkim/dkim_header_test.rb
|
107
|
+
- test/dkim/encodings_test.rb
|
108
|
+
- test/dkim/interceptor_test.rb
|
109
|
+
- test/dkim/options_test.rb
|
110
|
+
- test/dkim/signed_mail_test.rb
|
111
|
+
- test/dkim/tag_value_list_test.rb
|
40
112
|
- test/test_helper.rb
|
41
113
|
homepage: https://github.com/jhawthorn/dkim
|
42
114
|
licenses: []
|
43
|
-
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
44
117
|
rdoc_options: []
|
45
118
|
require_paths:
|
46
119
|
- lib
|
47
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
-
none: false
|
49
121
|
requirements:
|
50
|
-
- -
|
122
|
+
- - ">="
|
51
123
|
- !ruby/object:Gem::Version
|
52
124
|
version: '0'
|
53
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
126
|
requirements:
|
56
|
-
- -
|
127
|
+
- - ">="
|
57
128
|
- !ruby/object:Gem::Version
|
58
129
|
version: '0'
|
59
130
|
requirements: []
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
specification_version: 3
|
131
|
+
rubygems_version: 3.1.4
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
64
134
|
summary: DKIM library in ruby
|
65
135
|
test_files:
|
66
|
-
- test/canonicalization_test.rb
|
136
|
+
- test/dkim/canonicalization_test.rb
|
137
|
+
- test/dkim/canonicalized_headers_test.rb
|
138
|
+
- test/dkim/dkim_header_test.rb
|
139
|
+
- test/dkim/encodings_test.rb
|
140
|
+
- test/dkim/interceptor_test.rb
|
141
|
+
- test/dkim/options_test.rb
|
142
|
+
- test/dkim/signed_mail_test.rb
|
143
|
+
- test/dkim/tag_value_list_test.rb
|
67
144
|
- test/test_helper.rb
|
data/lib/dkim/header_list.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Dkim
|
2
|
-
class HeaderList
|
3
|
-
include Enumerable
|
4
|
-
def initialize headers
|
5
|
-
@headers = headers.split(/\r?\n(?!([ \t]))/).map do |header|
|
6
|
-
key, value = header.split(':', 2)
|
7
|
-
Header.new(key, value)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
def [](key)
|
11
|
-
@headers.detect do |header|
|
12
|
-
header.relaxed_key == key
|
13
|
-
end
|
14
|
-
end
|
15
|
-
def each(&block)
|
16
|
-
@headers.each(&block)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'test_helper'
|
3
|
-
|
4
|
-
class CanonicalizationTest < Test::Unit::TestCase
|
5
|
-
# from section 3.4.6 of rfc4871
|
6
|
-
def setup
|
7
|
-
@input = <<-eos.rfc_format
|
8
|
-
A: <SP> X <CRLF>
|
9
|
-
B <SP> : <SP> Y <HTAB><CRLF>
|
10
|
-
<HTAB> Z <SP><SP><CRLF>
|
11
|
-
<CRLF>
|
12
|
-
<SP> C <SP><CRLF>
|
13
|
-
D <SP><HTAB><SP> E <CRLF>
|
14
|
-
<CRLF>
|
15
|
-
<CRLF>
|
16
|
-
eos
|
17
|
-
@mail = Dkim::SignedMail.new(@input)
|
18
|
-
@mail.signable_headers = ['A', 'B']
|
19
|
-
end
|
20
|
-
def test_relaxed_header
|
21
|
-
@mail.header_canonicalization = 'relaxed'
|
22
|
-
expected_header = <<-eos.rfc_format
|
23
|
-
a:X <CRLF>
|
24
|
-
b:Y <SP> Z <CRLF>
|
25
|
-
eos
|
26
|
-
assert_equal expected_header, @mail.canonical_header
|
27
|
-
end
|
28
|
-
def test_relaxed_body
|
29
|
-
@mail.body_canonicalization = 'relaxed'
|
30
|
-
expected_body = <<-eos.rfc_format
|
31
|
-
<SP> C <CRLF>
|
32
|
-
D <SP> E <CRLF>
|
33
|
-
eos
|
34
|
-
assert_equal expected_body, @mail.canonical_body
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_simple_header
|
38
|
-
@mail.header_canonicalization = 'simple'
|
39
|
-
expected_header = <<-eos.rfc_format
|
40
|
-
A: <SP> X <CRLF>
|
41
|
-
B <SP> : <SP> Y <HTAB><CRLF>
|
42
|
-
<HTAB> Z <SP><SP><CRLF>
|
43
|
-
eos
|
44
|
-
assert_equal expected_header, @mail.canonical_header
|
45
|
-
end
|
46
|
-
def test_simple_body
|
47
|
-
@mail.body_canonicalization = 'simple'
|
48
|
-
expected_body = <<-eos.rfc_format
|
49
|
-
<SP> C <SP><CRLF>
|
50
|
-
D <SP><HTAB><SP> E <CRLF>
|
51
|
-
eos
|
52
|
-
assert_equal expected_body, @mail.canonical_body
|
53
|
-
end
|
54
|
-
|
55
|
-
# from errata: empty bodies
|
56
|
-
def test_simple_empty_body
|
57
|
-
@mail = Dkim::SignedMail.new("test: test\r\n\r\n")
|
58
|
-
@mail.body_canonicalization = 'simple'
|
59
|
-
|
60
|
-
assert_equal "\r\n", @mail.canonical_body
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_relaxed_empty_body
|
64
|
-
@mail = Dkim::SignedMail.new("test: test\r\n\r\n")
|
65
|
-
@mail.body_canonicalization = 'relaxed'
|
66
|
-
|
67
|
-
assert_equal "", @mail.canonical_body
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_relaxed_errata_1384
|
71
|
-
body = "testing<crlf><sp><sp><cr><lf><cr><lf>".rfc_format
|
72
|
-
@mail = Dkim::SignedMail.new("test: test\r\n\r\n#{body}")
|
73
|
-
@mail.body_canonicalization = 'relaxed'
|
74
|
-
|
75
|
-
assert_equal "testing\r\n", @mail.canonical_body
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|