postfix_admin 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 59fef8b37f476a21d64574f49a2175c75ea36e36
4
- data.tar.gz: 402c21e2842ad6eab990ecfed2bd6ea98c3b4c4a
2
+ SHA256:
3
+ metadata.gz: 69e3627f6b08953a75386f7c16256f03c2aacc2801c611c297f4a8e8b7249cb5
4
+ data.tar.gz: 982ceb31f432be52fa7a4960810fac0d84dddc6f7138d02be69d2a8fb7aeda26
5
5
  SHA512:
6
- metadata.gz: 3e2312e795f876059fe65f7907bc19a2d45c9619e713756a19a3a363cd827bc26c4d31f9207b0c66d8965e70686d718d34ae4a75f4f9bac2297c4ef0aeaa00f8
7
- data.tar.gz: eee17cbc79654a56a6fefd9eea01daf7340a62108c60c2b11000527ed6b704608f5546e3bc1ecd53527e3823f095b13fa9b20e182253ae703b65ef83030ff4d1
6
+ metadata.gz: 878ee894a9cb4b209361167e310569163c2eb6737ebf6a119a039b7ee55518439fe79ed5ed500b48b423c299acc852e6f7ed8d9d6077978fa0a46bacb7090195
7
+ data.tar.gz: 8abda8f37ac2d31bc38e1ace3ac225c2ee17813e80e7e8be60a3b4abb9539257ae959ea8ab6f3d1cdd4c72cedd2100d9e5f769c92e07ceaa69910de868c6d282
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .idea
19
+ .vagrant
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.1.4
2
+ * Add "log" command
3
+
4
+ ## 0.1.3
5
+ * Support for activation and deactivation of domain, admin and account
6
+ * Add "edit_admin" command
7
+
1
8
  ## 0.1.2
2
9
  * Support password hash by doveadm (external command)
3
10
  * Show active status
data/README.md CHANGED
@@ -43,13 +43,13 @@ Commands:
43
43
  postfix_admin delete_domain example.com # Delete a domain
44
44
  postfix_admin dump # Dump all data
45
45
  postfix_admin edit_account user@example.com # Edit an account
46
+ postfix_admin edit_admin admin@example.com # Edit an admin user
46
47
  postfix_admin edit_domain example.com # Edit a domain limitation
47
48
  postfix_admin help [COMMAND] # Describe available commands or one specific command
48
49
  postfix_admin schemes # List all supported password schemes
49
50
  postfix_admin setup example.com password # Setup a domain
50
51
  postfix_admin show [example.com | admin@example.com | user@example.com] # Show domains or admins or mailboxes
51
52
  postfix_admin summary [example.com] # Summarize the usage of PostfixAdmin
52
- postfix_admin super_admin admin@example.com # Enable super admin flag of an admin
53
53
  postfix_admin version # Show postfix_admin version
