remailer 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,228 +1,7 @@
1
1
  require File.expand_path(File.join(*%w[ .. helper ]), File.dirname(__FILE__))
2
2
 
3
3
  class RemailerTest < Test::Unit::TestCase
4
- def test_encode_data
5
- sample_data = "Line 1\r\nLine 2\r\n.\r\nLine 3\r\n.Line 4\r\n"
6
-
7
- assert_equal "Line 1\r\nLine 2\r\n..\r\nLine 3\r\n..Line 4\r\n", Remailer::Connection.encode_data(sample_data)
8
- end
9
-
10
- def test_connect
11
- engine do
12
- debug = { }
13
-
14
- connection = Remailer::Connection.open(
15
- TestConfig.smtp_server[:host],
16
- :debug => STDERR
17
- )
18
-
19
- after_complete_trigger = false
20
-
21
- connection.close_when_complete!
22
- connection.after_complete do
23
- after_complete_trigger = true
24
- end
25
-
26
- assert_equal :connecting, connection.state
27
- assert !connection.error?
28
-
29
- assert_eventually(15) do
30
- connection.state == :closed
31
- end
32
-
33
- assert_equal TestConfig.smtp_server[:host], connection.remote
34
-
35
- assert_equal true, after_complete_trigger
36
-
37
- assert_equal 52428800, connection.max_size
38
- assert_equal :esmtp, connection.protocol
39
- assert_equal true, connection.tls_support?
40
- end
41
- end
42
-
43
- def test_failed_connect
44
- engine do
45
- error_received = nil
46
-
47
- connection = Remailer::Connection.open(
48
- 'example.com',
49
- :debug => STDERR,
50
- :error => lambda { |code, message|
51
- error_received = [ code, message ]
52
- },
53
- :timeout => 1
54
- )
55
-
56
- assert_eventually(3) do
57
- error_received
58
- end
59
-
60
- assert_equal :timeout, error_received[0]
61
- end
62
- end
63
-
64
- def test_connect_with_auth
65
- engine do
66
- debug = { }
67
-
68
- connection = Remailer::Connection.open(
69
- TestConfig.public_smtp_server[:host],
70
- :port => 587,
71
- :debug => STDERR,
72
- :username => TestConfig.public_smtp_server[:username],
73
- :password => TestConfig.public_smtp_server[:password]
74
- )
75
-
76
- after_complete_trigger = false
77
-
78
- connection.close_when_complete!
79
- connection.after_complete do
80
- after_complete_trigger = true
81
- end
82
-
83
- assert_equal :connecting, connection.state
84
- assert !connection.error?
85
-
86
- assert_eventually(15) do
87
- connection.state == :closed
88
- end
89
-
90
- assert_equal TestConfig.public_smtp_server[:identifier], connection.remote
91
-
92
- assert_equal true, after_complete_trigger
93
-
94
- assert_equal 35651584, connection.max_size
95
- assert_equal :esmtp, connection.protocol
96
- assert_equal true, connection.tls_support?
97
- end
98
- end
99
-
100
- def test_connect_via_proxy
101
- engine do
102
- debug = { }
103
-
104
- connection = Remailer::Connection.open(
105
- TestConfig.smtp_server[:host],
106
- :debug => STDERR,
107
- :proxy => {
108
- :proto => :socks5,
109
- :host => TestConfig.proxy_server
110
- }
111
- )
112
-
113
- after_complete_trigger = false
114
-
115
- connection.close_when_complete!
116
- connection.after_complete do
117
- after_complete_trigger = true
118
- end
119
-
120
- assert_equal :connecting, connection.state
121
- assert !connection.error?
122
-
123
- assert_eventually(15) do
124
- connection.state == :closed
125
- end
126
-
127
- assert_equal TestConfig.smtp_server[:identifier], connection.remote
128
-
129
- assert_equal true, after_complete_trigger
130
-
131
- assert_equal 52428800, connection.max_size
132
- assert_equal :esmtp, connection.protocol
133
- assert_equal true, connection.tls_support?
134
- end
135
- end
136
-
137
- def test_connect_and_send_after_start
138
- engine do
139
- connection = Remailer::Connection.open(
140
- TestConfig.smtp_server[:host],
141
- :debug => STDERR
142
- )
143
-
144
- assert_equal :connecting, connection.state
145
-
146
- assert_eventually(10) do
147
- connection.state == :ready
148
- end
149
-
150
- result_code = nil
151
- connection.send_email(
152
- 'remailer+test@example.postageapp.com',
153
- 'remailer+test@example.postageapp.com',
154
- example_message
155
- ) do |c|
156
- result_code = c
157
- end
158
-
159
- assert_eventually(5) do
160
- result_code == 250
161
- end
162
- end
163
- end
164
-
165
- def test_connect_and_send_dotted_message
166
- engine do
167
- connection = Remailer::Connection.open(
168
- TestConfig.smtp_server[:host],
169
- :debug => STDERR
170
- )
171
-
172
- assert_equal :connecting, connection.state
173
- assert !connection.error?
174
-
175
- result_code = nil
176
- connection.send_email(
177
- 'remailer+test@example.postageapp.com',
178
- 'remailer+test@example.postageapp.com',
179
- example_message + "\r\n\.\r\nHam sandwich.\r\n"
180
- ) do |c|
181
- result_code = c
182
- end
183
-
184
- assert_eventually(15) do
185
- result_code == 250
186
- end
187
- end
188
- end
189
-
190
- def test_connect_and_long_send
191
- engine do
192
- connection = Remailer::Connection.open(TestConfig.smtp_server[:host])
193
-
194
- assert_equal :connecting, connection.state
195
-
196
- result_code = nil
197
- connection.send_email(
198
- TestConfig.sender,
199
- TestConfig.receiver,
200
- example_message + 'a' * 100000
201
- ) do |c|
202
- result_code = c
203
- end
204
-
205
- assert_eventually(15) do
206
- result_code == 250
207
- end
208
- end
209
- end
210
-
211
- protected
212
- def example_message
213
- example = <<__END__
214
- Date: Sat, 13 Nov 2010 02:25:24 +0000
215
- From: #{TestConfig.sender}
216
- To: Remailer Test <#{TestConfig.receiver}>
217
- Message-Id: <hfLkcIByfjYoNIxCO7DMsxBTX9svsFHikIOfAiYy@#{TestConfig.sender.split(/@/).last}>
218
- Subject: Example Subject
219
- Mime-Version: 1.0
220
- Content-Type: text/plain
221
- Auto-Submitted: auto-generated
222
-
223
- This is a very boring message. It is dreadfully dull.
224
- __END__
225
-
226
- example.gsub(/\n/, "\r\n")
4
+ def test_module_loaded
5
+ assert Remailer
227
6
  end
