chef-zero 4.8.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -4
  3. data/Rakefile +20 -10
  4. data/bin/chef-zero +12 -12
  5. data/chef-zero.gemspec +24 -24
  6. data/lib/chef_zero.rb +1 -1
  7. data/lib/chef_zero/chef_data/acl_path.rb +16 -16
  8. data/lib/chef_zero/chef_data/cookbook_data.rb +24 -24
  9. data/lib/chef_zero/chef_data/data_normalizer.rb +120 -120
  10. data/lib/chef_zero/chef_data/default_creator.rb +145 -145
  11. data/lib/chef_zero/data_store/data_already_exists_error.rb +1 -1
  12. data/lib/chef_zero/data_store/data_not_found_error.rb +2 -2
  13. data/lib/chef_zero/data_store/default_facade.rb +5 -5
  14. data/lib/chef_zero/data_store/interface_v1.rb +1 -1
  15. data/lib/chef_zero/data_store/interface_v2.rb +1 -1
  16. data/lib/chef_zero/data_store/memory_store.rb +4 -4
  17. data/lib/chef_zero/data_store/memory_store_v2.rb +8 -8
  18. data/lib/chef_zero/data_store/raw_file_store.rb +10 -10
  19. data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +9 -9
  20. data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +5 -5
  21. data/lib/chef_zero/endpoints/acl_endpoint.rb +6 -6
  22. data/lib/chef_zero/endpoints/acls_endpoint.rb +5 -5
  23. data/lib/chef_zero/endpoints/actor_default_key_endpoint.rb +1 -1
  24. data/lib/chef_zero/endpoints/actor_endpoint.rb +20 -20
  25. data/lib/chef_zero/endpoints/actor_key_endpoint.rb +1 -1
  26. data/lib/chef_zero/endpoints/actor_keys_endpoint.rb +5 -6
  27. data/lib/chef_zero/endpoints/actors_endpoint.rb +12 -12
  28. data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +10 -10
  29. data/lib/chef_zero/endpoints/container_endpoint.rb +4 -4
  30. data/lib/chef_zero/endpoints/containers_endpoint.rb +3 -3
  31. data/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb +1 -1
  32. data/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb +1 -1
  33. data/lib/chef_zero/endpoints/cookbook_artifacts_endpoint.rb +1 -1
  34. data/lib/chef_zero/endpoints/cookbook_endpoint.rb +5 -5
  35. data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +20 -16
  36. data/lib/chef_zero/endpoints/cookbooks_base.rb +13 -13
  37. data/lib/chef_zero/endpoints/cookbooks_endpoint.rb +4 -4
  38. data/lib/chef_zero/endpoints/data_bag_endpoint.rb +12 -12
  39. data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +6 -6
  40. data/lib/chef_zero/endpoints/data_bags_endpoint.rb +5 -5
  41. data/lib/chef_zero/endpoints/dummy_endpoint.rb +0 -2
  42. data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +6 -6
  43. data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +16 -16
  44. data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +6 -6
  45. data/lib/chef_zero/endpoints/environment_endpoint.rb +3 -3
  46. data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +6 -6
  47. data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +4 -4
  48. data/lib/chef_zero/endpoints/environment_role_endpoint.rb +8 -8
  49. data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +2 -2
  50. data/lib/chef_zero/endpoints/group_endpoint.rb +4 -4
  51. data/lib/chef_zero/endpoints/groups_endpoint.rb +3 -3
  52. data/lib/chef_zero/endpoints/license_endpoint.rb +5 -5
  53. data/lib/chef_zero/endpoints/node_endpoint.rb +3 -4
  54. data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +7 -7
  55. data/lib/chef_zero/endpoints/nodes_endpoint.rb +3 -4
  56. data/lib/chef_zero/endpoints/not_found_endpoint.rb +2 -2
  57. data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +2 -2
  58. data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +6 -6
  59. data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +8 -8
  60. data/lib/chef_zero/endpoints/organization_endpoint.rb +10 -10
  61. data/lib/chef_zero/endpoints/organization_user_base.rb +2 -2
  62. data/lib/chef_zero/endpoints/organization_user_default_key_endpoint.rb +1 -1
  63. data/lib/chef_zero/endpoints/organization_user_endpoint.rb +5 -5
  64. data/lib/chef_zero/endpoints/organization_user_key_endpoint.rb +2 -2
  65. data/lib/chef_zero/endpoints/organization_user_keys_endpoint.rb +1 -1
  66. data/lib/chef_zero/endpoints/organization_users_endpoint.rb +12 -12
  67. data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +6 -6
  68. data/lib/chef_zero/endpoints/organizations_endpoint.rb +12 -13
  69. data/lib/chef_zero/endpoints/policies_endpoint.rb +2 -2
  70. data/lib/chef_zero/endpoints/policy_endpoint.rb +1 -1
  71. data/lib/chef_zero/endpoints/policy_group_endpoint.rb +6 -6
  72. data/lib/chef_zero/endpoints/policy_group_policy_endpoint.rb +3 -4
  73. data/lib/chef_zero/endpoints/policy_groups_endpoint.rb +4 -4
  74. data/lib/chef_zero/endpoints/policy_revision_endpoint.rb +1 -1
  75. data/lib/chef_zero/endpoints/policy_revisions_endpoint.rb +1 -1
  76. data/lib/chef_zero/endpoints/principal_endpoint.rb +15 -15
  77. data/lib/chef_zero/endpoints/rest_list_endpoint.rb +4 -4
  78. data/lib/chef_zero/endpoints/rest_object_endpoint.rb +4 -4
  79. data/lib/chef_zero/endpoints/role_endpoint.rb +3 -3
  80. data/lib/chef_zero/endpoints/role_environments_endpoint.rb +3 -3
  81. data/lib/chef_zero/endpoints/sandbox_endpoint.rb +8 -8
  82. data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +9 -9
  83. data/lib/chef_zero/endpoints/search_endpoint.rb +51 -49
  84. data/lib/chef_zero/endpoints/searches_endpoint.rb +2 -2
  85. data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +2 -2
  86. data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +8 -8
  87. data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +12 -12
  88. data/lib/chef_zero/endpoints/user_association_requests_count_endpoint.rb +4 -4
  89. data/lib/chef_zero/endpoints/user_association_requests_endpoint.rb +4 -4
  90. data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +5 -5
  91. data/lib/chef_zero/endpoints/version_endpoint.rb +1 -1
  92. data/lib/chef_zero/log.rb +1 -1
  93. data/lib/chef_zero/rest_base.rb +25 -25
  94. data/lib/chef_zero/rest_request.rb +11 -11
  95. data/lib/chef_zero/rest_router.rb +30 -30
  96. data/lib/chef_zero/rspec.rb +33 -33
  97. data/lib/chef_zero/server.rb +188 -189
  98. data/lib/chef_zero/socketless_server_map.rb +2 -3
  99. data/lib/chef_zero/solr/query/binary_operator.rb +8 -8
  100. data/lib/chef_zero/solr/query/phrase.rb +1 -1
  101. data/lib/chef_zero/solr/query/range_query.rb +2 -2
  102. data/lib/chef_zero/solr/query/regexpable_query.rb +1 -0
  103. data/lib/chef_zero/solr/query/term.rb +5 -5
  104. data/lib/chef_zero/solr/query/unary_operator.rb +4 -4
  105. data/lib/chef_zero/solr/solr_doc.rb +4 -4
  106. data/lib/chef_zero/solr/solr_parser.rb +34 -33
  107. data/lib/chef_zero/version.rb +1 -1
  108. data/spec/run_oc_pedant.rb +61 -60
  109. data/spec/search_spec.rb +11 -11
  110. data/spec/server_spec.rb +35 -35
  111. data/spec/socketless_server_map_spec.rb +1 -3
  112. data/spec/support/oc_pedant.rb +20 -21
  113. metadata +2 -2
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef_zero/data_store/data_error'
19
+ require "chef_zero/data_store/data_error"
20
20
 
