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.
@@ -1,3 +1,3 @@
1
1
  module PostfixAdmin
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,24 +1,31 @@
1
1
  require File.expand_path('../lib/postfix_admin/version', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.add_dependency 'thor', '~> 0.19.1'
5
- gem.add_dependency 'data_mapper'
6
- gem.add_dependency 'do_mysql', '>= 0.10.17'
7
- gem.add_dependency 'dm-mysql-adapter'
8
- gem.add_development_dependency 'rake', '~> 10.5.0'
9
- gem.add_development_dependency 'rspec', '~> 3.4.0'
10
- gem.add_development_dependency 'dm-sqlite-adapter'
11
-
4
+ gem.name = "postfix_admin"
5
+ gem.version = PostfixAdmin::VERSION
12
6
  gem.authors = ["Hitoshi Kurokawa"]
13
7
  gem.email = ["hitoshi@nextseed.jp"]
14
- gem.description = %q{Command Line Tools of PostfixAdmin}
8
+
15
9
  gem.summary = gem.description
10
+ gem.description = %q{Command Line Tools for Postfix Admin}
16
11
  gem.homepage = "https://github.com/krhitoshi/postfix_admin"
17
12
 
18
- gem.files = `git ls-files`.split($\)
19
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.add_dependency 'thor', '~> 1.0.1'
14
+ gem.add_dependency 'activerecord', '~> 6.0.3'
15
+ gem.add_dependency 'mysql2', '>= 0.5.3'
16
+ gem.add_development_dependency 'pry'
17
+ gem.add_development_dependency 'rake', '~> 13.0.1'
18
+ gem.add_development_dependency 'rubocop'
19
+ gem.add_development_dependency 'rspec', '~> 3.9.0'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ gem.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ gem.bindir = "exe"
27
+ gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
28
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
- gem.name = "postfix_admin"
29
+
22
30
  gem.require_paths = ["lib"]
23
- gem.version = PostfixAdmin::VERSION
24
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postfix_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hitoshi Kurokawa
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-03 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,50 +16,50 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.19.1
19
+ version: 1.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.19.1
26
+ version: 1.0.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: data_mapper
28
+ name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 6.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 6.0.3
41
41
  - !ruby/object:Gem::Dependency
42
- name: do_mysql
42
+ name: mysql2
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.10.17
47
+ version: 0.5.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.10.17
54
+ version: 0.5.3
55
55
  - !ruby/object:Gem::Dependency
56
- name: dm-mysql-adapter
56
+ name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- type: :runtime
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -72,43 +72,43 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 10.5.0
75
+ version: 13.0.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 10.5.0
82
+ version: 13.0.1
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec
84
+ name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 3.4.0
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 3.4.0
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: dm-sqlite-adapter
98
+ name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 3.9.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
111
- description: Command Line Tools of PostfixAdmin
110
+ version: 3.9.0
111
+ description: Command Line Tools for Postfix Admin
112
112
  email:
113
113
  - hitoshi@nextseed.jp
114
114
  executables:
@@ -117,31 +117,39 @@ extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - ".gitignore"
120
+ - ".rubocop.yml"
120
121
  - CHANGELOG.md
122
+ - Dockerfile
121
123
  - Gemfile
122
124
  - LICENSE
123
125
  - README.md
124
126
  - Rakefile
125
127
  - Thorfile
126
- - bin/postfix_admin
128
+ - bin/console
129
+ - docker-compose.yml
130
+ - docker-entrypoint.sh
131
+ - exe/postfix_admin
127
132
  - lib/postfix_admin.rb
133
+ - lib/postfix_admin/admin.rb
134
+ - lib/postfix_admin/alias.rb
135
+ - lib/postfix_admin/application_record.rb
128
136
  - lib/postfix_admin/base.rb
129
137
  - lib/postfix_admin/cli.rb
138
+ - lib/postfix_admin/concerns/.keep
139
+ - lib/postfix_admin/concerns/dovecot_cram_md5_password.rb
140
+ - lib/postfix_admin/concerns/existing_timestamp.rb
141
+ - lib/postfix_admin/domain.rb
142
+ - lib/postfix_admin/domain_admin.rb
130
143
  - lib/postfix_admin/doveadm.rb
131
144
  - lib/postfix_admin/error.rb
145
+ - lib/postfix_admin/log.rb
146
+ - lib/postfix_admin/mail_domain.rb
147
+ - lib/postfix_admin/mailbox.rb
132
148
  - lib/postfix_admin/models.rb
149
+ - lib/postfix_admin/quota.rb
133
150
  - lib/postfix_admin/runner.rb
134
151
  - lib/postfix_admin/version.rb
135
152
  - postfix_admin.gemspec
136
- - spec/base_spec.rb
137
- - spec/cli_spec.rb
138
- - spec/doveadm_spec.rb
139
- - spec/models_spec.rb
140
- - spec/postfix_admin.conf
141
- - spec/postfix_test.sql
142
- - spec/runner_spec.rb
143
- - spec/spec_helper.rb
144
- - spec/tmp/.gitkeep
145
153
  homepage: https://github.com/krhitoshi/postfix_admin
146
154
  licenses: []
147
155
  metadata: {}
@@ -160,17 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
168
  - !ruby/object:Gem::Version
161
169
  version: '0'
162
170
  requirements: []
163
- rubygems_version: 3.0.1
171
+ rubygems_version: 3.0.3
164
172
  signing_key:
165
173
  specification_version: 4
166
- summary: Command Line Tools of PostfixAdmin
167
- test_files:
168
- - spec/base_spec.rb
169
- - spec/cli_spec.rb
170
- - spec/doveadm_spec.rb
171
- - spec/models_spec.rb
172
- - spec/postfix_admin.conf
173
- - spec/postfix_test.sql
174
- - spec/runner_spec.rb
175
- - spec/spec_helper.rb
176
- - spec/tmp/.gitkeep
174
+ summary: ''
175
+ test_files: []
@@ -1,253 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require 'postfix_admin/base'
3
-
4
- describe PostfixAdmin::Base do
5
- before do
6
- db_initialize
7
- @base = PostfixAdmin::Base.new({'database' => 'sqlite::memory:'})
8
- end
9
-
10
- it "DEFAULT_CONFIG" do
11
- PostfixAdmin::Base::DEFAULT_CONFIG.should == {
12
- 'database' => 'mysql://postfix:password@localhost/postfix',
13
- 'aliases' => 30,
14
- 'mailboxes' => 30,
15
- 'maxquota' => 100,
16
- 'scheme' => 'CRAM-MD5',
17
- }
18
- end
19
-
20
- it "#address_split" do
21
- @base.address_split('user@example.com').should == ['user', 'example.com']
22
- end
23
-
24
- it "#new without config" do
25
- lambda { PostfixAdmin::Base.new }.should raise_error(ArgumentError)
26
- end
27
-
28
- it "#new without database config" do
29
- lambda { PostfixAdmin::Base.new({}) }.should raise_error(ArgumentError)
30
- end
31
-
32
- it "Default configuration should be correct" do
33
- @base.config[:aliases].should == 30
34
- @base.config[:mailboxes].should == 30
35
- @base.config[:maxquota].should == 100
36
- @base.config[:mailbox_quota].should == 100 * KB_TO_MB
37
- @base.config[:scheme].should == 'CRAM-MD5'
38
- end
39
-
40
- it "#domain_exist?" do
41
- Domain.exist?('example.com').should be true
42
- end
43
-
44
- it "#alias_exist?" do
45
- Alias.exist?('user@example.com').should be true
46
- Alias.exist?('unknown@example.com').should be false
47
- end
48
-
49
- it "#mailbox_exist?" do
50
- Mailbox.exist?('user@example.com').should be true
51
- Mailbox.exist?('unknown@example.com').should be false
52
- end
53
-
54
- it "#admin_exist?" do
55
- Admin.exist?('admin@example.com').should be true
56
- Admin.exist?('unknown_admin@example.com').should be false
57
- end
58
-
59
- describe "#add_domain" do
60
- it "can add a new domain" do
61
- num_domains = Domain.count
62
- @base.add_domain('example.net')
63
- (Domain.count - num_domains).should be(1)
64
- end
65
-
66
- it "can not add exist domain" do
67
- lambda{ @base.add_domain('example.com') }.should raise_error Error
68
- end
69
-
70
- it "can not add invalid domain" do
71
- lambda{ @base.add_domain('localhost') }.should raise_error Error
72
- end
73
- end
74
-
75
- describe "#add_account" do
76
- it "can add a new account" do
77
- num_mailboxes = Mailbox.count
78
- num_aliases = Alias.count
79
- @base.add_account('new_user@example.com', 'password')
80
- (Mailbox.count - num_mailboxes).should be(1)
81
- (Alias.count - num_aliases).should be(1)
82
- end
83
-
84
- it "refuse empty password" do
85
- lambda{ @base.add_account('new_user@example.com', '') }.should raise_error Error
86
- end
87
-
88
- it "refuse nil password" do
89
- lambda{ @base.add_account('new_user@example.com', nil) }.should raise_error Error
90
- end
91
-
92
- it "can not add account which hsas invalid address" do
93
- lambda{ @base.add_account('invalid.example.com', 'password') }.should raise_error Error
94
- end
95
-
96
- it "can not add account for unknown domain" do
97
- lambda{ @base.add_account('user@unknown.example.com', 'password') }.should raise_error Error
98
- end
99
-
100
- it "can not add account which has same address as exist mailbox" do
101
- lambda{ @base.add_account('user@example.com', 'password') }.should raise_error Error
102
- end
103
-
104
- it "can not add account which has same address as exist alias" do
105
- lambda{ @base.add_account('alias@example.com', 'password') }.should raise_error Error
106
- end
107
- end
108
-
109
- describe "#add_admin" do
110
- it "can add an new admin" do
111
- num_admins = Admin.count
112
- @base.add_admin('admin@example.net', 'password')
113
- Admin.exist?('admin@example.net').should be true
114
- (Admin.count - num_admins).should be(1)
115
- end
116
-
117
- it "refuse empty password" do
118
- lambda{ @base.add_admin('admin@example.net', '') }.should raise_error Error
119
- end
120
-
121
- it "refuse nil password" do
122
- lambda{ @base.add_admin('admin@example.net', nil) }.should raise_error Error
123
- end
124
-
125
- it "can not add exist admin" do
126
- lambda{ @base.add_admin('admin@example.com', 'password') }.should raise_error Error
127
- end
128
- end
129
-
130
- describe "#add_admin_domain" do
131
- it "#add_admin_domain" do
132
- @base.add_admin_domain('admin@example.com', 'example.org')
133
- Admin.find('admin@example.com').has_domain?('example.org').should be true
134
- end
135
-
136
- it "can not add unknown domain for an admin" do
137
- lambda{ @base.add_admin_domain('admin@example.com', 'unknown.example.com') }.should raise_error Error
138
- end
139
-
140
- it "can not add domain for unknown admin" do
141
- lambda{ @base.add_admin_domain('unknown_admin@example.com', 'example.net') }.should raise_error Error
142
- end
143
-
144
- it "can not add a domain which the admin has already privileges for" do
145
- lambda{ @base.add_admin_domain('admin@example.com', 'example.com') }.should raise_error Error
146
- end
147
- end
148
-
149
- describe "#delete_admin_domain" do
150
- it "#delete_admin_domain" do
151
- lambda{ @base.delete_admin_domain('admin@example.com', 'example.com') }.should_not raise_error
152
- Admin.find('admin@example.com').has_domain?('example.com').should be false
153
- end
154
-
155
- it "can not delete not administrated domain" do
156
- lambda{ @base.delete_admin_domain('admin@example.com', 'example.org') }.should raise_error Error
157
- end
158
-
159
- it "raise error when unknown admin" do
160
- lambda{ @base.delete_admin_domain('unknown_admin@example.com', 'example.com') }.should raise_error Error
161
- end
162
-
163
- it "raise error when unknown domain" do
164
- lambda{ @base.delete_admin_domain('admin@example.com', 'unknown.example.com') }.should raise_error Error
165
- end
166
- end
167
-
168
- describe "#add_alias" do
169
- it "can add a new alias" do
170
- num_aliases = Alias.count
171
- lambda { @base.add_alias('new_alias@example.com', 'goto@example.jp') }.should_not raise_error
172
- (Alias.count - num_aliases).should be(1)
173
- Alias.exist?('new_alias@example.com').should be true
174
- end
175
-
176
- it "can not add an alias which has a same name as a mailbox" do
177
- lambda { @base.add_alias('user@example.com', 'goto@example.jp') }.should raise_error Error
178
- end
179
-
180
- it "can not add an alias which has a sama name as other alias" do
181
- @base.add_alias('new_alias@example.com', 'goto@example.jp')
182
- lambda { @base.add_alias('new_alias@example.com', 'goto@example.jp') }.should raise_error Error
183
- end
184
-
185
- it "can not add an alias of unknown domain" do
186
- lambda { @base.add_alias('new_alias@unknown.example.com', 'goto@example.jp') }.should raise_error Error
187
- end
188
- end
189
-
190
- describe "#delete_alias" do
191
- it "can delete an alias" do
192
- lambda{ @base.delete_alias('alias@example.com') }.should_not raise_error
193
- Alias.exist?('alias@example.com').should be false
194
- end
195
-
196
- it "can not delete mailbox" do
197
- lambda{ @base.delete_alias('user@example.com') }.should raise_error Error
198
- end
199
-
200
- it "can not delete unknown alias" do
201
- lambda{ @base.delete_alias('unknown@example.com') }.should raise_error Error
202
- end
203
- end
204
-
205
- describe "#delete_domain" do
206
- before do
207
- @base.add_account('user2@example.com', 'password')
208
- @base.add_account('user3@example.com', 'password')
209
-
210
- @base.add_alias('alias2@example.com', 'goto2@example.jp')
211
- @base.add_alias('alias3@example.com', 'goto3@example.jp')
212
- end
213
-
214
- it "can delete a domain" do
215
- lambda{ @base.delete_domain('example.com') }.should_not raise_error
216
-
217
- Domain.exist?('example.com').should be false
218
- Admin.exist?('admin@example.com').should be false
219
-
220
- Alias.all(:domain_name => 'example.com').count.should be(0)
221
- Mailbox.all(:domain_name => 'example.com').count.should be(0)
222
-
223
- DomainAdmin.all(:username => 'admin@example.com', :domain_name => 'example.com').count.should be(0)
224
- end
225
-
226
- it "can not delete unknown domain" do
227
- lambda{ @base.delete_domain('unknown.example.com') }.should raise_error Error
228
- end
229
- end
230
-
231
- describe "#delete_admin" do
232
- it "can delete an admin" do
233
- lambda{ @base.delete_admin('admin@example.com') }.should_not raise_error
234
- Admin.exist?('admin@example.com').should be false
235
- end
236
-
237
- it "can not delete unknown admin" do
238
- lambda{ @base.delete_admin('unknown_admin@example.com') }.should raise_error Error
239
- end
240
- end
241
-
242
- describe "#delete_account" do
243
- it "can delete an account" do
244
- lambda{ @base.delete_account('user@example.com') }.should_not raise_error
245
- Mailbox.exist?('user@example.com').should be false
246
- Alias.exist?('user@example.com').should be false
247
- end
248
-
249
- it "can not delete unknown account" do
250
- lambda{ @base.delete_account('unknown@example.com') }.should raise_error Error
251
- end
252
- end
253
- end