postfix_admin 0.2.1 → 0.3.1

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +52 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +20 -0
  5. data/CHANGELOG.md +26 -12
  6. data/Gemfile +1 -1
  7. data/LICENSE +1 -1
  8. data/README.md +26 -20
  9. data/Rakefile +48 -1
  10. data/bin/console +6 -2
  11. data/db/reset.rb +7 -0
  12. data/db/seeds.rb +26 -0
  13. data/docker-admin/config.local.php +6 -1
  14. data/docker-app/Dockerfile +2 -6
  15. data/docker-app/my.cnf +2 -2
  16. data/docker-compose.yml +20 -20
  17. data/lib/postfix_admin/base.rb +119 -112
  18. data/lib/postfix_admin/cli.rb +267 -158
  19. data/lib/postfix_admin/doveadm.rb +32 -20
  20. data/lib/postfix_admin/{admin.rb → models/admin.rb} +25 -2
  21. data/lib/postfix_admin/{alias.rb → models/alias.rb} +16 -26
  22. data/lib/postfix_admin/{application_record.rb → models/application_record.rb} +1 -1
  23. data/lib/postfix_admin/{concerns → models/concerns}/existing_timestamp.rb +1 -2
  24. data/lib/postfix_admin/models/concerns/has_password.rb +16 -0
  25. data/lib/postfix_admin/models/domain.rb +112 -0
  26. data/lib/postfix_admin/models/domain_admin.rb +19 -0
  27. data/lib/postfix_admin/models/log.rb +20 -0
  28. data/lib/postfix_admin/models/mailbox.rb +126 -0
  29. data/lib/postfix_admin/models/quota2.rb +18 -0
  30. data/lib/postfix_admin/models.rb +8 -9
  31. data/lib/postfix_admin/runner.rb +91 -28
  32. data/lib/postfix_admin/version.rb +1 -1
  33. data/postfix_admin.gemspec +12 -10
  34. metadata +61 -34
  35. data/.github/workflows/ruby.yml +0 -37
  36. data/docker-app/docker-entrypoint.sh +0 -5
  37. data/docker-app-2.5/Dockerfile +0 -15
  38. data/lib/postfix_admin/concerns/dovecot_cram_md5_password.rb +0 -30
  39. data/lib/postfix_admin/domain.rb +0 -98
  40. data/lib/postfix_admin/domain_admin.rb +0 -8
  41. data/lib/postfix_admin/log.rb +0 -5
  42. data/lib/postfix_admin/mail_domain.rb +0 -9
  43. data/lib/postfix_admin/mailbox.rb +0 -89
  44. data/lib/postfix_admin/quota.rb +0 -6
  45. /data/lib/postfix_admin/{concerns → models/concerns}/.keep +0 -0
@@ -24,36 +24,86 @@ module PostfixAdmin
24
24
  runner { puts PostfixAdmin::Doveadm.schemes.join(' ') }
25
25
  end
26
26
 
27
- desc "show [example.com | admin@example.com | user@example.com]", "Show domains or admins or mailboxes"
27
+ desc "show [example.com | admin@example.com | user@example.com]",
28
+ "Display details about domains, admins, or accounts"
28
29
  def show(name = nil)
29
30
  runner { @cli.show(name) }
30
31
  end
31
32
 
32
- desc "setup example.com password", "Setup a domain"
33
+ desc "admins", "List all admin users"
34
+ def admins
35
+ runner { @cli.show_admins }
36
+ end
37
+
38
+ desc "domains", "List all domains"
39
+ def domains
40
+ runner { @cli.show_domains }
41
+ end
42
+
43
+ desc "accounts", "List all accounts"
44
+ def accounts
45
+ runner { @cli.show_accounts }
46
+ end
47
+
48
+ desc "aliases", "List all aliases"
49
+ def aliases
50
+ runner { @cli.show_aliases }
51
+ end
52
+
53
+ desc "forwards", "List all forwards"
54
+ def forwards
55
+ runner { @cli.show_forwards }
56
+ end
57
+
58
+ desc "setup example.com password", "Set up a domain (add a domain and an admin user for it)"
59
+ method_option :scheme, type: :string, aliases: "-s", desc: "password scheme"
60
+ method_option :rounds, type: :string, aliases: "-r", desc: "encryption rounds for BLF-CRYPT, SHA256-CRYPT and SHA512-CRYPT schemes"
33
61
  def setup(domain_name, password)