21
21
  module ChefZero
22
22
  module DataStore
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef_zero/data_store/data_error'
19
+ require "chef_zero/data_store/data_error"
20
20
 
21
21
  module ChefZero
22
22
  module DataStore
@@ -26,4 +26,4 @@ module ChefZero
26
26
  end
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -1,5 +1,5 @@
1
- require 'chef_zero/data_store/interface_v2'
2
- require 'chef_zero/chef_data/default_creator'
1
+ require "chef_zero/data_store/interface_v2"
2
+ require "chef_zero/chef_data/default_creator"
3
3
 
4
4
  module ChefZero
5
5
  module DataStore
@@ -65,7 +65,7 @@ module ChefZero
65
65
  default_creator.created(path + [ name ], options_hash[:requestor], options.include?(:create_dir))
66
66
  end
67
67
 
68
- def get(path, request=nil)
68
+ def get(path, request = nil)
69
69
  begin
70
70
  real_store.get(path, request)
71
71
  rescue DataNotFoundError
@@ -83,8 +83,8 @@ module ChefZero
83
83
  real_store.set(path, data, *options)
84
84
  rescue DataNotFoundError
85
85
  if options.include?(:create_dir) ||
86
- options.include?(:create) && default_creator.exists?(path[0..-2]) ||
87
- default_creator.exists?(path)
86
+ options.include?(:create) && default_creator.exists?(path[0..-2]) ||
87
+ default_creator.exists?(path)
88
88
  real_store.set(path, data, :create, :create_dir, *options)
