postfix_admin 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +7 -5
- data/Dockerfile +24 -0
- data/README.md +22 -15
- data/Rakefile +5 -0
- data/bin/console +18 -0
- data/docker-compose.yml +24 -0
- data/docker-entrypoint.sh +5 -0
- data/{bin → exe}/postfix_admin +1 -0
- data/lib/postfix_admin.rb +1 -1
- data/lib/postfix_admin/admin.rb +52 -0
- data/lib/postfix_admin/alias.rb +65 -0
- data/lib/postfix_admin/application_record.rb +44 -0
- data/lib/postfix_admin/base.rb +98 -88
- data/lib/postfix_admin/cli.rb +50 -46
- data/lib/postfix_admin/concerns/.keep +0 -0
- data/lib/postfix_admin/concerns/dovecot_cram_md5_password.rb +30 -0
- data/lib/postfix_admin/concerns/existing_timestamp.rb +18 -0
- data/lib/postfix_admin/domain.rb +98 -0
- data/lib/postfix_admin/domain_admin.rb +8 -0
- data/lib/postfix_admin/doveadm.rb +1 -1
- data/lib/postfix_admin/log.rb +5 -0
- data/lib/postfix_admin/mail_domain.rb +9 -0
- data/lib/postfix_admin/mailbox.rb +89 -0
- data/lib/postfix_admin/models.rb +10 -213
- data/lib/postfix_admin/quota.rb +6 -0
- data/lib/postfix_admin/runner.rb +39 -36
- data/lib/postfix_admin/version.rb +1 -1
- data/postfix_admin.gemspec +20 -13
- metadata +49 -50
- data/spec/base_spec.rb +0 -253
- data/spec/cli_spec.rb +0 -300
- data/spec/doveadm_spec.rb +0 -35
- data/spec/models_spec.rb +0 -195
- data/spec/postfix_admin.conf +0 -5
- data/spec/postfix_test.sql +0 -250
- data/spec/runner_spec.rb +0 -370
- data/spec/spec_helper.rb +0 -201
data/spec/postfix_admin.conf
DELETED
data/spec/postfix_test.sql
DELETED
@@ -1,250 +0,0 @@
|
|
1
|
-
-- phpMyAdmin SQL Dump
|
2
|
-
-- version 3.4.7
|
3
|
-
-- http://www.phpmyadmin.net
|
4
|
-
--
|
5
|
-
-- ホスト: localhost
|
6
|
-
-- 生成時間: 2012 年 9 月 25 日 23:12
|
7
|
-
-- サーバのバージョン: 5.5.15
|
8
|
-
-- PHP のバージョン: 5.3.15
|
9
|
-
|
10
|
-
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
|
11
|
-
SET time_zone = "+00:00";
|
12
|
-
|
13
|
-
|
14
|
-
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
15
|
-
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
16
|
-
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
17
|
-
/*!40101 SET NAMES utf8 */;
|
18
|
-
|
19
|
-
--
|
20
|
-
-- データベース: `postfix_test`
|
21
|
-
--
|
22
|
-
|
23
|
-
-- --------------------------------------------------------
|
24
|
-
|
25
|
-
--
|
26
|
-
-- テーブルの構造 `admin`
|
27
|
-
--
|
28
|
-
|
29
|
-
CREATE TABLE IF NOT EXISTS `admin` (
|
30
|
-
`username` varchar(255) NOT NULL DEFAULT '',
|
31
|
-
`password` varchar(255) NOT NULL DEFAULT '',
|
32
|
-
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
33
|
-
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
34
|
-
`active` tinyint(1) NOT NULL DEFAULT '1',
|
35
|
-
PRIMARY KEY (`username`)
|
36
|
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Postfix Admin - Virtual Admins';
|
37
|
-
|
38
|
-
--
|
39
|
-
-- テーブルのデータをダンプしています `admin`
|
40
|
-
--
|
41
|
-
|
42
|
-
INSERT INTO `admin` (`username`, `password`, `created`, `modified`, `active`) VALUES
|
43
|
-
('all@example.com', 'password', '2012-08-31 15:39:02', '2012-08-31 15:39:19', 1),
|
44
|
-
('admin@example.com', 'password', '2012-08-31 10:27:58', '2012-08-31 10:28:16', 1);
|
45
|
-
|
46
|
-
-- --------------------------------------------------------
|
47
|
-
|
48
|
-
--
|
49
|
-
-- テーブルの構造 `alias`
|
50
|
-
--
|
51
|
-
|
52
|
-
CREATE TABLE IF NOT EXISTS `alias` (
|
53
|
-
`address` varchar(255) NOT NULL DEFAULT '',
|
54
|
-
`goto` text NOT NULL,
|
55
|
-
`domain` varchar(255) NOT NULL DEFAULT '',
|
56
|
-
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
57
|
-
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
58
|
-
`active` tinyint(1) NOT NULL DEFAULT '1',
|
59
|
-
PRIMARY KEY (`address`)
|
60
|
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Postfix Admin - Virtual Aliases';
|
61
|
-
|
62
|
-
--
|
63
|
-
-- テーブルのデータをダンプしています `alias`
|
64
|
-
--
|
65
|
-
|
66
|
-
INSERT INTO `alias` (`address`, `goto`, `domain`, `created`, `modified`, `active`) VALUES
|
67
|
-
('user@example.com', 'user@example.com', 'example.com', '2012-08-31 10:24:12', '2012-08-31 10:24:12', 1);
|
68
|
-
|
69
|
-
-- --------------------------------------------------------
|
70
|
-
|
71
|
-
--
|
72
|
-
-- テーブルの構造 `config`
|
73
|
-
--
|
74
|
-
|
75
|
-
CREATE TABLE IF NOT EXISTS `config` (
|
76
|
-
`id` int(11) NOT NULL AUTO_INCREMENT,
|
77
|
-
`name` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '',
|
78
|
-
`value` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '',
|
79
|
-
PRIMARY KEY (`id`),
|
80
|
-
UNIQUE KEY `name` (`name`)
|
81
|
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='PostfixAdmin settings' AUTO_INCREMENT=2 ;
|
82
|
-
|
83
|
-
--
|
84
|
-
-- テーブルのデータをダンプしています `config`
|
85
|
-
--
|
86
|
-
|
87
|
-
INSERT INTO `config` (`id`, `name`, `value`) VALUES
|
88
|
-
(1, 'version', '352');
|
89
|
-
|
90
|
-
-- --------------------------------------------------------
|
91
|
-
|
92
|
-
--
|
93
|
-
-- テーブルの構造 `domain`
|
94
|
-
--
|
95
|
-
|
96
|
-
CREATE TABLE IF NOT EXISTS `domain` (
|
97
|
-
`domain` varchar(255) NOT NULL DEFAULT '',
|
98
|
-
`description` varchar(255) NOT NULL DEFAULT '',
|
99
|
-
`aliases` int(10) NOT NULL DEFAULT '0',
|
100
|
-
`mailboxes` int(10) NOT NULL DEFAULT '0',
|
101
|
-
`maxquota` bigint(20) NOT NULL DEFAULT '0',
|
102
|
-
`quota` bigint(20) NOT NULL DEFAULT '0',
|
103
|
-
`transport` varchar(255) DEFAULT NULL,
|
104
|
-
`backupmx` tinyint(1) NOT NULL DEFAULT '0',
|
105
|
-
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
106
|
-
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
107
|
-
`active` tinyint(1) NOT NULL DEFAULT '1',
|
108
|
-
PRIMARY KEY (`domain`)
|
109
|
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Postfix Admin - Virtual Domains';
|
110
|
-
|
111
|
-
--
|
112
|
-
-- テーブルのデータをダンプしています `domain`
|
113
|
-
--
|
114
|
-
|
115
|
-
INSERT INTO `domain` (`domain`, `description`, `aliases`, `mailboxes`, `maxquota`, `quota`, `transport`, `backupmx`, `created`, `modified`, `active`) VALUES
|
116
|
-
('ALL', '', 0, 0, 0, 0, NULL, 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1),
|
117
|
-
('example.com', '', 100, 100, 100, 0, 'virtual', 0, '2012-08-31 10:21:49', '2012-08-31 10:21:49', 1);
|
118
|
-
|
119
|
-
-- --------------------------------------------------------
|
120
|
-
|
121
|
-
--
|
122
|
-
-- テーブルの構造 `domain_admins`
|
123
|
-
--
|
124
|
-
|
125
|
-
CREATE TABLE IF NOT EXISTS `domain_admins` (
|
126
|
-
`username` varchar(255) NOT NULL DEFAULT '',
|
127
|
-
`domain` varchar(255) NOT NULL DEFAULT '',
|
128
|
-
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
129
|
-
`active` tinyint(1) NOT NULL DEFAULT '1',
|
130
|
-
KEY `username` (`username`)
|
131
|
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Postfix Admin - Domain Admins';
|
132
|
-
|
133
|
-
--
|
134
|
-
-- テーブルのデータをダンプしています `domain_admins`
|
135
|
-
--
|
136
|
-
|
137
|
-
INSERT INTO `domain_admins` (`username`, `domain`, `created`, `active`) VALUES
|
138
|
-
('all@example.com', 'ALL', '2012-08-31 15:39:19', 1),
|
139
|
-
('admin@example.com', 'example.com', '2012-08-31 10:28:16', 1);
|
140
|
-
|
141
|
-
-- --------------------------------------------------------
|
142
|
-
|
143
|
-
--
|
144
|
-
-- テーブルの構造 `fetchmail`
|
145
|
-
--
|
146
|
-
|
147
|
-
CREATE TABLE IF NOT EXISTS `fetchmail` (
|
148
|
-
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
149
|
-
`mailbox` varchar(255) NOT NULL DEFAULT '',
|
150
|
-
`src_server` varchar(255) NOT NULL DEFAULT '',
|
151
|
-
`src_auth` enum('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any') DEFAULT NULL,
|
152
|
-
`src_user` varchar(255) NOT NULL DEFAULT '',
|
153
|
-
`src_password` varchar(255) NOT NULL DEFAULT '',
|
154
|
-
`src_folder` varchar(255) NOT NULL DEFAULT '',
|
155
|
-
`poll_time` int(11) unsigned NOT NULL DEFAULT '10',
|
156
|
-
`fetchall` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
157
|
-
`keep` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
158
|
-
`protocol` enum('POP3','IMAP','POP2','ETRN','AUTO') DEFAULT NULL,
|
159
|
-
`extra_options` text,
|
160
|
-
`returned_text` text,
|
161
|
-
`mda` varchar(255) NOT NULL DEFAULT '',
|
162
|
-
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
163
|
-
PRIMARY KEY (`id`)
|
164
|
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
165
|
-
|
166
|
-
-- --------------------------------------------------------
|
167
|
-
|
168
|
-
--
|
169
|
-
-- テーブルの構造 `log`
|
170
|
-
--
|
171
|
-
|
172
|
-
CREATE TABLE IF NOT EXISTS `log` (
|
173
|
-
`timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
174
|
-
`username` varchar(255) NOT NULL DEFAULT '',
|
175
|
-
`domain` varchar(255) NOT NULL DEFAULT '',
|
176
|
-
`action` varchar(255) NOT NULL DEFAULT '',
|
177
|
-
`data` varchar(255) NOT NULL DEFAULT '',
|
178
|
-
KEY `timestamp` (`timestamp`)
|
179
|
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Postfix Admin - Log';
|
180
|
-
|
181
|
-
-- --------------------------------------------------------
|
182
|
-
|
183
|
-
--
|
184
|
-
-- テーブルの構造 `mailbox`
|
185
|
-
--
|
186
|
-
|
187
|
-
CREATE TABLE IF NOT EXISTS `mailbox` (
|
188
|
-
`username` varchar(255) NOT NULL DEFAULT '',
|
189
|
-
`password` varchar(255) NOT NULL DEFAULT '',
|
190
|
-
`name` varchar(255) NOT NULL DEFAULT '',
|
191
|
-
`maildir` varchar(255) NOT NULL DEFAULT '',
|
192
|
-
`quota` bigint(20) NOT NULL DEFAULT '0',
|
193
|
-
`domain` varchar(255) NOT NULL DEFAULT '',
|
194
|
-
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
195
|
-
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
196
|
-
`active` tinyint(1) NOT NULL DEFAULT '1',
|
197
|
-
PRIMARY KEY (`username`)
|
198
|
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Postfix Admin - Virtual Mailboxes';
|
199
|
-
|
200
|
-
--
|
201
|
-
-- テーブルのデータをダンプしています `mailbox`
|
202
|
-
--
|
203
|
-
|
204
|
-
INSERT INTO `mailbox` (`username`, `password`, `name`, `maildir`, `quota`, `domain`, `created`, `modified`, `active`) VALUES
|
205
|
-
('user@example.com', 'password', '', 'example.com/user@example.com/', 102400000, 'example.com', '2012-08-31 10:24:12', '2012-08-31 10:24:12', 1);
|
206
|
-
|
207
|
-
-- --------------------------------------------------------
|
208
|
-
|
209
|
-
--
|
210
|
-
-- テーブルの構造 `vacation`
|
211
|
-
--
|
212
|
-
|
213
|
-
CREATE TABLE IF NOT EXISTS `vacation` (
|
214
|
-
`email` varchar(255) NOT NULL,
|
215
|
-
`subject` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
216
|
-
`body` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
217
|
-
`cache` text NOT NULL,
|
218
|
-
`domain` varchar(255) NOT NULL,
|
219
|
-
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
220
|
-
`active` tinyint(1) NOT NULL DEFAULT '1',
|
221
|
-
PRIMARY KEY (`email`),
|
222
|
-
KEY `email` (`email`)
|
223
|
-
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Postfix Admin - Virtual Vacation';
|
224
|
-
|
225
|
-
-- --------------------------------------------------------
|
226
|
-
|
227
|
-
--
|
228
|
-
-- テーブルの構造 `vacation_notification`
|
229
|
-
--
|
230
|
-
|
231
|
-
CREATE TABLE IF NOT EXISTS `vacation_notification` (
|
232
|
-
`on_vacation` varchar(255) NOT NULL,
|
233
|
-
`notified` varchar(255) NOT NULL,
|
234
|
-
`notified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
235
|
-
PRIMARY KEY (`on_vacation`,`notified`)
|
236
|
-
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Postfix Admin - Virtual Vacation Notifications';
|
237
|
-
|
238
|
-
--
|
239
|
-
-- ダンプしたテーブルの制約
|
240
|
-
--
|
241
|
-
|
242
|
-
--
|
243
|
-
-- テーブルの制約 `vacation_notification`
|
244
|
-
--
|
245
|
-
ALTER TABLE `vacation_notification`
|
246
|
-
ADD CONSTRAINT `vacation_notification_pkey` FOREIGN KEY (`on_vacation`) REFERENCES `vacation` (`email`) ON DELETE CASCADE;
|
247
|
-
|
248
|
-
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
249
|
-
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
250
|
-
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
data/spec/runner_spec.rb
DELETED
@@ -1,370 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
|
4
|
-
require 'postfix_admin/runner'
|
5
|
-
|
6
|
-
describe PostfixAdmin::Runner do
|
7
|
-
before do
|
8
|
-
db_initialize
|
9
|
-
end
|
10
|
-
|
11
|
-
it "version" do
|
12
|
-
capture(:stdout){ Runner.start(["version"]) }.should =~ /postfix_admin \d+\.\d+\.\d/
|
13
|
-
end
|
14
|
-
|
15
|
-
it "summary" do
|
16
|
-
capture(:stdout){ Runner.start(["summary"]) }.should =~ /\[Summary\]/
|
17
|
-
capture(:stdout){ Runner.start(["summary", "example.com"]) }.should =~ /\[Summary of example.com\]/
|
18
|
-
end
|
19
|
-
|
20
|
-
it "schemes" do
|
21
|
-
capture(:stdout){ Runner.start(["schemes"]) }.should =~ /CLEARTEXT/
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "show" do
|
25
|
-
it "shows information of example.com" do
|
26
|
-
capture(:stdout){ Runner.start(["show"]) }.should =~ /example.com\s+1\s+\/\s+30\s+1\s+\/\s+30\s+100/
|
27
|
-
end
|
28
|
-
|
29
|
-
it "shows information of admin@example.com" do
|
30
|
-
capture(:stdout){ Runner.start(["show"]) }.should =~ /admin@example.com\s+1\s+YES/
|
31
|
-
end
|
32
|
-
|
33
|
-
it "show the detail of example.com" do
|
34
|
-
capture(:stdout){ Runner.start(["show", "example.com"]) }.should =~ /user@example.com\s+100\s+YES/
|
35
|
-
end
|
36
|
-
|
37
|
-
it "when no admins, no aliases and no addresses" do
|
38
|
-
Admin.find('all@example.com').super_admin = false
|
39
|
-
out = capture(:stdout){ Runner.start(["show", "example.org"]) }
|
40
|
-
out.should =~ /No admins/
|
41
|
-
out.should =~ /No addresses/
|
42
|
-
out.should =~ /No aliases/
|
43
|
-
end
|
44
|
-
|
45
|
-
it "shows information of an admin" do
|
46
|
-
capture(:stdout){ Runner.start(["show", "admin@example.com"]) }.should =~ /admin@example.com/
|
47
|
-
end
|
48
|
-
|
49
|
-
it "shows information of an account" do
|
50
|
-
capture(:stdout){ Runner.start(["show", "user@example.com"]) }.should =~ /user@example.com/
|
51
|
-
end
|
52
|
-
|
53
|
-
it "shows information of an alias" do
|
54
|
-
capture(:stdout){ Runner.start(["show", "alias@example.com"]) }.should =~ /alias@example.com/
|
55
|
-
end
|
56
|
-
|
57
|
-
it "when no domains" do
|
58
|
-
capture(:stdout){ Runner.start(['delete_domain', 'example.com']) }.should =~ EX_DELETED
|
59
|
-
capture(:stdout){ Runner.start(['delete_domain', 'example.org']) }.should =~ EX_DELETED
|
60
|
-
capture(:stdout){ Runner.start(["show"]) }.should =~ /No domains/
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
it "setup" do
|
65
|
-
capture(:stdout){ Runner.start(['setup', 'example.net', 'password']) }.should =~ EX_REGISTERED
|
66
|
-
capture(:stdout){ Runner.start(['delete_domain', 'example.net']) }.should =~ EX_DELETED
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "admin_passwd" do
|
70
|
-
it "can change password of an admin" do
|
71
|
-
capture(:stdout){ Runner.start(['admin_passwd', 'admin@example.com', 'new_password']) }.should =~ /successfully changed/
|
72
|
-
end
|
73
|
-
|
74
|
-
it "can not use too short password (< 5)" do
|
75
|
-
exit_capture{ Runner.start(['admin_passwd', 'admin@example.com', '124']) }.should =~ /too short/
|
76
|
-
end
|
77
|
-
|
78
|
-
it "can not use for unknown admin" do
|
79
|
-
exit_capture{ Runner.start(['admin_passwd', 'unknown@example.com', 'new_password']) }.should =~ /Could not find/
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "account_passwd" do
|
84
|
-
it "can change password of an account" do
|
85
|
-
capture(:stdout){ Runner.start(['account_passwd', 'user@example.com', 'new_password']) }.should =~ /successfully changed/
|
86
|
-
Mailbox.find('user@example.com').password.should == CRAM_MD5_NEW_PASS
|
87
|
-
end
|
88
|
-
|
89
|
-
it "can not use too short password (< 5)" do
|
90
|
-
exit_capture{ Runner.start(['account_passwd', 'user@example.com', '1234']) }.should =~ /too short/
|
91
|
-
end
|
92
|
-
|
93
|
-
it "can not use for unknown account" do
|
94
|
-
exit_capture{ Runner.start(['account_passwd', 'unknown@example.com', 'new_password']) }.should =~ /Could not find/
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "add_alias and delete_alias" do
|
99
|
-
it "can add and delete an new alias." do
|
100
|
-
capture(:stdout){ Runner.start(['add_alias', 'new_alias@example.com', 'goto@example.jp']) }.should =~ EX_REGISTERED
|
101
|
-
capture(:stdout){ Runner.start(['delete_alias', 'new_alias@example.com']) }.should =~ EX_DELETED
|
102
|
-
end
|
103
|
-
|
104
|
-
it "can not delete mailbox alias." do
|
105
|
-
exit_capture{ Runner.start(['delete_alias', 'user@example.com']) }.should =~ /Can not delete mailbox/
|
106
|
-
end
|
107
|
-
|
108
|
-
it "can not add an alias for existed mailbox" do
|
109
|
-
exit_capture{ Runner.start(['add_alias', 'user@example.com', 'goto@example.jp']) }.should =~ /mailbox user@example.com is already registered!/
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe "edit_alias" do
|
114
|
-
it "can update active status" do
|
115
|
-
output = capture(:stdout){ Runner.start(['edit_alias', 'alias@example.com', '--no-active']) }
|
116
|
-
expect(output).to match EX_UPDATED
|
117
|
-
expect(output).to match /Active.+NO/
|
118
|
-
end
|
119
|
-
|
120
|
-
it "can update goto" do
|
121
|
-
output = capture(:stdout){ Runner.start(['edit_alias', 'alias@example.com', '-g', 'goto@example.com,user@example.com']) }
|
122
|
-
expect(output).to match EX_UPDATED
|
123
|
-
Alias.find('alias@example.com').goto.should == 'goto@example.com,user@example.com'
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe "add_admin" do
|
128
|
-
before do
|
129
|
-
@args = ['add_admin', 'admin@example.jp', 'password']
|
130
|
-
end
|
131
|
-
|
132
|
-
it "can add an new admin" do
|
133
|
-
capture(:stdout){ Runner.start(@args) }.should =~ EX_REGISTERED
|
134
|
-
end
|
135
|
-
|
136
|
-
describe "scheme option" do
|
137
|
-
it "--scheme does not show error" do
|
138
|
-
exit_capture{ Runner.start(@args + ['--scheme', 'CRAM-MD5']) }.should == ""
|
139
|
-
Admin.find('admin@example.jp').password.should == CRAM_MD5_PASS
|
140
|
-
end
|
141
|
-
|
142
|
-
it "--shceme can resister admin" do
|
143
|
-
capture(:stdout){ Runner.start(@args + ['--scheme', 'CRAM-MD5']) }.should =~ EX_REGISTERED
|
144
|
-
end
|
145
|
-
|
146
|
-
it "-s does not show error" do
|
147
|
-
exit_capture{ Runner.start(@args + ['-s', 'CRAM-MD5']) }.should == ""
|
148
|
-
end
|
149
|
-
|
150
|
-
it "-s can resister admin" do
|
151
|
-
capture(:stdout){ Runner.start(@args + ['-s', 'CRAM-MD5']) }.should =~ EX_REGISTERED
|
152
|
-
end
|
153
|
-
|
154
|
-
it "-s require argument" do
|
155
|
-
exit_capture{ Runner.start(@args + ['-s']) }.should =~ /Specify password scheme/
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
it "can use long password" do
|
160
|
-
capture(:stdout){ Runner.start(['add_admin', 'admin@example.jp', '9c5e77f2da26fc03e9fa9e13ccd77aeb50c85539a4d90b70812715aea9ebda1d']) }.should =~ EX_REGISTERED
|
161
|
-
end
|
162
|
-
|
163
|
-
it "--super option" do
|
164
|
-
capture(:stdout){ Runner.start(@args + ['--super']) }.should =~ /registered as a super admin/
|
165
|
-
end
|
166
|
-
|
167
|
-
it "-S (--super) option" do
|
168
|
-
capture(:stdout){ Runner.start(@args + ['-S']) }.should =~ /registered as a super admin/
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "edit_admin" do
|
173
|
-
it "when no options, shows usage" do
|
174
|
-
expect(capture(:stderr){ Runner.start(['edit_admin', 'admin@example.com']) }).to match /Use one or more options/
|
175
|
-
end
|
176
|
-
|
177
|
-
it "can update active status" do
|
178
|
-
output = capture(:stdout){ Runner.start(['edit_admin', 'admin@example.com', '--no-active']) }
|
179
|
-
expect(output).to match EX_UPDATED
|
180
|
-
expect(output).to match /Active.+NO/
|
181
|
-
expect(output).to match /Role.+Admin/
|
182
|
-
end
|
183
|
-
|
184
|
-
it "can update super admin status" do
|
185
|
-
output = capture(:stdout){ Runner.start(['edit_admin', 'admin@example.com', '--super']) }
|
186
|
-
expect(output).to match EX_UPDATED
|
187
|
-
expect(output).to match /Domains.+ALL/
|
188
|
-
expect(output).to match /Active.+YES/
|
189
|
-
expect(output).to match /Role.+Super admin/
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe "edit_domain" do
|
194
|
-
it "when no options, shows usage" do
|
195
|
-
exit_capture{ Runner.start(['edit_domain', 'example.com']) }.should =~ /Use one or more options/
|
196
|
-
end
|
197
|
-
|
198
|
-
it "can edit limitations of domain" do
|
199
|
-
output = capture(:stdout){ Runner.start(['edit_domain', 'example.com', '--aliases', '40', '--mailboxes', '40', '--maxquota', '400', '--no-active']) }
|
200
|
-
expect(output).to match EX_UPDATED
|
201
|
-
expect(output).to match /Active.+NO/
|
202
|
-
end
|
203
|
-
|
204
|
-
it "aliases options -a, -m, -q" do
|
205
|
-
capture(:stdout){ Runner.start(['edit_domain', 'example.com', '-a', '40', '-m', '40', '-m', '400']) }.should =~ EX_UPDATED
|
206
|
-
end
|
207
|
-
|
208
|
-
it "can not use unknown domain" do
|
209
|
-
exit_capture{ Runner.start(['edit_domain', 'unknown.example.com', '--aliases', '40', '--mailboxes', '40', '--maxquota', '400'])}.should =~ /Could not find/
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
describe "edit_account" do
|
214
|
-
before do
|
215
|
-
@args = ['edit_account', 'user@example.com']
|
216
|
-
end
|
217
|
-
|
218
|
-
it "when no options, shows usage" do
|
219
|
-
exit_capture{ Runner.start(@args) }.should =~ /Use one or more options/
|
220
|
-
end
|
221
|
-
|
222
|
-
it "can edit quota limitation" do
|
223
|
-
output = capture(:stdout){ Runner.start(@args + ['--quota', '50', '--no-active'])}
|
224
|
-
expect(output).to match EX_UPDATED
|
225
|
-
expect(output).to match /Quota/
|
226
|
-
expect(output).to match /Active.+NO/
|
227
|
-
end
|
228
|
-
|
229
|
-
it "can use alias -q option" do
|
230
|
-
capture(:stdout){ Runner.start(@args + ['-q', '50'])}.should =~ EX_UPDATED
|
231
|
-
end
|
232
|
-
|
233
|
-
it "-q option require an argment" do
|
234
|
-
exit_capture{ Runner.start(@args + ['-q'])}.should_not == ""
|
235
|
-
end
|
236
|
-
|
237
|
-
it "can update name using --name option" do
|
238
|
-
capture(:stdout){ Runner.start(@args + ['--name', 'Hitoshi Kurokawa'])}.should =~ EX_UPDATED
|
239
|
-
Mailbox.find('user@example.com').name.should == 'Hitoshi Kurokawa'
|
240
|
-
end
|
241
|
-
|
242
|
-
it "can update name using -n option" do
|
243
|
-
capture(:stdout){ Runner.start(@args + ['-n', 'Hitoshi Kurokawa'])}.should =~ EX_UPDATED
|
244
|
-
Mailbox.find('user@example.com').name.should == 'Hitoshi Kurokawa'
|
245
|
-
end
|
246
|
-
|
247
|
-
it "-n option supports Japanese" do
|
248
|
-
capture(:stdout){ Runner.start(@args + ['-n', '黒川 仁'])}.should =~ EX_UPDATED
|
249
|
-
Mailbox.find('user@example.com').name.should == '黒川 仁'
|
250
|
-
end
|
251
|
-
|
252
|
-
it "-n option require an argument" do
|
253
|
-
exit_capture{ Runner.start(@args + ['-n'])}.should_not == ""
|
254
|
-
end
|
255
|
-
|
256
|
-
it "can update goto" do
|
257
|
-
capture(:stdout){ Runner.start(@args + ['-g', 'user@example.com,forward@example.com'])}.should =~ EX_UPDATED
|
258
|
-
Alias.find('user@example.com').goto.should == 'user@example.com,forward@example.com'
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
it "add_admin_domain" do
|
263
|
-
capture(:stdout){ Runner.start(['add_admin_domain', 'admin@example.com', 'example.org']) }.should =~ EX_REGISTERED
|
264
|
-
end
|
265
|
-
|
266
|
-
it "delete_admin_domain" do
|
267
|
-
capture(:stdout){ Runner.start(['delete_admin_domain', 'admin@example.com', 'example.com']) }.should =~ EX_DELETED
|
268
|
-
end
|
269
|
-
|
270
|
-
it "delete_admin" do
|
271
|
-
capture(:stdout){ Runner.start(['delete_admin', 'admin@example.com']) }.should =~ EX_DELETED
|
272
|
-
end
|
273
|
-
|
274
|
-
it "add_account and delete_account" do
|
275
|
-
capture(:stdout){ Runner.start(['add_account', 'user2@example.com', 'password']) }.should =~ EX_REGISTERED
|
276
|
-
capture(:stdout){ Runner.start(['delete_account', 'user2@example.com']) }.should =~ EX_DELETED
|
277
|
-
end
|
278
|
-
|
279
|
-
describe "add_account" do
|
280
|
-
before do
|
281
|
-
@user = 'user2@example.com'
|
282
|
-
@args = ['add_account', @user, 'password']
|
283
|
-
@name = 'Hitoshi Kurokawa'
|
284
|
-
end
|
285
|
-
|
286
|
-
it "default scheme (CRAM-MD5) is applied" do
|
287
|
-
capture(:stdout){ Runner.start(@args) }.should =~ /scheme: CRAM-MD5/
|
288
|
-
Mailbox.find('user2@example.com').password.should == CRAM_MD5_PASS
|
289
|
-
end
|
290
|
-
|
291
|
-
it "add_account can use long password" do
|
292
|
-
capture(:stdout){ Runner.start(['add_account', 'user2@example.com', '9c5e77f2da26fc03e9fa9e13ccd77aeb50c85539a4d90b70812715aea9ebda1d']) }.should =~ EX_REGISTERED
|
293
|
-
end
|
294
|
-
|
295
|
-
describe "name option" do
|
296
|
-
it "--name options does not raise error" do
|
297
|
-
exit_capture{ Runner.start(@args + ['--name', @name]) }.should == ""
|
298
|
-
end
|
299
|
-
|
300
|
-
it "-n options does not raise error" do
|
301
|
-
exit_capture{ Runner.start(@args + ['-n', @name]) }.should == ""
|
302
|
-
end
|
303
|
-
|
304
|
-
it "require an argument" do
|
305
|
-
exit_capture{ Runner.start(@args + ['-n']) }.should_not == ""
|
306
|
-
end
|
307
|
-
|
308
|
-
it "can change full name" do
|
309
|
-
Runner.start(@args + ['-n', @name])
|
310
|
-
Mailbox.find(@user).name.should == @name
|
311
|
-
end
|
312
|
-
|
313
|
-
it "can use Japanese" do
|
314
|
-
exit_capture{ Runner.start(@args + ['-n', '黒川 仁']) }.should == ""
|
315
|
-
Mailbox.find(@user).name.should == '黒川 仁'
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe "scheme" do
|
320
|
-
it "--scheme require argument" do
|
321
|
-
exit_capture{ Runner.start(@args + ['--scheme']) }.should =~ /Specify password scheme/
|
322
|
-
end
|
323
|
-
|
324
|
-
it "can use CRAM-MD5 using --scheme" do
|
325
|
-
capture(:stdout){ Runner.start(@args + ['--scheme', 'CRAM-MD5']) }.should =~ EX_REGISTERED
|
326
|
-
Mailbox.find('user2@example.com').password.should == CRAM_MD5_PASS
|
327
|
-
end
|
328
|
-
|
329
|
-
it "can use CRAM-MD5 using -s" do
|
330
|
-
capture(:stdout){ Runner.start(@args + ['-s', 'CRAM-MD5']) }.should =~ EX_REGISTERED
|
331
|
-
Mailbox.find('user2@example.com').password.should == CRAM_MD5_PASS
|
332
|
-
end
|
333
|
-
|
334
|
-
it "can use MD5-CRYPT using -s" do
|
335
|
-
result = capture(:stdout){ Runner.start(@args + ['-s', 'MD5-CRYPT']) }
|
336
|
-
result.should =~ EX_REGISTERED
|
337
|
-
result.should =~ /scheme: MD5-CRYPT/
|
338
|
-
Mailbox.find('user2@example.com').password.should =~ EX_MD5_CRYPT
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
it "add and delete methods" do
|
344
|
-
lambda { Runner.start(['add_domain', 'example.net']) }.should_not raise_error
|
345
|
-
Runner.start(['add_admin', 'admin@example.net', 'password'])
|
346
|
-
Runner.start(['add_admin_domain', 'admin@example.net', 'example.net'])
|
347
|
-
|
348
|
-
lambda { Runner.start(['add_account', 'user1@example.net', 'password']) }.should_not raise_error
|
349
|
-
lambda { Runner.start(['add_account', 'user2@example.net', 'password']) }.should_not raise_error
|
350
|
-
lambda { Runner.start(['delete_domain', 'example.net']) }.should_not raise_error
|
351
|
-
end
|
352
|
-
|
353
|
-
describe "log" do
|
354
|
-
it "does not raise error" do
|
355
|
-
exit_capture{ Runner.start(['log']) }.should == ""
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
describe "dump" do
|
360
|
-
it "does not raise error" do
|
361
|
-
exit_capture{ Runner.start(['dump']) }.should == ""
|
362
|
-
end
|
363
|
-
|
364
|
-
it "all data" do
|
365
|
-
result = capture(:stdout){ Runner.start(['dump']) }
|
366
|
-
result.should =~ /Domains/
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
|
-
end
|