chef-zero 4.8.0 → 4.9.0
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.
- checksums.yaml +4 -4
- data/Gemfile +8 -4
- data/Rakefile +20 -10
- data/bin/chef-zero +12 -12
- data/chef-zero.gemspec +24 -24
- data/lib/chef_zero.rb +1 -1
- data/lib/chef_zero/chef_data/acl_path.rb +16 -16
- data/lib/chef_zero/chef_data/cookbook_data.rb +24 -24
- data/lib/chef_zero/chef_data/data_normalizer.rb +120 -120
- data/lib/chef_zero/chef_data/default_creator.rb +145 -145
- data/lib/chef_zero/data_store/data_already_exists_error.rb +1 -1
- data/lib/chef_zero/data_store/data_not_found_error.rb +2 -2
- data/lib/chef_zero/data_store/default_facade.rb +5 -5
- data/lib/chef_zero/data_store/interface_v1.rb +1 -1
- data/lib/chef_zero/data_store/interface_v2.rb +1 -1
- data/lib/chef_zero/data_store/memory_store.rb +4 -4
- data/lib/chef_zero/data_store/memory_store_v2.rb +8 -8
- data/lib/chef_zero/data_store/raw_file_store.rb +10 -10
- data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +9 -9
- data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +5 -5
- data/lib/chef_zero/endpoints/acl_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/acls_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/actor_default_key_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/actor_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/actor_key_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/actor_keys_endpoint.rb +5 -6
- data/lib/chef_zero/endpoints/actors_endpoint.rb +12 -12
- data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +10 -10
- data/lib/chef_zero/endpoints/container_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/containers_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/cookbook_artifacts_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/cookbook_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +20 -16
- data/lib/chef_zero/endpoints/cookbooks_base.rb +13 -13
- data/lib/chef_zero/endpoints/cookbooks_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/data_bag_endpoint.rb +12 -12
- data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/data_bags_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/dummy_endpoint.rb +0 -2
- data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/environment_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/environment_role_endpoint.rb +8 -8
- data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/group_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/groups_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/license_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/node_endpoint.rb +3 -4
- data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +7 -7
- data/lib/chef_zero/endpoints/nodes_endpoint.rb +3 -4
- data/lib/chef_zero/endpoints/not_found_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +8 -8
- data/lib/chef_zero/endpoints/organization_endpoint.rb +10 -10
- data/lib/chef_zero/endpoints/organization_user_base.rb +2 -2
- data/lib/chef_zero/endpoints/organization_user_default_key_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/organization_user_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/organization_user_key_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/organization_user_keys_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/organization_users_endpoint.rb +12 -12
- data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/organizations_endpoint.rb +12 -13
- data/lib/chef_zero/endpoints/policies_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/policy_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/policy_group_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/policy_group_policy_endpoint.rb +3 -4
- data/lib/chef_zero/endpoints/policy_groups_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/policy_revision_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/policy_revisions_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/principal_endpoint.rb +15 -15
- data/lib/chef_zero/endpoints/rest_list_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/rest_object_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/role_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/role_environments_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/sandbox_endpoint.rb +8 -8
- data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +9 -9
- data/lib/chef_zero/endpoints/search_endpoint.rb +51 -49
- data/lib/chef_zero/endpoints/searches_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +8 -8
- data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +12 -12
- data/lib/chef_zero/endpoints/user_association_requests_count_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/user_association_requests_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/version_endpoint.rb +1 -1
- data/lib/chef_zero/log.rb +1 -1
- data/lib/chef_zero/rest_base.rb +25 -25
- data/lib/chef_zero/rest_request.rb +11 -11
- data/lib/chef_zero/rest_router.rb +30 -30
- data/lib/chef_zero/rspec.rb +33 -33
- data/lib/chef_zero/server.rb +188 -189
- data/lib/chef_zero/socketless_server_map.rb +2 -3
- data/lib/chef_zero/solr/query/binary_operator.rb +8 -8
- data/lib/chef_zero/solr/query/phrase.rb +1 -1
- data/lib/chef_zero/solr/query/range_query.rb +2 -2
- data/lib/chef_zero/solr/query/regexpable_query.rb +1 -0
- data/lib/chef_zero/solr/query/term.rb +5 -5
- data/lib/chef_zero/solr/query/unary_operator.rb +4 -4
- data/lib/chef_zero/solr/solr_doc.rb +4 -4
- data/lib/chef_zero/solr/solr_parser.rb +34 -33
- data/lib/chef_zero/version.rb +1 -1
- data/spec/run_oc_pedant.rb +61 -60
- data/spec/search_spec.rb +11 -11
- data/spec/server_spec.rb +35 -35
- data/spec/socketless_server_map_spec.rb +1 -3
- data/spec/support/oc_pedant.rb +20 -21
- metadata +2 -2
@@ -18,13 +18,13 @@ module ChefZero
|
|
18
18
|
|
19
19
|
def matches_doc?(doc)
|
20
20
|
case @operator
|
21
|
-
when
|
21
|
+
when "AND"
|
22
22
|
left.matches_doc?(doc) && right.matches_doc?(doc)
|
23
|
-
when
|
23
|
+
when "OR"
|
24
24
|
left.matches_doc?(doc) || right.matches_doc?(doc)
|
25
|
-
when
|
25
|
+
when "^"
|
26
26
|
left.matches_doc?(doc)
|
27
|
-
when
|
27
|
+
when ":"
|
28
28
|
if left.respond_to?(:literal_string) && left.literal_string
|
29
29
|
values = doc[left.literal_string]
|
30
30
|
else
|
@@ -36,13 +36,13 @@ module ChefZero
|
|
36
36
|
|
37
37
|
def matches_values?(values)
|
38
38
|
case @operator
|
39
|
-
when
|
39
|
+
when "AND"
|
40
40
|
left.matches_values?(values) && right.matches_values?(values)
|
41
|
-
when
|
41
|
+
when "OR"
|
42
42
|
left.matches_values?(values) || right.matches_values?(values)
|
43
|
-
when
|
43
|
+
when "^"
|
44
44
|
left.matches_values?(values)
|
45
|
-
when
|
45
|
+
when ":"
|
46
46
|
raise ": does not work inside a : or term"
|
47
47
|
end
|
48
48
|
end
|
@@ -15,7 +15,7 @@ module ChefZero
|
|
15
15
|
|
16
16
|
def matches_values?(values)
|
17
17
|
values.any? do |value|
|
18
|
-
unless @from ==
|
18
|
+
unless @from == "*"
|
19
19
|
case @from <=> value
|
20
20
|
when -1
|
21
21
|
return false
|
@@ -23,7 +23,7 @@ module ChefZero
|
|
23
23
|
return false if !@from_inclusive
|
24
24
|
end
|
25
25
|
end
|
26
|
-
unless @to ==
|
26
|
+
unless @to == "*"
|
27
27
|
case value <=> @to
|
28
28
|
when 1
|
29
29
|
return false
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef_zero/solr/query/regexpable_query"
|
2
2
|
|
3
3
|
module ChefZero
|
4
4
|
module Solr
|
@@ -11,19 +11,19 @@ module ChefZero
|
|
11
11
|
regexp_string = ""
|
12
12
|
index = 0
|
13
13
|
while index < term.length
|
14
|
-
if term[index] ==
|
14
|
+
if term[index] == "*"
|
15
15
|
regexp_string << "#{WORD_CHARACTER}*"
|
16
16
|
literal_string = nil
|
17
17
|
index += 1
|
18
|
-
elsif term[index] ==
|
18
|
+
elsif term[index] == "?"
|
19
19
|
regexp_string << WORD_CHARACTER
|
20
20
|
literal_string = nil
|
21
21
|
index += 1
|
22
|
-
elsif term[index] ==
|
22
|
+
elsif term[index] == "~"
|
23
23
|
raise "~ unsupported"
|
24
24
|
else
|
25
25
|
if term[index] == '\\'
|
26
|
-
index = index+1
|
26
|
+
index = index + 1
|
27
27
|
if index >= term.length
|
28
28
|
raise "Backslash at end of string '#{term}'"
|
29
29
|
end
|
@@ -16,9 +16,9 @@ module ChefZero
|
|
16
16
|
|
17
17
|
def matches_doc?(doc)
|
18
18
|
case @operator
|
19
|
-
when
|
19
|
+
when "-", "NOT"
|
20
20
|
!operand.matches_doc?(doc)
|
21
|
-
when
|
21
|
+
when "+"
|
22
22
|
# TODO This operator uses relevance to eliminate other, unrelated
|
23
23
|
# expressions. +a OR b means "if it has b but not a, don't return it"
|
24
24
|
raise "+ not supported yet, because it is hard."
|
@@ -27,9 +27,9 @@ module ChefZero
|
|
27
27
|
|
28
28
|
def matches_values?(values)
|
29
29
|
case @operator
|
30
|
-
when
|
30
|
+
when "-", "NOT"
|
31
31
|
!operand.matches_values?(values)
|
32
|
-
when
|
32
|
+
when "+"
|
33
33
|
# TODO This operator uses relevance to eliminate other, unrelated
|
34
34
|
# expressions. +a OR b means "if it has b but not a, don't return it"
|
35
35
|
raise "+ not supported yet, because it is hard."
|
@@ -15,12 +15,12 @@ module ChefZero
|
|
15
15
|
def matching_values(&block)
|
16
16
|
result = []
|
17
17
|
key_values(nil, @json) do |key, value|
|
18
|
-
if
|
18
|
+
if yield(key)
|
19
19
|
result << value.to_s
|
20
20
|
end
|
21
21
|
end
|
22
22
|
# Handle manufactured value(s)
|
23
|
-
if
|
23
|
+
if yield("X_CHEF_id_CHEF_X")
|
24
24
|
result << @id.to_s
|
25
25
|
end
|
26
26
|
|
@@ -32,7 +32,7 @@ module ChefZero
|
|
32
32
|
def key_values(key_so_far, value, &block)
|
33
33
|
if value.is_a?(Hash)
|
34
34
|
value.each_pair do |child_key, child_value|
|
35
|
-
|
35
|
+
yield(child_key, child_value.to_s)
|
36
36
|
if key_so_far
|
37
37
|
new_key = "#{key_so_far}_#{child_key}"
|
38
38
|
key_values(new_key, child_value, &block)
|
@@ -45,7 +45,7 @@ module ChefZero
|
|
45
45
|
key_values(key_so_far, child_value, &block)
|
46
46
|
end
|
47
47
|
else
|
48
|
-
|
48
|
+
yield(key_so_far || "text", value.to_s)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require "chef_zero/solr/query/binary_operator"
|
2
|
+
require "chef_zero/solr/query/unary_operator"
|
3
|
+
require "chef_zero/solr/query/term"
|
4
|
+
require "chef_zero/solr/query/phrase"
|
5
|
+
require "chef_zero/solr/query/range_query"
|
6
|
+
require "chef_zero/solr/query/subquery"
|
7
7
|
|
8
8
|
module ChefZero
|
9
9
|
module Solr
|
@@ -40,19 +40,20 @@ module ChefZero
|
|
40
40
|
# Operators
|
41
41
|
operator = peek_operator_token
|
42
42
|
if operator
|
43
|
-
@index+=operator.length
|
43
|
+
@index += operator.length
|
44
44
|
operator
|
45
45
|
else
|
46
46
|
# Everything that isn't whitespace or an operator, is part of a term
|
47
47
|
# (characters plus backslashed escaped characters)
|
48
48
|
start_index = @index
|
49
|
-
|
49
|
+
loop do
|
50
50
|
if @query_string[@index] == '\\'
|
51
|
-
@index+=1
|
51
|
+
@index += 1
|
52
52
|
end
|
53
|
-
@index+=1 if !eof?
|
54
|
-
|
55
|
-
|
53
|
+
@index += 1 if !eof?
|
54
|
+
break if eof? || !peek_term_token
|
55
|
+
end
|
56
|
+
@query_string[start_index..@index - 1]
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
@@ -66,15 +67,15 @@ module ChefZero
|
|
66
67
|
def peek_term_token
|
67
68
|
return nil if @query_string[@index] =~ /\s/
|
68
69
|
op = peek_operator_token
|
69
|
-
return !op || op ==
|
70
|
+
return !op || op == "-"
|
70
71
|
end
|
71
72
|
|
72
73
|
def peek_operator_token
|
73
|
-
if ['"',
|
74
|
+
if ['"', "+", "-", "!", "(", ")", "{", "}", "[", "]", "^", ":"].include?(@query_string[@index])
|
74
75
|
return @query_string[@index]
|
75
76
|
else
|
76
|
-
result = @query_string[@index..@index+1]
|
77
|
-
if [
|
77
|
+
result = @query_string[@index..@index + 1]
|
78
|
+
if ["&&", "||"].include?(result)
|
78
79
|
return result
|
79
80
|
end
|
80
81
|
end
|
@@ -91,19 +92,19 @@ module ChefZero
|
|
91
92
|
# Expression is over when we hit a close paren or eof
|
92
93
|
# (peek_token has the side effect of skipping whitespace for us, so we
|
93
94
|
# really know if we're at eof or not)
|
94
|
-
until peek_token ==
|
95
|
+
until peek_token == ")" || eof?
|
95
96
|
operator = peek_token
|
96
97
|
if binary_operator?(operator)
|
97
98
|
next_token
|
98
99
|
else
|
99
100
|
# If 2 terms are next to each other, the default operator is OR
|
100
|
-
operator =
|
101
|
+
operator = "OR"
|
101
102
|
end
|
102
103
|
next_expression = read_single_expression
|
103
104
|
|
104
105
|
# Build the operator, taking precedence into account
|
105
106
|
if result.is_a?(Query::BinaryOperator) &&
|
106
|
-
|
107
|
+
binary_operator_precedence(operator) > binary_operator_precedence(result.operator)
|
107
108
|
# a+b*c -> a+(b*c)
|
108
109
|
new_right = Query::BinaryOperator.new(result.right, operator, next_expression)
|
109
110
|
result = Query::BinaryOperator.new(result.left, result.operator, new_right)
|
@@ -142,7 +143,7 @@ module ChefZero
|
|
142
143
|
Query::Phrase.new(phrase_terms)
|
143
144
|
|
144
145
|
# If it's the start of a range query, build that
|
145
|
-
elsif token ==
|
146
|
+
elsif token == "{" || token == "["
|
146
147
|
left = next_token
|
147
148
|
parse_error(left, "Expected left term in range query") if !left
|
148
149
|
to = next_token
|
@@ -150,17 +151,17 @@ module ChefZero
|
|
150
151
|
right = next_token
|
151
152
|
parse_error(right, "Expected left term in range query") if !right
|
152
153
|
end_range = next_token
|
153
|
-
parse_error(right, "Expected end range '#{end_range}") if ![
|
154
|
-
Query::RangeQuery.new(left, right, token ==
|
154
|
+
parse_error(right, "Expected end range '#{end_range}") if !["}", "]"].include?(end_range)
|
155
|
+
Query::RangeQuery.new(left, right, token == "[", end_range == "]")
|
155
156
|
|
156
|
-
elsif token ==
|
157
|
+
elsif token == "("
|
157
158
|
subquery = read_expression
|
158
159
|
close_paren = next_token
|
159
|
-
parse_error(close_paren, "Expected ')'") if close_paren !=
|
160
|
+
parse_error(close_paren, "Expected ')'") if close_paren != ")"
|
160
161
|
Query::Subquery.new(subquery)
|
161
162
|
|
162
163
|
# If it's the end of a closure, raise an exception
|
163
|
-
elsif [
|
164
|
+
elsif ["}", "]", ")"].include?(token)
|
164
165
|
parse_error(token, "Unexpected end paren")
|
165
166
|
|
166
167
|
# If it's a binary operator, raise an exception
|
@@ -170,7 +171,7 @@ module ChefZero
|
|
170
171
|
# Otherwise it's a term.
|
171
172
|
else
|
172
173
|
term = Query::Term.new(token)
|
173
|
-
if peek_token ==
|
174
|
+
if peek_token == ":"
|
174
175
|
Query::BinaryOperator.new(term, next_token, read_single_expression)
|
175
176
|
else
|
176
177
|
term
|
@@ -179,27 +180,27 @@ module ChefZero
|
|
179
180
|
end
|
180
181
|
|
181
182
|
def unary_operator?(token)
|
182
|
-
[
|
183
|
+
[ "NOT", "+", "-" ].include?(token)
|
183
184
|
end
|
184
185
|
|
185
186
|
def binary_operator?(token)
|
186
|
-
[
|
187
|
+
[ "AND", "OR", "^", ":"].include?(token)
|
187
188
|
end
|
188
189
|
|
189
190
|
def binary_operator_precedence(token)
|
190
191
|
case token
|
191
|
-
when
|
192
|
+
when "^"
|
192
193
|
4
|
193
|
-
when
|
194
|
+
when ":"
|
194
195
|
3
|
195
|
-
when
|
196
|
+
when "AND"
|
196
197
|
2
|
197
|
-
when
|
198
|
+
when "OR"
|
198
199
|
1
|
199
200
|
end
|
200
201
|
end
|
201
202
|
|
202
|
-
DEFAULT_FIELD =
|
203
|
+
DEFAULT_FIELD = "text"
|
203
204
|
end
|
204
205
|
end
|
205
206
|
end
|
data/lib/chef_zero/version.rb
CHANGED
data/spec/run_oc_pedant.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "bundler"
|
3
|
+
require "bundler/setup"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require "chef_zero/server"
|
6
|
+
require "rspec/core"
|
7
7
|
|
8
8
|
# This file runs oc-chef-pedant specs and is invoked by `rake pedant`
|
9
9
|
# and other Rake tasks. Run `rake -T` to list tasks.
|
@@ -29,56 +29,56 @@ DEFAULT_SERVER_OPTIONS = {
|
|
29
29
|
DEFAULT_LOG_LEVEL = :warn
|
30
30
|
|
31
31
|
def log_level
|
32
|
-
return ENV[
|
33
|
-
return :debug if ENV[
|
32
|
+
return ENV["LOG_LEVEL"].downcase.to_sym if ENV["LOG_LEVEL"]
|
33
|
+
return :debug if ENV["DEBUG"]
|
34
34
|
DEFAULT_LOG_LEVEL
|
35
35
|
end
|
36
36
|
|
37
|
-
def start_chef_server(opts={})
|
37
|
+
def start_chef_server(opts = {})
|
38
38
|
opts = DEFAULT_SERVER_OPTIONS.merge(opts)
|
39
39
|
opts[:log_level] = log_level
|
40
40
|
|
41
|
-
ChefZero::Server.new(opts).tap {|server| server.start_background }
|
41
|
+
ChefZero::Server.new(opts).tap { |server| server.start_background }
|
42
42
|
end
|
43
43
|
|
44
44
|
def start_cheffs_server(chef_repo_path)
|
45
|
-
require
|
46
|
-
require
|
47
|
-
require
|
48
|
-
require
|
49
|
-
require
|
45
|
+
require "chef/version"
|
46
|
+
require "chef/config"
|
47
|
+
require "chef/chef_fs/config"
|
48
|
+
require "chef/chef_fs/chef_fs_data_store"
|
49
|
+
require "chef_zero/server"
|
50
50
|
|
51
51
|
Dir.mkdir(chef_repo_path) if !File.exists?(chef_repo_path)
|
52
52
|
|
53
53
|
# 11.6 and below had a bug where it couldn't create the repo children automatically
|
54
54
|
if Chef::VERSION.to_f < 11.8
|
55
|
-
%w
|
55
|
+
%w{clients cookbooks data_bags environments nodes roles users}.each do |child|
|
56
56
|
Dir.mkdir("#{chef_repo_path}/#{child}") if !File.exists?("#{chef_repo_path}/#{child}")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
# Start the new server
|
61
|
-
Chef::Config.repo_mode =
|
61
|
+
Chef::Config.repo_mode = "hosted_everything"
|
62
62
|
Chef::Config.chef_repo_path = chef_repo_path
|
63
63
|
Chef::Config.versioned_cookbooks = true
|
64
64
|
chef_fs_config = Chef::ChefFS::Config.new
|
65
65
|
|
66
66
|
data_store = Chef::ChefFS::ChefFSDataStore.new(chef_fs_config.local_fs, chef_fs_config.chef_config)
|
67
|
-
data_store = ChefZero::DataStore::V1ToV2Adapter.new(data_store,
|
68
|
-
data_store = ChefZero::DataStore::DefaultFacade.new(data_store,
|
69
|
-
data_store.create(%w
|
70
|
-
data_store.set(%w
|
71
|
-
data_store.set(%w
|
67
|
+
data_store = ChefZero::DataStore::V1ToV2Adapter.new(data_store, "pedant-testorg")
|
68
|
+
data_store = ChefZero::DataStore::DefaultFacade.new(data_store, "pedant-testorg", false)
|
69
|
+
data_store.create(%w{organizations pedant-testorg users}, "pivotal", "{}")
|
70
|
+
data_store.set(%w{organizations pedant-testorg groups admins}, '{ "users": [ "pivotal" ] }')
|
71
|
+
data_store.set(%w{organizations pedant-testorg groups users}, '{ "users": [ "pivotal" ] }')
|
72
72
|
|
73
73
|
start_chef_server(data_store: data_store)
|
74
74
|
end
|
75
75
|
|
76
76
|
def pedant_args_from_env
|
77
|
-
args_from_env(
|
77
|
+
args_from_env("PEDANT_OPTS")
|
78
78
|
end
|
79
79
|
|
80
80
|
def rspec_args_from_env
|
81
|
-
args_from_env(
|
81
|
+
args_from_env("RSPEC_OPTS")
|
82
82
|
end
|
83
83
|
|
84
84
|
def args_from_env(key)
|
@@ -89,17 +89,17 @@ end
|
|
89
89
|
begin
|
90
90
|
tmpdir = nil
|
91
91
|
server =
|
92
|
-
if ENV[
|
93
|
-
require
|
94
|
-
require
|
92
|
+
if ENV["FILE_STORE"]
|
93
|
+
require "tmpdir"
|
94
|
+
require "chef_zero/data_store/raw_file_store"
|
95
95
|
tmpdir = Dir.mktmpdir
|
96
96
|
data_store = ChefZero::DataStore::RawFileStore.new(tmpdir, true)
|
97
97
|
data_store = ChefZero::DataStore::DefaultFacade.new(data_store, false, false)
|
98
98
|
|
99
99
|
start_chef_server(data_store: data_store)
|
100
100
|
|
101
|
-
elsif ENV[
|
102
|
-
require
|
101
|
+
elsif ENV["CHEF_FS"]
|
102
|
+
require "tmpdir"
|
103
103
|
tmpdir = Dir.mktmpdir
|
104
104
|
start_cheffs_server(tmpdir)
|
105
105
|
|
@@ -107,42 +107,43 @@ begin
|
|
107
107
|
start_chef_server
|
108
108
|
end
|
109
109
|
|
110
|
-
require
|
111
|
-
require
|
112
|
-
require
|
110
|
+
require "rspec/core"
|
111
|
+
require "pedant"
|
112
|
+
require "pedant/organization"
|
113
113
|
|
114
114
|
# Pedant::Config.rerun = true
|
115
115
|
|
116
|
-
Pedant.config.suite =
|
116
|
+
Pedant.config.suite = "api"
|
117
117
|
|
118
|
-
Pedant.config[:config_file] =
|
118
|
+
Pedant.config[:config_file] = "spec/support/oc_pedant.rb"
|
119
119
|
|
120
120
|
# Because ChefFS can only ever have one user (pivotal), we can't do most of the
|
121
121
|
# tests that involve multiple
|
122
|
-
chef_fs_skips = if ENV[
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
# The latest released Chef doesn't do ACLs, Cookbook Artifacts or Policies yet
|
139
|
-
chef_fs_skips << '--skip-acl'
|
140
|
-
chef_fs_skips << '--skip-cookbook-artifacts'
|
141
|
-
chef_fs_skips << '--skip-policies'
|
122
|
+
chef_fs_skips = if ENV["CHEF_FS"]
|
123
|
+
[ "--skip-association",
|
124
|
+
"--skip-users",
|
125
|
+
"--skip-organizations",
|
126
|
+
"--skip-multiuser",
|
127
|
+
"--skip-user-keys",
|
128
|
+
|
129
|
+
# chef-zero has some non-removable quirks, such as the fact that files
|
130
|
+
# with 255-character names cannot be stored in local mode. This is
|
131
|
+
# reserved only for quirks that are *irrevocable* and by design; and
|
132
|
+
# should barely be used at all.
|
133
|
+
"--skip-chef-zero-quirks",
|
134
|
+
]
|
135
|
+
else
|
136
|
+
[]
|
137
|
+
end
|
142
138
|
|
143
|
-
# Multi-keys don't work prior to 12.8
|
144
139
|
unless Gem::Requirement.new(">= 12.8.0").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
145
|
-
chef_fs_skips <<
|
140
|
+
chef_fs_skips << "--skip-keys"
|
141
|
+
end
|
142
|
+
|
143
|
+
unless Gem::Requirement.new(">= 12.13.19").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
144
|
+
chef_fs_skips << "--skip-acl"
|
145
|
+
chef_fs_skips << "--skip-cookbook-artifacts"
|
146
|
+
chef_fs_skips << "--skip-policies"
|
146
147
|
end
|
147
148
|
|
148
149
|
# These things aren't supported by Chef Zero in any mode of operation:
|
@@ -153,30 +154,30 @@ begin
|
|
153
154
|
# ...but we're not there yet
|
154
155
|
|
155
156
|
# Chef Zero does not intend to support validation the way erchef does.
|
156
|
-
|
157
|
+
"--skip-validation",
|
157
158
|
|
158
159
|
# Chef Zero does not intend to support authentication the way erchef does.
|
159
|
-
|
160
|
+
"--skip-authentication",
|
160
161
|
|
161
162
|
# Chef Zero does not intend to support authorization the way erchef does.
|
162
|
-
|
163
|
+
"--skip-authorization",
|
163
164
|
|
164
165
|
# Omnibus tests depend on erchef features that are specific to erchef and
|
165
166
|
# bundled in the omnibus package. Currently the only test in this category
|
166
167
|
# is for the search reindexing script.
|
167
|
-
|
168
|
+
"--skip-omnibus",
|
168
169
|
|
169
170
|
# USAGs (user-specific association groups) are Authz groups that contain
|
170
171
|
# only one user and represent that user's association with an org. Though
|
171
172
|
# there are good reasons for them, they don't work well in practice and
|
172
173
|
# only the manage console really uses them. Since Chef Zero + Manage is a
|
173
174
|
# quite unusual configuration, we're ignoring them.
|
174
|
-
|
175
|
+
"--skip-usags",
|
175
176
|
|
176
177
|
# Chef 12 features not yet 100% supported by Chef Zero
|
177
178
|
|
178
179
|
# The universe endpoint is unlikely to ever make sense for Chef Zero
|
179
|
-
|
180
|
+
"--skip-universe",
|
180
181
|
]
|
181
182
|
|
182
183
|
# The knife tests are very slow and don't give us a lot of extra coverage,
|