89
89
  else
90
90
  raise
@@ -24,7 +24,7 @@ module ChefZero
24
24
  end
25
25
 
26
26
  # Get a file.
27
- def get(path, request=nil)
27
+ def get(path, request = nil)
28
28
  raise "get not implemented by class #{self.class}"
29
29
  end
30
30
 
@@ -1,4 +1,4 @@
1
- require 'chef_zero/data_store/interface_v1'
1
+ require "chef_zero/data_store/interface_v1"
2
2
 
3
3
  module ChefZero
4
4
  module DataStore
@@ -16,16 +16,16 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef_zero/data_store/v2_to_v1_adapter'
20
- require 'chef_zero/data_store/memory_store_v2'
21
- require 'chef_zero/data_store/default_facade'
19
+ require "chef_zero/data_store/v2_to_v1_adapter"
20
+ require "chef_zero/data_store/memory_store_v2"
21
+ require "chef_zero/data_store/default_facade"
22
22
 
23
23
  module ChefZero
24
24
  module DataStore
25
25
  class MemoryStore < ChefZero::DataStore::V2ToV1Adapter
26
26
  def initialize
27
27
  super
28
- @real_store = ChefZero::DataStore::DefaultFacade.new(ChefZero::DataStore::MemoryStoreV2.new, 'chef', true)
28
+ @real_store = ChefZero::DataStore::DefaultFacade.new(ChefZero::DataStore::MemoryStoreV2.new, "chef", true)
29
29
  clear
30
30
  end
31
31
  end
@@ -16,9 +16,9 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef_zero/data_store/data_already_exists_error'
20
- require 'chef_zero/data_store/data_not_found_error'
21
- require 'chef_zero/data_store/interface_v2'
19
+ require "chef_zero/data_store/data_already_exists_error"
20
+ require "chef_zero/data_store/data_not_found_error"
21
+ require "chef_zero/data_store/interface_v2"
22
22
 
23
23
  module ChefZero
24
24
  module DataStore
@@ -58,7 +58,7 @@ module ChefZero
58
58
  parent[name] = data
59
59
  end
60
60
 
61
- def get(path, request=nil)
61
+ def get(path, request = nil)
62
62
  value = _get(path)
63
63
  if value.is_a?(Hash)