34
- runner { @cli.setup_domain(domain_name, password) }
62
+ runner do
63
+ @cli.setup_domain(domain_name, password,
64
+ scheme: options[:scheme], rounds: options[:rounds])
65
+ end
35
66
  end
36
67
 
37
- desc "admin_passwd admin@example.com new_password", "Change password of admin"
68
+ desc "teardown example.com", "Tear down a domain (delete a domain and an admin user for it)"
69
+ def teardown(domain_name)
70
+ runner { @cli.teardown_domain(domain_name) }
71
+ end
72
+
73
+ desc "admin_passwd admin@example.com new_password",
74
+ "Change the password of an admin user"
75
+ method_option :scheme, type: :string, aliases: "-s", desc: "password scheme"
76
+ method_option :rounds, type: :string, aliases: "-r", desc: "encryption rounds for BLF-CRYPT, SHA256-CRYPT and SHA512-CRYPT schemes"
38
77
  def admin_passwd(user_name, password)
39
- runner { @cli.change_admin_password(user_name, password) }
78
+ runner do
79
+ @cli.change_admin_password(user_name, password,
80
+ scheme: options[:scheme], rounds: options[:rounds])
81
+ end
40
82
  end
41
83
 
42
- desc "account_passwd user@example.com new_password", "Change password of account"
84
+ desc "account_passwd user@example.com new_password",
85
+ "Change the password of an account"
86
+ method_option :scheme, type: :string, aliases: "-s", desc: "password scheme"
87
+ method_option :rounds, type: :string, aliases: "-r", desc: "encryption rounds for BLF-CRYPT, SHA256-CRYPT and SHA512-CRYPT schemes"
43
88
  def account_passwd(user_name, password)
44
- runner { @cli.change_account_password(user_name, password) }
89
+ runner do
90
+ @cli.change_account_password(user_name, password,
91
+ scheme: options[:scheme], rounds: options[:rounds])
92
+ end
45
93
  end
46
94
 
47
- desc "add_domain example.com", "Add a domain"
95
+ desc "add_domain example.com", "Add a new domain"
96
+ method_option :description, type: :string, aliases: "-d", desc: "description"
48
97
  def add_domain(domain_name)
49
- runner { @cli.add_domain(domain_name) }
98
+ runner { @cli.add_domain(domain_name, description: options[:description]) }
50
99
  end
51
100
 
52
- desc "edit_domain example.com", "Edit a domain limitation"
101
+ desc "edit_domain example.com", "Edit a domain"
53
102
  method_option :aliases, type: :numeric, aliases: "-a", desc: "Edit aliases limitation"
54
103
  method_option :mailboxes, type: :numeric, aliases: "-m", desc: "Edit mailboxes limitation"
55
104
  method_option :maxquota, type: :numeric, aliases: "-q", desc: "Edit max quota limitation"
56
105
  method_option :active, type: :boolean, desc: "Update active status"
106
+ method_option :description, type: :string, aliases: "-d", desc: "Edit description"
57
107
  def edit_domain(domain_name)
58
108
  runner do
59
109
  if options.size == 0
@@ -70,7 +120,7 @@ module PostfixAdmin
70
120
  runner { @cli.delete_domain(domain_name) }
71
121
  end
72
122
 
73
- desc "delete_admin admin@example.com", "Delete an admin"
123
+ desc "delete_admin admin@example.com", "Delete an admin user"
74
124
  def delete_admin(user_name)
75
125
  runner { @cli.delete_admin(user_name) }
76
126
  end
@@ -80,9 +130,10 @@ module PostfixAdmin
80
130
  runner { @cli.delete_account(address) }
81
131
  end
82
132
 
83
- desc "add_account user@example.com password", "Add an account"
84
- method_option :scheme, type: :string, aliases: "-s", desc: "password scheme"
133
+ desc "add_account user@example.com password", "Add a new account"
85
134
  method_option :name, type: :string, aliases: "-n", desc: "full name"
135
+ method_option :scheme, type: :string, aliases: "-s", desc: "password scheme"
136
+ method_option :rounds, type: :string, aliases: "-r", desc: "encryption rounds for BLF-CRYPT, SHA256-CRYPT and SHA512-CRYPT schemes"
86
137
  def add_account(address, password)
87
138
  runner do
88
139
  if options[:scheme] == 'scheme'