54
54
  ```
55
55
 
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -283,10 +283,27 @@ module PostfixAdmin
283
283
  mailbox.active = options[:active] unless options[:active].nil?
284
284
  mailbox.save or raise "Could not save Mailbox"
285
285
 
286
+ if options[:goto]
287
+ mail_alias = Alias.find(address)
288
+ mail_alias.goto = options[:goto]
289
+ mail_alias.save or raise "Could not save Alias"
290
+ end
291
+
286
292
  puts "Successfully updated #{address}"
287
293
  show_account_details(address)
288
294
  end
289
295
 
296
+ def edit_alias(address, options)
297
+ alias_check(address)
298
+ mail_alias = Alias.find(address)
299
+ mail_alias.goto = options[:goto] if options[:goto]
300
+ mail_alias.active = options[:active] unless options[:active].nil?
301
+ mail_alias.save or raise "Could not save Alias"
302
+
303
+ puts "Successfully updated #{address}"
304
+ show_alias_details(address)
305
+ end
306
+
290
307
  def delete_alias(address)
291
308
  @base.delete_alias(address)
292
309
  puts_deleted(address)
@@ -302,6 +319,13 @@ module PostfixAdmin
302
319
  puts_deleted(address)
303
320
  end
304
321
 
322
+ def log
323
+ Log.all.each do |l|
324
+ time = l.timestamp.strftime("%Y-%m-%d %X %Z")
325
+ puts "#{time} #{l.username} #{l.domain_name} #{l.action} #{l.data}"
326
+ end
327
+ end
328
+
305
329
  def dump
306
330
  puts "Admins"
307
331
  puts "User Name,Password,Super Admin,Active"
@@ -197,4 +197,17 @@ module PostfixAdmin
197
197
  Mailbox.exist?(address)
198
198
  end
199
199
  end
200
+
201
+ class Log
202
+ include ::DataMapper::Resource
203
+ property :timestamp, DateTime, key: true, default: DateTime.now
204
+ property :username, String, length: 0..255
205
+ property :domain_name, String, field: 'domain', length: 0..255
206
+ property :action, String, length: 0..255
207
+ property :data, Text
208
+
209
+ belongs_to :domain, :model => 'Domain', :child_key => :domain_name
210
+
211
+ storage_names[:default] = 'log'
212
+ end
200
213
  end
@@ -96,7 +96,8 @@ module PostfixAdmin
96
96
  end
97
97
 
98
98
  desc "edit_account user@example.com", "Edit an account"
99
- method_option :quota, :type => :numeric, :aliases => "-q", :desc => "quota limitation"
99
+ method_option :goto, :type => :string, :aliases => "-g", :desc => "mailboxes, addresses e-mails are delivered to"
100
+ method_option :quota, :type => :numeric, :aliases => "-q", :desc => "quota limitation (MB)"
100
101
  method_option :name, :type => :string, :aliases => "-n", :desc => "full name"
101
102
  method_option :active, type: :boolean, desc: "Update active status"
102
103
  def edit_account(address)
@@ -153,6 +154,20 @@ module PostfixAdmin
153
154
  runner{ @cli.delete_admin_domain(user_name, domain_name) }
154
155
  end
155
156
 
157
+ desc "edit_alias alias@example.com", "Edit an alias"
158
+ method_option :goto, :type => :string, :aliases => "-g",
159
+ :desc => "mailboxes, addresses e-mails are delivered to"
160
+ method_option :active, type: :boolean, desc: "Update active status"
161
+ def edit_alias(address)
162
+ runner do
163
+ if options.size == 0
164
+ warn "Use one or more options."
165
+ help('edit_alias')
166
+ else
167
+ @cli.edit_alias(address, options)
168
+ end
169
+ end
170
+ end
156
171
 
157
172
  desc "add_alias alias@example.com goto@example.net", "Add an alias"
158
173
  def add_alias(address, goto)
@@ -164,6 +179,11 @@ module PostfixAdmin
164
179
  runner{ @cli.delete_alias(address) }
165
180
  end
166
181
 
182
+ desc "log", "Show action logs"
183
+ def log
184
+ runner{ @cli.log }
185
+ end
186
+
167
187
  desc "dump", "Dump all data"
168
188
  def dump
169
189
  runner{ @cli.dump }
@@ -1,3 +1,3 @@
1
1
  module PostfixAdmin
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/spec/runner_spec.rb CHANGED
@@ -110,6 +110,20 @@ describe PostfixAdmin::Runner do
110
110
  end
111
111
  end
112
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
+
113
127
  describe "add_admin" do
114
128
  before do
115
129
  @args = ['add_admin', 'admin@example.jp', 'password']
@@ -238,6 +252,11 @@ describe PostfixAdmin::Runner do
238
252
  it "-n option require an argument" do
239
253
  exit_capture{ Runner.start(@args + ['-n'])}.should_not == ""
240
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
241
260
  end
242
261
 
243
262
  it "add_admin_domain" do
@@ -331,6 +350,12 @@ describe PostfixAdmin::Runner do
331
350
  lambda { Runner.start(['delete_domain', 'example.net']) }.should_not raise_error
332
351
  end
333
352
 
353
+ describe "log" do
354
+ it "does not raise error" do
355
+ exit_capture{ Runner.start(['log']) }.should == ""
356
+ end
357
+ end
358
+
334
359
  describe "dump" do
335
360
  it "does not raise error" do
336
361
  exit_capture{ Runner.start(['dump']) }.should == ""
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hitoshi Kurokawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-27 00:00:00.000000000 Z
11
+ date: 2019-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -121,6 +121,7 @@ files:
121
121
  - Gemfile
122
122
  - LICENSE
123
123
  - README.md
124
+ - Rakefile
124
125
  - Thorfile
125
126
  - bin/postfix_admin
126
127
  - lib/postfix_admin.rb
@@ -159,8 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
160
  - !ruby/object:Gem::Version
160
161
  version: '0'
161
162
  requirements: []
162
- rubyforge_project:
163
- rubygems_version: 2.5.1
163
+ rubygems_version: 3.0.1
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Command Line Tools of PostfixAdmin
@@ -174,4 +174,3 @@ test_files:
174
174
  - spec/runner_spec.rb
175
175
  - spec/spec_helper.rb
176
176
  - spec/tmp/.gitkeep
177
- has_rdoc: