spice 0.4.2 → 0.5.0.beta.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/.watchr +22 -0
- data/Gemfile +14 -1
- data/Rakefile +5 -0
- data/lib/spice.rb +1 -1
- data/lib/spice/client.rb +4 -4
- data/lib/spice/connection.rb +9 -4
- data/lib/spice/node.rb +7 -0
- data/lib/spice/version.rb +1 -1
- data/spec/spec_helper.rb +29 -19
- data/spec/spice/chef_spec.rb +31 -83
- data/spec/spice/client_spec.rb +42 -85
- data/spec/spice/cookbook_spec.rb +42 -81
- data/spec/spice/data_bag_spec.rb +84 -85
- data/spec/spice/node_spec.rb +75 -0
- data/spec/spice/role_spec.rb +61 -0
- data/spec/spice/search_spec.rb +2 -0
- data/{file.txt → spec/support/chef_requests.rb} +0 -0
- data/spec/support/client_requests.rb +52 -54
- data/spec/support/cookbook_requests.rb +53 -130
- data/spec/support/node_requests.rb +138 -0
- data/spec/support/requests.rb +97 -97
- data/spec/support/role_requests.rb +95 -0
- data/spice.gemspec +2 -3
- metadata +17 -22
- data/spec/support/vcr.rb +0 -8
data/spec/support/requests.rb
CHANGED
@@ -1,97 +1,97 @@
|
|
1
|
-
def stub_client_list(name="testclient")
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def stub_client_show(name, status=200)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def stub_client_create(name, admin=false, status=201)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
def stub_client_update(name, admin=false, private_key=false, status=200)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
def stub_client_delete(name, status=200)
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
1
|
+
# def stub_client_list(name="testclient")
|
2
|
+
# stub_request(:get, "http://localhost:4000/clients").
|
3
|
+
# to_return(
|
4
|
+
# :status => 200,
|
5
|
+
# :body => "{\"#{name}\":\"http://localhost:4000/clients/#{name}\"}",
|
6
|
+
# :headers => {})
|
7
|
+
# end
|
8
|
+
#
|
9
|
+
# def stub_client_show(name, status=200)
|
10
|
+
# case status
|
11
|
+
# when 200
|
12
|
+
# stub_request(:get, "http://localhost:4000/clients/#{name}").
|
13
|
+
# to_return(
|
14
|
+
# :status => status,
|
15
|
+
# :body => %Q{{"name": "#{name}",
|
16
|
+
# "chef_type": "client",
|
17
|
+
# "json_class": "Chef::ApiClient",
|
18
|
+
# "public_key": "RSA PUBLIC KEY",
|
19
|
+
# "_rev": "1-68532bf2122a54464db6ad65a24e2225",
|
20
|
+
# "admin": true}
|
21
|
+
# }
|
22
|
+
# )
|
23
|
+
# when 404
|
24
|
+
# stub_request(:get, "http://localhost:4000/clients/#{name}").
|
25
|
+
# to_return(
|
26
|
+
# :status => status,
|
27
|
+
# :body => "{\"error\":[\"Cannot load client #{name}\"]}")
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# def stub_client_create(name, admin=false, status=201)
|
32
|
+
# case status
|
33
|
+
# when 201
|
34
|
+
# stub_request(:post, "http://localhost:4000/clients").
|
35
|
+
# with(
|
36
|
+
# :body => "{\"name\":\"#{name}\",\"admin\":#{admin}}").
|
37
|
+
# to_return(
|
38
|
+
# :status => status,
|
39
|
+
# :body => %Q{
|
40
|
+
# {
|
41
|
+
# "private_key":"RSA PRIVATE KEY",
|
42
|
+
# "uri":"http://http://localhost:4000/clients/#{name}"}
|
43
|
+
# },
|
44
|
+
# :headers => {}
|
45
|
+
# )
|
46
|
+
# when 409
|
47
|
+
# stub_request(:post, "http://localhost:4000/clients").
|
48
|
+
# with(
|
49
|
+
# :body => "{\"name\":\"#{name}\",\"admin\":#{admin}}").
|
50
|
+
# to_return(
|
51
|
+
# :status => status,
|
52
|
+
# :body => %Q{
|
53
|
+
# {
|
54
|
+
# "private_key":"RSA PRIVATE KEY",
|
55
|
+
# "uri":"http://http://localhost:4000/clients/#{name}"}
|
56
|
+
# },
|
57
|
+
# :headers => {}
|
58
|
+
# )
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# def stub_client_update(name, admin=false, private_key=false, status=200)
|
63
|
+
# case status
|
64
|
+
# when 200
|
65
|
+
# stub_request(:put, "http://localhost:4000/clients/#{name}").
|
66
|
+
# with(:body => "{\"admin\":#{admin},\"private_key\":#{private_key}}").
|
67
|
+
# to_return(
|
68
|
+
# :status => status,
|
69
|
+
# :body => %Q{{#{"\"private_key\":\"RSA PRIVATE KEY\"," if private_key}\"admin\": true}
|
70
|
+
# }
|
71
|
+
# )
|
72
|
+
# # when 404
|
73
|
+
# # stub_request(:get, "http://localhost:4000/clients/#{name}").
|
74
|
+
# # to_return(
|
75
|
+
# # :status => status,
|
76
|
+
# # :body => "{\"error\":[\"Cannot load client #{name}\"]}")
|
77
|
+
# end
|
78
|
+
# end
|
79
|
+
#
|
80
|
+
# def stub_client_delete(name, status=200)
|
81
|
+
# case status
|
82
|
+
# when 200
|
83
|
+
# stub_request(:delete, "http://localhost:4000/clients/#{name}").
|
84
|
+
# with(:body => "").
|
85
|
+
# to_return(
|
86
|
+
# :status => status,
|
87
|
+
# :body => ""
|
88
|
+
# )
|
89
|
+
# when 404
|
90
|
+
# stub_request(:delete, "http://localhost:4000/clients/#{name}").
|
91
|
+
# with(:body => "").
|
92
|
+
# to_return(
|
93
|
+
# :status => status,
|
94
|
+
# :body => "{\"error\":[\"Cannot load client sasdasdf\"]}"
|
95
|
+
# )
|
96
|
+
# end
|
97
|
+
# end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
def stub_role_list
|
2
|
+
stub_request(:get, "http://localhost:4000/roles").
|
3
|
+
to_return(
|
4
|
+
:status => 200,
|
5
|
+
:body => role_list_response
|
6
|
+
)
|
7
|
+
end
|
8
|
+
|
9
|
+
def stub_role_show(status=200)
|
10
|
+
case status
|
11
|
+
when 200
|
12
|
+
stub_request(:get, "http://localhost:4000/roles/testrole").
|
13
|
+
to_return(
|
14
|
+
:status => status,
|
15
|
+
:body => role_show_response
|
16
|
+
)
|
17
|
+
when 404
|
18
|
+
stub_request(:get, "http://localhost:4000/roles/testrole").
|
19
|
+
to_return(
|
20
|
+
:status => status,
|
21
|
+
:body => role_not_found
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def stub_role_create(status=201)
|
27
|
+
case status
|
28
|
+
when 201
|
29
|
+
stub_request(:post, "http://localhost:4000/roles").
|
30
|
+
with(
|
31
|
+
:body => role_create_payload ).
|
32
|
+
to_return(
|
33
|
+
:status => status,
|
34
|
+
:body => role_create_response
|
35
|
+
)
|
36
|
+
when 409
|
37
|
+
stub_request(:post, "http://localhost:4000/roles").
|
38
|
+
with(
|
39
|
+
:body => role_create_payload ).
|
40
|
+
to_return(
|
41
|
+
:status => status,
|
42
|
+
:body => role_conflict
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def stub_role_delete(status=200)
|
48
|
+
case status
|
49
|
+
when 200
|
50
|
+
stub_request(:delete, "http://localhost:4000/roles/testrole").
|
51
|
+
with(:body => "").
|
52
|
+
to_return(
|
53
|
+
:status => status,
|
54
|
+
:body => role_delete_response
|
55
|
+
)
|
56
|
+
when 404
|
57
|
+
stub_request(:delete, "http://localhost:4000/roles/testrole").
|
58
|
+
with(:body => "").
|
59
|
+
to_return(
|
60
|
+
:status => status,
|
61
|
+
:body => role_not_found
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# payloads and responses
|
67
|
+
|
68
|
+
def role_list_response
|
69
|
+
{ "testrole" => "http://localhost:4000/roles/testrole" }
|
70
|
+
end
|
71
|
+
|
72
|
+
def role_show_response
|
73
|
+
{ "adam" => "http://localhost:4000/roles/testrole" }
|
74
|
+
end
|
75
|
+
|
76
|
+
def role_delete_response
|
77
|
+
{ "name" => "users", "json_class" => "Chef::Role", "chef_type" => "role" }
|
78
|
+
end
|
79
|
+
|
80
|
+
def role_not_found
|
81
|
+
{ "error" => [ "Could not load role testrole" ] }
|
82
|
+
end
|
83
|
+
|
84
|
+
def role_conflict
|
85
|
+
{ "error" => [ "Role already exists" ] }
|
86
|
+
end
|
87
|
+
|
88
|
+
def role_create_payload
|
89
|
+
{ "name" => "testrole" }
|
90
|
+
end
|
91
|
+
|
92
|
+
def role_create_response
|
93
|
+
{ "private_key"=>"-----BEGIN RSA PRIVATE KEY-----",
|
94
|
+
"uri"=>"http://localhost:4000/roles/testrole" }
|
95
|
+
end
|
data/spice.gemspec
CHANGED
@@ -21,10 +21,9 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency "yard", "~> 0.6.4"
|
22
22
|
s.add_development_dependency "rspec", "~> 2.5.0"
|
23
23
|
s.add_development_dependency "cucumber", "~> 0.10.0"
|
24
|
-
s.add_development_dependency "webmock", "~> 1.6.
|
24
|
+
s.add_development_dependency "webmock", "~> 1.6.2"
|
25
25
|
s.add_development_dependency "timecop", "~> 0.3.5"
|
26
|
-
s.add_development_dependency "
|
27
|
-
s.add_development_dependency "chef"
|
26
|
+
s.add_development_dependency "webmock", "~> 1.6.2"
|
28
27
|
|
29
28
|
s.files = `git ls-files`.split("\n")
|
30
29
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.5.0.beta.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dan Ryan
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 1.6.
|
90
|
+
version: 1.6.2
|
91
91
|
type: :development
|
92
92
|
version_requirements: *id007
|
93
93
|
- !ruby/object:Gem::Dependency
|
@@ -102,27 +102,16 @@ dependencies:
|
|
102
102
|
type: :development
|
103
103
|
version_requirements: *id008
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
105
|
+
name: webmock
|
106
106
|
prerelease: false
|
107
107
|
requirement: &id009 !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|
110
|
-
- -
|
110
|
+
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
112
|
+
version: 1.6.2
|
113
113
|
type: :development
|
114
114
|
version_requirements: *id009
|
115
|
-
- !ruby/object:Gem::Dependency
|
116
|
-
name: chef
|
117
|
-
prerelease: false
|
118
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
|
-
requirements:
|
121
|
-
- - ">="
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: "0"
|
124
|
-
type: :development
|
125
|
-
version_requirements: *id010
|
126
115
|
description: Spice is a zesty Chef API wrapper. Its primary purpose is to let you easily integrate your apps with a Chef server easily. Spice provides support for the entire released Chef API
|
127
116
|
email:
|
128
117
|
- hi@iamdanryan.com
|
@@ -137,6 +126,7 @@ files:
|
|
137
126
|
- .document
|
138
127
|
- .gitignore
|
139
128
|
- .rspec
|
129
|
+
- .watchr
|
140
130
|
- CHANGELOG.md
|
141
131
|
- Gemfile
|
142
132
|
- LICENSE.txt
|
@@ -147,7 +137,6 @@ files:
|
|
147
137
|
- features/spice.feature
|
148
138
|
- features/step_definitions/spice_steps.rb
|
149
139
|
- features/support/env.rb
|
150
|
-
- file.txt
|
151
140
|
- lib/spice.rb
|
152
141
|
- lib/spice/authentication.rb
|
153
142
|
- lib/spice/chef.rb
|
@@ -171,14 +160,17 @@ files:
|
|
171
160
|
- spec/spice/data_bag_spec.rb
|
172
161
|
- spec/spice/node_spec.rb
|
173
162
|
- spec/spice/role_spec.rb
|
163
|
+
- spec/spice/search_spec.rb
|
174
164
|
- spec/spice_spec.rb
|
165
|
+
- spec/support/chef_requests.rb
|
175
166
|
- spec/support/client_requests.rb
|
176
167
|
- spec/support/cookbook_requests.rb
|
177
168
|
- spec/support/data_bag_item_requests.rb
|
178
169
|
- spec/support/data_bag_requests.rb
|
170
|
+
- spec/support/node_requests.rb
|
179
171
|
- spec/support/requests.rb
|
180
172
|
- spec/support/respond_with_matcher.rb
|
181
|
-
- spec/support/
|
173
|
+
- spec/support/role_requests.rb
|
182
174
|
- spice.gemspec
|
183
175
|
has_rdoc: true
|
184
176
|
homepage: http://github.com/danryan/spice
|
@@ -198,9 +190,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
191
|
none: false
|
200
192
|
requirements:
|
201
|
-
- - "
|
193
|
+
- - ">"
|
202
194
|
- !ruby/object:Gem::Version
|
203
|
-
version:
|
195
|
+
version: 1.3.1
|
204
196
|
requirements: []
|
205
197
|
|
206
198
|
rubyforge_project: spice
|
@@ -221,11 +213,14 @@ test_files:
|
|
221
213
|
- spec/spice/data_bag_spec.rb
|
222
214
|
- spec/spice/node_spec.rb
|
223
215
|
- spec/spice/role_spec.rb
|
216
|
+
- spec/spice/search_spec.rb
|
224
217
|
- spec/spice_spec.rb
|
218
|
+
- spec/support/chef_requests.rb
|
225
219
|
- spec/support/client_requests.rb
|
226
220
|
- spec/support/cookbook_requests.rb
|
227
221
|
- spec/support/data_bag_item_requests.rb
|
228
222
|
- spec/support/data_bag_requests.rb
|
223
|
+
- spec/support/node_requests.rb
|
229
224
|
- spec/support/requests.rb
|
230
225
|
- spec/support/respond_with_matcher.rb
|
231
|
-
- spec/support/
|
226
|
+
- spec/support/role_requests.rb
|