@@ -93,17 +144,22 @@ module PostfixAdmin
93
144
  warn "Specify name"
94
145
  help('add_account')
95
146
  else
96
- @cli.add_account(address, password, options[:scheme], options[:name])
147
+ @cli.add_account(address, password, name: options[:name],
148
+ scheme: options[:scheme], rounds: options[:rounds])
97
149
  end
98
150
  end
99
151
  end
100
152
  end
101
153
 
102
154
  desc "edit_account user@example.com", "Edit an account"
103
- method_option :goto, type: :string, aliases: "-g", desc: "mailboxes, addresses e-mails are delivered to"
104
- method_option :quota, type: :numeric, aliases: "-q", desc: "quota limitation (MB)"
105
- method_option :name, type: :string, aliases: "-n", desc: "full name"
106
- method_option :active, type: :boolean, desc: "Update active status"
155
+ method_option :goto, type: :string, aliases: "-g",
156
+ desc: "mailboxes, addresses e-mails are delivered to"
157
+ method_option :quota, type: :numeric, aliases: "-q",
158
+ desc: "quota limitation (MB)"
159
+ method_option :name, type: :string, aliases: "-n",
160
+ desc: "full name"
161
+ method_option :active, type: :boolean,
162
+ desc: "Update active status"
107
163
  def edit_account(address)
108
164
  runner do
109
165
  if options.size == 0
@@ -134,26 +190,31 @@ module PostfixAdmin
134
190
  end
135
191
  end
136
192
 
137
- desc "add_admin admin@example.com password", "Add an admin user"
193
+ desc "add_admin admin@example.com password", "Add a new admin user"
138
194
  method_option :super, type: :boolean, aliases: "-S", desc: "register as a super admin"
139
195
  method_option :scheme, type: :string, aliases: "-s", desc: "password scheme"
196
+ method_option :rounds, type: :string, aliases: "-r", desc: "encryption rounds for BLF-CRYPT, SHA256-CRYPT and SHA512-CRYPT schemes"
140
197
  def add_admin(user_name, password)
141
198
  runner do
142
199
  if options[:scheme] == 'scheme'
143
200
  warn "Specify password scheme"
144
201
  help('add_admin')
145
202
  else
146
- @cli.add_admin(user_name, password, options[:super], options[:scheme])
203
+ @cli.add_admin(user_name, password,
204
+ super_admin: options[:super], scheme: options[:scheme],
205
+ rounds: options[:rounds])
147
206
  end
148
207
  end
149
208
  end
150
209
 
151
- desc "add_admin_domain admin@example.com example.com", "Add admin_domain"
210
+ desc "add_admin_domain admin@example.com example.com",
211
+ "Grant an admin user access to a specific domain"
152
212
  def add_admin_domain(user_name, domain_name)
153
213
  runner { @cli.add_admin_domain(user_name, domain_name) }
154
214
  end
155
215
 
156
- desc "delete_admin_domain admin@example.com example.com", "Delete admin_domain"
216
+ desc "delete_admin_domain admin@example.com example.com",
217
+ "Revoke an admin user's access to a specific domain"
157
218
  def delete_admin_domain(user_name, domain_name)
158
219
  runner { @cli.delete_admin_domain(user_name, domain_name) }
159
220
  end
@@ -173,7 +234,7 @@ module PostfixAdmin
173
234
  end
174
235
  end
175
236
 
176
- desc "add_alias alias@example.com goto@example.net", "Add an alias"
237
+ desc "add_alias alias@example.com goto@example.net", "Add a new alias"
177
238
  def add_alias(address, goto)
178
239
  runner { @cli.add_alias(address, goto) }
179
240
  end
@@ -183,9 +244,11 @@ module PostfixAdmin
183
244
  runner { @cli.delete_alias(address) }
184
245
  end
185
246
 
186
- desc "log", "Show action logs"
247
+ desc "log", "Display action logs"
248
+ method_option :domain, type: :string, aliases: "-d", desc: "Filter by domain"
249
+ method_option :last, type: :numeric, aliases: "-l", desc: "Display the last N lines"
187
250
  def log
188
- runner { @cli.log }
251
+ runner { @cli.log(domain: options[:domain], last: options[:last]) }
189
252
  end
190
253
 
191
254
  desc "dump", "Dump all data"
@@ -193,7 +256,7 @@ module PostfixAdmin
193
256
  runner { @cli.dump }
