chef-zero 4.2.3 → 4.3.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/LICENSE +201 -201
- data/README.md +155 -150
- data/Rakefile +31 -31
- data/bin/chef-zero +100 -100
- data/lib/chef_zero.rb +10 -7
- data/lib/chef_zero/chef_data/acl_path.rb +139 -139
- data/lib/chef_zero/chef_data/cookbook_data.rb +240 -240
- data/lib/chef_zero/chef_data/data_normalizer.rb +207 -207
- data/lib/chef_zero/chef_data/default_creator.rb +446 -446
- data/lib/chef_zero/data_store/data_already_exists_error.rb +29 -29
- data/lib/chef_zero/data_store/data_error.rb +31 -31
- data/lib/chef_zero/data_store/data_not_found_error.rb +28 -28
- data/lib/chef_zero/data_store/default_facade.rb +149 -149
- 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 +155 -155
- data/lib/chef_zero/data_store/raw_file_store.rb +147 -147
- data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +142 -142
- data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +107 -107
- data/lib/chef_zero/endpoints/acl_endpoint.rb +38 -38
- data/lib/chef_zero/endpoints/acls_endpoint.rb +29 -29
- data/lib/chef_zero/endpoints/actor_endpoint.rb +94 -88
- data/lib/chef_zero/endpoints/actors_endpoint.rb +64 -64
- data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +31 -31
- data/lib/chef_zero/endpoints/container_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/containers_endpoint.rb +13 -13
- data/lib/chef_zero/endpoints/cookbook_endpoint.rb +39 -39
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +119 -119
- data/lib/chef_zero/endpoints/cookbooks_base.rb +65 -65
- 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/environment_cookbook_endpoint.rb +24 -24
- data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +123 -123
- 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 +17 -17
- data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +22 -0
- 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 -29
- data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +26 -26
- data/lib/chef_zero/endpoints/organization_endpoint.rb +46 -41
- data/lib/chef_zero/endpoints/organization_user_base.rb +15 -0
- data/lib/chef_zero/endpoints/organization_user_endpoint.rb +26 -48
- data/lib/chef_zero/endpoints/organization_users_endpoint.rb +43 -14
- data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/organizations_endpoint.rb +62 -55
- data/lib/chef_zero/endpoints/policies_endpoint.rb +151 -154
- data/lib/chef_zero/endpoints/principal_endpoint.rb +42 -42
- data/lib/chef_zero/endpoints/rest_list_endpoint.rb +42 -42
- data/lib/chef_zero/endpoints/rest_object_endpoint.rb +63 -63
- 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 +50 -50
- data/lib/chef_zero/endpoints/search_endpoint.rb +194 -192
- data/lib/chef_zero/endpoints/searches_endpoint.rb +18 -18
- data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +14 -0
- data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +30 -30
- data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +40 -40
- 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 +12 -12
- data/lib/chef_zero/log.rb +7 -7
- data/lib/chef_zero/rest_base.rb +242 -214
- data/lib/chef_zero/rest_error_response.rb +11 -11
- data/lib/chef_zero/rest_request.rb +69 -65
- data/lib/chef_zero/rest_router.rb +45 -45
- data/lib/chef_zero/rspec.rb +308 -308
- data/lib/chef_zero/server.rb +642 -637
- data/lib/chef_zero/socketless_server_map.rb +92 -92
- 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 +29 -29
- 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 +43 -43
- data/lib/chef_zero/solr/solr_doc.rb +53 -53
- data/lib/chef_zero/solr/solr_parser.rb +203 -203
- data/lib/chef_zero/version.rb +3 -3
- data/spec/run_oc_pedant.rb +63 -56
- data/spec/search_spec.rb +32 -32
- data/spec/server_spec.rb +92 -91
- data/spec/socketless_server_map_spec.rb +76 -76
- data/spec/support/oc_pedant.rb +132 -134
- data/spec/support/stickywicket.pem +27 -27
- metadata +10 -15
- data/spec/run_pedant.rb +0 -103
- data/spec/support/pedant.rb +0 -129
data/Rakefile
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
require 'bundler'
|
|
2
|
-
require 'bundler/gem_tasks'
|
|
3
|
-
|
|
4
|
-
require 'chef_zero/version'
|
|
5
|
-
|
|
6
|
-
task :default => :pedant
|
|
7
|
-
|
|
8
|
-
desc "run specs"
|
|
9
|
-
task :spec do
|
|
10
|
-
system('rspec spec/*_spec.rb')
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
desc "run pedant"
|
|
14
|
-
task :pedant do
|
|
15
|
-
require File.expand_path('spec/
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
desc "run oc pedant"
|
|
19
|
-
task :oc_pedant do
|
|
20
|
-
require File.expand_path('spec/run_oc_pedant')
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
task :chef_spec do
|
|
24
|
-
gem_path = Bundler.environment.specs['chef'].first.full_gem_path
|
|
25
|
-
system("cd #{gem_path} && rspec spec/integration")
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
task :berkshelf_spec do
|
|
29
|
-
gem_path = Bundler.environment.specs['berkshelf'].first.full_gem_path
|
|
30
|
-
system("cd #{gem_path} && thor spec:ci")
|
|
31
|
-
end
|
|
1
|
+
require 'bundler'
|
|
2
|
+
require 'bundler/gem_tasks'
|
|
3
|
+
|
|
4
|
+
require 'chef_zero/version'
|
|
5
|
+
|
|
6
|
+
task :default => :pedant
|
|
7
|
+
|
|
8
|
+
desc "run specs"
|
|
9
|
+
task :spec do
|
|
10
|
+
system('rspec spec/*_spec.rb')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc "run oc pedant"
|
|
14
|
+
task :pedant do
|
|
15
|
+
require File.expand_path('spec/run_oc_pedant')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "run oc pedant"
|
|
19
|
+
task :oc_pedant do
|
|
20
|
+
require File.expand_path('spec/run_oc_pedant')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
task :chef_spec do
|
|
24
|
+
gem_path = Bundler.environment.specs['chef'].first.full_gem_path
|
|
25
|
+
system("cd #{gem_path} && rspec spec/integration")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
task :berkshelf_spec do
|
|
29
|
+
gem_path = Bundler.environment.specs['berkshelf'].first.full_gem_path
|
|
30
|
+
system("cd #{gem_path} && thor spec:ci")
|
|
31
|
+
end
|
data/bin/chef-zero
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
# Trap interrupts to quit cleanly.
|
|
4
|
-
Signal.trap('INT') { exit 1 }
|
|
5
|
-
|
|
6
|
-
require 'rubygems'
|
|
7
|
-
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
|
|
8
|
-
|
|
9
|
-
require 'chef_zero/log'
|
|
10
|
-
require 'chef_zero/version'
|
|
11
|
-
require 'chef_zero/server'
|
|
12
|
-
require 'chef_zero/data_store/raw_file_store'
|
|
13
|
-
require 'optparse'
|
|
14
|
-
|
|
15
|
-
def parse_port(port)
|
|
16
|
-
array = []
|
|
17
|
-
port.split(',').each do |part|
|
|
18
|
-
a,b = part.split('-',2)
|
|
19
|
-
if b
|
|
20
|
-
array = array.concat(a.to_i.upto(b.to_i).to_a)
|
|
21
|
-
else
|
|
22
|
-
array = array.concat([a.to_i])
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
array
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
options = {}
|
|
29
|
-
|
|
30
|
-
OptionParser.new do |opts|
|
|
31
|
-
opts.banner = "Usage: chef-zero [ARGS]"
|
|
32
|
-
|
|
33
|
-
opts.on("-H", "--host HOST", "Host to bind to (default: 127.0.0.1)") do |value|
|
|
34
|
-
options[:host] = value
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
opts.on("-p", "--port PORT", "Port to listen on (e.g. 8889, or 8500-8600 or 8885,8888)") do |value|
|
|
38
|
-
options[:port] ||= []
|
|
39
|
-
options[:port] += parse_port(value)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
opts.on("--[no-]generate-keys", "Whether to generate actual keys or fake it (faster). Default: false.") do |value|
|
|
43
|
-
options[:generate_real_keys] = value
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
opts.on("-d", "--daemon", "Run as a daemon process") do |value|
|
|
47
|
-
options[:daemon] = value
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
opts.on("-l", "--log-level LEVEL", "Set the output log level") do |value|
|
|
51
|
-
options[:log_level] = value
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
opts.on("--log-file FILE", "Log to a file") do |value|
|
|
55
|
-
options[:log_file] = value
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
opts.on("--multi-org", "Whether to run in multi-org mode") do |value|
|
|
59
|
-
options[:single_org] = nil
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
opts.on("--file-store PATH", "Persist data to files at the given path") do |value|
|
|
63
|
-
options[:data_store] = ChefZero::DataStore::RawFileStore.new(value)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
opts.on("--[no-]ssl", "Use SSL with self-signed certificate(Auto generate before every run). Default: false.") do |value|
|
|
67
|
-
options[:ssl] = value
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
|
71
|
-
puts opts
|
|
72
|
-
exit
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
opts.on_tail("--version", "Show version") do
|
|
76
|
-
puts ChefZero::VERSION
|
|
77
|
-
exit
|
|
78
|
-
end
|
|
79
|
-
end.parse!
|
|
80
|
-
|
|
81
|
-
if options[:data_store]
|
|
82
|
-
options[:data_store] = ChefZero::DataStore::DefaultFacade.new(options[:data_store], options[:single_org], false)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
if options[:log_file]
|
|
86
|
-
ChefZero::Log.init(options[:log_file])
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
server = ChefZero::Server.new(options)
|
|
90
|
-
|
|
91
|
-
if options[:daemon]
|
|
92
|
-
if Process.respond_to?(:daemon)
|
|
93
|
-
Process.daemon(true)
|
|
94
|
-
server.start(true)
|
|
95
|
-
else
|
|
96
|
-
abort 'Process.daemon requires Ruby >= 1.9'
|
|
97
|
-
end
|
|
98
|
-
else
|
|
99
|
-
server.start(true)
|
|
100
|
-
end
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Trap interrupts to quit cleanly.
|
|
4
|
+
Signal.trap('INT') { exit 1 }
|
|
5
|
+
|
|
6
|
+
require 'rubygems'
|
|
7
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
|
|
8
|
+
|
|
9
|
+
require 'chef_zero/log'
|
|
10
|
+
require 'chef_zero/version'
|
|
11
|
+
require 'chef_zero/server'
|
|
12
|
+
require 'chef_zero/data_store/raw_file_store'
|
|
13
|
+
require 'optparse'
|
|
14
|
+
|
|
15
|
+
def parse_port(port)
|
|
16
|
+
array = []
|
|
17
|
+
port.split(',').each do |part|
|
|
18
|
+
a,b = part.split('-',2)
|
|
19
|
+
if b
|
|
20
|
+
array = array.concat(a.to_i.upto(b.to_i).to_a)
|
|
21
|
+
else
|
|
22
|
+
array = array.concat([a.to_i])
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
array
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
options = {}
|
|
29
|
+
|
|
30
|
+
OptionParser.new do |opts|
|
|
31
|
+
opts.banner = "Usage: chef-zero [ARGS]"
|
|
32
|
+
|
|
33
|
+
opts.on("-H", "--host HOST", "Host to bind to (default: 127.0.0.1)") do |value|
|
|
34
|
+
options[:host] = value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
opts.on("-p", "--port PORT", "Port to listen on (e.g. 8889, or 8500-8600 or 8885,8888)") do |value|
|
|
38
|
+
options[:port] ||= []
|
|
39
|
+
options[:port] += parse_port(value)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
opts.on("--[no-]generate-keys", "Whether to generate actual keys or fake it (faster). Default: false.") do |value|
|
|
43
|
+
options[:generate_real_keys] = value
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
opts.on("-d", "--daemon", "Run as a daemon process") do |value|
|
|
47
|
+
options[:daemon] = value
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
opts.on("-l", "--log-level LEVEL", "Set the output log level") do |value|
|
|
51
|
+
options[:log_level] = value
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
opts.on("--log-file FILE", "Log to a file") do |value|
|
|
55
|
+
options[:log_file] = value
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
opts.on("--multi-org", "Whether to run in multi-org mode") do |value|
|
|
59
|
+
options[:single_org] = nil
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
opts.on("--file-store PATH", "Persist data to files at the given path") do |value|
|
|
63
|
+
options[:data_store] = ChefZero::DataStore::RawFileStore.new(value)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
opts.on("--[no-]ssl", "Use SSL with self-signed certificate(Auto generate before every run). Default: false.") do |value|
|
|
67
|
+
options[:ssl] = value
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
|
71
|
+
puts opts
|
|
72
|
+
exit
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
opts.on_tail("--version", "Show version") do
|
|
76
|
+
puts ChefZero::VERSION
|
|
77
|
+
exit
|
|
78
|
+
end
|
|
79
|
+
end.parse!
|
|
80
|
+
|
|
81
|
+
if options[:data_store]
|
|
82
|
+
options[:data_store] = ChefZero::DataStore::DefaultFacade.new(options[:data_store], options[:single_org], false)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
if options[:log_file]
|
|
86
|
+
ChefZero::Log.init(options[:log_file])
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
server = ChefZero::Server.new(options)
|
|
90
|
+
|
|
91
|
+
if options[:daemon]
|
|
92
|
+
if Process.respond_to?(:daemon)
|
|
93
|
+
Process.daemon(true)
|
|
94
|
+
server.start(true)
|
|
95
|
+
else
|
|
96
|
+
abort 'Process.daemon requires Ruby >= 1.9'
|
|
97
|
+
end
|
|
98
|
+
else
|
|
99
|
+
server.start(true)
|
|
100
|
+
end
|
data/lib/chef_zero.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
module ChefZero
|
|
2
|
-
require 'chef_zero/log'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
module ChefZero
|
|
2
|
+
require 'chef_zero/log'
|
|
3
|
+
|
|
4
|
+
MIN_API_VERSION = 0
|
|
5
|
+
MAX_API_VERSION = 1
|
|
6
|
+
|
|
7
|
+
CERTIFICATE = "-----BEGIN CERTIFICATE-----\nMIIDMzCCApygAwIBAgIBATANBgkqhkiG9w0BAQUFADCBnjELMAkGA1UEBhMCVVMx\nEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxFjAUBgNVBAoM\nDU9wc2NvZGUsIEluYy4xHDAaBgNVBAsME0NlcnRpZmljYXRlIFNlcnZpY2UxMjAw\nBgNVBAMMKW9wc2NvZGUuY29tL2VtYWlsQWRkcmVzcz1hdXRoQG9wc2NvZGUuY29t\nMB4XDTEyMTEyMTAwMzQyMVoXDTIyMTExOTAwMzQyMVowgZsxEDAOBgNVBAcTB1Nl\nYXR0bGUxEzARBgNVBAgTCldhc2hpbmd0b24xCzAJBgNVBAYTAlVTMRwwGgYDVQQL\nExNDZXJ0aWZpY2F0ZS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x/y4qxbJYpYqXMrit0wVf7yAgkCgYEA1twI\ngFaXqesetTPoEHSQSgC8S4D5/NkdriUXCYb06REcvo9IpFMuiOkVUYNN5d3MDNTP\nIdBicfmvfNELvBtXDomEUD8ls1UuoTIXRNGZ0VsZXu7OErXCK0JKNNyqRmOwcvYL\nJRqLfnlei5Ndo1lu286yL74c5rdTLs/nI2p4e+0CgYB079ZmcLeILrmfBoFI8+Y/\ngJLmPrFvXBOE6+lRV7kqUFPtZ6I3yQzyccETZTDvrnx0WjaiFavUPH27WMjY01S2\nTMtO0Iq1MPsbSrglO1as8MvjB9ldFcvp7gy4Q0Sv6XT0yqJ/S+vo8Df0m+H4UBpU\nf5o6EwBSd/UQxwtZIE0lsQKBgQCswfjX8Eg8KL/lJNpIOOE3j4XXE9ptksmJl2sB\njxDnQYoiMqVO808saHVquC/vTrpd6tKtNpehWwjeTFuqITWLi8jmmQ+gNTKsC9Gn\n1Pxf2Gb67PqnEpwQGln+TRtgQ5HBrdHiQIi+5am+gnw89pDrjjO5rZwhanAo6KPJ\n1zcPNQKBgQDxFu8v4frDmRNCVaZS4f1B6wTrcMrnibIDlnzrK9GG6Hz1U7dDv8s8\nNf4UmeMzDXjlPWZVOvS5+9HKJPdPj7/onv8B2m18+lcgTTDJBkza7R1mjL1Cje/Z\nKcVGsryKN6cjE7yCDasnA7R2rVBV/7NWeJV77bmzT5O//rW4yIfUIg==\n-----END RSA PRIVATE KEY-----\n"
|
|
10
|
+
end
|
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
module ChefZero
|
|
2
|
-
module ChefData
|
|
3
|
-
# Manages translations between REST and ACL data paths
|
|
4
|
-
# and parent paths.
|
|
5
|
-
#
|
|
6
|
-
# Suggestions
|
|
7
|
-
# - make /organizations/ORG/_acl and deprecate organization/_acl and organizations/_acl
|
|
8
|
-
# - add endpoints for /containers/(users|organizations|containers)(/_acl)
|
|
9
|
-
# - add PUT for */_acl
|
|
10
|
-
# - add endpoints for /organizations/ORG/data/containers and /organizations/ORG/cookbooks/containers
|
|
11
|
-
# - sane, fully documented ACL model
|
|
12
|
-
# - sane inheritance / override model: if actors or groups are explicitly
|
|
13
|
-
# specified on X, they are not inherited from X's parent
|
|
14
|
-
# - stop adding pivotal to acls (he already has access to what he needs)
|
|
15
|
-
module AclPath
|
|
16
|
-
ORG_DATA_TYPES = %w(clients cookbooks containers data environments groups nodes roles sandboxes)
|
|
17
|
-
TOP_DATA_TYPES = %w(containers organizations users)
|
|
18
|
-
|
|
19
|
-
# ACL data paths for a partition are:
|
|
20
|
-
# / -> /acls/root
|
|
21
|
-
# /TYPE -> /acls/containers/TYPE
|
|
22
|
-
# /TYPE/NAME -> /acls/TYPE/NAME
|
|
23
|
-
#
|
|
24
|
-
# The root partition "/" has its own acls, so it looks like this:
|
|
25
|
-
#
|
|
26
|
-
# / -> /acls/root
|
|
27
|
-
# /users -> /acls/containers/users
|
|
28
|
-
# /organizations -> /acls/containers/organizations
|
|
29
|
-
# /users/schlansky -> /acls/users/schlansky
|
|
30
|
-
#
|
|
31
|
-
# Each organization is its own partition, so it looks like this:
|
|
32
|
-
#
|
|
33
|
-
# /organizations/blah -> /organizations/blah/acls/root
|
|
34
|
-
# /organizations/blah/roles -> /organizations/blah/acls/containers/roles
|
|
35
|
-
# /organizations/blah/roles/web -> /organizations/blah/acls/roles/web
|
|
36
|
-
# /organizations/ORG is its own partition. ACLs for anything under it follow
|
|
37
|
-
|
|
38
|
-
# This method takes a Chef REST path and returns the chef-zero path
|
|
39
|
-
# used to look up the ACL. If an object does not have an ACL directly,
|
|
40
|
-
# it will return nil. Paths like /organizations/ORG/data/bag/item will
|
|
41
|
-
# return nil, because it is the parent path (data/bag) that has an ACL.
|
|
42
|
-
def self.get_acl_data_path(path)
|
|
43
|
-
# Things under organizations have their own acls hierarchy
|
|
44
|
-
if path[0] == 'organizations' && path.size >= 2
|
|
45
|
-
under_org = partition_acl_data_path(path[2..-1], ORG_DATA_TYPES)
|
|
46
|
-
if under_org
|
|
47
|
-
path[0..1] + under_org
|
|
48
|
-
end
|
|
49
|
-
else
|
|
50
|
-
partition_acl_data_path(path, TOP_DATA_TYPES)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
# Reverse transform from acl_data_path to path.
|
|
56
|
-
# /acls/root -> /
|
|
57
|
-
# /acls/** -> /**
|
|
58
|
-
# /organizations/ORG/acls/root -> /organizations/ORG
|
|
59
|
-
# /organizations/ORG/acls/** -> /organizations/ORG/**
|
|
60
|
-
#
|
|
61
|
-
# This means that /acls/containers/nodes maps to
|
|
62
|
-
# /containers/nodes, not /nodes.
|
|
63
|
-
#
|
|
64
|
-
def self.get_object_path(acl_data_path)
|
|
65
|
-
if acl_data_path[0] == 'acls'
|
|
66
|
-
if acl_data_path[1] == 'root'
|
|
67
|
-
[]
|
|
68
|
-
else
|
|
69
|
-
acl_data_path[1..-1]
|
|
70
|
-
end
|
|
71
|
-
elsif acl_data_path[0] == 'organizations' && acl_data_path[2] == 'acls'
|
|
72
|
-
if acl_data_path[3] == 'root'
|
|
73
|
-
acl_data_path[0..1]
|
|
74
|
-
else
|
|
75
|
-
acl_data_path[0..1] + acl_data_path[3..-1]
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# Method *assumes* acl_data_path is valid.
|
|
81
|
-
# /organizations/BLAH's parent is /organizations
|
|
82
|
-
#
|
|
83
|
-
# An example traversal up the whole tree:
|
|
84
|
-
# /organizations/foo/acls/nodes/mario ->
|
|
85
|
-
# /organizations/foo/acls/containers/nodes ->
|
|
86
|
-
# /organizations/foo/acls/containers/containers ->
|
|
87
|
-
# /organizations/foo/acls/root ->
|
|
88
|
-
# /acls/containers/organizations ->
|
|
89
|
-
# /acls/containers/containers ->
|
|
90
|
-
# /acls/root ->
|
|
91
|
-
# nil
|
|
92
|
-
def self.parent_acl_data_path(acl_data_path)
|
|
93
|
-
if acl_data_path[0] == 'organizations'
|
|
94
|
-
under_org = partition_parent_acl_data_path(acl_data_path[2..-1])
|
|
95
|
-
if under_org
|
|
96
|
-
acl_data_path[0..1] + under_org
|
|
97
|
-
else
|
|
98
|
-
# ACL data path is /organizations/X/acls/root; therefore parent is "/organizations"
|
|
99
|
-
[ 'acls', 'containers', 'organizations' ]
|
|
100
|
-
end
|
|
101
|
-
else
|
|
102
|
-
partition_parent_acl_data_path(acl_data_path)
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
private
|
|
107
|
-
|
|
108
|
-
# /acls/root -> nil
|
|
109
|
-
# /acls/containers/containers -> /acls/root
|
|
110
|
-
# /acls/TYPE/X -> /acls/containers/TYPE
|
|
111
|
-
#
|
|
112
|
-
# Method *assumes* acl_data_path is valid.
|
|
113
|
-
# Returns nil if the path is /acls/root
|
|
114
|
-
def self.partition_parent_acl_data_path(acl_data_path)
|
|
115
|
-
if acl_data_path.size == 3
|
|
116
|
-
if acl_data_path == %w(acls containers containers)
|
|
117
|
-
[ 'acls', 'root' ]
|
|
118
|
-
else
|
|
119
|
-
[ 'acls', 'containers', acl_data_path[1]]
|
|
120
|
-
end
|
|
121
|
-
else
|
|
122
|
-
nil
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def self.partition_acl_data_path(path, data_types)
|
|
127
|
-
if path.size == 0
|
|
128
|
-
[ 'acls', 'root']
|
|
129
|
-
elsif data_types.include?(path[0])
|
|
130
|
-
if path.size == 0
|
|
131
|
-
[ 'acls', 'containers', path[0] ]
|
|
132
|
-
elsif path.size == 2
|
|
133
|
-
[ 'acls', path[0], path[1] ]
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
1
|
+
module ChefZero
|
|
2
|
+
module ChefData
|
|
3
|
+
# Manages translations between REST and ACL data paths
|
|
4
|
+
# and parent paths.
|
|
5
|
+
#
|
|
6
|
+
# Suggestions
|
|
7
|
+
# - make /organizations/ORG/_acl and deprecate organization/_acl and organizations/_acl
|
|
8
|
+
# - add endpoints for /containers/(users|organizations|containers)(/_acl)
|
|
9
|
+
# - add PUT for */_acl
|
|
10
|
+
# - add endpoints for /organizations/ORG/data/containers and /organizations/ORG/cookbooks/containers
|
|
11
|
+
# - sane, fully documented ACL model
|
|
12
|
+
# - sane inheritance / override model: if actors or groups are explicitly
|
|
13
|
+
# specified on X, they are not inherited from X's parent
|
|
14
|
+
# - stop adding pivotal to acls (he already has access to what he needs)
|
|
15
|
+
module AclPath
|
|
16
|
+
ORG_DATA_TYPES = %w(clients cookbooks containers data environments groups nodes roles sandboxes)
|
|
17
|
+
TOP_DATA_TYPES = %w(containers organizations users)
|
|
18
|
+
|
|
19
|
+
# ACL data paths for a partition are:
|
|
20
|
+
# / -> /acls/root
|
|
21
|
+
# /TYPE -> /acls/containers/TYPE
|
|
22
|
+
# /TYPE/NAME -> /acls/TYPE/NAME
|
|
23
|
+
#
|
|
24
|
+
# The root partition "/" has its own acls, so it looks like this:
|
|
25
|
+
#
|
|
26
|
+
# / -> /acls/root
|
|
27
|
+
# /users -> /acls/containers/users
|
|
28
|
+
# /organizations -> /acls/containers/organizations
|
|
29
|
+
# /users/schlansky -> /acls/users/schlansky
|
|
30
|
+
#
|
|
31
|
+
# Each organization is its own partition, so it looks like this:
|
|
32
|
+
#
|
|
33
|
+
# /organizations/blah -> /organizations/blah/acls/root
|
|
34
|
+
# /organizations/blah/roles -> /organizations/blah/acls/containers/roles
|
|
35
|
+
# /organizations/blah/roles/web -> /organizations/blah/acls/roles/web
|
|
36
|
+
# /organizations/ORG is its own partition. ACLs for anything under it follow
|
|
37
|
+
|
|
38
|
+
# This method takes a Chef REST path and returns the chef-zero path
|
|
39
|
+
# used to look up the ACL. If an object does not have an ACL directly,
|
|
40
|
+
# it will return nil. Paths like /organizations/ORG/data/bag/item will
|
|
41
|
+
# return nil, because it is the parent path (data/bag) that has an ACL.
|
|
42
|
+
def self.get_acl_data_path(path)
|
|
43
|
+
# Things under organizations have their own acls hierarchy
|
|
44
|
+
if path[0] == 'organizations' && path.size >= 2
|
|
45
|
+
under_org = partition_acl_data_path(path[2..-1], ORG_DATA_TYPES)
|
|
46
|
+
if under_org
|
|
47
|
+
path[0..1] + under_org
|
|
48
|
+
end
|
|
49
|
+
else
|
|
50
|
+
partition_acl_data_path(path, TOP_DATA_TYPES)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# Reverse transform from acl_data_path to path.
|
|
56
|
+
# /acls/root -> /
|
|
57
|
+
# /acls/** -> /**
|
|
58
|
+
# /organizations/ORG/acls/root -> /organizations/ORG
|
|
59
|
+
# /organizations/ORG/acls/** -> /organizations/ORG/**
|
|
60
|
+
#
|
|
61
|
+
# This means that /acls/containers/nodes maps to
|
|
62
|
+
# /containers/nodes, not /nodes.
|
|
63
|
+
#
|
|
64
|
+
def self.get_object_path(acl_data_path)
|
|
65
|
+
if acl_data_path[0] == 'acls'
|
|
66
|
+
if acl_data_path[1] == 'root'
|
|
67
|
+
[]
|
|
68
|
+
else
|
|
69
|
+
acl_data_path[1..-1]
|
|
70
|
+
end
|
|
71
|
+
elsif acl_data_path[0] == 'organizations' && acl_data_path[2] == 'acls'
|
|
72
|
+
if acl_data_path[3] == 'root'
|
|
73
|
+
acl_data_path[0..1]
|
|
74
|
+
else
|
|
75
|
+
acl_data_path[0..1] + acl_data_path[3..-1]
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Method *assumes* acl_data_path is valid.
|
|
81
|
+
# /organizations/BLAH's parent is /organizations
|
|
82
|
+
#
|
|
83
|
+
# An example traversal up the whole tree:
|
|
84
|
+
# /organizations/foo/acls/nodes/mario ->
|
|
85
|
+
# /organizations/foo/acls/containers/nodes ->
|
|
86
|
+
# /organizations/foo/acls/containers/containers ->
|
|
87
|
+
# /organizations/foo/acls/root ->
|
|
88
|
+
# /acls/containers/organizations ->
|
|
89
|
+
# /acls/containers/containers ->
|
|
90
|
+
# /acls/root ->
|
|
91
|
+
# nil
|
|
92
|
+
def self.parent_acl_data_path(acl_data_path)
|
|
93
|
+
if acl_data_path[0] == 'organizations'
|
|
94
|
+
under_org = partition_parent_acl_data_path(acl_data_path[2..-1])
|
|
95
|
+
if under_org
|
|
96
|
+
acl_data_path[0..1] + under_org
|
|
97
|
+
else
|
|
98
|
+
# ACL data path is /organizations/X/acls/root; therefore parent is "/organizations"
|
|
99
|
+
[ 'acls', 'containers', 'organizations' ]
|
|
100
|
+
end
|
|
101
|
+
else
|
|
102
|
+
partition_parent_acl_data_path(acl_data_path)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
private
|
|
107
|
+
|
|
108
|
+
# /acls/root -> nil
|
|
109
|
+
# /acls/containers/containers -> /acls/root
|
|
110
|
+
# /acls/TYPE/X -> /acls/containers/TYPE
|
|
111
|
+
#
|
|
112
|
+
# Method *assumes* acl_data_path is valid.
|
|
113
|
+
# Returns nil if the path is /acls/root
|
|
114
|
+
def self.partition_parent_acl_data_path(acl_data_path)
|
|
115
|
+
if acl_data_path.size == 3
|
|
116
|
+
if acl_data_path == %w(acls containers containers)
|
|
117
|
+
[ 'acls', 'root' ]
|
|
118
|
+
else
|
|
119
|
+
[ 'acls', 'containers', acl_data_path[1]]
|
|
120
|
+
end
|
|
121
|
+
else
|
|
122
|
+
nil
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self.partition_acl_data_path(path, data_types)
|
|
127
|
+
if path.size == 0
|
|
128
|
+
[ 'acls', 'root']
|
|
129
|
+
elsif data_types.include?(path[0])
|
|
130
|
+
if path.size == 0
|
|
131
|
+
[ 'acls', 'containers', path[0] ]
|
|
132
|
+
elsif path.size == 2
|
|
133
|
+
[ 'acls', path[0], path[1] ]
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|