64
64
  raise "get() called on directory #{path.join('/')}"
@@ -81,7 +81,7 @@ module ChefZero
81
81
  end
82
82
 
83
83
  def delete(path)
84
- parent = _get(path[0,path.length-1])
84
+ parent = _get(path[0, path.length - 1])
85
85
  if !parent.has_key?(path[-1])
86
86
  raise DataNotFoundError.new(path)
87
87
  end
@@ -92,7 +92,7 @@ module ChefZero
92
92
  end
93
93
 
94
94
  def delete_dir(path, *options)
95
- parent = _get(path[0,path.length-1])
95
+ parent = _get(path[0, path.length - 1])
96
96
  if !parent.has_key?(path[-1])
97
97
  raise DataNotFoundError.new(path)
98
98
  end
@@ -136,14 +136,14 @@ module ChefZero
136
136
 
137
137
  private
138
138
 
139
- def _get(path, create_dir=false)
139
+ def _get(path, create_dir = false)
140
140
  value = @data
141
141
  path.each_with_index do |path_part, index|
142
142
  if !value.has_key?(path_part)
143
143
  if create_dir
144
144
  value[path_part] = {}
145
145
  else
146
- raise DataNotFoundError.new(path[0,index+1])
146
+ raise DataNotFoundError.new(path[0, index + 1])
147
147
  end
148
148
  end
149
149
  value = value[path_part]
@@ -16,10 +16,10 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef_zero/data_store/data_already_exists_error'
20
- require 'chef_zero/data_store/data_not_found_error'
21
- require 'chef_zero/data_store/interface_v2'
22
- require 'fileutils'
19
+ require "chef_zero/data_store/data_already_exists_error"
20
+ require "chef_zero/data_store/data_not_found_error"
21
+ require "chef_zero/data_store/interface_v2"
22
+ require "fileutils"
23
23
 
24
24
  module ChefZero
25
25
  module DataStore
@@ -32,7 +32,7 @@ module ChefZero
32
32
  attr_reader :root
33
33
  attr_reader :destructible
34
34
 
35
- def path_to(path, name=nil)
35
+ def path_to(path, name = nil)
36
36
  if name
37
37
  File.join(root, *path, name)
38
38
  else
@@ -43,7 +43,7 @@ module ChefZero
43
43
  def clear
44
44
  if destructible
45
45
  Dir.entries(root).each do |entry|
46
- next if entry == '.' || entry == '..'
46
+ next if entry == "." || entry == ".."
47
47
  FileUtils.rm_rf(Path.join(root, entry))
48
48
  end
49
49
  end
@@ -69,7 +69,7 @@ module ChefZero
69
69
  FileUtils.mkdir_p(path_to(path))
70
70
  end
71
71
  begin
72
- File.open(path_to(path, name), File::WRONLY|File::CREAT|File::EXCL|File::BINARY, :internal_encoding => nil) do |file|
72
+ File.open(path_to(path, name), File::WRONLY | File::CREAT | File::EXCL | File::BINARY, :internal_encoding => nil) do |file|
73
73
  file.write data
74
74
  end
75
75
  rescue Errno::ENOENT
@@ -79,7 +79,7 @@ module ChefZero
79
79
  end
80
80
  end
81
81
 
82
- def get(path, request=nil)
82
+ def get(path, request = nil)
83
83
  begin
84
84
  return IO.read(path_to(path))
85
85
  rescue Errno::ENOENT
@@ -92,7 +92,7 @@ module ChefZero
92
92
  FileUtils.mkdir_p(path_to(path[0..-2]))
93
93
  end
94
94
  begin
95
- mode = File::WRONLY|File::TRUNC|File::BINARY
95
+ mode = File::WRONLY | File::TRUNC | File::BINARY
96
96
  if options.include?(:create)
97
97
  mode |= File::CREAT
98
98
  end
@@ -129,7 +129,7 @@ module ChefZero
129
129
 
130
130
  def list(path)
131
131
  begin
