chef-zero 4.3.2 → 4.4.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 +14 -0
- data/Rakefile +12 -0
- data/bin/chef-zero +5 -0
- data/chef-zero.gemspec +33 -0
- data/lib/chef_zero/chef_data/data_normalizer.rb +30 -11
- data/lib/chef_zero/chef_data/default_creator.rb +5 -2
- data/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_endpoint.rb +24 -0
- data/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb +67 -0
- data/lib/chef_zero/endpoints/cookbook_artifacts_endpoint.rb +34 -0
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/dummy_endpoint.rb +31 -0
- data/lib/chef_zero/endpoints/node_endpoint.rb +14 -0
- data/lib/chef_zero/endpoints/nodes_endpoint.rb +35 -0
- data/lib/chef_zero/endpoints/policies_endpoint.rb +14 -139
- data/lib/chef_zero/endpoints/policy_endpoint.rb +24 -0
- data/lib/chef_zero/endpoints/policy_group_endpoint.rb +46 -0
- data/lib/chef_zero/endpoints/policy_group_policy_endpoint.rb +84 -0
- data/lib/chef_zero/endpoints/policy_groups_endpoint.rb +38 -0
- data/lib/chef_zero/endpoints/policy_revision_endpoint.rb +23 -0
- data/lib/chef_zero/endpoints/policy_revisions_endpoint.rb +15 -0
- data/lib/chef_zero/endpoints/principal_endpoint.rb +4 -0
- data/lib/chef_zero/rest_base.rb +39 -4
- data/lib/chef_zero/rspec.rb +33 -0
- data/lib/chef_zero/server.rb +45 -5
- data/lib/chef_zero/version.rb +1 -1
- data/spec/run_oc_pedant.rb +68 -7
- data/spec/support/oc_pedant.rb +33 -13
- metadata +58 -4
data/lib/chef_zero/version.rb
CHANGED
data/spec/run_oc_pedant.rb
CHANGED
@@ -5,6 +5,45 @@ require 'bundler/setup'
|
|
5
5
|
require 'chef_zero/server'
|
6
6
|
require 'rspec/core'
|
7
7
|
|
8
|
+
def start_cheffs_server(chef_repo_path)
|
9
|
+
require 'chef/version'
|
10
|
+
require 'chef/config'
|
11
|
+
require 'chef/chef_fs/config'
|
12
|
+
require 'chef/chef_fs/chef_fs_data_store'
|
13
|
+
require 'chef_zero/server'
|
14
|
+
|
15
|
+
Dir.mkdir(chef_repo_path) if !File.exists?(chef_repo_path)
|
16
|
+
|
17
|
+
# 11.6 and below had a bug where it couldn't create the repo children automatically
|
18
|
+
if Chef::VERSION.to_f < 11.8
|
19
|
+
%w(clients cookbooks data_bags environments nodes roles users).each do |child|
|
20
|
+
Dir.mkdir("#{chef_repo_path}/#{child}") if !File.exists?("#{chef_repo_path}/#{child}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Start the new server
|
25
|
+
Chef::Config.repo_mode = 'hosted_everything'
|
26
|
+
Chef::Config.chef_repo_path = chef_repo_path
|
27
|
+
Chef::Config.versioned_cookbooks = true
|
28
|
+
chef_fs_config = Chef::ChefFS::Config.new
|
29
|
+
|
30
|
+
data_store = Chef::ChefFS::ChefFSDataStore.new(chef_fs_config.local_fs, chef_fs_config.chef_config)
|
31
|
+
data_store = ChefZero::DataStore::V1ToV2Adapter.new(data_store, 'pedant-testorg')
|
32
|
+
data_store = ChefZero::DataStore::DefaultFacade.new(data_store, 'pedant-testorg', false)
|
33
|
+
data_store.create(%w(organizations pedant-testorg users), 'pivotal', '{}')
|
34
|
+
data_store.set(%w(organizations pedant-testorg groups admins), '{ "users": [ "pivotal" ] }')
|
35
|
+
data_store.set(%w(organizations pedant-testorg groups users), '{ "users": [ "pivotal" ] }')
|
36
|
+
|
37
|
+
server = ChefZero::Server.new(
|
38
|
+
port: 8889,
|
39
|
+
data_store: data_store,
|
40
|
+
single_org: false,
|
41
|
+
#log_level: :debug
|
42
|
+
)
|
43
|
+
server.start_background
|
44
|
+
server
|
45
|
+
end
|
46
|
+
|
8
47
|
tmpdir = nil
|
9
48
|
|
10
49
|
begin
|
@@ -17,6 +56,11 @@ begin
|
|
17
56
|
server = ChefZero::Server.new(:port => 8889, :single_org => false, :data_store => data_store)
|
18
57
|
server.start_background
|
19
58
|
|
59
|
+
elsif ENV['CHEF_FS']
|
60
|
+
require 'tmpdir'
|
61
|
+
tmpdir = Dir.mktmpdir
|
62
|
+
server = start_cheffs_server(tmpdir)
|
63
|
+
|
20
64
|
else
|
21
65
|
server = ChefZero::Server.new(:port => 8889, :single_org => false)#, :log_level => :debug)
|
22
66
|
server.start_background
|
@@ -26,12 +70,29 @@ begin
|
|
26
70
|
require 'pedant'
|
27
71
|
require 'pedant/organization'
|
28
72
|
|
29
|
-
#Pedant::Config.rerun = true
|
73
|
+
# Pedant::Config.rerun = true
|
30
74
|
|
31
75
|
Pedant.config.suite = 'api'
|
32
|
-
|
76
|
+
|
33
77
|
Pedant.config[:config_file] = 'spec/support/oc_pedant.rb'
|
34
|
-
|
78
|
+
|
79
|
+
# Because ChefFS can only ever have one user (pivotal), we can't do most of the
|
80
|
+
# tests that involve multiple
|
81
|
+
chef_fs_skips = if ENV['CHEF_FS']
|
82
|
+
[ '--skip-association',
|
83
|
+
'--skip-users',
|
84
|
+
'--skip-organizations',
|
85
|
+
'--skip-multiuser',
|
86
|
+
|
87
|
+
# will be supported.
|
88
|
+
'--skip-policies',
|
89
|
+
'--skip-cookbook-artifacts',
|
90
|
+
]
|
91
|
+
else
|
92
|
+
[]
|
93
|
+
end
|
94
|
+
|
95
|
+
# "the goal is that only authorization, authentication and validation tests are turned off" - @jkeiser
|
35
96
|
Pedant.setup([
|
36
97
|
'--skip-knife',
|
37
98
|
'--skip-keys',
|
@@ -46,14 +107,14 @@ begin
|
|
46
107
|
'--skip-headers',
|
47
108
|
|
48
109
|
# Chef 12 features not yet 100% supported by Chef Zero
|
49
|
-
'--skip-policies',
|
50
|
-
'--skip-cookbook-artifacts',
|
51
110
|
'--skip-containers',
|
52
111
|
'--skip-api-v1'
|
112
|
+
] + chef_fs_skips)
|
53
113
|
|
54
|
-
]
|
114
|
+
fail_fast = []
|
115
|
+
# fail_fast = ["--fail-fast"]
|
55
116
|
|
56
|
-
result = RSpec::Core::Runner.run(Pedant.config.rspec_args)
|
117
|
+
result = RSpec::Core::Runner.run(Pedant.config.rspec_args + fail_fast)
|
57
118
|
|
58
119
|
server.stop if server.running?
|
59
120
|
ensure
|
data/spec/support/oc_pedant.rb
CHANGED
@@ -45,6 +45,16 @@ maximum_search_time 0
|
|
45
45
|
# # to be enabled for Pedant tests to work correctly
|
46
46
|
explicit_port_url true
|
47
47
|
|
48
|
+
server_api_version 0
|
49
|
+
|
50
|
+
internal_server chef_server
|
51
|
+
|
52
|
+
# see dummy_endpoint.rb for details.
|
53
|
+
search_server chef_server
|
54
|
+
search_commit_url "/dummy"
|
55
|
+
search_url_fmt "/dummy?fq=+X_CHEF_type_CHEF_X:%{type}&q=%{query}&wt=json"
|
56
|
+
|
57
|
+
|
48
58
|
# We're starting to break tests up into groups based on different
|
49
59
|
# criteria. The proper API tests (the results of which are viewable
|
50
60
|
# to OPC customers) should be the only ones run by Pedant embedded in
|
@@ -59,9 +69,12 @@ explicit_port_url true
|
|
59
69
|
# value.
|
60
70
|
include_internal false
|
61
71
|
|
62
|
-
|
63
|
-
|
64
|
-
|
72
|
+
key = 'spec/support/stickywicket.pem'
|
73
|
+
|
74
|
+
org(name: "pedant-testorg",
|
75
|
+
create_me: !ENV['CHEF_FS'],
|
76
|
+
validator_key: key)
|
77
|
+
|
65
78
|
internal_account_url chef_server
|
66
79
|
delete_org true
|
67
80
|
|
@@ -72,11 +85,16 @@ delete_org true
|
|
72
85
|
# are using pre-existing users, you must supply a ':key_file' key,
|
73
86
|
# which should be the fully-qualified path /on the machine Pedant is
|
74
87
|
# running on/ to a private key for that user.
|
75
|
-
key = 'spec/support/stickywicket.pem'
|
76
88
|
superuser_name 'pivotal'
|
77
89
|
superuser_key key
|
78
90
|
webui_key key
|
79
91
|
|
92
|
+
def cheffs_or_else_user(value)
|
93
|
+
ENV['CHEF_FS'] ? "pivotal" : value
|
94
|
+
end
|
95
|
+
|
96
|
+
keyfile_maybe = ENV['CHEF_FS'] ? { key_file: key } : { key_file: nil }
|
97
|
+
|
80
98
|
requestors({
|
81
99
|
:clients => {
|
82
100
|
# The the admin user, for the purposes of getting things rolling
|
@@ -102,24 +120,26 @@ requestors({
|
|
102
120
|
:users => {
|
103
121
|
# An administrator in the testing organization
|
104
122
|
:admin => {
|
105
|
-
:name => "pedant_admin_user",
|
106
|
-
:create_me =>
|
123
|
+
:name => cheffs_or_else_user("pedant_admin_user"),
|
124
|
+
:create_me => !ENV['CHEF_FS'],
|
125
|
+
:associate => !ENV['CHEF_FS'],
|
107
126
|
:create_knife => true
|
108
|
-
},
|
127
|
+
}.merge(keyfile_maybe),
|
109
128
|
|
110
129
|
:non_admin => {
|
111
|
-
:name => "pedant_user",
|
112
|
-
:create_me =>
|
130
|
+
:name => cheffs_or_else_user("pedant_user"),
|
131
|
+
:create_me => !ENV['CHEF_FS'],
|
132
|
+
:associate => !ENV['CHEF_FS'],
|
113
133
|
:create_knife => true
|
114
|
-
},
|
134
|
+
}.merge(keyfile_maybe),
|
115
135
|
|
116
136
|
# A user that is not a member of the testing organization
|
117
137
|
:bad => {
|
118
|
-
:name => "pedant-nobody",
|
119
|
-
:create_me =>
|
138
|
+
:name => cheffs_or_else_user("pedant-nobody"),
|
139
|
+
:create_me => !ENV['CHEF_FS'],
|
120
140
|
:create_knife => true,
|
121
141
|
:associate => false
|
122
|
-
},
|
142
|
+
}.merge(keyfile_maybe),
|
123
143
|
}
|
124
144
|
})
|
125
145
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-log
|
@@ -86,6 +86,48 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: pry
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: pry-byebug
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: pry-stack_explorer
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
89
131
|
- !ruby/object:Gem::Dependency
|
90
132
|
name: rake
|
91
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,10 +178,12 @@ executables:
|
|
136
178
|
extensions: []
|
137
179
|
extra_rdoc_files: []
|
138
180
|
files:
|
181
|
+
- Gemfile
|
139
182
|
- LICENSE
|
140
183
|
- README.md
|
141
184
|
- Rakefile
|
142
185
|
- bin/chef-zero
|
186
|
+
- chef-zero.gemspec
|
143
187
|
- lib/chef_zero.rb
|
144
188
|
- lib/chef_zero/chef_data/acl_path.rb
|
145
189
|
- lib/chef_zero/chef_data/cookbook_data.rb
|
@@ -163,6 +207,9 @@ files:
|
|
163
207
|
- lib/chef_zero/endpoints/authenticate_user_endpoint.rb
|
164
208
|
- lib/chef_zero/endpoints/container_endpoint.rb
|
165
209
|
- lib/chef_zero/endpoints/containers_endpoint.rb
|
210
|
+
- lib/chef_zero/endpoints/cookbook_artifacts_cookbook_endpoint.rb
|
211
|
+
- lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb
|
212
|
+
- lib/chef_zero/endpoints/cookbook_artifacts_endpoint.rb
|
166
213
|
- lib/chef_zero/endpoints/cookbook_endpoint.rb
|
167
214
|
- lib/chef_zero/endpoints/cookbook_version_endpoint.rb
|
168
215
|
- lib/chef_zero/endpoints/cookbooks_base.rb
|
@@ -170,6 +217,7 @@ files:
|
|
170
217
|
- lib/chef_zero/endpoints/data_bag_endpoint.rb
|
171
218
|
- lib/chef_zero/endpoints/data_bag_item_endpoint.rb
|
172
219
|
- lib/chef_zero/endpoints/data_bags_endpoint.rb
|
220
|
+
- lib/chef_zero/endpoints/dummy_endpoint.rb
|
173
221
|
- lib/chef_zero/endpoints/environment_cookbook_endpoint.rb
|
174
222
|
- lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb
|
175
223
|
- lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb
|
@@ -183,6 +231,7 @@ files:
|
|
183
231
|
- lib/chef_zero/endpoints/license_endpoint.rb
|
184
232
|
- lib/chef_zero/endpoints/node_endpoint.rb
|
185
233
|
- lib/chef_zero/endpoints/node_identifiers_endpoint.rb
|
234
|
+
- lib/chef_zero/endpoints/nodes_endpoint.rb
|
186
235
|
- lib/chef_zero/endpoints/not_found_endpoint.rb
|
187
236
|
- lib/chef_zero/endpoints/organization_association_request_endpoint.rb
|
188
237
|
- lib/chef_zero/endpoints/organization_association_requests_endpoint.rb
|
@@ -194,6 +243,12 @@ files:
|
|
194
243
|
- lib/chef_zero/endpoints/organization_validator_key_endpoint.rb
|
195
244
|
- lib/chef_zero/endpoints/organizations_endpoint.rb
|
196
245
|
- lib/chef_zero/endpoints/policies_endpoint.rb
|
246
|
+
- lib/chef_zero/endpoints/policy_endpoint.rb
|
247
|
+
- lib/chef_zero/endpoints/policy_group_endpoint.rb
|
248
|
+
- lib/chef_zero/endpoints/policy_group_policy_endpoint.rb
|
249
|
+
- lib/chef_zero/endpoints/policy_groups_endpoint.rb
|
250
|
+
- lib/chef_zero/endpoints/policy_revision_endpoint.rb
|
251
|
+
- lib/chef_zero/endpoints/policy_revisions_endpoint.rb
|
197
252
|
- lib/chef_zero/endpoints/principal_endpoint.rb
|
198
253
|
- lib/chef_zero/endpoints/rest_list_endpoint.rb
|
199
254
|
- lib/chef_zero/endpoints/rest_object_endpoint.rb
|
@@ -254,10 +309,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
309
|
version: '0'
|
255
310
|
requirements: []
|
256
311
|
rubyforge_project:
|
257
|
-
rubygems_version: 2.
|
312
|
+
rubygems_version: 2.2.3
|
258
313
|
signing_key:
|
259
314
|
specification_version: 4
|
260
315
|
summary: Self-contained, easy-setup, fast-start in-memory Chef server for testing
|
261
316
|
and solo setup purposes
|
262
317
|
test_files: []
|
263
|
-
has_rdoc:
|