diff options
author | John Keiser <jkeiser@opscode.com> | 2014-08-21 12:37:22 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-08-22 09:20:50 -0700 |
commit | a4efe10a02590f9caa21544504a2b1d6f5ffb295 (patch) | |
tree | 52bc642cc69f0f29a804bdbc00cd5d0016e78da5 | |
parent | 57203ee3aabee96aaa5ba6437e4d6b373793d897 (diff) | |
download | chef-zero-a4efe10a02590f9caa21544504a2b1d6f5ffb295.tar.gz |
Make acls endpoints return 405 for disallowed methods
-rw-r--r-- | lib/chef_zero/chef_data/default_creator.rb | 6 | ||||
-rw-r--r-- | lib/chef_zero/data_normalizer.rb | 5 | ||||
-rw-r--r-- | lib/chef_zero/data_store/default_facade.rb | 2 | ||||
-rw-r--r-- | lib/chef_zero/endpoints/acl_endpoint.rb | 13 | ||||
-rw-r--r-- | lib/chef_zero/endpoints/acls_endpoint.rb | 13 | ||||
-rw-r--r-- | lib/chef_zero/server.rb | 2 | ||||
-rw-r--r-- | spec/support/oc_pedant.rb | 1 |
7 files changed, 10 insertions, 32 deletions
diff --git a/lib/chef_zero/chef_data/default_creator.rb b/lib/chef_zero/chef_data/default_creator.rb index 667268b..f0403ab 100644 --- a/lib/chef_zero/chef_data/default_creator.rb +++ b/lib/chef_zero/chef_data/default_creator.rb @@ -244,8 +244,8 @@ module ChefZero when "groups/users" users = data.list(path[0..1] + [ 'users' ]) - users += @creators[path[0..1]] if @creators[path[0..1]] - { 'users' => users.uniq } + users |= @creators[path[0..1]] if @creators[path[0..1]] + { 'users' => users } when "org" {} @@ -362,7 +362,7 @@ module ChefZero owners |= @creators[path] if @creators[path] end - owners += superusers + owners |= superusers end owners.uniq diff --git a/lib/chef_zero/data_normalizer.rb b/lib/chef_zero/data_normalizer.rb index 8492656..39cccc5 100644 --- a/lib/chef_zero/data_normalizer.rb +++ b/lib/chef_zero/data_normalizer.rb @@ -142,6 +142,11 @@ module ChefZero group['orgname'] ||= orgname if orgname group['name'] ||= name group['groupname'] ||= name + + group['users'].uniq! + group['clients'].uniq! + group['actors'].uniq! + group['groups'].uniq! group end diff --git a/lib/chef_zero/data_store/default_facade.rb b/lib/chef_zero/data_store/default_facade.rb index abc3f47..2beb8c5 100644 --- a/lib/chef_zero/data_store/default_facade.rb +++ b/lib/chef_zero/data_store/default_facade.rb @@ -90,7 +90,7 @@ module ChefZero end end - def delete(path) + def delete(path, *options) deleted = default_creator.deleted(path) begin real_store.delete(path) diff --git a/lib/chef_zero/endpoints/acl_endpoint.rb b/lib/chef_zero/endpoints/acl_endpoint.rb index e0310c7..8e97344 100644 --- a/lib/chef_zero/endpoints/acl_endpoint.rb +++ b/lib/chef_zero/endpoints/acl_endpoint.rb @@ -26,10 +26,6 @@ module ChefZero [acl_path, perm] end - def get(request) - raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}") - end - def put(request) path, perm = validate_request(request) acls = JSON.parse(get_data(request, path), :create_additions => false) @@ -37,15 +33,6 @@ module ChefZero set_data(request, path, JSON.pretty_generate(acls)) json_response(200, {'uri' => "#{build_uri(request.base_uri, request.rest_path)}"}) end - - # Remove these to get them doing 405 again like they ought to - def post(request) - raise RestErrorResponse.new(404, "Method not allowed: POST #{build_uri(request.base_uri, request.rest_path)}") - end - - def delete(request) - raise RestErrorResponse.new(404, "Method not allowed: DELETE #{build_uri(request.base_uri, request.rest_path)}") - end end end end diff --git a/lib/chef_zero/endpoints/acls_endpoint.rb b/lib/chef_zero/endpoints/acls_endpoint.rb index 41fb874..e62fd36 100644 --- a/lib/chef_zero/endpoints/acls_endpoint.rb +++ b/lib/chef_zero/endpoints/acls_endpoint.rb @@ -24,19 +24,6 @@ module ChefZero acls = DataNormalizer.normalize_acls(acls) json_response(200, acls) end - - # Remove these to get them doing 405 again like they ought to - def put(request) - raise RestErrorResponse.new(404, "Method not allowed: POST #{build_uri(request.base_uri, request.rest_path)}") - end - - def post(request) - raise RestErrorResponse.new(404, "Method not allowed: POST #{build_uri(request.base_uri, request.rest_path)}") - end - - def delete(request) - raise RestErrorResponse.new(404, "Method not allowed: DELETE #{build_uri(request.base_uri, request.rest_path)}") - end end end end diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb index 6ccdb89..73e0561 100644 --- a/lib/chef_zero/server.rb +++ b/lib/chef_zero/server.rb @@ -444,10 +444,8 @@ module ChefZero [ "/organizations/*/containers/*", ContainerEndpoint.new(self) ], [ "/organizations/*/groups", GroupsEndpoint.new(self) ], [ "/organizations/*/groups/*", GroupEndpoint.new(self) ], - [ "/organizations/*/organization/_acl", AclsEndpoint.new(self) ], [ "/organizations/*/organizations/_acl", AclsEndpoint.new(self) ], [ "/organizations/*/*/*/_acl", AclsEndpoint.new(self) ], - [ "/organizations/*/organization/_acl/*", AclEndpoint.new(self) ], [ "/organizations/*/organizations/_acl/*", AclEndpoint.new(self) ], [ "/organizations/*/*/*/_acl/*", AclEndpoint.new(self) ] ] diff --git a/spec/support/oc_pedant.rb b/spec/support/oc_pedant.rb index 4d033c0..60e3629 100644 --- a/spec/support/oc_pedant.rb +++ b/spec/support/oc_pedant.rb @@ -130,4 +130,5 @@ self[:tags] = [:validation, :authentication, :authorization] verify_error_messages false ruby_users_endpoint? false +ruby_acls_endpoint? false ruby_org_assoc? false |