sugoi-mail 0.0.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.
- data/README +35 -0
- data/Rakefile +10 -0
- data/app/apis/mailservice_api.rb +178 -0
- data/app/controllers/.sugoi_admin_controller.rb.swp +0 -0
- data/app/controllers/account_controller.rb +39 -0
- data/app/controllers/address_controller.rb +49 -0
- data/app/controllers/application.rb +4 -0
- data/app/controllers/commandline_controller.rb +15 -0
- data/app/controllers/domain_controller.rb +37 -0
- data/app/controllers/mailinglist_controller.rb +51 -0
- data/app/controllers/mailservice_controller.rb +497 -0
- data/app/controllers/sugoi_admin_controller.rb +93 -0
- data/app/helpers/account_helper.rb +2 -0
- data/app/helpers/address_helper.rb +2 -0
- data/app/helpers/application_helper.rb +3 -0
- data/app/helpers/domain_helper.rb +2 -0
- data/app/helpers/mailservice_helper.rb +2 -0
- data/app/helpers/sugoi_admin_helper.rb +2 -0
- data/app/models/address.rb +110 -0
- data/app/models/admin_message.rb +45 -0
- data/app/models/confirmationcode.rb +59 -0
- data/app/models/domain.rb +76 -0
- data/app/models/mailinglist.rb +336 -0
- data/app/models/mailinglist_class.rb +39 -0
- data/app/models/message.rb +293 -0
- data/app/models/proxy_link.rb +25 -0
- data/app/models/user.rb +150 -0
- data/app/views/account/login.rhtml +22 -0
- data/app/views/account/logout.rhtml +10 -0
- data/app/views/account/signup.rhtml +17 -0
- data/app/views/account/welcome.rhtml +13 -0
- data/app/views/address/_form.rhtml +7 -0
- data/app/views/address/edit.rhtml +10 -0
- data/app/views/address/list.rhtml +27 -0
- data/app/views/address/new.rhtml +8 -0
- data/app/views/address/show.rhtml +8 -0
- data/app/views/domain/login.rhtml +22 -0
- data/app/views/domain/logout.rhtml +10 -0
- data/app/views/domain/signup.rhtml +17 -0
- data/app/views/domain/welcome.rhtml +13 -0
- data/app/views/layouts/address.rhtml +13 -0
- data/app/views/layouts/scaffold.rhtml +13 -0
- data/app/views/mailinglist/_form.rhtml +28 -0
- data/app/views/mailinglist/edit.rhtml +10 -0
- data/app/views/mailinglist/list.rhtml +27 -0
- data/app/views/mailinglist/new.rhtml +8 -0
- data/app/views/mailinglist/show.rhtml +16 -0
- data/app/views/sugoi_admin/create_domain.rhtml +1 -0
- data/app/views/sugoi_admin/list_addresses.rhtml +1 -0
- data/app/views/sugoi_admin/list_domains.rhtml +2 -0
- data/app/views/sugoi_admin/list_mailinglists.rhtml +1 -0
- data/bin/mailc +32 -0
- data/bin/maild +133 -0
- data/bin/sugoi-admin +21 -0
- data/bin/sugoi-mail +20 -0
- data/config/boot.rb +44 -0
- data/config/environment.rb +54 -0
- data/config/environments/bench.rb +21 -0
- data/config/environments/coverage.rb +21 -0
- data/config/environments/development.rb +21 -0
- data/config/environments/production.rb +18 -0
- data/config/environments/test.rb +19 -0
- data/config/lighttpd.conf +46 -0
- data/config/routes.rb +29 -0
- data/db/migrate/001_mailproxy.rb +7 -0
- data/db/migrate/002_create_users.rb +13 -0
- data/db/migrate/003_create_mailinglists.rb +13 -0
- data/db/migrate/004_create_addresses.rb +12 -0
- data/db/migrate/005_create_addresses_mailinglists.rb +13 -0
- data/db/migrate/006_alter_mailinglists.rb +9 -0
- data/db/migrate/007_create_messages.rb +25 -0
- data/db/migrate/008_add_mailinglistid_to_users.rb +14 -0
- data/db/migrate/009_add_domainadmin_to_users.rb +9 -0
- data/db/migrate/010_add_domain_to_users.rb +16 -0
- data/db/migrate/011_add_active_to_addresses.rb +14 -0
- data/db/migrate/012_create_confirmationcodes.rb +14 -0
- data/db/migrate/013_add_description_to_mailinglists.rb +9 -0
- data/db/migrate/014_create_admin_messages.rb +69 -0
- data/db/migrate/015_add_messages_to_mailinglists.rb +26 -0
- data/db/migrate/016_add_mailinglist_admin_to_users.rb +9 -0
- data/db/migrate/017_add_mailinglist_types.rb +94 -0
- data/db/migrate/018_add_bounciness_to_addresses.rb +20 -0
- data/db/migrate/019_add_archived_to_mailinglist_classes.rb +25 -0
- data/db/migrate/020_add_envelope_data_to_messages.rb +11 -0
- data/db/migrate/021_add_addresses_users.rb +14 -0
- data/db/migrate/022_add_virtual_to_users.rb +14 -0
- data/db/migrate/023_drop_openposting_from_mailinglists.rb +9 -0
- data/db/migrate/024_add_proxy_links.rb +21 -0
- data/db/migrate/025_add_proxify_to_mailinglist_classes.rb +25 -0
- data/db/schema.mysql.sql +104 -0
- data/db/schema.postgresql.sql +104 -0
- data/db/schema.rb +85 -0
- data/db/schema.sqlite.sql +104 -0
- data/db/schema.sqlserver.sql +113 -0
- data/db/schema_version +1 -0
- data/doc/README_FOR_APP +179 -0
- data/doc/mailinglist_classes description.txt +28 -0
- data/installer/rails_installer_defaults.yml +5 -0
- data/lib/daemonize.rb +56 -0
- data/lib/domain_system.rb +87 -0
- data/lib/gurgitate-rules.rb +69 -0
- data/lib/limitedfork.rb +66 -0
- data/lib/login_system.rb +87 -0
- data/public/.htaccess +40 -0
- data/public/404.html +8 -0
- data/public/500.html +8 -0
- data/public/dispatch.cgi +10 -0
- data/public/dispatch.fcgi +24 -0
- data/public/dispatch.rb +10 -0
- data/public/favicon.ico +0 -0
- data/public/images/rails.png +0 -0
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/controls.js +815 -0
- data/public/javascripts/dragdrop.js +913 -0
- data/public/javascripts/effects.js +958 -0
- data/public/javascripts/prototype.js +2006 -0
- data/public/robots.txt +1 -0
- data/public/stylesheets/scaffold.css +74 -0
- data/public/stylesheets/trestle.css +74 -0
- data/script/about +3 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/destroy +3 -0
- data/script/fakedeliver +19 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/plugin +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/sugoi-mail.gemspec +36 -0
- data/test/fixtures/addresses.yml +70 -0
- data/test/fixtures/addresses_mailinglists.yml +20 -0
- data/test/fixtures/admin_messages.yml +65 -0
- data/test/fixtures/confirmationcodes.yml +13 -0
- data/test/fixtures/domains.yml +9 -0
- data/test/fixtures/mailinglist_classes.yml +45 -0
- data/test/fixtures/mailinglists.yml +80 -0
- data/test/fixtures/messages.yml +154 -0
- data/test/fixtures/proxy_links.yml +5 -0
- data/test/fixtures/users.yml +50 -0
- data/test/functional/domain_controller_test.rb +74 -0
- data/test/functional/mailservice_controller_test.rb +546 -0
- data/test/integration/test_soap.rb +413 -0
- data/test/integration/test_xmlrpc.rb +198 -0
- data/test/mocks/test/net-smtp-stub.rb +24 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/address_test.rb +44 -0
- data/test/unit/admin_message_test.rb +41 -0
- data/test/unit/confirmationcode_test.rb +64 -0
- data/test/unit/domain_test.rb +128 -0
- data/test/unit/mailinglist_class_test.rb +82 -0
- data/test/unit/mailinglist_test.rb +145 -0
- data/test/unit/message_test.rb +151 -0
- data/test/unit/user_test.rb +126 -0
- data/test/units.rb +4 -0
- data/vendor/plugins/active_command/init.rb +1 -0
- data/vendor/plugins/active_command/lib/active_command/request.rb +137 -0
- data/vendor/plugins/active_command/lib/active_command/response.rb +132 -0
- data/vendor/plugins/active_command/lib/active_command.rb +2 -0
- data/vendor/plugins/ar_fixtures/CHANGELOG +10 -0
- data/vendor/plugins/ar_fixtures/MIT-LICENSE +20 -0
- data/vendor/plugins/ar_fixtures/README +19 -0
- data/vendor/plugins/ar_fixtures/Rakefile +54 -0
- data/vendor/plugins/ar_fixtures/about.yml +7 -0
- data/vendor/plugins/ar_fixtures/init.rb +1 -0
- data/vendor/plugins/ar_fixtures/lib/ar_fixtures.rb +102 -0
- data/vendor/plugins/ar_fixtures/tasks/ar_fixtures.rake +39 -0
- data/vendor/plugins/ar_fixtures/test/ar_fixtures_test.rb +53 -0
- data/vendor/plugins/ar_fixtures/test/database.yml +18 -0
- data/vendor/plugins/ar_fixtures/test/fixtures/beer.rb +5 -0
- data/vendor/plugins/ar_fixtures/test/fixtures/beers.yml +9 -0
- data/vendor/plugins/ar_fixtures/test/fixtures/beers_drunkards.yml +8 -0
- data/vendor/plugins/ar_fixtures/test/fixtures/drunkard.rb +6 -0
- data/vendor/plugins/ar_fixtures/test/fixtures/drunkards.yml +8 -0
- data/vendor/plugins/ar_fixtures/test/fixtures/glass.rb +2 -0
- data/vendor/plugins/ar_fixtures/test/fixtures/glasses.yml +9 -0
- data/vendor/plugins/ar_fixtures/test/schema.rb +21 -0
- data/vendor/plugins/ar_fixtures/test/test_helper.rb +37 -0
- metadata +320 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
require 'net-smtp-stub'
|
4
|
+
|
5
|
+
class Idemhash # stub hash for render tests
|
6
|
+
def initialize(keys); @keys=keys end
|
7
|
+
def each_key; @keys.each { |k| yield k } end
|
8
|
+
def [](*stuff); stuff end
|
9
|
+
def []=(*stuff);stuff end
|
10
|
+
end
|
11
|
+
|
12
|
+
class AdminMessagesTest < Test::Unit::TestCase
|
13
|
+
fixtures :admin_messages, :mailinglists
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@prerendered_test = "From: requestaddress\n"+
|
17
|
+
"To: address\n"+
|
18
|
+
"Subject: Test from name\n"+
|
19
|
+
"\n"+
|
20
|
+
"address\n"
|
21
|
+
@prerender_template_vals=Idemhash.new(%w/requestaddress address name/)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_render
|
25
|
+
m=AdminMessage.find(4)
|
26
|
+
assert_equal @loaded_fixtures["admin_messages"]["test"]["message"],
|
27
|
+
m.message
|
28
|
+
assert_equal @prerendered_test,
|
29
|
+
m.render(@prerender_template_vals)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_send
|
33
|
+
m=AdminMessage.find 4
|
34
|
+
assert m.send_mail("from", "to", @prerender_template_vals)
|
35
|
+
assert_equal "from", Net::SMTP.from
|
36
|
+
assert_equal "to", Net::SMTP.to
|
37
|
+
assert_equal @prerendered_test, Net::SMTP.message
|
38
|
+
assert_equal "localhost", Net::SMTP.hostname
|
39
|
+
assert_equal 25, Net::SMTP.port
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class ConfirmationcodeTest < Test::Unit::TestCase
|
4
|
+
fixtures :mailinglists, :addresses_mailinglists, :addresses,
|
5
|
+
:confirmationcodes
|
6
|
+
|
7
|
+
def test_existing
|
8
|
+
code1=Confirmationcode.find 1
|
9
|
+
assert_equal Mailinglist.find(1), code1.mailinglist
|
10
|
+
assert_equal Address.find(1), code1.address
|
11
|
+
assert_equal "7154578968941962", code1.code
|
12
|
+
assert_equal true, code1.confirmed
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_new
|
16
|
+
newcode=Confirmationcode.new
|
17
|
+
assert newcode.code =~ /[0-9a-z]{16}/
|
18
|
+
assert_equal false, newcode.save
|
19
|
+
newcode.address_id = 1
|
20
|
+
newcode.mailinglist_id = 1
|
21
|
+
assert newcode.save
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_changing_code
|
25
|
+
newcode=Confirmationcode.new
|
26
|
+
assert newcode.code =~ /[0-9a-z]{16}/
|
27
|
+
newcode.address_id = 1
|
28
|
+
newcode.mailinglist_id = 1
|
29
|
+
assert_raises TypeError, "Can't modify code string" do
|
30
|
+
newcode.code = '0123456789012345'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_nonexistent_mailinglist
|
35
|
+
newcode=Confirmationcode.new
|
36
|
+
newcode.address_id = 1
|
37
|
+
newcode.mailinglist_id = 999
|
38
|
+
assert_equal false, newcode.save
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_nonexistent_address
|
42
|
+
newcode=Confirmationcode.new
|
43
|
+
newcode.address_id = 999
|
44
|
+
newcode.mailinglist_id = 1
|
45
|
+
assert_equal false, newcode.save
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_confirm_address
|
49
|
+
|
50
|
+
assert_equal true, Confirmationcode.confirmed?(1, 1)
|
51
|
+
assert_equal false, Confirmationcode.confirmed?(1, 2)
|
52
|
+
assert_equal nil, Confirmationcode.confirmed?(1, 999)
|
53
|
+
|
54
|
+
code=@loaded_fixtures["confirmationcodes"] \
|
55
|
+
["confirmationcode_testuser_address2"]["code"]
|
56
|
+
|
57
|
+
assert_nil Confirmationcode.confirm(Mailinglist.find(1),
|
58
|
+
Address.find(1), code)
|
59
|
+
assert_equal true, Confirmationcode.confirm(Mailinglist.find(1),
|
60
|
+
Address.find(2), code)
|
61
|
+
|
62
|
+
assert_equal true, Confirmationcode.confirmed?(1, 2)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
# Set salt to 'change-me' because thats what the fixtures assume.
|
4
|
+
# Domain.salt = 'change-me'
|
5
|
+
|
6
|
+
class DomainTest < Test::Unit::TestCase
|
7
|
+
fixtures :domains
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@testdomain = Domain.find 1
|
11
|
+
@domains=@loaded_fixtures["domains"]
|
12
|
+
@domain_testdomain=@domains["testdomain"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_aa_break_everything
|
16
|
+
@testdomain.destroy
|
17
|
+
assert_raise ActiveRecord::RecordNotFound do
|
18
|
+
Domain.find @testdomain.id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_find
|
23
|
+
domain_1 = Domain.find 1
|
24
|
+
assert domain_1
|
25
|
+
|
26
|
+
assert_equal @domain_testdomain["name"], domain_1.name
|
27
|
+
assert_equal @domain_testdomain["password"], domain_1.password
|
28
|
+
assert_equal @domain_testdomain["id"], domain_1.id
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_auth_notfound
|
32
|
+
assert_nil Domain.authenticate("nontest.domain", "foobar")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_auth
|
36
|
+
|
37
|
+
domain_1 = Domain.find 1
|
38
|
+
assert domain_1
|
39
|
+
|
40
|
+
domain_testdomain = Domain.authenticate "test.domain", "foobar"
|
41
|
+
assert domain_testdomain
|
42
|
+
|
43
|
+
assert_equal domain_1, domain_testdomain
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_disallowed_passwords
|
47
|
+
|
48
|
+
u = Domain.new
|
49
|
+
u.name = "nonbob"
|
50
|
+
|
51
|
+
u.password = u.password_confirmation = "tiny"
|
52
|
+
assert !u.save
|
53
|
+
assert u.errors.invalid?('password')
|
54
|
+
|
55
|
+
u.password = u.password_confirmation = "hugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehuge"
|
56
|
+
assert !u.save
|
57
|
+
assert u.errors.invalid?('password')
|
58
|
+
|
59
|
+
u.password = u.password_confirmation = ""
|
60
|
+
assert !u.save
|
61
|
+
assert u.errors.invalid?('password')
|
62
|
+
|
63
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
64
|
+
assert u.save
|
65
|
+
# assert u.errors.empty?
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_bad_names
|
70
|
+
|
71
|
+
u = Domain.new
|
72
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
73
|
+
|
74
|
+
u.name = "x"
|
75
|
+
assert !u.save
|
76
|
+
assert u.errors.invalid?('name')
|
77
|
+
|
78
|
+
u.name = "hugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhug"
|
79
|
+
assert !u.save
|
80
|
+
assert u.errors.invalid?('name')
|
81
|
+
|
82
|
+
u.name = ""
|
83
|
+
assert !u.save
|
84
|
+
assert u.errors.invalid?('name')
|
85
|
+
|
86
|
+
u.name = "okbob"
|
87
|
+
assert u.save
|
88
|
+
# assert u.errors.empty?
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_collision
|
93
|
+
u = Domain.new
|
94
|
+
u.name = "test.domain"
|
95
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
96
|
+
assert !u.save
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_create
|
100
|
+
u = Domain.new
|
101
|
+
u.name = "nonexistingbob"
|
102
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
103
|
+
|
104
|
+
assert u.save
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_sha1
|
108
|
+
u = Domain.new
|
109
|
+
u.name = "nonexistingbob"
|
110
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
111
|
+
assert u.save
|
112
|
+
|
113
|
+
assert_equal '826005bc4b82d02a3e6097556a45083375fe556c', u.password
|
114
|
+
end
|
115
|
+
|
116
|
+
# def test_change_nothing
|
117
|
+
# d = Domain.find_by_name "test.domain"
|
118
|
+
# assert_equal 'e7ce1e2e20ec9f11ce8e86c9c47ab9911c1d221e', d.password
|
119
|
+
# d.password = d.password_confirmation = nil
|
120
|
+
# result = d.save
|
121
|
+
# unless result == true
|
122
|
+
# d.errors.each do |thing, string|
|
123
|
+
# puts "#{thing}: #{string}"
|
124
|
+
# end
|
125
|
+
# end
|
126
|
+
# assert result
|
127
|
+
# end
|
128
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class MailinglistClassTest < Test::Unit::TestCase
|
4
|
+
fixtures :mailinglist_classes, :mailinglists, :users, :domains
|
5
|
+
|
6
|
+
# Replace this with your real tests.
|
7
|
+
def test_truth
|
8
|
+
assert true
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@ltma_class=MailinglistClass.find 1
|
13
|
+
@mailinglist_class=MailinglistClass.find 2
|
14
|
+
@distributionlist_class=MailinglistClass.find 3
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_existence
|
18
|
+
assert_kind_of MailinglistClass, @ltma_class
|
19
|
+
assert_kind_of MailinglistClass, @mailinglist_class
|
20
|
+
assert_kind_of MailinglistClass, @distributionlist_class
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_ltma_parameters
|
24
|
+
assert_equal "LTMA",@ltma_class.name
|
25
|
+
assert_equal "Lifetime Mail Address", @ltma_class.description
|
26
|
+
assert_equal false, @ltma_class.moderated
|
27
|
+
assert_equal true, @ltma_class.public
|
28
|
+
assert_equal true, @ltma_class.confirmation
|
29
|
+
assert_equal false, @ltma_class.joinable
|
30
|
+
assert_equal false, @ltma_class.closed
|
31
|
+
assert_equal false, @ltma_class.archived
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_mailinglist_parameters
|
35
|
+
assert_equal "Mailing List",@mailinglist_class.name
|
36
|
+
assert_equal "A normal, unmoderated, private-posting mailing list",
|
37
|
+
@mailinglist_class.description
|
38
|
+
assert_equal false, @mailinglist_class.moderated
|
39
|
+
assert_equal false, @mailinglist_class.public
|
40
|
+
assert_equal true, @mailinglist_class.confirmation
|
41
|
+
assert_equal true, @mailinglist_class.joinable
|
42
|
+
assert_equal false, @mailinglist_class.closed
|
43
|
+
assert_equal false, @mailinglist_class.archived
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_distributionlist_parameters
|
47
|
+
assert_equal "Distribution List", @distributionlist_class.name
|
48
|
+
assert_equal "A private distribution list",
|
49
|
+
@distributionlist_class.description
|
50
|
+
assert_equal false, @distributionlist_class.moderated
|
51
|
+
assert_equal false, @distributionlist_class.public
|
52
|
+
assert_equal false, @distributionlist_class.confirmation
|
53
|
+
assert_equal false, @distributionlist_class.joinable
|
54
|
+
assert_equal true, @distributionlist_class.closed
|
55
|
+
assert_equal false, @distributionlist_class.archived
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_creation
|
59
|
+
c=MailinglistClass.new
|
60
|
+
assert c
|
61
|
+
c.name="Test"
|
62
|
+
c.description="Test mailing list class"
|
63
|
+
c.moderated = true
|
64
|
+
c.public = true
|
65
|
+
c.confirmation = true
|
66
|
+
c.joinable = true
|
67
|
+
c.closed = true
|
68
|
+
c.archived = true
|
69
|
+
assert c.save
|
70
|
+
id=c.id
|
71
|
+
d=MailinglistClass.find id
|
72
|
+
assert d
|
73
|
+
assert d.name="Test"
|
74
|
+
assert d.description="Test mailing list class"
|
75
|
+
assert d.moderated
|
76
|
+
assert d.public
|
77
|
+
assert d.confirmation
|
78
|
+
assert d.joinable
|
79
|
+
assert d.closed
|
80
|
+
assert d.archived
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
require 'net-smtp-stub'
|
4
|
+
|
5
|
+
class MailinglistTest < Test::Unit::TestCase
|
6
|
+
fixtures :mailinglists, :addresses_mailinglists, :addresses,
|
7
|
+
:confirmationcodes, :users, :admin_messages, :domains, :messages
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@ml=Mailinglist.find 1
|
11
|
+
@addr1=Address.find 1
|
12
|
+
@addr2=Address.find 2
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_subscribing
|
16
|
+
assert @ml.subscribe("brandnewuser@foo.test")
|
17
|
+
assert addr=Address.find_by_address("brandnewuser@foo.test")
|
18
|
+
assert @ml.addresses.member?(addr)
|
19
|
+
assert @ml.pending_addresses.member?(addr)
|
20
|
+
assert !@ml.confirmed_addresses.member?(addr)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_confirming
|
24
|
+
assert_equal [@addr1],@ml.confirmed_addresses
|
25
|
+
assert_equal [@addr2],@ml.pending_addresses
|
26
|
+
confirmationcode=@loaded_fixtures["confirmationcodes"] \
|
27
|
+
["confirmationcode_testuser_address2"] \
|
28
|
+
["code"]
|
29
|
+
assert_nothing_raised do
|
30
|
+
@ml.confirm(@addr2,confirmationcode)
|
31
|
+
end
|
32
|
+
assert_equal [@addr1, @addr2],
|
33
|
+
@ml.confirmed_addresses.sort_by { |a| a.id }
|
34
|
+
assert_equal [], @ml.pending_addresses
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_confirming_by_addr_string
|
38
|
+
confirmationcode=@loaded_fixtures["confirmationcodes"] \
|
39
|
+
["confirmationcode_testuser_address2"] \
|
40
|
+
["code"]
|
41
|
+
assert_nothing_raised do
|
42
|
+
@ml.confirm(@addr2.address,confirmationcode)
|
43
|
+
end
|
44
|
+
assert_equal [@addr1, @addr2],
|
45
|
+
@ml.confirmed_addresses.sort_by { |a| a.id }
|
46
|
+
assert_equal [], @ml.pending_addresses
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_new_confirmation
|
50
|
+
@ml.subscribe 'brandnewuser@foo.test'
|
51
|
+
addr=Address.find_by_address("brandnewuser@foo.test")
|
52
|
+
assert @ml.addresses.member?(addr)
|
53
|
+
assert @ml.pending_addresses.member?(addr)
|
54
|
+
assert !@ml.confirmed_addresses.member?(addr)
|
55
|
+
assert Confirmationcode.find_by_address_id(addr.id)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_creating
|
59
|
+
ml=Mailinglist.new
|
60
|
+
ml.name="testing-new-mailing-list"
|
61
|
+
ml.user=User.find 1
|
62
|
+
ml.description="Testing new mailing list"
|
63
|
+
ml.mailinglist_class=MailinglistClass.find 2
|
64
|
+
assert ml.save
|
65
|
+
|
66
|
+
assert_equal 1, ml.welcome_admin_message_id
|
67
|
+
assert_equal 2, ml.confirmed_admin_message_id
|
68
|
+
assert_equal 3, ml.sayonara_admin_message_id
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_creating_nonexistent_user
|
72
|
+
ml=Mailinglist.new
|
73
|
+
ml.name="testing-new-mailing-list"
|
74
|
+
ml.user_id=999
|
75
|
+
ml.description="Testing new mailing list"
|
76
|
+
ml.mailinglist_class=MailinglistClass.find 2
|
77
|
+
assert_equal false, ml.save
|
78
|
+
assert_equal [["user", "can't be blank"]], ml.errors.to_a
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_creating_name_collision
|
82
|
+
ml=Mailinglist.new
|
83
|
+
ml.name="testml"
|
84
|
+
ml.user_id=1
|
85
|
+
ml.description="Testing new mailing list"
|
86
|
+
ml.mailinglist_class=MailinglistClass.find 2
|
87
|
+
assert_equal false, ml.save
|
88
|
+
assert_equal [["name", "Address already exists: testml@test.domain"]], ml.errors.to_a
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_canonical
|
92
|
+
ml=Mailinglist.find 1
|
93
|
+
assert ml.canonical_address?
|
94
|
+
ml=Mailinglist.find 3
|
95
|
+
assert_equal false, ml.canonical_address?
|
96
|
+
end
|
97
|
+
|
98
|
+
def has_address
|
99
|
+
ml=Mailinglist.find 1
|
100
|
+
assert ml.has_address?(@loaded_fixtures["addresses"]["address_1"]\
|
101
|
+
["address"])
|
102
|
+
end
|
103
|
+
|
104
|
+
def messages
|
105
|
+
ml=Mailinglist.find 1
|
106
|
+
assert_equal 3, ml.messages_count
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_expanded_addresses
|
110
|
+
ml=Mailinglist.find 4
|
111
|
+
addrs=ml.addresses
|
112
|
+
assert Mailinglist.find_by_address(addrs[0].address)
|
113
|
+
assert Mailinglist.find_by_address(addrs[1].address)
|
114
|
+
assert_equal [ Address.find_by_address("address1@foo.test"),
|
115
|
+
Address.find_by_address("address2@foo.test") ],
|
116
|
+
ml.expand_addresses . sort_by { |a| a.address }
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_has_address
|
120
|
+
ml=Mailinglist.find 4
|
121
|
+
assert_equal true, ml.has_address?("address1@foo.test")
|
122
|
+
assert_equal false, ml.has_address?("address3@foo.test")
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_find_by_address
|
126
|
+
ml, cmd, realaddress = Mailinglist.find_by_address("testuser-42@test.domain")
|
127
|
+
assert_equal :proxy, cmd
|
128
|
+
assert_equal 1, ml.id
|
129
|
+
assert_equal Address.find_by_address("addressmessage1@foo.test"),
|
130
|
+
realaddress
|
131
|
+
|
132
|
+
info = Mailinglist.find_by_address("testuser-10@test.domain")
|
133
|
+
assert_nil info
|
134
|
+
# assert_nil ml.id
|
135
|
+
# assert_equal 42, proxy.id
|
136
|
+
|
137
|
+
ml, cmd = Mailinglist.find_by_address("testuser-bounces@test.domain")
|
138
|
+
assert_equal :bounces, cmd
|
139
|
+
assert_equal 1, ml.id
|
140
|
+
|
141
|
+
ml, cmd = Mailinglist.find_by_address("testuser-request@test.domain")
|
142
|
+
assert_equal :request, cmd
|
143
|
+
assert_equal 1, ml.id
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require 'net-smtp-stub'
|
3
|
+
|
4
|
+
class MessageTest < Test::Unit::TestCase
|
5
|
+
fixtures :mailinglists, :messages, :users, :addresses_mailinglists,
|
6
|
+
:addresses, :domains
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@message_1=@loaded_fixtures["messages"]["message_1"]
|
10
|
+
@message_2=@loaded_fixtures["messages"]["message_2"]
|
11
|
+
@message_3=@loaded_fixtures["messages"]["message_3"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_truth
|
15
|
+
assert true
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_first_message_exists
|
19
|
+
m=Message.find 1
|
20
|
+
assert_equal m.subject, @message_1["subject"]
|
21
|
+
assert_equal m.messageid, @message_1["messageid"]
|
22
|
+
assert_equal m.headers, @message_1["headers"]
|
23
|
+
assert_equal m.body, @message_1["body"]
|
24
|
+
assert_equal m.timestamp, @message_1["timestamp"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_first_message_children
|
28
|
+
m=Message.find 1
|
29
|
+
child1, child2 = m.responses.sort_by { |mess| mess.id }
|
30
|
+
assert_kind_of Message, child1
|
31
|
+
assert_kind_of Message, child2
|
32
|
+
|
33
|
+
assert_equal 2, child1.id
|
34
|
+
assert_equal 3, child2.id
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_second_message_parent
|
38
|
+
m=Message.find 2
|
39
|
+
|
40
|
+
assert_equal 1, m.parent.id
|
41
|
+
siblings=m.siblings
|
42
|
+
assert_equal 1, siblings.length
|
43
|
+
assert_equal 3, siblings[0].id
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_new_message
|
47
|
+
new_message_headers = <<EOT
|
48
|
+
From: brandnewaddress@foo.test (Brand New Address)
|
49
|
+
Delivered-To: testuser@test.domain
|
50
|
+
Message-Id: <280826ee-bdad-4564-9dc4-5218b8143b54@localhost>
|
51
|
+
To: testuser@test.domain
|
52
|
+
Subject: Test message
|
53
|
+
EOT
|
54
|
+
|
55
|
+
new_message_body = <<EOT
|
56
|
+
This is a test message.
|
57
|
+
EOT
|
58
|
+
|
59
|
+
m=Message.parse(new_message_headers+"\n"+new_message_body,
|
60
|
+
"testuser@test.domain",
|
61
|
+
"brandnewaddress@foo.test")
|
62
|
+
|
63
|
+
assert m
|
64
|
+
assert_equal "brandnewaddress@foo.test", m.envelope_from
|
65
|
+
assert_equal ["testuser@test.domain"], m.envelope_to
|
66
|
+
assert m.messageid
|
67
|
+
assert m.timestamp
|
68
|
+
assert m.headers
|
69
|
+
assert m.body
|
70
|
+
assert_equal nil, m.parent
|
71
|
+
assert_equal new_message_headers.split("\n").sort, m.headers.split("\n").sort
|
72
|
+
assert_equal "\n"+new_message_body, m.body
|
73
|
+
assert Address.find_by_address("brandnewaddress@foo.test")
|
74
|
+
assert m.deliver
|
75
|
+
assert_equal "testuser-bounces@test.domain",Net::SMTP.from
|
76
|
+
assert_equal ["address1@foo.test"], Net::SMTP.to
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_rewrite_message
|
80
|
+
m=Message.find 4
|
81
|
+
assert_equal "To: root@test.domain\nFrom: testuser@test.domain\nSubject: Test with rewriting\nDate: Thu, 26 Oct 2006 18:35:00 +0900 (JST)\nMessage-Id: <testmessage-3@foo.test>\n\n\nThis one gets rewritten\n".split(/\n\n+/)[0].split(/\n/).sort.join("\n"), m.send(:proxify_addresses).split(/\n\n+/)[0].split(/\n/).sort.join("\n")
|
82
|
+
m.deliver
|
83
|
+
assert_equal "testuser-bounces@test.domain", Net::SMTP.from
|
84
|
+
assert_equal [ "address1@foo.test" ], Net::SMTP.to
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_rewrite_virtual_mailing_list
|
88
|
+
m=Message.find 5
|
89
|
+
|
90
|
+
# step by step, simplify debugging
|
91
|
+
proxified=m.send(:proxify_addresses)
|
92
|
+
proxified_headers = proxified.split(/\n\n+/)[0]
|
93
|
+
headers_array = proxified_headers.split(/\n/).sort
|
94
|
+
headers_sorted=headers_array.join("\n")
|
95
|
+
|
96
|
+
assert_equal "To: virtml@test.domain\nFrom: =?UTF-8?B?VmlydHVhbCBVc2Vy?= <virtuser@test.domain>\nSubject: Test with rewriting\nDate: Thu, 11 Nov 2006 19:13:00 +0900 (JST)\nMessage-Id: <testmessage-4@foo.test>\n\n\nThis one gets rewritten to have a To line of virtuser, right?\n".split(/\n\n+/)[0].split(/\n/).sort.join("\n"),
|
97
|
+
headers_sorted
|
98
|
+
assert m.deliver
|
99
|
+
assert_equal "virtml-bounces@test.domain",Net::SMTP.from
|
100
|
+
assert_equal [], Net::SMTP.to
|
101
|
+
# puts Net::SMTP.message
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_rewrite_virtual_mailing_list_without_a_description
|
105
|
+
m=Message.find 8
|
106
|
+
|
107
|
+
# puts m.to_s
|
108
|
+
|
109
|
+
# step by step, simplify debugging
|
110
|
+
proxified=m.send(:proxify_addresses)
|
111
|
+
# puts m.to_s
|
112
|
+
proxified_headers = proxified.split(/\n\n+/)[0]
|
113
|
+
headers_array = proxified_headers.split(/\n/).sort
|
114
|
+
headers_sorted=headers_array.join("\n")
|
115
|
+
|
116
|
+
assert_equal "To: nodescml@test.domain\nFrom: nodesc@test.domain\nSubject: Test with rewriting\nDate: Thu, 11 Nov 2006 19:13:00 +0900 (JST)\nMessage-Id: <testmessage-8@foo.test>\n\n\nThis one gets rewritten to have a To line of nodesc, right?\n".split(/\n\n+/)[0].split(/\n/).sort.join("\n"),
|
117
|
+
headers_sorted
|
118
|
+
assert m.deliver
|
119
|
+
assert_equal "nodescml-bounces@test.domain",Net::SMTP.from
|
120
|
+
assert_equal [], Net::SMTP.to
|
121
|
+
# puts Net::SMTP.message
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
def test_add_replyto_on_external_message
|
126
|
+
m=Message.find 6
|
127
|
+
|
128
|
+
proxified = m.send :proxify_addresses
|
129
|
+
# puts proxified
|
130
|
+
proxified_headers = proxified.split(/\n\n+/)[0]
|
131
|
+
headers_array = proxified_headers.split(/\n/).sort
|
132
|
+
headers_sorted=headers_array.join("\n")
|
133
|
+
assert_not_equal [], headers_sorted.grep(/^Reply-To:/)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_plain_rewrite
|
137
|
+
m=Message.find 7
|
138
|
+
|
139
|
+
proxified = m.send :proxify_addresses
|
140
|
+
# puts proxified
|
141
|
+
proxified_headers = proxified.split(/\n\n+/)[0]
|
142
|
+
headers_array = proxified_headers.split(/\n/).sort
|
143
|
+
headers_sorted=headers_array.join("\n")
|
144
|
+
assert_equal ["Message-Id: <testmessage-7@foo.test>",
|
145
|
+
"Subject: Test for plain rewrite",
|
146
|
+
"From: testuser@test.domain",
|
147
|
+
"To: plainrewrite@foo.test",
|
148
|
+
"Date: Thu, 11 Nov 2006 19:13:00 +0900 (JST)" ] .
|
149
|
+
sort . join("\n"), headers_sorted
|
150
|
+
end
|
151
|
+
end
|