228
7
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Tadman
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-22 00:00:00 -05:00
17
+ date: 2010-12-02 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -34,8 +34,18 @@ files:
34
34
  - VERSION
35
35
  - lib/remailer.rb
36
36
  - lib/remailer/connection.rb
37
+ - lib/remailer/connection/smtp_interpreter.rb
38
+ - lib/remailer/connection/socks5_interpreter.rb
39
+ - lib/remailer/interpreter.rb
40
+ - lib/remailer/interpreter/state_proxy.rb
37
41
  - remailer.gemspec
42
+ - test/config.example.rb
38
43
  - test/helper.rb
44
+ - test/unit/remailer_connection_smtp_interpreter_test.rb
45
+ - test/unit/remailer_connection_socks5_interpreter_test.rb
46
+ - test/unit/remailer_connection_test.rb
47
+ - test/unit/remailer_interpreter_state_proxy_test.rb
48
+ - test/unit/remailer_interpreter_test.rb
39
49
  - test/unit/remailer_test.rb
40
50
  has_rdoc: true
41
51
  homepage: http://github.com/twg/remailer
@@ -70,5 +80,11 @@ signing_key:
70
80
  specification_version: 3
71
81
  summary: Reactor-Ready SMTP Mailer
72
82
  test_files:
83
+ - test/config.example.rb
73
84
  - test/helper.rb
85
+ - test/unit/remailer_connection_smtp_interpreter_test.rb
86
+ - test/unit/remailer_connection_socks5_interpreter_test.rb
87
+ - test/unit/remailer_connection_test.rb
88
+ - test/unit/remailer_interpreter_state_proxy_test.rb
89
+ - test/unit/remailer_interpreter_test.rb
74
90
  - test/unit/remailer_test.rb