132
- Dir.entries(path_to(path)).select { |entry| entry != '.' && entry != '..' }.to_a
132
+ Dir.entries(path_to(path)).select { |entry| entry != "." && entry != ".." }.to_a
133
133
  rescue Errno::ENOENT
134
134
  raise DataNotFoundError.new(path)
135
135
  end
@@ -1,4 +1,4 @@
1
- require 'chef_zero/data_store/interface_v2'
1
+ require "chef_zero/data_store/interface_v2"
2
2
 
3
3
  module ChefZero
4
4
  module DataStore
@@ -35,13 +35,13 @@ module ChefZero
35
35
  end
36
36
  end
37
37
 
38
- def get(path, request=nil)
38
+ def get(path, request = nil)
39
39
  raise DataNotFoundError.new(path) if skip_organizations?(path)
40
40
  fix_exceptions do
41
41
  # Make it so build_uri will include /organizations/ORG inside the V1 data store
42
42
  if request && request.rest_base_prefix.size == 0
43
43
  old_base_uri = request.base_uri
44
- request.base_uri = File.join(request.base_uri, 'organizations', single_org)
44
+ request.base_uri = File.join(request.base_uri, "organizations", single_org)
45
45
  end
46
46
  begin
47
47
  real_store.get(path[2..-1], request)
@@ -75,8 +75,8 @@ module ChefZero
75
75
  def list(path)
76
76
  raise DataNotFoundError.new(path) if skip_organizations?(path)
77
77
  if path == []
78
- [ 'organizations' ]
79
- elsif path == [ 'organizations' ]
78
+ [ "organizations" ]
79
+ elsif path == [ "organizations" ]
80
80
  [ single_org ]
81
81
  else
82
82
  fix_exceptions do
@@ -96,7 +96,7 @@ module ChefZero
96
96
  return false if skip_organizations?(path)
97
97
  if path == []
98
98
  true
99
- elsif path == [ 'organizations' ] || path == [ 'users' ]
99
+ elsif path == [ "organizations" ] || path == [ "users" ]
100
100
  true
101
101
  else
102
102
  return false if skip_organizations?(path)
@@ -112,11 +112,11 @@ module ChefZero
112
112
  begin
113
113
  yield
114
114
  rescue DataAlreadyExistsError => e
115
- err = DataAlreadyExistsError.new([ 'organizations', single_org ] + e.path, e)
115
+ err = DataAlreadyExistsError.new([ "organizations", single_org ] + e.path, e)
116
116
  err.set_backtrace(e.backtrace)
117
117
  raise err
118
118
  rescue DataNotFoundError => e
119
- err = DataNotFoundError.new([ 'organizations', single_org ] + e.path, e)
119
+ err = DataNotFoundError.new([ "organizations", single_org ] + e.path, e)
120
120
  err.set_backtrace(e.backtrace)
121
121
  raise e
122
122
  end
@@ -125,7 +125,7 @@ module ChefZero
125
125
  def skip_organizations?(path, name = nil)
126
126
  if path == []
127
127
  false
128
- elsif path[0] == 'organizations'
128
+ elsif path[0] == "organizations"
129
129
  if path.size == 1
130
130
  false
131
131
  elsif path.size >= 2 && path[1] != single_org
@@ -16,13 +16,13 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef_zero/data_store/interface_v1'
19
+ require "chef_zero/data_store/interface_v1"
20
20
 
21
21
  module ChefZero
22
22
  module DataStore
23
23
  class V2ToV1Adapter < ChefZero::DataStore::InterfaceV1
24
24
  def initialize
25
- @single_org = 'chef'
25
+ @single_org = "chef"
26
26
  end
27
27
 
28
28
  attr_reader :real_store
@@ -30,7 +30,7 @@ module ChefZero
30
30
 
31
31
  def clear
32
32
  real_store.clear
33
- real_store.create_dir([ 'organizations' ], single_org, :recursive)
33
+ real_store.create_dir([ "organizations" ], single_org, :recursive)
34
34
  end
