chef-server-api 10.12.0 → 10.14.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/clients.rb +2 -2
- data/lib/chef-server-api/version.rb +1 -1
- data/spec/spec_helper.rb +6 -4
- data/spec/spec_model_helper.rb +7 -0
- data/spec/unit/clients_controller_spec.rb +74 -0
- metadata +56 -51
data/app/controllers/clients.rb
CHANGED
@@ -23,9 +23,9 @@ class Clients < Application
|
|
23
23
|
provides :json
|
24
24
|
|
25
25
|
before :authenticate_every
|
26
|
-
before :is_admin, :only => [ :index, :update
|
26
|
+
before :is_admin, :only => [ :index, :update ]
|
27
27
|
before :is_admin_or_validator, :only => [ :create ]
|
28
|
-
before :admin_or_requesting_node, :only => [ :show ]
|
28
|
+
before :admin_or_requesting_node, :only => [ :show, :destroy ]
|
29
29
|
|
30
30
|
# GET /clients
|
31
31
|
def index
|
data/spec/spec_helper.rb
CHANGED
@@ -78,12 +78,14 @@ def request_json(method, path, params, env, &block)
|
|
78
78
|
@response_json = Chef::JSONCompat.from_json(@response_raw)
|
79
79
|
end
|
80
80
|
|
81
|
-
def stub_authentication(controller)
|
81
|
+
def stub_authentication(controller,user=nil)
|
82
82
|
username = "tester"
|
83
83
|
|
84
|
-
user
|
85
|
-
|
86
|
-
|
84
|
+
unless user
|
85
|
+
user = Chef::ApiClient.new
|
86
|
+
user.name(username)
|
87
|
+
user.admin(true)
|
88
|
+
end
|
87
89
|
|
88
90
|
# authenticate_every has a side-effect of setting @auth_user
|
89
91
|
controller.stub!(:authenticate_every).and_return(true)
|
data/spec/spec_model_helper.rb
CHANGED
@@ -53,6 +53,13 @@ def make_runlist(*items)
|
|
53
53
|
res
|
54
54
|
end
|
55
55
|
|
56
|
+
def make_client(name,admin=false)
|
57
|
+
res = Chef::ApiClient.new
|
58
|
+
res.name(name)
|
59
|
+
res.admin(admin)
|
60
|
+
res
|
61
|
+
end
|
62
|
+
|
56
63
|
def stub_checksum(checksum, present = true)
|
57
64
|
Chef::Checksum.should_receive(:new).with(checksum).and_return do
|
58
65
|
obj = stub(Chef::Checksum)
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Michael Ivey (<ivey@gweezlebur.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
20
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_model_helper')
|
21
|
+
require 'pp'
|
22
|
+
|
23
|
+
describe "Clients Controller" do
|
24
|
+
before do
|
25
|
+
Merb.logger.set_log(StringIO.new)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when deleting a client" do
|
29
|
+
before do
|
30
|
+
@client = make_client("deleted_client")
|
31
|
+
@caller = make_client("deleting_client")
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "from an admin client" do
|
35
|
+
before do
|
36
|
+
@caller.admin(true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should delete the client" do
|
40
|
+
Chef::ApiClient.stub!(:cdb_load).and_return(@client)
|
41
|
+
@client.should_receive(:cdb_destroy).and_return(true)
|
42
|
+
@controller = mock_request("/clients/deleted_client", {}, {'HTTP_ACCEPT' => "application/json", :request_method => "DELETE"}) do |controller|
|
43
|
+
stub_authentication(controller, @caller)
|
44
|
+
end
|
45
|
+
@response_raw = @controller.body
|
46
|
+
@response_json = Chef::JSONCompat.from_json(@response_raw)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "from a non-admin client" do
|
51
|
+
it "should not delete the client" do
|
52
|
+
Chef::ApiClient.stub!(:cdb_load).and_return(@client)
|
53
|
+
lambda {
|
54
|
+
@controller = mock_request("/clients/deleted_client", {}, {'HTTP_ACCEPT' => "application/json", :request_method => "DELETE"}) do |controller|
|
55
|
+
stub_authentication(controller, @caller)
|
56
|
+
end
|
57
|
+
}.should raise_error(Merb::ControllerExceptions::Forbidden, /You are not the correct node.*not an API admin/)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "from the same client as it is trying to delete" do
|
62
|
+
it "should delete the client" do
|
63
|
+
Chef::ApiClient.stub!(:cdb_load).and_return(@client)
|
64
|
+
@client.should_receive(:cdb_destroy).and_return(true)
|
65
|
+
@controller = mock_request("/clients/deleted_client", {}, {'HTTP_ACCEPT' => "application/json", :request_method => "DELETE"}) do |controller|
|
66
|
+
stub_authentication(controller, @client)
|
67
|
+
end
|
68
|
+
@response_raw = @controller.body
|
69
|
+
@response_json = Chef::JSONCompat.from_json(@response_raw)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-server-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 628631041
|
5
|
+
prerelease: 8
|
6
6
|
segments:
|
7
7
|
- 10
|
8
|
-
-
|
8
|
+
- 14
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- beta
|
11
|
+
- 1
|
12
|
+
version: 10.14.0.beta.1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Opscode
|
@@ -15,9 +17,11 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2012-
|
20
|
+
date: 2012-07-02 00:00:00 Z
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
21
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
22
26
|
none: false
|
23
27
|
requirements:
|
@@ -29,11 +33,11 @@ dependencies:
|
|
29
33
|
- 1
|
30
34
|
- 0
|
31
35
|
version: 1.1.0
|
32
|
-
version_requirements: *id001
|
33
36
|
name: merb-core
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
34
39
|
prerelease: false
|
35
40
|
type: :runtime
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
42
|
none: false
|
39
43
|
requirements:
|
@@ -45,11 +49,11 @@ dependencies:
|
|
45
49
|
- 1
|
46
50
|
- 0
|
47
51
|
version: 1.1.0
|
48
|
-
version_requirements: *id002
|
49
52
|
name: merb-assets
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
50
55
|
prerelease: false
|
51
56
|
type: :runtime
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
57
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
58
|
none: false
|
55
59
|
requirements:
|
@@ -61,11 +65,11 @@ dependencies:
|
|
61
65
|
- 1
|
62
66
|
- 0
|
63
67
|
version: 1.1.0
|
64
|
-
version_requirements: *id003
|
65
68
|
name: merb-helpers
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
66
71
|
prerelease: false
|
67
72
|
type: :runtime
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
73
|
requirement: &id004 !ruby/object:Gem::Requirement
|
70
74
|
none: false
|
71
75
|
requirements:
|
@@ -77,11 +81,11 @@ dependencies:
|
|
77
81
|
- 1
|
78
82
|
- 0
|
79
83
|
version: 1.1.0
|
80
|
-
version_requirements: *id004
|
81
84
|
name: merb-param-protection
|
85
|
+
version_requirements: *id004
|
86
|
+
- !ruby/object:Gem::Dependency
|
82
87
|
prerelease: false
|
83
88
|
type: :runtime
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
89
|
requirement: &id005 !ruby/object:Gem::Requirement
|
86
90
|
none: false
|
87
91
|
requirements:
|
@@ -93,11 +97,11 @@ dependencies:
|
|
93
97
|
- 1
|
94
98
|
- 3
|
95
99
|
version: 1.1.3
|
96
|
-
version_requirements: *id005
|
97
100
|
name: mixlib-authentication
|
101
|
+
version_requirements: *id005
|
102
|
+
- !ruby/object:Gem::Dependency
|
98
103
|
prerelease: false
|
99
104
|
type: :runtime
|
100
|
-
- !ruby/object:Gem::Dependency
|
101
105
|
requirement: &id006 !ruby/object:Gem::Requirement
|
102
106
|
none: false
|
103
107
|
requirements:
|
@@ -109,11 +113,11 @@ dependencies:
|
|
109
113
|
- 0
|
110
114
|
- 3
|
111
115
|
version: 0.0.3
|
112
|
-
version_requirements: *id006
|
113
116
|
name: dep_selector
|
117
|
+
version_requirements: *id006
|
118
|
+
- !ruby/object:Gem::Dependency
|
114
119
|
prerelease: false
|
115
120
|
type: :runtime
|
116
|
-
- !ruby/object:Gem::Dependency
|
117
121
|
requirement: &id007 !ruby/object:Gem::Requirement
|
118
122
|
none: false
|
119
123
|
requirements:
|
@@ -125,11 +129,11 @@ dependencies:
|
|
125
129
|
- 1
|
126
130
|
- 1
|
127
131
|
version: 2.1.1
|
128
|
-
version_requirements: *id007
|
129
132
|
name: uuidtools
|
133
|
+
version_requirements: *id007
|
134
|
+
- !ruby/object:Gem::Dependency
|
130
135
|
prerelease: false
|
131
136
|
type: :runtime
|
132
|
-
- !ruby/object:Gem::Dependency
|
133
137
|
requirement: &id008 !ruby/object:Gem::Requirement
|
134
138
|
none: false
|
135
139
|
requirements:
|
@@ -139,10 +143,8 @@ dependencies:
|
|
139
143
|
segments:
|
140
144
|
- 0
|
141
145
|
version: "0"
|
142
|
-
version_requirements: *id008
|
143
146
|
name: thin
|
144
|
-
|
145
|
-
type: :runtime
|
147
|
+
version_requirements: *id008
|
146
148
|
description: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
|
147
149
|
email: chef@opscode.com
|
148
150
|
executables:
|
@@ -159,54 +161,55 @@ files:
|
|
159
161
|
- README.rdoc
|
160
162
|
- Rakefile
|
161
163
|
- config/init.rb
|
164
|
+
- config/environments/development.rb
|
162
165
|
- config/router.rb
|
163
166
|
- config/rack.rb
|
164
|
-
- config/environments/development.rb
|
165
|
-
- lib/chef-server-api/version.rb
|
166
167
|
- lib/chef-server-api.rb
|
168
|
+
- lib/chef-server-api/version.rb
|
167
169
|
- spec/unit/sandbox_file_spec.rb
|
168
170
|
- spec/unit/nodes_controller_environments_spec.rb
|
169
|
-
- spec/unit/environments_controller_spec.rb
|
170
|
-
- spec/unit/cookbooks_controller_spec.rb
|
171
171
|
- spec/unit/nodes_controller_spec.rb
|
172
|
+
- spec/unit/clients_controller_spec.rb
|
173
|
+
- spec/unit/cookbooks_controller_spec.rb
|
174
|
+
- spec/unit/environments_controller_spec.rb
|
172
175
|
- spec/spec_helper.rb
|
173
176
|
- spec/spec.opts
|
174
177
|
- spec/spec_model_helper.rb
|
175
|
-
- app/
|
176
|
-
- app/views/main/index.html.erb
|
177
|
-
- app/views/exceptions/not_found.html.erb
|
178
|
-
- app/views/exceptions/bad_request.json.erb
|
179
|
-
- app/views/exceptions/internal_server_error.html.erb
|
180
|
-
- app/views/exceptions/standard_error.html.erb
|
181
|
-
- app/views/exceptions/not_acceptable.html.haml
|
182
|
-
- app/controllers/search.rb
|
183
|
-
- app/controllers/exceptions.rb
|
184
|
-
- app/controllers/nodes.rb
|
178
|
+
- app/controllers/roles.rb
|
185
179
|
- app/controllers/application.rb
|
186
|
-
- app/controllers/
|
180
|
+
- app/controllers/cookbooks.rb
|
187
181
|
- app/controllers/main.rb
|
188
|
-
- app/controllers/
|
182
|
+
- app/controllers/data_item.rb
|
183
|
+
- app/controllers/exceptions.rb
|
184
|
+
- app/controllers/nodes.rb
|
185
|
+
- app/controllers/environments.rb
|
189
186
|
- app/controllers/users.rb
|
190
187
|
- app/controllers/clients.rb
|
191
|
-
- app/controllers/sandboxes.rb
|
192
|
-
- app/controllers/environments.rb
|
193
188
|
- app/controllers/data_bags.rb
|
194
|
-
- app/controllers/
|
189
|
+
- app/controllers/search.rb
|
190
|
+
- app/controllers/sandboxes.rb
|
191
|
+
- app/models/sandbox_file.rb
|
192
|
+
- app/views/main/index.html.erb
|
193
|
+
- app/views/exceptions/standard_error.html.erb
|
194
|
+
- app/views/exceptions/internal_server_error.html.erb
|
195
|
+
- app/views/exceptions/not_found.html.erb
|
196
|
+
- app/views/exceptions/bad_request.json.erb
|
197
|
+
- app/views/exceptions/not_acceptable.html.haml
|
198
|
+
- app/views/layout/application.html.erb
|
195
199
|
- app/helpers/tarball_helper.rb
|
196
200
|
- app/helpers/cookbook_version_helper.rb
|
197
|
-
- app/models/sandbox_file.rb
|
198
|
-
- public/images/avatar.png
|
199
201
|
- public/images/indicator.gif
|
200
202
|
- public/images/merb.jpg
|
203
|
+
- public/images/avatar.png
|
201
204
|
- public/stylesheets/base.css
|
202
205
|
- public/stylesheets/chef.css
|
203
|
-
- public/stylesheets/themes/default/style.css
|
204
206
|
- public/stylesheets/themes/kathleene/style.css
|
205
|
-
- public/stylesheets/themes/djime-cerulean/style.css
|
206
207
|
- public/stylesheets/themes/blue/style.css
|
207
|
-
- public/stylesheets/themes/
|
208
|
-
- public/stylesheets/themes/reidb-greenish/style.css
|
208
|
+
- public/stylesheets/themes/djime-cerulean/style.css
|
209
209
|
- public/stylesheets/themes/orange/style.css
|
210
|
+
- public/stylesheets/themes/default/style.css
|
211
|
+
- public/stylesheets/themes/reidb-greenish/style.css
|
212
|
+
- public/stylesheets/themes/bec-green/style.css
|
210
213
|
- public/stylesheets/themes/bec/style.css
|
211
214
|
- bin/chef-server
|
212
215
|
- config.ru
|
@@ -231,12 +234,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
235
|
none: false
|
233
236
|
requirements:
|
234
|
-
- - "
|
237
|
+
- - ">"
|
235
238
|
- !ruby/object:Gem::Version
|
236
|
-
hash:
|
239
|
+
hash: 25
|
237
240
|
segments:
|
238
|
-
-
|
239
|
-
|
241
|
+
- 1
|
242
|
+
- 3
|
243
|
+
- 1
|
244
|
+
version: 1.3.1
|
240
245
|
requirements: []
|
241
246
|
|
242
247
|
rubyforge_project:
|