chef-zero 15.0.17 → 15.0.21
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 +36 -31
- data/LICENSE +201 -201
- data/Rakefile +73 -68
- data/bin/chef-zero +111 -111
- data/chef-zero.gemspec +34 -33
- data/lib/chef_zero/chef_data/acl_path.rb +140 -140
- data/lib/chef_zero/chef_data/cookbook_data.rb +237 -237
- data/lib/chef_zero/chef_data/data_normalizer.rb +276 -276
- data/lib/chef_zero/chef_data/default_creator.rb +476 -476
- data/lib/chef_zero/data_store/data_already_exists_error.rb +29 -29
- data/lib/chef_zero/data_store/data_error.rb +32 -32
- data/lib/chef_zero/data_store/data_not_found_error.rb +29 -29
- data/lib/chef_zero/data_store/default_facade.rb +143 -147
- data/lib/chef_zero/data_store/interface_v1.rb +67 -67
- data/lib/chef_zero/data_store/interface_v2.rb +18 -18
- data/lib/chef_zero/data_store/memory_store.rb +33 -33
- data/lib/chef_zero/data_store/memory_store_v2.rb +159 -159
- data/lib/chef_zero/data_store/raw_file_store.rb +143 -143
- data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +150 -150
- data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +105 -105
- data/lib/chef_zero/dist.rb +9 -9
- data/lib/chef_zero/endpoints/acl_endpoint.rb +39 -39
- data/lib/chef_zero/endpoints/acls_endpoint.rb +41 -41
- data/lib/chef_zero/endpoints/actor_default_key_endpoint.rb +78 -78
- data/lib/chef_zero/endpoints/actor_endpoint.rb +184 -184
- data/lib/chef_zero/endpoints/actor_key_endpoint.rb +62 -62
- data/lib/chef_zero/endpoints/actor_keys_endpoint.rb +129 -129
- data/lib/chef_zero/endpoints/actors_endpoint.rb +104 -104
- data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +32 -32
- data/lib/chef_zero/endpoints/container_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/containers_endpoint.rb +25 -25
- data/lib/chef_zero/endpoints/controls_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb +24 -24
- data/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb +68 -68
- data/lib/chef_zero/endpoints/cookbook_artifacts_endpoint.rb +34 -34
- data/lib/chef_zero/endpoints/cookbook_endpoint.rb +39 -39
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +136 -136
- data/lib/chef_zero/endpoints/cookbooks_base.rb +80 -80
- data/lib/chef_zero/endpoints/cookbooks_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/data_bag_endpoint.rb +45 -45
- data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +25 -25
- data/lib/chef_zero/endpoints/data_bags_endpoint.rb +23 -23
- data/lib/chef_zero/endpoints/dummy_endpoint.rb +29 -29
- data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +24 -24
- data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +126 -126
- data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/environment_endpoint.rb +33 -33
- data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +23 -23
- data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/environment_role_endpoint.rb +36 -36
- data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/group_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/groups_endpoint.rb +13 -13
- data/lib/chef_zero/endpoints/license_endpoint.rb +25 -25
- data/lib/chef_zero/endpoints/node_endpoint.rb +34 -34
- data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/nodes_endpoint.rb +34 -34
- data/lib/chef_zero/endpoints/not_found_endpoint.rb +11 -11
- data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +30 -30
- data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +26 -26
- data/lib/chef_zero/endpoints/organization_endpoint.rb +47 -47
- data/lib/chef_zero/endpoints/organization_user_base.rb +15 -15
- data/lib/chef_zero/endpoints/organization_user_default_key_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/organization_user_endpoint.rb +26 -26
- data/lib/chef_zero/endpoints/organization_user_key_endpoint.rb +17 -17
- data/lib/chef_zero/endpoints/organization_user_keys_endpoint.rb +17 -17
- data/lib/chef_zero/endpoints/organization_users_endpoint.rb +43 -43
- data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/organizations_endpoint.rb +61 -61
- data/lib/chef_zero/endpoints/policies_endpoint.rb +26 -26
- data/lib/chef_zero/endpoints/policy_endpoint.rb +24 -24
- data/lib/chef_zero/endpoints/policy_group_endpoint.rb +46 -46
- data/lib/chef_zero/endpoints/policy_group_policy_endpoint.rb +83 -83
- data/lib/chef_zero/endpoints/policy_groups_endpoint.rb +38 -38
- data/lib/chef_zero/endpoints/policy_revision_endpoint.rb +66 -66
- data/lib/chef_zero/endpoints/policy_revisions_endpoint.rb +15 -15
- data/lib/chef_zero/endpoints/principal_endpoint.rb +55 -55
- data/lib/chef_zero/endpoints/rest_list_endpoint.rb +42 -42
- data/lib/chef_zero/endpoints/rest_object_endpoint.rb +78 -78
- data/lib/chef_zero/endpoints/role_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/role_environments_endpoint.rb +14 -14
- data/lib/chef_zero/endpoints/sandbox_endpoint.rb +27 -27
- data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +51 -51
- data/lib/chef_zero/endpoints/search_endpoint.rb +208 -208
- data/lib/chef_zero/endpoints/searches_endpoint.rb +18 -18
- data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +14 -14
- data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +30 -30
- data/lib/chef_zero/endpoints/universe_endpoint.rb +15 -15
- data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +41 -41
- data/lib/chef_zero/endpoints/user_association_requests_count_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/user_association_requests_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/version_endpoint.rb +13 -13
- data/lib/chef_zero/log.rb +7 -7
- data/lib/chef_zero/rest_base.rb +332 -332
- data/lib/chef_zero/rest_error_response.rb +11 -11
- data/lib/chef_zero/rest_request.rb +84 -88
- data/lib/chef_zero/rest_router.rb +72 -72
- data/lib/chef_zero/rspec.rb +355 -355
- data/lib/chef_zero/server.rb +730 -730
- data/lib/chef_zero/socketless_server_map.rb +92 -93
- data/lib/chef_zero/solr/query/binary_operator.rb +52 -52
- data/lib/chef_zero/solr/query/phrase.rb +23 -23
- data/lib/chef_zero/solr/query/range_query.rb +46 -46
- data/lib/chef_zero/solr/query/regexpable_query.rb +30 -30
- data/lib/chef_zero/solr/query/subquery.rb +37 -37
- data/lib/chef_zero/solr/query/term.rb +45 -45
- data/lib/chef_zero/solr/query/unary_operator.rb +41 -41
- data/lib/chef_zero/solr/solr_doc.rb +53 -53
- data/lib/chef_zero/solr/solr_parser.rb +208 -208
- data/lib/chef_zero/version.rb +3 -3
- data/lib/chef_zero.rb +10 -10
- data/spec/run_oc_pedant.rb +226 -226
- data/spec/search_spec.rb +36 -36
- data/spec/server_spec.rb +96 -96
- data/spec/socketless_server_map_spec.rb +74 -74
- data/spec/support/oc_pedant.rb +149 -149
- data/spec/support/secrets.json +6 -6
- data/spec/support/stickywicket.pem +27 -27
- metadata +35 -18
data/spec/run_oc_pedant.rb
CHANGED
@@ -1,226 +1,226 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require "json" unless defined?(JSON)
|
3
|
-
require "bundler"
|
4
|
-
require "bundler/setup"
|
5
|
-
|
6
|
-
require "chef_zero/server"
|
7
|
-
require "rspec/core"
|
8
|
-
|
9
|
-
# This file runs oc-chef-pedant specs and is invoked by `rake pedant`
|
10
|
-
# and other Rake tasks. Run `rake -T` to list tasks.
|
11
|
-
#
|
12
|
-
# Options for oc-chef-pedant and rspec can be specified via
|
13
|
-
# ENV['PEDANT_OPTS'] and ENV['RSPEC_OPTS'], respectively.
|
14
|
-
#
|
15
|
-
# The log level can be specified via ENV['LOG_LEVEL'].
|
16
|
-
#
|
17
|
-
# Example:
|
18
|
-
#
|
19
|
-
# $ PEDANT_OPTS="--focus-users --skip-keys" \
|
20
|
-
# > RSPEC_OPTS="--fail-fast --profile 5" \
|
21
|
-
# > LOG_LEVEL=debug \
|
22
|
-
# > rake pedant
|
23
|
-
#
|
24
|
-
|
25
|
-
DEFAULT_SERVER_OPTIONS = {
|
26
|
-
port: 8889,
|
27
|
-
single_org: false,
|
28
|
-
}.freeze
|
29
|
-
|
30
|
-
DEFAULT_LOG_LEVEL = :warn
|
31
|
-
|
32
|
-
def log_level
|
33
|
-
return ENV["LOG_LEVEL"].downcase.to_sym if ENV["LOG_LEVEL"]
|
34
|
-
return :debug if ENV["DEBUG"]
|
35
|
-
|
36
|
-
DEFAULT_LOG_LEVEL
|
37
|
-
end
|
38
|
-
|
39
|
-
def start_chef_server(opts = {})
|
40
|
-
opts = DEFAULT_SERVER_OPTIONS.merge(opts)
|
41
|
-
opts[:log_level] = log_level
|
42
|
-
|
43
|
-
ChefZero::Server.new(opts).tap(&:start_background)
|
44
|
-
end
|
45
|
-
|
46
|
-
def start_cheffs_server(chef_repo_path)
|
47
|
-
require "chef/version"
|
48
|
-
require "chef/config"
|
49
|
-
require "chef/chef_fs/config"
|
50
|
-
require "chef/chef_fs/chef_fs_data_store"
|
51
|
-
require "chef_zero/server"
|
52
|
-
|
53
|
-
Dir.mkdir(chef_repo_path) unless File.exist?(chef_repo_path)
|
54
|
-
|
55
|
-
# 11.6 and below had a bug where it couldn't create the repo children automatically
|
56
|
-
if Chef::VERSION.to_f < 11.8
|
57
|
-
%w{clients cookbooks data_bags environments nodes roles users}.each do |child|
|
58
|
-
Dir.mkdir("#{chef_repo_path}/#{child}") unless File.exist?("#{chef_repo_path}/#{child}")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Start the new server
|
63
|
-
Chef::Config.repo_mode = "hosted_everything"
|
64
|
-
Chef::Config.chef_repo_path = chef_repo_path
|
65
|
-
Chef::Config.versioned_cookbooks = true
|
66
|
-
chef_fs_config = Chef::ChefFS::Config.new
|
67
|
-
|
68
|
-
data_store = Chef::ChefFS::ChefFSDataStore.new(chef_fs_config.local_fs, chef_fs_config.chef_config)
|
69
|
-
data_store = ChefZero::DataStore::V1ToV2Adapter.new(data_store, "pedant-testorg")
|
70
|
-
data_store = ChefZero::DataStore::DefaultFacade.new(data_store, "pedant-testorg", false)
|
71
|
-
data_store.create(%w{organizations pedant-testorg users}, "pivotal", "{}")
|
72
|
-
data_store.set(%w{organizations pedant-testorg groups admins}, '{ "users": [ "pivotal" ] }')
|
73
|
-
data_store.set(%w{organizations pedant-testorg groups users}, '{ "users": [ "pivotal" ] }')
|
74
|
-
|
75
|
-
start_chef_server(data_store: data_store)
|
76
|
-
end
|
77
|
-
|
78
|
-
def pedant_args_from_env
|
79
|
-
args_from_env("PEDANT_OPTS")
|
80
|
-
end
|
81
|
-
|
82
|
-
def rspec_args_from_env
|
83
|
-
args_from_env("RSPEC_OPTS")
|
84
|
-
end
|
85
|
-
|
86
|
-
def args_from_env(key)
|
87
|
-
return [] unless ENV[key]
|
88
|
-
|
89
|
-
ENV[key].split
|
90
|
-
end
|
91
|
-
|
92
|
-
begin
|
93
|
-
tmpdir = nil
|
94
|
-
server =
|
95
|
-
if ENV["FILE_STORE"]
|
96
|
-
require "tmpdir" unless defined?(Dir.mktmpdir)
|
97
|
-
require "chef_zero/data_store/raw_file_store"
|
98
|
-
tmpdir = Dir.mktmpdir
|
99
|
-
data_store = ChefZero::DataStore::RawFileStore.new(tmpdir, true)
|
100
|
-
data_store = ChefZero::DataStore::DefaultFacade.new(data_store, false, false)
|
101
|
-
|
102
|
-
start_chef_server(data_store: data_store)
|
103
|
-
|
104
|
-
elsif ENV["CHEF_FS"]
|
105
|
-
require "tmpdir" unless defined?(Dir.mktmpdir)
|
106
|
-
tmpdir = Dir.mktmpdir
|
107
|
-
start_cheffs_server(tmpdir)
|
108
|
-
|
109
|
-
else
|
110
|
-
start_chef_server
|
111
|
-
end
|
112
|
-
|
113
|
-
test_secrets = JSON.parse(File.read("spec/support/secrets.json"))
|
114
|
-
ENV["SUPERUSER_KEY"] = test_secrets["chef-server"]["superuser_key"]
|
115
|
-
ENV["WEBUI_KEY"] = test_secrets["chef-server"]["webui_key"]
|
116
|
-
|
117
|
-
require "rspec/core"
|
118
|
-
require "pedant"
|
119
|
-
require "pedant/organization"
|
120
|
-
|
121
|
-
# Pedant::Config.rerun = true
|
122
|
-
|
123
|
-
Pedant.config.suite = "api"
|
124
|
-
|
125
|
-
Pedant.config[:config_file] = "spec/support/oc_pedant.rb"
|
126
|
-
|
127
|
-
# Because ChefFS can only ever have one user (pivotal), we can't do most of the
|
128
|
-
# tests that involve multiple
|
129
|
-
chef_fs_skips = if ENV["CHEF_FS"]
|
130
|
-
[ "--skip-association",
|
131
|
-
"--skip-users",
|
132
|
-
"--skip-organizations",
|
133
|
-
"--skip-multiuser",
|
134
|
-
"--skip-user-keys",
|
135
|
-
]
|
136
|
-
else
|
137
|
-
[]
|
138
|
-
end
|
139
|
-
|
140
|
-
unless Gem::Requirement.new(">= 12.8.0").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
141
|
-
chef_fs_skips << "--skip-keys"
|
142
|
-
end
|
143
|
-
|
144
|
-
unless Gem::Requirement.new(">= 12.13.19").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
145
|
-
chef_fs_skips << "--skip-acl"
|
146
|
-
chef_fs_skips << "--skip-cookbook-artifacts"
|
147
|
-
chef_fs_skips << "--skip-policies"
|
148
|
-
end
|
149
|
-
|
150
|
-
# These things aren't supported by Chef Zero in any mode of operation:
|
151
|
-
default_skips = [
|
152
|
-
# "the goal is that only authorization, authentication and validation tests
|
153
|
-
# are turned off" - @jkeiser
|
154
|
-
#
|
155
|
-
# ...but we're not there yet
|
156
|
-
|
157
|
-
# Chef Zero does not intend to support validation the way erchef does.
|
158
|
-
"--skip-validation",
|
159
|
-
|
160
|
-
# Chef Zero does not intend to support authentication the way erchef does.
|
161
|
-
"--skip-authentication",
|
162
|
-
|
163
|
-
# Chef Zero does not intend to support authorization the way erchef does.
|
164
|
-
"--skip-authorization",
|
165
|
-
|
166
|
-
# Chef Zero does not intend to support oc_id authentication/authorization
|
167
|
-
# the way erchef does.
|
168
|
-
"--skip-oc_id",
|
169
|
-
|
170
|
-
# Omnibus tests depend on erchef features that are specific to erchef and
|
171
|
-
# bundled in the omnibus package. Currently the only test in this category
|
172
|
-
# is for the search reindexing script.
|
173
|
-
"--skip-omnibus",
|
174
|
-
|
175
|
-
# USAGs (user-specific association groups) are Authz groups that contain
|
176
|
-
# only one user and represent that user's association with an org. Though
|
177
|
-
# there are good reasons for them, they don't work well in practice and
|
178
|
-
# only the manage console really uses them. Since Chef Zero + Manage is a
|
179
|
-
# quite unusual configuration, we're ignoring them.
|
180
|
-
"--skip-usags",
|
181
|
-
|
182
|
-
# Chef 12 features not yet 100% supported by Chef Zero
|
183
|
-
|
184
|
-
# chef-zero has some non-removable quirks, such as the fact that files
|
185
|
-
# with 255-character names cannot be stored in local mode. This is
|
186
|
-
# reserved only for quirks that are *irrevocable* and by design; and
|
187
|
-
# should barely be used at all. This is also used to skip the user acl
|
188
|
-
# tests from chef-server as the user acls are not supported in chef-zero
|
189
|
-
# at this time.
|
190
|
-
"--skip-chef-zero-quirks",
|
191
|
-
|
192
|
-
"--skip-status",
|
193
|
-
"--skip=email_case_insensitive",
|
194
|
-
"--skip=nginx_default_error",
|
195
|
-
"--skip=response_headers"
|
196
|
-
]
|
197
|
-
|
198
|
-
# The knife tests are very slow and don't give us a lot of extra coverage,
|
199
|
-
# so we run them in a different entry in the travis test matrix.
|
200
|
-
pedant_args =
|
201
|
-
if ENV["PEDANT_KNIFE_TESTS"]
|
202
|
-
default_skips + %w{ --focus-knife }
|
203
|
-
else
|
204
|
-
default_skips + chef_fs_skips + %w{ --skip-knife }
|
205
|
-
end
|
206
|
-
|
207
|
-
Pedant.setup(pedant_args + pedant_args_from_env)
|
208
|
-
|
209
|
-
rspec_args = Pedant.config.rspec_args + rspec_args_from_env
|
210
|
-
|
211
|
-
if defined? Chef::ChefFS::FileSystemCache
|
212
|
-
RSpec.configure do |c|
|
213
|
-
c.before(:each) do
|
214
|
-
Chef::ChefFS::FileSystemCache.instance.reset!
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
result = RSpec::Core::Runner.run(rspec_args)
|
220
|
-
|
221
|
-
server.stop if server.running?
|
222
|
-
ensure
|
223
|
-
FileUtils.remove_entry_secure(tmpdir) if tmpdir
|
224
|
-
end
|
225
|
-
|
226
|
-
exit(result)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "json" unless defined?(JSON)
|
3
|
+
require "bundler"
|
4
|
+
require "bundler/setup"
|
5
|
+
|
6
|
+
require "chef_zero/server"
|
7
|
+
require "rspec/core"
|
8
|
+
|
9
|
+
# This file runs oc-chef-pedant specs and is invoked by `rake pedant`
|
10
|
+
# and other Rake tasks. Run `rake -T` to list tasks.
|
11
|
+
#
|
12
|
+
# Options for oc-chef-pedant and rspec can be specified via
|
13
|
+
# ENV['PEDANT_OPTS'] and ENV['RSPEC_OPTS'], respectively.
|
14
|
+
#
|
15
|
+
# The log level can be specified via ENV['LOG_LEVEL'].
|
16
|
+
#
|
17
|
+
# Example:
|
18
|
+
#
|
19
|
+
# $ PEDANT_OPTS="--focus-users --skip-keys" \
|
20
|
+
# > RSPEC_OPTS="--fail-fast --profile 5" \
|
21
|
+
# > LOG_LEVEL=debug \
|
22
|
+
# > rake pedant
|
23
|
+
#
|
24
|
+
|
25
|
+
DEFAULT_SERVER_OPTIONS = {
|
26
|
+
port: 8889,
|
27
|
+
single_org: false,
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
DEFAULT_LOG_LEVEL = :warn
|
31
|
+
|
32
|
+
def log_level
|
33
|
+
return ENV["LOG_LEVEL"].downcase.to_sym if ENV["LOG_LEVEL"]
|
34
|
+
return :debug if ENV["DEBUG"]
|
35
|
+
|
36
|
+
DEFAULT_LOG_LEVEL
|
37
|
+
end
|
38
|
+
|
39
|
+
def start_chef_server(opts = {})
|
40
|
+
opts = DEFAULT_SERVER_OPTIONS.merge(opts)
|
41
|
+
opts[:log_level] = log_level
|
42
|
+
|
43
|
+
ChefZero::Server.new(opts).tap(&:start_background)
|
44
|
+
end
|
45
|
+
|
46
|
+
def start_cheffs_server(chef_repo_path)
|
47
|
+
require "chef/version"
|
48
|
+
require "chef/config"
|
49
|
+
require "chef/chef_fs/config"
|
50
|
+
require "chef/chef_fs/chef_fs_data_store"
|
51
|
+
require "chef_zero/server"
|
52
|
+
|
53
|
+
Dir.mkdir(chef_repo_path) unless File.exist?(chef_repo_path)
|
54
|
+
|
55
|
+
# 11.6 and below had a bug where it couldn't create the repo children automatically
|
56
|
+
if Chef::VERSION.to_f < 11.8
|
57
|
+
%w{clients cookbooks data_bags environments nodes roles users}.each do |child|
|
58
|
+
Dir.mkdir("#{chef_repo_path}/#{child}") unless File.exist?("#{chef_repo_path}/#{child}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Start the new server
|
63
|
+
Chef::Config.repo_mode = "hosted_everything"
|
64
|
+
Chef::Config.chef_repo_path = chef_repo_path
|
65
|
+
Chef::Config.versioned_cookbooks = true
|
66
|
+
chef_fs_config = Chef::ChefFS::Config.new
|
67
|
+
|
68
|
+
data_store = Chef::ChefFS::ChefFSDataStore.new(chef_fs_config.local_fs, chef_fs_config.chef_config)
|
69
|
+
data_store = ChefZero::DataStore::V1ToV2Adapter.new(data_store, "pedant-testorg")
|
70
|
+
data_store = ChefZero::DataStore::DefaultFacade.new(data_store, "pedant-testorg", false)
|
71
|
+
data_store.create(%w{organizations pedant-testorg users}, "pivotal", "{}")
|
72
|
+
data_store.set(%w{organizations pedant-testorg groups admins}, '{ "users": [ "pivotal" ] }')
|
73
|
+
data_store.set(%w{organizations pedant-testorg groups users}, '{ "users": [ "pivotal" ] }')
|
74
|
+
|
75
|
+
start_chef_server(data_store: data_store)
|
76
|
+
end
|
77
|
+
|
78
|
+
def pedant_args_from_env
|
79
|
+
args_from_env("PEDANT_OPTS")
|
80
|
+
end
|
81
|
+
|
82
|
+
def rspec_args_from_env
|
83
|
+
args_from_env("RSPEC_OPTS")
|
84
|
+
end
|
85
|
+
|
86
|
+
def args_from_env(key)
|
87
|
+
return [] unless ENV[key]
|
88
|
+
|
89
|
+
ENV[key].split
|
90
|
+
end
|
91
|
+
|
92
|
+
begin
|
93
|
+
tmpdir = nil
|
94
|
+
server =
|
95
|
+
if ENV["FILE_STORE"]
|
96
|
+
require "tmpdir" unless defined?(Dir.mktmpdir)
|
97
|
+
require "chef_zero/data_store/raw_file_store"
|
98
|
+
tmpdir = Dir.mktmpdir
|
99
|
+
data_store = ChefZero::DataStore::RawFileStore.new(tmpdir, true)
|
100
|
+
data_store = ChefZero::DataStore::DefaultFacade.new(data_store, false, false)
|
101
|
+
|
102
|
+
start_chef_server(data_store: data_store)
|
103
|
+
|
104
|
+
elsif ENV["CHEF_FS"]
|
105
|
+
require "tmpdir" unless defined?(Dir.mktmpdir)
|
106
|
+
tmpdir = Dir.mktmpdir
|
107
|
+
start_cheffs_server(tmpdir)
|
108
|
+
|
109
|
+
else
|
110
|
+
start_chef_server
|
111
|
+
end
|
112
|
+
|
113
|
+
test_secrets = JSON.parse(File.read("spec/support/secrets.json"))
|
114
|
+
ENV["SUPERUSER_KEY"] = test_secrets["chef-server"]["superuser_key"]
|
115
|
+
ENV["WEBUI_KEY"] = test_secrets["chef-server"]["webui_key"]
|
116
|
+
|
117
|
+
require "rspec/core"
|
118
|
+
require "pedant"
|
119
|
+
require "pedant/organization"
|
120
|
+
|
121
|
+
# Pedant::Config.rerun = true
|
122
|
+
|
123
|
+
Pedant.config.suite = "api"
|
124
|
+
|
125
|
+
Pedant.config[:config_file] = "spec/support/oc_pedant.rb"
|
126
|
+
|
127
|
+
# Because ChefFS can only ever have one user (pivotal), we can't do most of the
|
128
|
+
# tests that involve multiple
|
129
|
+
chef_fs_skips = if ENV["CHEF_FS"]
|
130
|
+
[ "--skip-association",
|
131
|
+
"--skip-users",
|
132
|
+
"--skip-organizations",
|
133
|
+
"--skip-multiuser",
|
134
|
+
"--skip-user-keys",
|
135
|
+
]
|
136
|
+
else
|
137
|
+
[]
|
138
|
+
end
|
139
|
+
|
140
|
+
unless Gem::Requirement.new(">= 12.8.0").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
141
|
+
chef_fs_skips << "--skip-keys"
|
142
|
+
end
|
143
|
+
|
144
|
+
unless Gem::Requirement.new(">= 12.13.19").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
145
|
+
chef_fs_skips << "--skip-acl"
|
146
|
+
chef_fs_skips << "--skip-cookbook-artifacts"
|
147
|
+
chef_fs_skips << "--skip-policies"
|
148
|
+
end
|
149
|
+
|
150
|
+
# These things aren't supported by Chef Zero in any mode of operation:
|
151
|
+
default_skips = [
|
152
|
+
# "the goal is that only authorization, authentication and validation tests
|
153
|
+
# are turned off" - @jkeiser
|
154
|
+
#
|
155
|
+
# ...but we're not there yet
|
156
|
+
|
157
|
+
# Chef Zero does not intend to support validation the way erchef does.
|
158
|
+
"--skip-validation",
|
159
|
+
|
160
|
+
# Chef Zero does not intend to support authentication the way erchef does.
|
161
|
+
"--skip-authentication",
|
162
|
+
|
163
|
+
# Chef Zero does not intend to support authorization the way erchef does.
|
164
|
+
"--skip-authorization",
|
165
|
+
|
166
|
+
# Chef Zero does not intend to support oc_id authentication/authorization
|
167
|
+
# the way erchef does.
|
168
|
+
"--skip-oc_id",
|
169
|
+
|
170
|
+
# Omnibus tests depend on erchef features that are specific to erchef and
|
171
|
+
# bundled in the omnibus package. Currently the only test in this category
|
172
|
+
# is for the search reindexing script.
|
173
|
+
"--skip-omnibus",
|
174
|
+
|
175
|
+
# USAGs (user-specific association groups) are Authz groups that contain
|
176
|
+
# only one user and represent that user's association with an org. Though
|
177
|
+
# there are good reasons for them, they don't work well in practice and
|
178
|
+
# only the manage console really uses them. Since Chef Zero + Manage is a
|
179
|
+
# quite unusual configuration, we're ignoring them.
|
180
|
+
"--skip-usags",
|
181
|
+
|
182
|
+
# Chef 12 features not yet 100% supported by Chef Zero
|
183
|
+
|
184
|
+
# chef-zero has some non-removable quirks, such as the fact that files
|
185
|
+
# with 255-character names cannot be stored in local mode. This is
|
186
|
+
# reserved only for quirks that are *irrevocable* and by design; and
|
187
|
+
# should barely be used at all. This is also used to skip the user acl
|
188
|
+
# tests from chef-server as the user acls are not supported in chef-zero
|
189
|
+
# at this time.
|
190
|
+
"--skip-chef-zero-quirks",
|
191
|
+
|
192
|
+
"--skip-status",
|
193
|
+
"--skip=email_case_insensitive",
|
194
|
+
"--skip=nginx_default_error",
|
195
|
+
"--skip=response_headers",
|
196
|
+
]
|
197
|
+
|
198
|
+
# The knife tests are very slow and don't give us a lot of extra coverage,
|
199
|
+
# so we run them in a different entry in the travis test matrix.
|
200
|
+
pedant_args =
|
201
|
+
if ENV["PEDANT_KNIFE_TESTS"]
|
202
|
+
default_skips + %w{ --focus-knife }
|
203
|
+
else
|
204
|
+
default_skips + chef_fs_skips + %w{ --skip-knife }
|
205
|
+
end
|
206
|
+
|
207
|
+
Pedant.setup(pedant_args + pedant_args_from_env)
|
208
|
+
|
209
|
+
rspec_args = Pedant.config.rspec_args + rspec_args_from_env
|
210
|
+
|
211
|
+
if defined? Chef::ChefFS::FileSystemCache
|
212
|
+
RSpec.configure do |c|
|
213
|
+
c.before(:each) do
|
214
|
+
Chef::ChefFS::FileSystemCache.instance.reset!
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
result = RSpec::Core::Runner.run(rspec_args)
|
220
|
+
|
221
|
+
server.stop if server.running?
|
222
|
+
ensure
|
223
|
+
FileUtils.remove_entry_secure(tmpdir) if tmpdir
|
224
|
+
end
|
225
|
+
|
226
|
+
exit(result)
|
data/spec/search_spec.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
require "chef_zero/solr/solr_parser"
|
2
|
-
require "chef_zero/solr/solr_doc"
|
3
|
-
|
4
|
-
describe ChefZero::Solr::SolrParser do
|
5
|
-
let(:all_docs) do
|
6
|
-
docs = []
|
7
|
-
[{ "foo" => "a" },
|
8
|
-
{ "foo" => "d" }].each_with_index do |h, i|
|
9
|
-
docs.push ChefZero::Solr::SolrDoc.new(h, i)
|
10
|
-
end
|
11
|
-
docs
|
12
|
-
end
|
13
|
-
|
14
|
-
def search_for(query)
|
15
|
-
q = ChefZero::Solr::SolrParser.new(query).parse
|
16
|
-
all_docs.select { |doc| q.matches_doc?(doc) }
|
17
|
-
end
|
18
|
-
|
19
|
-
it "handles terms" do
|
20
|
-
search_for("foo:d").size.should eq(1)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "handles ranges" do
|
24
|
-
search_for("foo:[a TO c]").size.should eq(1)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "handles -" do
|
28
|
-
search_for("-foo:a").size.should eq(1)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "handles wildcard ranges" do
|
32
|
-
search_for("foo:[* TO c]").size.should eq(1)
|
33
|
-
search_for("foo:[c TO *]").size.should eq(1)
|
34
|
-
search_for("foo:[* TO *]").size.should eq(2)
|
35
|
-
end
|
36
|
-
end
|
1
|
+
require "chef_zero/solr/solr_parser"
|
2
|
+
require "chef_zero/solr/solr_doc"
|
3
|
+
|
4
|
+
describe ChefZero::Solr::SolrParser do
|
5
|
+
let(:all_docs) do
|
6
|
+
docs = []
|
7
|
+
[{ "foo" => "a" },
|
8
|
+
{ "foo" => "d" }].each_with_index do |h, i|
|
9
|
+
docs.push ChefZero::Solr::SolrDoc.new(h, i)
|
10
|
+
end
|
11
|
+
docs
|
12
|
+
end
|
13
|
+
|
14
|
+
def search_for(query)
|
15
|
+
q = ChefZero::Solr::SolrParser.new(query).parse
|
16
|
+
all_docs.select { |doc| q.matches_doc?(doc) }
|
17
|
+
end
|
18
|
+
|
19
|
+
it "handles terms" do
|
20
|
+
search_for("foo:d").size.should eq(1)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "handles ranges" do
|
24
|
+
search_for("foo:[a TO c]").size.should eq(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "handles -" do
|
28
|
+
search_for("-foo:a").size.should eq(1)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "handles wildcard ranges" do
|
32
|
+
search_for("foo:[* TO c]").size.should eq(1)
|
33
|
+
search_for("foo:[c TO *]").size.should eq(1)
|
34
|
+
search_for("foo:[* TO *]").size.should eq(2)
|
35
|
+
end
|
36
|
+
end
|