194
257
  end
195
258
 
196
- desc "version", "Show postfix_admin version"
259
+ desc "version", "Display the version of postfix_admin"
197
260
  def version
198
261
  require 'postfix_admin/version'
199
262
  runner { say "postfix_admin #{VERSION}" }
@@ -201,9 +264,9 @@ module PostfixAdmin
201
264
 
202
265
  private
203
266
 
204
- def runner
267
+ def runner(&block)
205
268
  @cli.db_setup
206
- yield
269
+ block.call
207
270
  rescue StandardError => e
208
271
  abort "Error: #{e.message}"
209
272
  end
@@ -1,3 +1,3 @@
1
1
  module PostfixAdmin
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../lib/postfix_admin/version', __FILE__)
1
+ require File.expand_path("../lib/postfix_admin/version", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "postfix_admin"
@@ -10,19 +10,21 @@ Gem::Specification.new do |gem|
10
10
  gem.description = %q{Command Line Tools for Postfix Admin}
11
11
  gem.homepage = "https://github.com/krhitoshi/postfix_admin"
12
12
 
13
- gem.required_ruby_version = ">= 2.5.0"
13
+ gem.required_ruby_version = ">= 2.6.0"
14
14
 
15
- gem.add_dependency 'thor', '~> 1.0.1'
16
- gem.add_dependency 'activerecord', '~> 6.0.3'
17
- gem.add_dependency 'mysql2', '>= 0.5.3'
18
- gem.add_development_dependency 'pry'
19
- gem.add_development_dependency 'rake', '~> 13.0.1'
20
- gem.add_development_dependency 'rubocop'
21
- gem.add_development_dependency 'rspec', '~> 3.9.0'
15
+ gem.add_dependency "thor", "~> 1.3.1"
16
+ gem.add_dependency "activerecord", "~> 6.1.7"
17
+ gem.add_dependency "mysql2", "~> 0.5"
18
+ gem.add_dependency "terminal-table", "~> 3.0.2"
19
+ gem.add_development_dependency "pry"
20
+ gem.add_development_dependency "factory_bot", "~> 6.3.0"
21
+ gem.add_development_dependency "rake", "~> 13.2.1"
22
+ gem.add_development_dependency "rubocop"
23
+ gem.add_development_dependency "rspec", "~> 3.13.0"
22
24
 
23
25
  # Specify which files should be added to the gem when it is released.
24
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- gem.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
+ gem.files = Dir.chdir(File.expand_path("..", __FILE__)) do
26
28
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
29
  end
28
30
  gem.bindir = "exe"
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.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hitoshi Kurokawa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-18 00:00:00.000000000 Z
11
+ date: 2024-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,42 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.1
19
+ version: 1.3.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: 1.0.1
26
+ version: 1.3.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 6.0.3
33
+ version: 6.1.7
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: 6.0.3
40
+ version: 6.1.7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mysql2
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.3
47
+ version: '0.5'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: terminal-table
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 0.5.3
68
+ version: 3.0.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: pry
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +80,34 @@ dependencies:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: factory_bot
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 6.3.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 6.3.0
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rake
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: 13.0.1
103
+ version: 13.2.1
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: 13.0.1
110
+ version: 13.2.1
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: rubocop
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +128,14 @@ dependencies:
100
128
  requirements:
101
129
  - - "~>"
102
130
  - !ruby/object:Gem::Version
103
- version: 3.9.0
131
+ version: 3.13.0
104
132
  type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
136
  - - "~>"
109
137
  - !ruby/object:Gem::Version
110
- version: 3.9.0
138
+ version: 3.13.0
111
139
  description: Command Line Tools for Postfix Admin
112
140
  email:
113
141
  - hitoshi@nextseed.jp
@@ -116,7 +144,7 @@ executables:
116
144
  extensions: []
117
145
  extra_rdoc_files: []
118
146
  files:
119
- - ".github/workflows/ruby.yml"
147
+ - ".github/workflows/ci.yml"
120
148
  - ".gitignore"
121
149
  - ".rubocop.yml"
122
150
  - CHANGELOG.md
@@ -126,11 +154,11 @@ files:
126
154
  - Rakefile
127
155
  - Thorfile
128
156
  - bin/console
157
+ - db/reset.rb
158
+ - db/seeds.rb
129
159
  - docker-admin/Dockerfile
130
160
  - docker-admin/config.local.php
131
- - docker-app-2.5/Dockerfile
132
161
  - docker-app/Dockerfile
133
- - docker-app/docker-entrypoint.sh
134
162
  - docker-app/my.cnf
135
163
  - docker-compose.yml
136
164
  - docker-db/postfix.v1841.sql
@@ -138,30 +166,29 @@ files:
138
166
  - docker-db/postfix.v740.sql
139
167
  - exe/postfix_admin
140
168
  - lib/postfix_admin.rb
141
- - lib/postfix_admin/admin.rb
142
- - lib/postfix_admin/alias.rb
143
- - lib/postfix_admin/application_record.rb
144
169
  - lib/postfix_admin/base.rb
145
170
  - lib/postfix_admin/cli.rb
146
- - lib/postfix_admin/concerns/.keep
147
- - lib/postfix_admin/concerns/dovecot_cram_md5_password.rb
148
- - lib/postfix_admin/concerns/existing_timestamp.rb
149
- - lib/postfix_admin/domain.rb
150
- - lib/postfix_admin/domain_admin.rb
151
171
  - lib/postfix_admin/doveadm.rb
152
172
  - lib/postfix_admin/error.rb
153
- - lib/postfix_admin/log.rb
154
- - lib/postfix_admin/mail_domain.rb
155
- - lib/postfix_admin/mailbox.rb
156
173
  - lib/postfix_admin/models.rb
157
- - lib/postfix_admin/quota.rb
174
+ - lib/postfix_admin/models/admin.rb
175
+ - lib/postfix_admin/models/alias.rb
176
+ - lib/postfix_admin/models/application_record.rb
177
+ - lib/postfix_admin/models/concerns/.keep
178
+ - lib/postfix_admin/models/concerns/existing_timestamp.rb
179
+ - lib/postfix_admin/models/concerns/has_password.rb
180
+ - lib/postfix_admin/models/domain.rb
181
+ - lib/postfix_admin/models/domain_admin.rb
182
+ - lib/postfix_admin/models/log.rb
183
+ - lib/postfix_admin/models/mailbox.rb
184
+ - lib/postfix_admin/models/quota2.rb
158
185
  - lib/postfix_admin/runner.rb
159
186
  - lib/postfix_admin/version.rb
160
187
  - postfix_admin.gemspec
161
188
  homepage: https://github.com/krhitoshi/postfix_admin
162
189
  licenses: []
163
190
  metadata: {}
164
- post_install_message:
191
+ post_install_message:
165
192
  rdoc_options: []
166
193
  require_paths:
167
194
  - lib
@@ -169,15 +196,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
196
  requirements:
170
197
  - - ">="
171
198
  - !ruby/object:Gem::Version
172
- version: 2.5.0
199
+ version: 2.6.0
173
200
  required_rubygems_version: !ruby/object:Gem::Requirement
174
201
  requirements:
175
202
  - - ">="
176
203
  - !ruby/object:Gem::Version
177
204
  version: '0'
178
205
  requirements: []
179
- rubygems_version: 3.0.3
180
- signing_key:
206
+ rubygems_version: 3.5.3
207
+ signing_key:
181
208
  specification_version: 4
182
209
  summary: ''
183
210
  test_files: []
@@ -1,37 +0,0 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
- name: Ruby
9
-
10
- on:
11
- push:
12
- branches: [ master ]
13
- pull_request:
14
- branches: [ master ]
15
-
16
- jobs:
17
- test:
18
-
19
- runs-on: ubuntu-latest
20
-
21
- steps:
22
- - uses: actions/checkout@v2
23
- - name: Set up Ruby
24
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
- # uses: ruby/setup-ruby@v1
27
- uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
- with:
29
- ruby-version: 2.6
30
- - name: docker-compose up
31
- run: docker-compose up -d
32
- - name: Run tests for Ruby 2.6
33
- run: docker-compose exec -T app /wait-for-it.sh db:3306 -- rake
34
- - name: Remove Gemfile.lock
35
- run: rm -f Gemfile.lock
36
- - name: Run tests for Ruby 2.5.0
37
- run: docker-compose exec -T app2.5 rake
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -eu
4
-
5
- exec "$@"
@@ -1,15 +0,0 @@
1
- FROM ruby:2.5.0
2
-
3
- RUN apt-get update && \
4
- apt-get install -y dovecot-core iproute2 mariadb-client && \
5
- rm -rf /var/lib/apt/lists/*
6
-
7
- WORKDIR /app
8
-
9
- COPY Gemfile postfix_admin.gemspec ./
10
- COPY ./lib/postfix_admin/version.rb ./lib/postfix_admin/version.rb
11
-
12
- RUN gem install bundler && bundle install
13
-
14
- COPY spec/postfix_admin.conf /root/.postfix_admin.conf
15
- COPY docker-app/my.cnf /root/.my.cnf
@@ -1,30 +0,0 @@
1
- require 'active_support/concern'
2
-
3
- module DovecotCramMD5Password
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- validates :password_unencrypted, length: { minimum: 5 }, allow_blank: true
8
- validates_confirmation_of :password_unencrypted, allow_blank: true
9
-
10
- validate do |record|
11
- record.errors.add(:password_unencrypted, :blank) unless record.password.present?
12
- end
13
-
14
- attr_reader :password_unencrypted
15
- attr_accessor :password_unencrypted_confirmation
16
- end
17
-
18
- def password_unencrypted=(unencrypted_password)
19
- if unencrypted_password.nil?
20
- self.password = nil
21
- elsif !unencrypted_password.empty?
22
- @password_unencrypted = unencrypted_password
23
- self.password = DovecotCrammd5.calc(unencrypted_password)
24
- end
25
- end
26
-
27
- def authenticate(unencrypted_password)
28
- password == DovecotCrammd5.calc(unencrypted_password) && self
29
- end
30
- end
@@ -1,98 +0,0 @@
1
- module PostfixAdmin
2
- class Domain < ApplicationRecord
3
- self.table_name = :domain
4
- self.primary_key = :domain
5
-
6
- validates :domain, presence: true, uniqueness: { case_sensitive: false },
7
- format: { with: RE_DOMAIN_NAME_LIKE_WITH_ANCHORS,
8
- message: "must be a valid domain name" }
9
- validates :transport, presence: true
10
-
11
- validates :aliases, presence: true,
12
- numericality: { only_integer: true,
13
- greater_than_or_equal_to: 0 }
14
- validates :mailboxes, presence: true,
15
- numericality: { only_integer: true,
16
- greater_than_or_equal_to: 0 }
17
- validates :maxquota, presence: true,
18
- numericality: { only_integer: true,
19
- greater_than_or_equal_to: 0 }
20
-
21
- has_many :rel_mailboxes, class_name: "Mailbox", foreign_key: :domain,
22
- dependent: :destroy
23
- has_many :rel_aliases, class_name: "Alias", foreign_key: :domain,
24
- dependent: :destroy
25
-
26
- has_many :domain_admins, foreign_key: :domain, dependent: :delete_all
27
- has_many :admins, through: :domain_admins
28
-
29
- before_validation do |domain|
30
- domain.domain = domain.domain.downcase unless domain.domain.empty?
31
- domain.transport = "virtual"
32
- end
33
-
34
- scope :without_all, -> { where.not(domain: "ALL") }
35
-
36
- def pure_aliases
37
- rel_aliases.pure
38
- end
39
-
40
- def aliases_unlimited?
41
- aliases.zero?
42
- end
43
-
44
- def mailboxes_unlimited?
45
- mailboxes.zero?
46
- end
47
-
48
- def aliases_str
49
- num_str(aliases)
50
- end
51
-
52
- def mailboxes_str
53
- num_str(mailboxes)
54
- end
55
-
56
- def aliases_short_str
57
- num_short_str(aliases)
58
- end
59
-
60
- def mailboxes_short_str
61
- num_short_str(mailboxes)
62
- end
63
-
64
- def maxquota_str
65
- if maxquota.zero?
66
- "Unlimited"
67
- else
68
- "#{maxquota} MB"
69
- end
70
- end
71
-
72
- def maxquota_short_str
73
- if maxquota.zero?
74
- "--"
75
- else
76
- "#{maxquota} MB"
77
- end
78
- end
79
-
80
- private
81
-
82
- def num_str(num)
83
- if num.zero?
84
- "Unlimited"
85
- else
86
- num.to_s
87
- end
88
- end
89
-
90
- def num_short_str(num)
91
- if num.zero?
92
- "--"
93
- else
94
- num.to_s
95
- end
96
- end
97
- end
98
- end