35
35
 
36
36
  def create_dir(path, name, *options)
@@ -45,7 +45,7 @@ module ChefZero
45
45
  end
46
46
  end
47
47
 
48
- def get(path, request=nil)
48
+ def get(path, request = nil)
49
49
  fix_exceptions do
50
50
  real_store.get(fix_path(path), request)
51
51
  end
@@ -100,7 +100,7 @@ module ChefZero
100
100
  end
101
101
 
102
102
  def fix_path(path)
103
- [ 'organizations', single_org ] + path
103
+ [ "organizations", single_org ] + path
104
104
  end
105
105
  end
106
106
  end
@@ -1,6 +1,6 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
3
- require 'chef_zero/chef_data/acl_path'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
+ require "chef_zero/chef_data/acl_path"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -17,10 +17,10 @@ module ChefZero
17
17
  class AclEndpoint < RestBase
18
18
  def validate_request(request)
19
19
  path = request.rest_path[0..-3] # Strip off _acl/PERM
20
- path = path[0..1] if path.size == 3 && path[0] == 'organizations' && %w(organization organizations).include?(path[2])
20
+ path = path[0..1] if path.size == 3 && path[0] == "organizations" && %w{organization organizations}.include?(path[2])
21
21
  acl_path = ChefData::AclPath.get_acl_data_path(path)
22
22
  perm = request.rest_path[-1]
23
- if !acl_path || !%w(read create update delete grant).include?(perm)
23
+ if !acl_path || !%w{read create update delete grant}.include?(perm)
24
24
  raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
25
25
  end
26
26
  [acl_path, perm]
@@ -31,7 +31,7 @@ module ChefZero
31
31
  acls = FFI_Yajl::Parser.parse(get_data(request, path), :create_additions => false)
32
32
  acls[perm] = FFI_Yajl::Parser.parse(request.body, :create_additions => false)[perm]
33
33
  set_data(request, path, FFI_Yajl::Encoder.encode(acls, :pretty => true))
34
- json_response(200, {'uri' => "#{build_uri(request.base_uri, request.rest_path)}"})
34
+ json_response(200, { "uri" => "#{build_uri(request.base_uri, request.rest_path)}" })
35
35
  end
36
36
  end
37
37
  end
@@ -1,7 +1,7 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
3
- require 'chef_zero/chef_data/data_normalizer'
4
- require 'chef_zero/chef_data/acl_path'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
+ require "chef_zero/chef_data/data_normalizer"
4
+ require "chef_zero/chef_data/acl_path"
5
5
 
6
6
  module ChefZero
7
7
  module Endpoints
@@ -15,7 +15,7 @@ module ChefZero
15
15
  class AclsEndpoint < RestBase
16
16
  def get(request)
17
17
  path = request.rest_path[0..-2] # Strip off _acl
18
- path = path[0..1] if path.size == 3 && path[0] == 'organizations' && %w(organization organizations).include?(path[2])
18
+ path = path[0..1] if path.size == 3 && path[0] == "organizations" && %w{organization organizations}.include?(path[2])
19
19
  acl_path = ChefData::AclPath.get_acl_data_path(path)
20
20
  if !acl_path
21
21
  raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
@@ -1,4 +1,4 @@
1
- require 'chef_zero/rest_base'
1
+ require "chef_zero/rest_base"
2
2
 
3
3
  module ChefZero
4
4
  module Endpoints
@@ -1,6 +1,6 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/endpoints/rest_object_endpoint'
3
- require 'chef_zero/chef_data/data_normalizer'
1
+ require "ffi_yajl"
2
+ require "chef_zero/endpoints/rest_object_endpoint"
3
+ require "chef_zero/chef_data/data_normalizer"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -21,10 +21,10 @@ module ChefZero
21
21
  def delete(request)
22
22
  result = super
23
23
 
