chef-zero 14.0.6 → 14.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +9 -1
- data/Rakefile +11 -14
- data/chef-zero.gemspec +4 -8
- data/lib/chef_zero.rb +3 -3
- data/lib/chef_zero/chef_data/acl_path.rb +2 -2
- data/lib/chef_zero/chef_data/cookbook_data.rb +6 -6
- data/lib/chef_zero/chef_data/data_normalizer.rb +4 -4
- data/lib/chef_zero/chef_data/default_creator.rb +4 -4
- data/lib/chef_zero/data_store/default_facade.rb +1 -1
- data/lib/chef_zero/data_store/memory_store_v2.rb +5 -5
- data/lib/chef_zero/data_store/raw_file_store.rb +2 -2
- data/lib/chef_zero/endpoints/acl_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/actor_keys_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/container_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/data_bags_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/environment_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/group_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/node_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/nodes_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/not_found_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/organization_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/organization_users_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/organizations_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/rest_list_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/rest_object_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/role_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/sandbox_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +9 -9
- data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +1 -1
- data/lib/chef_zero/rest_base.rb +4 -4
- data/lib/chef_zero/rspec.rb +3 -3
- data/lib/chef_zero/server.rb +19 -19
- data/lib/chef_zero/solr/query/range_query.rb +1 -1
- data/lib/chef_zero/solr/query/regexpable_query.rb +3 -3
- data/lib/chef_zero/solr/solr_parser.rb +1 -1
- data/lib/chef_zero/version.rb +1 -1
- data/spec/server_spec.rb +4 -4
- data/spec/support/oc_pedant.rb +32 -32
- metadata +8 -45
- data/README.md +0 -168
@@ -9,9 +9,9 @@ module ChefZero
|
|
9
9
|
def get(request)
|
10
10
|
if get_data(request, request.rest_path[0..3])
|
11
11
|
result = {
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
12
|
+
id: UUIDTools::UUID.parse_raw(request.rest_path[0..4].to_s).to_s.delete("-"),
|
13
|
+
authz_id: "0" * 32,
|
14
|
+
org_id: UUIDTools::UUID.parse_raw(request.rest_path[0..1].to_s).to_s.delete("-") }
|
15
15
|
json_response(200, result)
|
16
16
|
else
|
17
17
|
raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
|
@@ -12,12 +12,12 @@ module ChefZero
|
|
12
12
|
if request.rest_path.last == "nodes"
|
13
13
|
data = parse_json(request.body)
|
14
14
|
|
15
|
-
if data.
|
16
|
-
return error(400, "Field 'policy_name' invalid", :
|
15
|
+
if data.key?("policy_name") && policy_name_invalid?(data["policy_name"])
|
16
|
+
return error(400, "Field 'policy_name' invalid", pretty: false)
|
17
17
|
end
|
18
18
|
|
19
|
-
if data.
|
20
|
-
return error(400, "Field 'policy_group' invalid", :
|
19
|
+
if data.key?("policy_group") && policy_name_invalid?(data["policy_group"])
|
20
|
+
return error(400, "Field 'policy_group' invalid", pretty: false)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -27,7 +27,7 @@ module ChefZero
|
|
27
27
|
def populate_defaults(request, response_json)
|
28
28
|
node = FFI_Yajl::Parser.parse(response_json)
|
29
29
|
node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3])
|
30
|
-
FFI_Yajl::Encoder.encode(node, :
|
30
|
+
FFI_Yajl::Encoder.encode(node, pretty: true)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -4,7 +4,7 @@ module ChefZero
|
|
4
4
|
module Endpoints
|
5
5
|
class NotFoundEndpoint
|
6
6
|
def call(request)
|
7
|
-
[404, { "Content-Type" => "application/json" }, FFI_Yajl::Encoder.encode({ "error" => ["Object not found: #{request.env['REQUEST_PATH']}"] }, :
|
7
|
+
[404, { "Content-Type" => "application/json" }, FFI_Yajl::Encoder.encode({ "error" => ["Object not found: #{request.env['REQUEST_PATH']}"] }, pretty: true)]
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -16,14 +16,14 @@ module ChefZero
|
|
16
16
|
new_org.each do |key, value|
|
17
17
|
org[key] = value
|
18
18
|
end
|
19
|
-
save_org = FFI_Yajl::Encoder.encode(org, :
|
19
|
+
save_org = FFI_Yajl::Encoder.encode(org, pretty: true)
|
20
20
|
if new_org["name"] != request.rest_path[-1]
|
21
21
|
# This is a rename
|
22
22
|
return error(400, "Cannot rename org #{request.rest_path[-1]} to #{new_org['name']}: rename not supported for orgs")
|
23
23
|
end
|
24
24
|
set_data(request, request.rest_path + [ "org" ], save_org)
|
25
25
|
json_response(200, {
|
26
|
-
"uri" =>
|
26
|
+
"uri" => (build_uri(request.base_uri, request.rest_path)).to_s,
|
27
27
|
"name" => org["name"],
|
28
28
|
"org_type" => org["org_type"],
|
29
29
|
"full_name" => org["full_name"],
|
@@ -39,7 +39,7 @@ module ChefZero
|
|
39
39
|
def populate_defaults(request, response_json)
|
40
40
|
org = FFI_Yajl::Parser.parse(response_json)
|
41
41
|
org = ChefData::DataNormalizer.normalize_organization(org, request.rest_path[1])
|
42
|
-
FFI_Yajl::Encoder.encode(org, :
|
42
|
+
FFI_Yajl::Encoder.encode(org, pretty: true)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -30,7 +30,7 @@ module ChefZero
|
|
30
30
|
if !users["users"] || !users["users"].include?(username)
|
31
31
|
users["users"] ||= []
|
32
32
|
users["users"] |= [ username ]
|
33
|
-
set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, :
|
33
|
+
set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, pretty: true))
|
34
34
|
end
|
35
35
|
json_response(201, { "uri" => build_uri(request.base_uri, request.rest_path + [ username ]) })
|
36
36
|
end
|
@@ -12,7 +12,7 @@ module ChefZero
|
|
12
12
|
validator = FFI_Yajl::Parser.parse(get_data(request, validator_path))
|
13
13
|
private_key, public_key = server.gen_key_pair
|
14
14
|
validator["public_key"] = public_key
|
15
|
-
set_data(request, validator_path, FFI_Yajl::Encoder.encode(validator, :
|
15
|
+
set_data(request, validator_path, FFI_Yajl::Encoder.encode(validator, pretty: true))
|
16
16
|
json_response(200, { "private_key" => private_key })
|
17
17
|
end
|
18
18
|
end
|
@@ -25,14 +25,14 @@ module ChefZero
|
|
25
25
|
elsif exists_data_dir?(request, request.rest_path + [ name ])
|
26
26
|
error(409, "Organization already exists")
|
27
27
|
else
|
28
|
-
create_data_dir(request, request.rest_path, name, :
|
28
|
+
create_data_dir(request, request.rest_path, name, requestor: request.requestor)
|
29
29
|
|
30
30
|
org = {
|
31
31
|
"guid" => UUIDTools::UUID.random_create.to_s.delete("-"),
|
32
32
|
"assigned_at" => Time.now.to_s,
|
33
33
|
}.merge(contents)
|
34
34
|
org_path = request.rest_path + [ name ]
|
35
|
-
set_data(request, org_path + [ "org" ], FFI_Yajl::Encoder.encode(org, :
|
35
|
+
set_data(request, org_path + [ "org" ], FFI_Yajl::Encoder.encode(org, pretty: true))
|
36
36
|
|
37
37
|
if server.generate_real_keys?
|
38
38
|
# Create the validator client
|
@@ -42,12 +42,12 @@ module ChefZero
|
|
42
42
|
validator = FFI_Yajl::Encoder.encode({
|
43
43
|
"validator" => true,
|
44
44
|
"public_key" => public_key,
|
45
|
-
}, :
|
45
|
+
}, pretty: true)
|
46
46
|
set_data(request, validator_path, validator)
|
47
47
|
end
|
48
48
|
|
49
49
|
json_response(201, {
|
50
|
-
"uri" =>
|
50
|
+
"uri" => (build_uri(request.base_uri, org_path)).to_s,
|
51
51
|
"name" => name,
|
52
52
|
"org_type" => org["org_type"],
|
53
53
|
"full_name" => full_name,
|
@@ -17,7 +17,7 @@ module ChefZero
|
|
17
17
|
# Get the result
|
18
18
|
result_hash = {}
|
19
19
|
list_data(request).sort.each do |name|
|
20
|
-
result_hash[name] =
|
20
|
+
result_hash[name] = (build_uri(request.base_uri, request.rest_path + [name])).to_s
|
21
21
|
end
|
22
22
|
json_response(200, result_hash)
|
23
23
|
end
|
@@ -29,7 +29,7 @@ module ChefZero
|
|
29
29
|
error(400, "Must specify #{identity_keys.map { |k| k.inspect }.join(' or ')} in JSON")
|
30
30
|
else
|
31
31
|
create_data(request, request.rest_path, key, contents)
|
32
|
-
json_response(201, { "uri" =>
|
32
|
+
json_response(201, { "uri" => (build_uri(request.base_uri, request.rest_path + [key])).to_s })
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -52,7 +52,7 @@ module ChefZero
|
|
52
52
|
existing_json = FFI_Yajl::Parser.parse(existing_value)
|
53
53
|
merged_json = existing_json.merge(request_json)
|
54
54
|
if merged_json.size > request_json.size
|
55
|
-
return FFI_Yajl::Encoder.encode(merged_json, :
|
55
|
+
return FFI_Yajl::Encoder.encode(merged_json, pretty: true)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -9,7 +9,7 @@ module ChefZero
|
|
9
9
|
def populate_defaults(request, response_json)
|
10
10
|
role = FFI_Yajl::Parser.parse(response_json)
|
11
11
|
role = ChefData::DataNormalizer.normalize_role(role, request.rest_path[3])
|
12
|
-
FFI_Yajl::Encoder.encode(role, :
|
12
|
+
FFI_Yajl::Encoder.encode(role, pretty: true)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -15,11 +15,11 @@ module ChefZero
|
|
15
15
|
end
|
16
16
|
delete_data(request)
|
17
17
|
json_response(200, {
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
18
|
+
guid: request.rest_path[3],
|
19
|
+
name: request.rest_path[3],
|
20
|
+
checksums: existing_sandbox["checksums"],
|
21
|
+
create_time: existing_sandbox["create_time"],
|
22
|
+
is_completed: true,
|
23
23
|
})
|
24
24
|
end
|
25
25
|
end
|
@@ -17,11 +17,11 @@ module ChefZero
|
|
17
17
|
result_checksums = {}
|
18
18
|
needed_checksums.keys.each do |needed_checksum|
|
19
19
|
if list_data(request, request.rest_path[0..1] + %w{file_store checksums}).include?(needed_checksum)
|
20
|
-
result_checksums[needed_checksum] = { :
|
20
|
+
result_checksums[needed_checksum] = { needs_upload: false }
|
21
21
|
else
|
22
22
|
result_checksums[needed_checksum] = {
|
23
|
-
:
|
24
|
-
:
|
23
|
+
needs_upload: true,
|
24
|
+
url: build_uri(request.base_uri, request.rest_path[0..1] + ["file_store", "checksums", needed_checksum]),
|
25
25
|
}
|
26
26
|
sandbox_checksums << needed_checksum
|
27
27
|
end
|
@@ -35,14 +35,14 @@ module ChefZero
|
|
35
35
|
time_str = "#{time_str[0..21]}:#{time_str[22..23]}"
|
36
36
|
|
37
37
|
create_data(request, request.rest_path, id, FFI_Yajl::Encoder.encode({
|
38
|
-
:
|
39
|
-
:
|
40
|
-
}, :
|
38
|
+
create_time: time_str,
|
39
|
+
checksums: sandbox_checksums,
|
40
|
+
}, pretty: true))
|
41
41
|
|
42
42
|
json_response(201, {
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
43
|
+
uri: build_uri(request.base_uri, request.rest_path + [id]),
|
44
|
+
checksums: result_checksums,
|
45
|
+
sandbox_id: id,
|
46
46
|
})
|
47
47
|
end
|
48
48
|
end
|
@@ -26,7 +26,7 @@ module ChefZero
|
|
26
26
|
if !users["users"] || !users["users"].include?(username)
|
27
27
|
users["users"] ||= []
|
28
28
|
users["users"] |= [ username ]
|
29
|
-
set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, :
|
29
|
+
set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, pretty: true))
|
30
30
|
end
|
31
31
|
elsif json["response"] == "reject"
|
32
32
|
delete_data(request, association_request_path)
|
data/lib/chef_zero/rest_base.rb
CHANGED
@@ -145,7 +145,7 @@ module ChefZero
|
|
145
145
|
def set_data(request, rest_path, data, *options)
|
146
146
|
rest_path ||= request.rest_path
|
147
147
|
begin
|
148
|
-
data_store.set(rest_path, data, *options, :
|
148
|
+
data_store.set(rest_path, data, *options, requestor: request.requestor)
|
149
149
|
rescue DataStore::DataNotFoundError
|
150
150
|
if options.include?(:data_store_exceptions)
|
151
151
|
raise
|
@@ -158,7 +158,7 @@ module ChefZero
|
|
158
158
|
def create_data_dir(request, rest_path, name, *options)
|
159
159
|
rest_path ||= request.rest_path
|
160
160
|
begin
|
161
|
-
data_store.create_dir(rest_path, name, *options, :
|
161
|
+
data_store.create_dir(rest_path, name, *options, requestor: request.requestor)
|
162
162
|
rescue DataStore::DataNotFoundError
|
163
163
|
if options.include?(:data_store_exceptions)
|
164
164
|
raise
|
@@ -177,7 +177,7 @@ module ChefZero
|
|
177
177
|
def create_data(request, rest_path, name, data, *options)
|
178
178
|
rest_path ||= request.rest_path
|
179
179
|
begin
|
180
|
-
data_store.create(rest_path, name, data, *options, :
|
180
|
+
data_store.create(rest_path, name, data, *options, requestor: request.requestor)
|
181
181
|
rescue DataStore::DataNotFoundError
|
182
182
|
if options.include?(:data_store_exceptions)
|
183
183
|
raise
|
@@ -296,7 +296,7 @@ module ChefZero
|
|
296
296
|
end
|
297
297
|
|
298
298
|
def to_json(data)
|
299
|
-
FFI_Yajl::Encoder.encode(data, :
|
299
|
+
FFI_Yajl::Encoder.encode(data, pretty: true)
|
300
300
|
end
|
301
301
|
|
302
302
|
def get_data_or_else(request, path, or_else_value)
|
data/lib/chef_zero/rspec.rb
CHANGED
@@ -219,7 +219,7 @@ module ChefZero
|
|
219
219
|
with_object_path("cookbooks/#{name}") do
|
220
220
|
# If you didn't specify metadata.rb, we generate it for you. If you
|
221
221
|
# explicitly set it to nil, that means you don't want it at all.
|
222
|
-
if data.
|
222
|
+
if data.key?("metadata.rb")
|
223
223
|
if data["metadata.rb"].nil?
|
224
224
|
data.delete("metadata.rb")
|
225
225
|
end
|
@@ -235,7 +235,7 @@ module ChefZero
|
|
235
235
|
with_object_path("cookbook_artifacts/#{name}") do
|
236
236
|
# If you didn't specify metadata.rb, we generate it for you. If you
|
237
237
|
# explicitly set it to nil, that means you don't want it at all.
|
238
|
-
if data.
|
238
|
+
if data.key?("metadata.rb")
|
239
239
|
if data["metadata.rb"].nil?
|
240
240
|
data.delete("metadata.rb")
|
241
241
|
end
|
@@ -333,7 +333,7 @@ module ChefZero
|
|
333
333
|
if data.is_a?(String)
|
334
334
|
data
|
335
335
|
else
|
336
|
-
FFI_Yajl::Encoder.encode(data, :
|
336
|
+
FFI_Yajl::Encoder.encode(data, pretty: true)
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
data/lib/chef_zero/server.rb
CHANGED
@@ -112,23 +112,23 @@ module ChefZero
|
|
112
112
|
class Server
|
113
113
|
|
114
114
|
DEFAULT_OPTIONS = {
|
115
|
-
:
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
115
|
+
host: ["127.0.0.1"],
|
116
|
+
port: 8889,
|
117
|
+
log_level: :warn,
|
118
|
+
generate_real_keys: true,
|
119
|
+
single_org: "chef",
|
120
|
+
ssl: false,
|
121
121
|
}.freeze
|
122
122
|
|
123
123
|
GLOBAL_ENDPOINTS = [
|
124
124
|
"/license",
|
125
125
|
"/version",
|
126
126
|
"/server_api_version",
|
127
|
-
]
|
127
|
+
].freeze
|
128
128
|
|
129
129
|
def initialize(options = {})
|
130
130
|
@options = DEFAULT_OPTIONS.merge(options)
|
131
|
-
if @options[:single_org] && !@options.
|
131
|
+
if @options[:single_org] && !@options.key?(:osc_compat)
|
132
132
|
@options[:osc_compat] = true
|
133
133
|
end
|
134
134
|
@options.freeze
|
@@ -281,14 +281,14 @@ module ChefZero
|
|
281
281
|
|
282
282
|
def start_background(wait = 5)
|
283
283
|
@server = WEBrick::HTTPServer.new(
|
284
|
-
:
|
285
|
-
:
|
286
|
-
:
|
287
|
-
:
|
288
|
-
:
|
289
|
-
:
|
290
|
-
:
|
291
|
-
:
|
284
|
+
DoNotListen: true,
|
285
|
+
AccessLog: [],
|
286
|
+
Logger: WEBrick::Log.new(StringIO.new, 7),
|
287
|
+
RequestTimeout: 300,
|
288
|
+
SSLEnable: options[:ssl],
|
289
|
+
SSLOptions: ssl_opts,
|
290
|
+
SSLCertName: [ [ "CN", WEBrick::Utils.getservername ] ],
|
291
|
+
StartCallback: proc do
|
292
292
|
@running = true
|
293
293
|
end
|
294
294
|
)
|
@@ -484,7 +484,7 @@ module ChefZero
|
|
484
484
|
if contents["policy_groups"]
|
485
485
|
contents["policy_groups"].each_pair do |group_name, group|
|
486
486
|
group["policies"].each do |policy_name, policy_revision|
|
487
|
-
data_store.set(["organizations", org_name, "policy_groups", group_name, "policies", policy_name], FFI_Yajl::Encoder.encode(policy_revision["revision_id"], :
|
487
|
+
data_store.set(["organizations", org_name, "policy_groups", group_name, "policies", policy_name], FFI_Yajl::Encoder.encode(policy_revision["revision_id"], pretty: true), :create, :create_dir)
|
488
488
|
end
|
489
489
|
end
|
490
490
|
end
|
@@ -502,7 +502,7 @@ module ChefZero
|
|
502
502
|
end
|
503
503
|
raise "No version specified" if !cookbook_data[:version]
|
504
504
|
data_store.create_dir(["organizations", org_name, cookbook_type], cookbook_data[:cookbook_name], :recursive)
|
505
|
-
data_store.set(["organizations", org_name, cookbook_type, cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, :
|
505
|
+
data_store.set(["organizations", org_name, cookbook_type, cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, pretty: true), :create)
|
506
506
|
cookbook_data.values.each do |files|
|
507
507
|
next unless files.is_a? Array
|
508
508
|
files.each do |file|
|
@@ -699,7 +699,7 @@ module ChefZero
|
|
699
699
|
end
|
700
700
|
|
701
701
|
def dejsonize(value)
|
702
|
-
value.is_a?(Hash) ? FFI_Yajl::Encoder.encode(value, :
|
702
|
+
value.is_a?(Hash) ? FFI_Yajl::Encoder.encode(value, pretty: true) : value
|
703
703
|
end
|
704
704
|
|
705
705
|
def get_file(directory, path)
|
@@ -21,9 +21,9 @@ module ChefZero
|
|
21
21
|
values.any? { |value| !@regexp.match(value).nil? }
|
22
22
|
end
|
23
23
|
|
24
|
-
DEFAULT_FIELD = "text"
|
25
|
-
WORD_CHARACTER = "[A-Za-z0-9@._':\-]"
|
26
|
-
NON_WORD_CHARACTER = "[^A-Za-z0-9@._':\-]"
|
24
|
+
DEFAULT_FIELD = "text".freeze
|
25
|
+
WORD_CHARACTER = "[A-Za-z0-9@._':\-]".freeze
|
26
|
+
NON_WORD_CHARACTER = "[^A-Za-z0-9@._':\-]".freeze
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/chef_zero/version.rb
CHANGED
data/spec/server_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require "uri"
|
|
5
5
|
describe ChefZero::Server do
|
6
6
|
context "with a server bound to port 8889" do
|
7
7
|
before :each do
|
8
|
-
@server = ChefZero::Server.new(:
|
8
|
+
@server = ChefZero::Server.new(port: 8889)
|
9
9
|
@server.start_background
|
10
10
|
end
|
11
11
|
after :each do
|
@@ -13,18 +13,18 @@ describe ChefZero::Server do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "a second server bound to port 8889 throws EADDRINUSE" do
|
16
|
-
expect { ChefZero::Server.new(:
|
16
|
+
expect { ChefZero::Server.new(port: 8889).start }.to raise_error Errno::EADDRINUSE
|
17
17
|
end
|
18
18
|
|
19
19
|
it "a server bound to range 8889-9999 binds to a port > 8889" do
|
20
|
-
server = ChefZero::Server.new(:
|
20
|
+
server = ChefZero::Server.new(port: 8889.upto(9999))
|
21
21
|
server.start_background
|
22
22
|
expect(server.port).to be > 8889
|
23
23
|
expect(URI(server.url).port).to be > 8889
|
24
24
|
end
|
25
25
|
|
26
26
|
it "a server bound to range 8889-8889 throws an exception" do
|
27
|
-
expect { ChefZero::Server.new(:
|
27
|
+
expect { ChefZero::Server.new(port: 8889.upto(8889)).start_background }.to raise_error Errno::EADDRINUSE
|
28
28
|
end
|
29
29
|
|
30
30
|
it "has a very patient request timeout" do
|
data/spec/support/oc_pedant.rb
CHANGED
@@ -32,7 +32,7 @@ chef_server "http://127.0.0.1:8889"
|
|
32
32
|
# testing location, you should not specify a value for this parameter.
|
33
33
|
# The tests will still run, albeit slower, as they will now need to
|
34
34
|
# poll for a period to ensure they are querying committed results.
|
35
|
-
#search_server "http://localhost:8983"
|
35
|
+
# search_server "http://localhost:8983"
|
36
36
|
|
37
37
|
# Related to the 'search_server' parameter, this specifies the maximum
|
38
38
|
# amout of time (in seconds) that search endpoint requests should be
|
@@ -93,49 +93,49 @@ end
|
|
93
93
|
keyfile_maybe = ENV["CHEF_FS"] ? { key_file: key } : { key_file: nil }
|
94
94
|
|
95
95
|
requestors({
|
96
|
-
:
|
96
|
+
clients: {
|
97
97
|
# The the admin user, for the purposes of getting things rolling
|
98
|
-
:
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
98
|
+
admin: {
|
99
|
+
name: "pedant_admin_client",
|
100
|
+
create_me: true,
|
101
|
+
create_knife: true,
|
102
|
+
admin: true,
|
103
103
|
},
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:
|
104
|
+
non_admin: {
|
105
|
+
name: "pedant_client",
|
106
|
+
create_me: true,
|
107
|
+
create_knife: true,
|
108
108
|
},
|
109
|
-
:
|
110
|
-
:
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
109
|
+
bad: {
|
110
|
+
name: "bad_client",
|
111
|
+
create_me: true,
|
112
|
+
create_knife: true,
|
113
|
+
bogus: true,
|
114
114
|
},
|
115
115
|
},
|
116
116
|
|
117
|
-
:
|
117
|
+
users: {
|
118
118
|
# An administrator in the testing organization
|
119
|
-
:
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
119
|
+
admin: {
|
120
|
+
name: cheffs_or_else_user("pedant_admin_user"),
|
121
|
+
create_me: !ENV["CHEF_FS"],
|
122
|
+
associate: !ENV["CHEF_FS"],
|
123
|
+
create_knife: true,
|
124
124
|
}.merge(keyfile_maybe),
|
125
125
|
|
126
|
-
:
|
127
|
-
:
|
128
|
-
:
|
129
|
-
:
|
130
|
-
:
|
126
|
+
non_admin: {
|
127
|
+
name: cheffs_or_else_user("pedant_user"),
|
128
|
+
create_me: !ENV["CHEF_FS"],
|
129
|
+
associate: !ENV["CHEF_FS"],
|
130
|
+
create_knife: true,
|
131
131
|
}.merge(keyfile_maybe),
|
132
132
|
|
133
133
|
# A user that is not a member of the testing organization
|
134
|
-
:
|
135
|
-
:
|
136
|
-
:
|
137
|
-
:
|
138
|
-
:
|
134
|
+
bad: {
|
135
|
+
name: cheffs_or_else_user("pedant-nobody"),
|
136
|
+
create_me: !ENV["CHEF_FS"],
|
137
|
+
create_knife: true,
|
138
|
+
associate: false,
|
139
139
|
}.merge(keyfile_maybe),
|
140
140
|
},
|
141
141
|
})
|