fusebox 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fusebox/core_ext/net_http.rb +1 -0
- data/lib/fusebox/request.rb +3 -3
- data/lib/fusebox/version.rb +1 -1
- data/spec/fixtures/fusemail.yaml +2 -0
- data/spec/integration/integration_spec.rb +171 -0
- data/vendor/curl-cacert.pem +0 -0
- metadata +7 -4
@@ -13,6 +13,7 @@ module Net
|
|
13
13
|
http = new(url.host, url.port)
|
14
14
|
http.use_ssl = (url.scheme == 'https')
|
15
15
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
16
|
+
http.ca_file = File.expand_path('../../../../vendor/curl-cacert.pem', __FILE__)
|
16
17
|
http.start {|http|
|
17
18
|
http.request(req)
|
18
19
|
}
|
data/lib/fusebox/request.rb
CHANGED
@@ -22,7 +22,7 @@ module Fusebox
|
|
22
22
|
self.url = 'https://www.fusemail.com/api/request.html'
|
23
23
|
|
24
24
|
# @return [Array<String>] List of available API commands
|
25
|
-
COMMANDS = %w(adddomain addforward changeusername checkalias checkdomain suspend enable getforward modify order terminate removealias removedomain removeforward report reportmail
|
25
|
+
COMMANDS = %w(adddomain addforward changeusername checkalias checkdomain suspend enable getforward modify order terminate removealias removedomain removeforward report reportmail)
|
26
26
|
|
27
27
|
# @param [String] username API username. If not provided, auth_yaml_paths will be searched for authentication information instead.
|
28
28
|
# @param [String] password API password
|
@@ -85,7 +85,7 @@ module Fusebox
|
|
85
85
|
end
|
86
86
|
|
87
87
|
# This request is used to change the an account's username
|
88
|
-
# @see http://www.fusemail.com/support/administration-api/requests/changeusername
|
88
|
+
# @see http://www.fusemail.com/support/administration-api/requests/changeusername changeusername API documentation
|
89
89
|
# @param [Array] opts
|
90
90
|
# @param opts [String] :user Username of FuseMail account to modify
|
91
91
|
# @param opts [String] :newuser New username of the account
|
@@ -115,7 +115,7 @@ module Fusebox
|
|
115
115
|
end
|
116
116
|
|
117
117
|
# This request is used to change the an account's username
|
118
|
-
# @see http://www.fusemail.com/support/administration-api/requests/
|
118
|
+
# @see http://www.fusemail.com/support/administration-api/requests/suspend suspend API documentation
|
119
119
|
# @param [Array] opts
|
120
120
|
# @option opts [String] :user Username of FuseMail account to modify
|
121
121
|
# @return [Response]
|
data/lib/fusebox/version.rb
CHANGED
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# These specs run all the commands on your *live* Fusemail account. Fusemail
|
4
|
+
# unfortunately does not provide a "test mode" in its API, which makes these
|
5
|
+
# tests difficult to run. These tests are non-atomic, and each test relies
|
6
|
+
# on the previous test to set up the data, and a later test to clean up.
|
7
|
+
# Additionally, some tests like "order" have a lengthy "sleep" delay to allow
|
8
|
+
# the data its necessary propagation time for it to be available to subsequent
|
9
|
+
# tests. Tests *may* fail if fusemail's servers are overloaded and the data
|
10
|
+
# has not propagated.
|
11
|
+
#
|
12
|
+
# If you have any ideas for improving these tests, please feel free to refactor
|
13
|
+
# or drop suggestions.
|
14
|
+
describe Fusebox::Request do
|
15
|
+
before(:all) do
|
16
|
+
@fixtures = YAML.load(File.read(File.expand_path('~/.fusemail.yaml')))['spec']
|
17
|
+
raise "Integration tests require 'spec' properties defined in ~/.fusemail.yaml" unless @fixtures
|
18
|
+
|
19
|
+
# These are globals shared between the tests.
|
20
|
+
# Is there a more appropriate way to share data between the specs?
|
21
|
+
@@spec_domain ||= ActiveSupport::SecureRandom.hex(4) + '.example.com'
|
22
|
+
@@secondary_domain ||= ActiveSupport::SecureRandom.hex(4) + '.example.com'
|
23
|
+
@@forward ||= ActiveSupport::SecureRandom.hex(4) + "@#{@@spec_domain}"
|
24
|
+
@@sleep_duration = 30 # How long the tests should sleep after the initial "order" to allow the data to propagate
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
describe "commands" do
|
29
|
+
|
30
|
+
describe "order" do
|
31
|
+
it "should not be successful when adding existing account" do
|
32
|
+
@response = Fusebox::Request.new.order(:account_type => @fixtures['group_account_type'], :user => 'postmaster@mudbugmedia.com', :password => ActiveSupport::SecureRandom.hex)
|
33
|
+
@response.detail.should match('already exists')
|
34
|
+
@response.success?.should == false
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should be successful when adding new group account" do
|
38
|
+
@response = Fusebox::Request.new.order(:account_type => @fixtures['group_account_type'], :user => "postmaster@#{@@spec_domain}", :password => ActiveSupport::SecureRandom.hex, :first_name => 'fusebox rspec sandbox', :last_name => '(delete me)')
|
39
|
+
@response.detail.should match('Order Created Succesfully')
|
40
|
+
@response.success?.should == true
|
41
|
+
sleep @@sleep_duration # Let fusemail catch up.. hopefully.
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be successful when adding group subaccounts" do
|
45
|
+
@response = Fusebox::Request.new.order(:account_type => 'group_subaccount', :group_parent => "postmaster@#{@@spec_domain}", :user => "user@#{@@spec_domain}", :password => ActiveSupport::SecureRandom.hex, :first_name => 'fusebox rspec sandbox', :last_name => '(delete me)')
|
46
|
+
@response.detail.should match('Order Created Succesfully')
|
47
|
+
@response.success?.should == true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "modify" do
|
52
|
+
it "should be successful" do
|
53
|
+
@response = Fusebox::Request.new.modify(:user => "postmaster@#{@@spec_domain}", :first_name => 'fusebox rspec sandbox modified')
|
54
|
+
@response.detail.should match('modification complete')
|
55
|
+
@response.success?.should == true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "report" do
|
60
|
+
it "should be return a array of hash results" do
|
61
|
+
@response = Fusebox::Request.new.report('user' => "postmaster@#{@@spec_domain}", 'group_subaccount' => 'yes')
|
62
|
+
@response.records.should be_instance_of(Array)
|
63
|
+
@response.records.first.should be_instance_of(Hash)
|
64
|
+
@response.records.map { |r| r[:username] }.should include("postmaster@#{@@spec_domain}")
|
65
|
+
@response.success?.should == true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "adddomain" do
|
70
|
+
it "should be successful" do
|
71
|
+
@response = Fusebox::Request.new.adddomain(:domain => @@secondary_domain, :user => "postmaster@#{@@spec_domain}")
|
72
|
+
@response.detail.should match('Domain was added')
|
73
|
+
@response.success?.should == true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "checkdomain" do
|
78
|
+
it "should not be successful for existing domains" do
|
79
|
+
@response = Fusebox::Request.new.checkdomain(:domain => @@secondary_domain)
|
80
|
+
@response.detail.should match('already exists')
|
81
|
+
@response.success?.should == false
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should be successful for new domains" do
|
85
|
+
@response = Fusebox::Request.new.checkdomain(:domain => ActiveSupport::SecureRandom.hex(4) + '.example.com')
|
86
|
+
@response.detail.should match('Domain is Available')
|
87
|
+
@response.success?.should == true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "removedomain" do
|
92
|
+
it "should be successful" do
|
93
|
+
@response = Fusebox::Request.new.removedomain(:domain => @@secondary_domain)
|
94
|
+
@response.detail.should match('Domain was removed')
|
95
|
+
@response.success?.should == true
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
describe "addforward" do
|
101
|
+
it "should be successful" do
|
102
|
+
@response = Fusebox::Request.new.addforward(:forward_what => @@forward, :forward_to => "postmaster@#{@@spec_domain}", :user => "postmaster@#{@@spec_domain}")
|
103
|
+
@response.detail.should match('Your forwarder has been successfully submitted')
|
104
|
+
@response.success?.should == true
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "getforward" do
|
109
|
+
it "should be successful for existing forwards" do
|
110
|
+
@response = Fusebox::Request.new.getforward(:forward_what => @@forward, :user => "postmaster@#{@@spec_domain}")
|
111
|
+
@response.detail.should match("postmaster@#{@@spec_domain}")
|
112
|
+
@response.success?.should == true
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "removeforward" do
|
117
|
+
it "should be successful" do
|
118
|
+
@response = Fusebox::Request.new.removeforward(:forward_what => @@forward, :forward_to => "postmaster@#{@@spec_domain}", :user => "postmaster@#{@@spec_domain}")
|
119
|
+
@response.detail.should match('Your forwarder has been successfully removed')
|
120
|
+
@response.success?.should == true
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
describe "checkalias" do
|
126
|
+
it "should not be successful for existing aliases" do
|
127
|
+
@response = Fusebox::Request.new.checkalias(:alias => "postmaster@#{@@spec_domain}")
|
128
|
+
@response.should be_instance_of(Fusebox::Response)
|
129
|
+
@response.detail.should match('already taken')
|
130
|
+
@response.success?.should == false
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should be successful for new aliases" do
|
134
|
+
@response = Fusebox::Request.new.checkalias(:alias => ActiveSupport::SecureRandom.hex + "@#{@@spec_domain}")
|
135
|
+
@response.detail.should match('Alias is Available')
|
136
|
+
@response.success?.should == true
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "suspend" do
|
141
|
+
it "should be successful when suspending existing accounts" do
|
142
|
+
@response = Fusebox::Request.new.suspend(:user => "postmaster@#{@@spec_domain}")
|
143
|
+
@response.detail.should match('Account Succesfully Suspended')
|
144
|
+
@response.success?.should == true
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "enable" do
|
149
|
+
it "should be successful when enabling suspended accounts" do
|
150
|
+
@response = Fusebox::Request.new.enable(:user => "postmaster@#{@@spec_domain}")
|
151
|
+
@response.detail.should match('Account Successfully Enabled')
|
152
|
+
@response.success?.should == true
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "terminate" do
|
157
|
+
it "should not be successful when purging non-existing accounts" do
|
158
|
+
@response = Fusebox::Request.new.terminate(:user => ActiveSupport::SecureRandom.hex + "@#{@@spec_domain}", :purge => true)
|
159
|
+
@response.detail.should match('Terminate account failed Could not find user')
|
160
|
+
@response.success?.should == false
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should be successful purge existing accounts" do
|
164
|
+
@response = Fusebox::Request.new.terminate(:user => "postmaster@#{@@spec_domain}", :purge => true)
|
165
|
+
@response.detail.should match('Account Successfully Terminated')
|
166
|
+
@response.success?.should == true
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fusebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gabe Martin-Dempesy
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-11 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -79,11 +79,14 @@ files:
|
|
79
79
|
- lib/fusebox/response.rb
|
80
80
|
- lib/fusebox/version.rb
|
81
81
|
- lib/fusebox.rb
|
82
|
+
- spec/fixtures/fusemail.yaml
|
82
83
|
- spec/fusebox_request_spec.rb
|
83
84
|
- spec/fusebox_response_spec.rb
|
85
|
+
- spec/integration/integration_spec.rb
|
84
86
|
- spec/net_http_spec.rb
|
85
87
|
- spec/spec.opts
|
86
88
|
- spec/spec_helper.rb
|
89
|
+
- vendor/curl-cacert.pem
|
87
90
|
- LICENSE
|
88
91
|
- README.md
|
89
92
|
- bin/fusebox
|