postfix_admin 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/spec/models_spec.rb CHANGED
@@ -133,4 +133,14 @@ describe PostfixAdmin::Alias do
133
133
  Alias.exist?('unknown@unknown.example.com').should === false
134
134
  end
135
135
  end
136
+
137
+ describe ".mailbox?" do
138
+ it "when there is same address in maiboxes returns true" do
139
+ Alias.find('user@example.com').mailbox?.should === true
140
+ end
141
+
142
+ it "when there is no same address in maiboxes returns false" do
143
+ Alias.find('alias@example.com').mailbox?.should === false
144
+ end
145
+ end
136
146
  end
data/spec/runner_spec.rb CHANGED
@@ -25,7 +25,7 @@ describe PostfixAdmin::Runner do
25
25
  end
26
26
 
27
27
  it "show the detail of example.com" do
28
- capture(:stdout){ Runner.start(["show", "example.com"]) }.should =~ /user@example.com\s+100.0\s+password/
28
+ capture(:stdout){ Runner.start(["show", "example.com"]) }.should =~ /user@example.com\s+100\s+password/
29
29
  end
30
30
 
31
31
  it "when no admins, no aliases and no addresses" do
@@ -36,6 +36,10 @@ describe PostfixAdmin::Runner do
36
36
  out.should =~ /No aliases/
37
37
  end
38
38
 
39
+ it "shows information of an account" do
40
+ capture(:stdout){ Runner.start(["show", "user@example.com"]) }.should =~ /user@example.com/
41
+ end
42
+
39
43
  it "when no domains" do
40
44
  capture(:stdout){ Runner.start(['delete_domain', 'example.com']) }.should =~ EX_DELETED
41
45
  capture(:stdout){ Runner.start(['delete_domain', 'example.org']) }.should =~ EX_DELETED
@@ -110,6 +114,10 @@ describe PostfixAdmin::Runner do
110
114
  capture(:stdout){ Runner.start(['add_admin', 'admin@example.jp', 'password']) }.should =~ EX_REGISTERED
111
115
  end
112
116
 
117
+ it "can use long password" do
118
+ capture(:stdout){ Runner.start(['add_admin', 'admin@example.jp', '9c5e77f2da26fc03e9fa9e13ccd77aeb50c85539a4d90b70812715aea9ebda1d']) }.should =~ EX_REGISTERED
119
+ end
120
+
113
121
  it "--super option" do
114
122
  capture(:stdout){ Runner.start(['add_admin', 'admin@example.jp', 'password', '--super']) }.should =~ /registered as a super admin/
115
123
  end
@@ -119,10 +127,48 @@ describe PostfixAdmin::Runner do
119
127
  end
120
128
  end
121
129
 
130
+ describe "edit_domain" do
131
+ it "when no options, shows usage" do
132
+ capture(:stderr){ Runner.start(['edit_domain', 'example.com']) }.should =~ /Use one or more options/
133
+ end
134
+
135
+ it "can edit limitations of domain" do
136
+ capture(:stdout){ Runner.start(['edit_domain', 'example.com', '--aliases', '40', '--mailboxes', '40', '--maxquota', '400']) }.should =~ /Successfully updated/
137
+ end
138
+
139
+ it "aliases options -a, -m, -q" do
140
+ capture(:stdout){ Runner.start(['edit_domain', 'example.com', '-a', '40', '-m', '40', '-m', '400']) }.should =~ /Successfully updated/
141
+ end
142
+
143
+ it "can not use unknown domain" do
144
+ capture(:stderr){ Runner.start(['edit_domain', 'unknown.example.com', '--aliases', '40', '--mailboxes', '40', '--maxquota', '400'])}.should =~ /Could not find/
145
+ end
146
+ end
147
+
148
+ describe "edit_account" do
149
+ it "when no options, shows usage" do
150
+ capture(:stderr){ Runner.start(['edit_account', 'user@example.com']) }.should =~ /Use one or more options/
151
+ end
152
+
153
+ it "can edit quota limitation" do
154
+ output = capture(:stdout){ Runner.start(['edit_account', 'user@example.com', '--quota', '50'])}
155
+ output.should =~ /Successfully updated/
156
+ output.should =~ /Quota/
157
+ end
158
+
159
+ it "can use alias -q option" do
160
+ capture(:stdout){ Runner.start(['edit_account', 'user@example.com', '-q', '50'])}.should =~ /Successfully updated/
161
+ end
162
+ end
163
+
122
164
  it "add_admin_domain" do
123
165
  capture(:stdout){ Runner.start(['add_admin_domain', 'admin@example.com', 'example.org']) }.should =~ EX_REGISTERED
124
166
  end
125
167
 
168
+ it "delete_admin_domain" do
169
+ capture(:stdout){ Runner.start(['delete_admin_domain', 'admin@example.com', 'example.com']) }.should =~ EX_DELETED
170
+ end
171
+
126
172
  it "delete_admin" do
127
173
  capture(:stdout){ Runner.start(['delete_admin', 'admin@example.com']) }.should =~ EX_DELETED
128
174
  end
@@ -132,6 +178,10 @@ describe PostfixAdmin::Runner do
132
178
  capture(:stdout){ Runner.start(['delete_account', 'user2@example.com']) }.should =~ EX_DELETED