24
- if request.rest_path[0] == 'users'
25
- list_data(request, [ 'organizations' ]).each do |org|
24
+ if request.rest_path[0] == "users"
25
+ list_data(request, [ "organizations" ]).each do |org|
26
26
  begin
27
- delete_data(request, [ 'organizations', org, 'users', request.rest_path[1] ], :data_store_exceptions)
27
+ delete_data(request, [ "organizations", org, "users", request.rest_path[1] ], :data_store_exceptions)
28
28
  rescue DataStore::DataNotFoundError
29
29
  end
30
30
  end
@@ -38,22 +38,22 @@ module ChefZero
38
38
  # Find out if we're updating the public key.
39
39
  request_body = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
40
40
 
41
- if request_body['public_key'].nil?
41
+ if request_body["public_key"].nil?
42
42
  # If public_key is null, then don't overwrite it. Weird patchiness.
43
43
  body_modified = true
44
- request_body.delete('public_key')
44
+ request_body.delete("public_key")
45
45
  else
46
46
  updating_public_key = true
47
47
  end
48
48
 
49
49
  # Generate private_key if requested.
50
- if request_body.key?('private_key')
50
+ if request_body.key?("private_key")
51
51
  body_modified = true
52
52
 
53
- if request_body.delete('private_key')
53
+ if request_body.delete("private_key")
54
54
  private_key, public_key = server.gen_key_pair
55
55
  updating_public_key = true
56
- request_body['public_key'] = public_key
56
+ request_body["public_key"] = public_key
57
57
  end
58
58
  end
59
59
 
@@ -73,22 +73,22 @@ module ChefZero
73
73
  rename_keys!(request, client_or_user_name)
74
74
  end
75
75
 
76
- if request.rest_path[0] == 'users'
76
+ if request.rest_path[0] == "users"
77
77
  response = {
78
- 'uri' => build_uri(request.base_uri, [ 'users', client_or_user_name ])
78
+ "uri" => build_uri(request.base_uri, [ "users", client_or_user_name ]),
79
79
  }
80
80
  else
81
81
  response = parse_json(result[2])
82
82
  end
83
83
 
84
84
  if client?(request)
85
- response['private_key'] = private_key ? private_key : false
85
+ response["private_key"] = private_key ? private_key : false
86
86
  else
87
- response['private_key'] = private_key if private_key
88
- response.delete('public_key') unless updating_public_key
87
+ response["private_key"] = private_key if private_key
88
+ response.delete("public_key") unless updating_public_key
89
89
  end
90
90
 
91
- response.delete('password')
91
+ response.delete("password")
92
92
 
93
93
  json_response(result[0], response)
94
94
  else
@@ -125,7 +125,7 @@ module ChefZero
125
125
  def rename_keys!(request, new_client_or_user_name)
126
126
  orig_keys_path = keys_path_base(request)
127
127
  new_keys_path = orig_keys_path.dup
128
- .tap {|path| path[-2] = new_client_or_user_name }
128
+ .tap { |path| path[-2] = new_client_or_user_name }
129
129
 
130
130
  key_names = list_data_or_else(request, orig_keys_path, nil)
131
131
  return unless key_names # No keys to move
@@ -154,7 +154,7 @@ module ChefZero
154
154
  rescue DataStore::DataNotFoundError
155
155
  end
156
156
 
157
- def client?(request, rest_path=nil)
157
+ def client?(request, rest_path = nil)
158
158
  rest_path ||= request.rest_path
159
159
  request.rest_path[2] == "clients"
160
160
  end
@@ -165,7 +165,7 @@ module ChefZero
165
165
  # /organizations/ORG/users/USER -> /organizations/ORG/user_keys/USER/keys
166
166
  # /users/USER -> /user_keys/USER
167
167
  #
168
- def keys_path_base(request, client_or_user_name=nil)
168
+ def keys_path_base(request, client_or_user_name = nil)
169
169
  rest_path = (rest_path || request.rest_path).dup
170
170
  rest_path = rest_path.dup
171
171
  case rest_path[-2]