panelbeater 0.1.0 → 0.1.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.
- data/Rakefile +2 -2
- data/lib/panelbeater/response.rb +4 -0
- data/panelbeater.gemspec +36 -0
- data/pkg/panelbeater-0.1.0.gem +0 -0
- data/test/test_helper.rb +6 -9
- data/test/whm_test.rb +42 -14
- metadata +5 -5
- data/cpanel-gem.gemspec +0 -30
- data/pkg/cpanel-gem-0.1.0.gem +0 -0
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
# Change these as appropriate
|
19
19
|
s.name = "panelbeater"
|
20
|
-
s.version = "0.1.
|
20
|
+
s.version = "0.1.1"
|
21
21
|
s.summary = "A gem for communicating with the cPanel and WHM API's"
|
22
22
|
s.author = "Jamie Dyer"
|
23
23
|
s.email = "jamie@kernowsoul.com"
|
@@ -41,7 +41,7 @@ spec = Gem::Specification.new do |s|
|
|
41
41
|
|
42
42
|
# If your tests use any gems, include them here
|
43
43
|
s.add_development_dependency("shoulda")
|
44
|
-
s.add_development_dependency("
|
44
|
+
s.add_development_dependency("webmock")
|
45
45
|
|
46
46
|
# If you want to publish automatically to rubyforge, you'll may need
|
47
47
|
# to tweak this, and the publishing task below too.
|
data/lib/panelbeater/response.rb
CHANGED
data/panelbeater.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{panelbeater}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Jamie Dyer"]
|
9
|
+
s.date = %q{2010-04-03}
|
10
|
+
s.email = %q{jamie@kernowsoul.com}
|
11
|
+
s.files = ["lib", "lib/panelbeater", "lib/panelbeater/cpanel", "lib/panelbeater/cpanel/commands.rb", "lib/panelbeater/model.rb", "lib/panelbeater/remote.rb", "lib/panelbeater/response.rb", "lib/panelbeater/whm", "lib/panelbeater/whm/commands.rb", "lib/panelbeater.rb", "panelbeater.gemspec", "pkg", "pkg/panelbeater-0.1.0.gem", "Rakefile", "Readme.markdown", "test", "test/fixtures", "test/fixtures/applist.json", "test/fixtures/createacct_fail.json", "test/fixtures/createacct_success.json", "test/fixtures/passwd_fail.json", "test/fixtures/passwd_success.json", "test/test_helper.rb", "test/whm_test.rb", "~"]
|
12
|
+
s.homepage = %q{http://kernowsoul.com}
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
s.rubygems_version = %q{1.3.5}
|
15
|
+
s.summary = %q{A gem for communicating with the cPanel and WHM API's}
|
16
|
+
s.test_files = ["test/fixtures/applist.json", "test/fixtures/createacct_fail.json", "test/fixtures/createacct_success.json", "test/fixtures/passwd_fail.json", "test/fixtures/passwd_success.json", "test/test_helper.rb", "test/whm_test.rb"]
|
17
|
+
|
18
|
+
if s.respond_to? :specification_version then
|
19
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
20
|
+
s.specification_version = 3
|
21
|
+
|
22
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
23
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
24
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
25
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
26
|
+
else
|
27
|
+
s.add_dependency(%q<json>, [">= 0"])
|
28
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
29
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<json>, [">= 0"])
|
33
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
34
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
35
|
+
end
|
36
|
+
end
|
Binary file
|
data/test/test_helper.rb
CHANGED
@@ -6,18 +6,15 @@ require 'panelbeater'
|
|
6
6
|
|
7
7
|
require 'test/unit'
|
8
8
|
require 'shoulda'
|
9
|
-
require '
|
10
|
-
|
9
|
+
require 'webmock'
|
10
|
+
require 'webmock/test_unit'
|
11
|
+
|
11
12
|
class Test::Unit::TestCase
|
12
13
|
|
13
|
-
|
14
|
-
FakeWeb.allow_net_connect = false
|
14
|
+
include WebMock
|
15
15
|
|
16
|
-
#
|
17
|
-
|
18
|
-
# def response(name)
|
19
|
-
# Pepper::Stanzas::Epp.parse File.read( File.join(File.dirname(__FILE__),"fixtures", "#{name}.xml") )
|
20
|
-
# end
|
16
|
+
# we don't want any connections to the outside world
|
17
|
+
WebMock.disable_net_connect!
|
21
18
|
|
22
19
|
def fixture(name)
|
23
20
|
File.read( File.join(File.dirname(__FILE__),"fixtures", "#{name}.json") )
|
data/test/whm_test.rb
CHANGED
@@ -4,29 +4,57 @@ require "test_helper"
|
|
4
4
|
class WhmTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
|
-
FakeWeb.clean_registry
|
8
7
|
@expected_url = 'https://cpanel.server.local:2087/json-api/'
|
9
|
-
@
|
8
|
+
@expected_auth_header = "WHM root:12345678"
|
9
|
+
@connection = CpanelApi::Whm::Commands.new({ :url => 'cpanel.server.local', :api_key => "1234\r5678" })
|
10
10
|
end
|
11
11
|
|
12
12
|
|
13
13
|
context "404 error handling" do
|
14
14
|
setup do
|
15
|
-
|
15
|
+
stub_request(:get, "#{@expected_url}applist?").with(:headers => { 'Authorization' => @expected_auth_header }).to_return(:status => "404")
|
16
16
|
@response = @connection.applist
|
17
17
|
end
|
18
18
|
|
19
19
|
should "return an error status" do
|
20
|
-
assert_equal 'Not Found', @response.message
|
21
20
|
assert_equal '404', @response.code
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
|
25
|
+
context "returning a successful response" do
|
26
|
+
setup do
|
27
|
+
stub_request(:get, "#{@expected_url}applist?").
|
28
|
+
with(:headers => { 'Authorization' => @expected_auth_header }).
|
29
|
+
to_return(:body => fixture('createacct_success'))
|
30
|
+
@response = @connection.applist
|
31
|
+
end
|
32
|
+
|
33
|
+
should "return true" do
|
34
|
+
assert @response.success?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
context "returning a unsuccessful response" do
|
40
|
+
setup do
|
41
|
+
stub_request(:get, "#{@expected_url}applist?").
|
42
|
+
with(:headers => { 'Authorization' => @expected_auth_header }).
|
43
|
+
to_return(:body => fixture('createacct_fail'))
|
44
|
+
@response = @connection.applist
|
45
|
+
end
|
46
|
+
|
47
|
+
should "return false" do
|
48
|
+
assert !@response.success?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
26
52
|
|
27
53
|
context "getting a list of commands the server supports" do
|
28
54
|
setup do
|
29
|
-
|
55
|
+
stub_request(:get, "#{@expected_url}applist?").
|
56
|
+
with(:headers => { 'Authorization' => @expected_auth_header }).
|
57
|
+
to_return(:body => fixture('applist'))
|
30
58
|
@response = @connection.applist
|
31
59
|
end
|
32
60
|
|
@@ -38,9 +66,9 @@ class WhmTest < Test::Unit::TestCase
|
|
38
66
|
|
39
67
|
context "creating a new account" do
|
40
68
|
setup do
|
41
|
-
|
42
|
-
|
43
|
-
|
69
|
+
stub_request(:get, "#{@expected_url}createacct?cpmod=x3&maxlst=0&hasshell=n&reseller=0&featurelist=default&ip=n&username=amos&cgi=y&frontpage=n").
|
70
|
+
with(:headers => { 'Authorization' => @expected_auth_header }).
|
71
|
+
to_return(:body => fixture('createacct_success'))
|
44
72
|
@response = @connection.createacct :username => 'amos'
|
45
73
|
end
|
46
74
|
|
@@ -52,9 +80,9 @@ class WhmTest < Test::Unit::TestCase
|
|
52
80
|
|
53
81
|
context "creating a new account with key mappings" do
|
54
82
|
setup do
|
55
|
-
|
56
|
-
|
57
|
-
|
83
|
+
stub_request(:get, "#{@expected_url}createacct?cpmod=x3&maxlst=0&hasshell=n&reseller=0&featurelist=default&ip=n&username=amos&cgi=y&frontpage=n").
|
84
|
+
with(:headers => { 'Authorization' => @expected_auth_header }).
|
85
|
+
to_return(:body => fixture('createacct_success'))
|
58
86
|
@response = @connection.createacct({ :krazy => 'amos' }, { :krazy => :username })
|
59
87
|
end
|
60
88
|
|
@@ -66,9 +94,9 @@ class WhmTest < Test::Unit::TestCase
|
|
66
94
|
|
67
95
|
context "changing a users password" do
|
68
96
|
setup do
|
69
|
-
|
70
|
-
|
71
|
-
|
97
|
+
stub_request(:get, "#{@expected_url}passwd?user=bob&pass=hello").
|
98
|
+
with(:headers => { 'Authorization' => @expected_auth_header }).
|
99
|
+
to_return(:body => fixture('passwd_success'))
|
72
100
|
@response = @connection.passwd('bob', 'hello')
|
73
101
|
end
|
74
102
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panelbeater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Dyer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-03 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: webmock
|
37
37
|
type: :development
|
38
38
|
version_requirement:
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,14 +51,14 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
|
53
53
|
files:
|
54
|
-
- cpanel-gem.gemspec
|
55
54
|
- lib/panelbeater/cpanel/commands.rb
|
56
55
|
- lib/panelbeater/model.rb
|
57
56
|
- lib/panelbeater/remote.rb
|
58
57
|
- lib/panelbeater/response.rb
|
59
58
|
- lib/panelbeater/whm/commands.rb
|
60
59
|
- lib/panelbeater.rb
|
61
|
-
-
|
60
|
+
- panelbeater.gemspec
|
61
|
+
- pkg/panelbeater-0.1.0.gem
|
62
62
|
- Rakefile
|
63
63
|
- Readme.markdown
|
64
64
|
- test/fixtures/applist.json
|
data/cpanel-gem.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{cpanel-gem}
|
5
|
-
s.version = "0.1.0"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Jamie Dyer"]
|
9
|
-
s.date = %q{2010-01-29}
|
10
|
-
s.email = %q{jamie@kernowsoul.com}
|
11
|
-
s.files = ["cpanel-gem.gemspec", "lib", "lib/cpanel_api", "lib/cpanel_api/cpanel", "lib/cpanel_api/cpanel/commands.rb", "lib/cpanel_api/model.rb", "lib/cpanel_api/remote.rb", "lib/cpanel_api/response.rb", "lib/cpanel_api/whm", "lib/cpanel_api/whm/commands.rb", "lib/cpanel_api.rb", "Rakefile", "Readme.markdown", "test", "test/fixtures", "test/fixtures/applist.json", "test/fixtures/createacct_fail.json", "test/fixtures/createacct_success.json", "test/fixtures/passwd_fail.json", "test/fixtures/passwd_success.json", "test/test_helper.rb", "test/whm_test.rb", "~"]
|
12
|
-
s.homepage = %q{http://kernowsoul.com}
|
13
|
-
s.require_paths = ["lib"]
|
14
|
-
s.rubygems_version = %q{1.3.5}
|
15
|
-
s.summary = %q{A gem for communicating with cPanel}
|
16
|
-
s.test_files = ["test/fixtures/applist.json", "test/fixtures/createacct_fail.json", "test/fixtures/createacct_success.json", "test/fixtures/passwd_fail.json", "test/fixtures/passwd_success.json", "test/test_helper.rb", "test/whm_test.rb"]
|
17
|
-
|
18
|
-
if s.respond_to? :specification_version then
|
19
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
20
|
-
s.specification_version = 3
|
21
|
-
|
22
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
23
|
-
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
24
|
-
else
|
25
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
26
|
-
end
|
27
|
-
else
|
28
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
29
|
-
end
|
30
|
-
end
|
data/pkg/cpanel-gem-0.1.0.gem
DELETED
Binary file
|