133
179
  end
134
180
 
181
+ it "add_account can use long passwrod" do
182
+ capture(:stdout){ Runner.start(['add_account', 'user2@example.com', '9c5e77f2da26fc03e9fa9e13ccd77aeb50c85539a4d90b70812715aea9ebda1d']) }.should =~ EX_REGISTERED
183
+ end
184
+
135
185
  it "add and delete methods" do
136
186
  lambda { Runner.start(['add_domain', 'example.net']) }.should_not raise_error
137
187
  Runner.start(['add_admin', 'admin@example.net', 'password'])
data/spec/spec_helper.rb CHANGED
@@ -2,14 +2,8 @@
2
2
  $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
3
 
4
4
  require 'postfix_admin'
5
+ require 'postfix_admin/cli'
5
6
 
6
- module PostfixAdmin
7
- class CLI
8
- def config_file
9
- File.join(File.dirname(__FILE__) , 'postfix_admin.conf')
10
- end
11
- end
12
- end
13
7
 
14
8
  include PostfixAdmin
15
9
 
@@ -27,7 +21,11 @@ include PostfixAdmin
27
21
  # user@example.com
28
22
  #
29
23
  # Alias:
30
- # alias@example.com
24
+ # alias@example.com -> goto@example.jp
25
+
26
+ def config_initialize
27
+ CLI.config_file = File.join(File.dirname(__FILE__) , 'postfix_admin.conf')
28
+ end
31
29
 
32
30
  def db_clear
33
31
  DomainAdmin.all.destroy
@@ -90,7 +88,7 @@ def db_initialize
90
88
  forward = Alias.new
91
89
  forward.attributes = {
92
90
  :address => 'alias@example.com',
93
- :goto => 'example.jp',
91
+ :goto => 'goto@example.jp',
94
92
  }
95
93
  domain.aliases << forward
96
94
 
@@ -103,7 +101,7 @@ def db_initialize
103
101
  :password => 'password',
104
102
  :name => '',
105
103
  :maildir => path,
106
- :quota => 100 * 1024 * 1000,
104
+ :quota => 100 * KB_TO_MB,
107
105
  # :local_part => user,
108
106
  }
109
107
  domain.mailboxes << mailbox
@@ -114,6 +112,7 @@ DataMapper.setup(:default, 'sqlite::memory:')
114
112
  DataMapper.finalize
115
113
  DataMapper.auto_migrate!
116
114
  db_initialize
115
+ config_initialize
117
116
 
118
117
  module PostfixAdmin
119
118
  class Base
data/spec/tmp/.gitkeep ADDED
File without changes
metadata CHANGED
@@ -1,78 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postfix_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Hitoshi Kurokawa
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-07 00:00:00.000000000 Z
11
+ date: 2013-05-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: data_mapper
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: do_mysql
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.10.9
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.10.9
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: dm-mysql-adapter
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ! '>='
59
+ - - '>='
52
60
  - !ruby/object:Gem::Version
53
61
  version: '0'
54
62
  type: :runtime
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - '>='
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 2.11.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 2.11.0
62
83
  - !ruby/object:Gem::Dependency
63
84
  name: dm-sqlite-adapter
64
85
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
86
  requirements:
67
- - - ! '>='
87
+ - - '>='
68
88
  - !ruby/object:Gem::Version
69
89
  version: '0'
70
90
  type: :development
71
91
  prerelease: false
72
92
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
93
  requirements:
75
- - - ! '>='
94
+ - - '>='
76
95
  - !ruby/object:Gem::Version
77
96
  version: '0'
78
97
  description: Command Line Tools of PostfixAdmin
@@ -104,29 +123,29 @@ files:
104
123
  - spec/postfix_test.sql
105
124
  - spec/runner_spec.rb
106
125
  - spec/spec_helper.rb
126
+ - spec/tmp/.gitkeep
107
127
  homepage: https://github.com/krhitoshi/postfix_admin
108
128
  licenses: []
129
+ metadata: {}
109
130
  post_install_message:
110
131
  rdoc_options: []
111
132
  require_paths:
112
133
  - lib
113
134
  required_ruby_version: !ruby/object:Gem::Requirement
114
- none: false
115
135
  requirements:
116
- - - ! '>='
136
+ - - '>='
117
137
  - !ruby/object:Gem::Version
118
138
  version: '0'
119
139
  required_rubygems_version: !ruby/object:Gem::Requirement
120
- none: false
121
140
  requirements:
122
- - - ! '>='
141
+ - - '>='
123
142
  - !ruby/object:Gem::Version
124
143
  version: '0'
125
144
  requirements: []
126
145
  rubyforge_project:
127
- rubygems_version: 1.8.24
146
+ rubygems_version: 2.0.0
128
147
  signing_key:
129
- specification_version: 3
148
+ specification_version: 4
130
149
  summary: Command Line Tools of PostfixAdmin
131
150
  test_files:
132
151
  - spec/base_spec.rb
@@ -136,3 +155,4 @@ test_files:
136
155
  - spec/postfix_test.sql
137
156
  - spec/runner_spec.rb
138
157
  - spec/spec_helper.rb
158
+ - spec/tmp/.gitkeep