-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CS12 Support #117
CS12 Support #117
Changes from all commits
2758425
fd95d9e
ad69f42
eb7ee61
d0a1484
aa95900
a921e1a
b2381bf
e38a9bf
4366f5e
113e41e
aabb201
64dfcde
ae7634c
3197fc4
67b0d4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
source 'https://rubygems.org' | ||
gemspec :path => '../' | ||
|
||
gem 'rest-client', :github => 'opscode/rest-client', :branch => 'lcg/1.6.7-version-lying' | ||
gem 'chef-pedant', :github => 'opscode/chef-pedant', :ref => '81f3b4ecbc09d04950f2819b38a6a8f906ada2a7' | ||
gem 'oc-chef-pedant', :git => '[email protected]:opscode/oc-chef-pedant', :ref => '3c0eb31f1e49aa947b81ad51387b7a68adbc5f91' | ||
gem 'chef', :github => 'opscode/chef' | ||
gem 'rest-client', :github => 'chef/rest-client', :branch => 'lcg/1.6.7-version-lying' | ||
gem 'oc-chef-pedant', :github => 'chef/oc-chef-pedant', :tag => '2.0.0' | ||
gem 'chef', :github => 'chef/chef' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'ffi_yajl' | ||
require 'chef_zero/rest_base' | ||
require 'uuidtools' | ||
|
||
module ChefZero | ||
module Endpoints | ||
# /organizations/NAME/nodes/NAME/_identifiers | ||
class NodeIdentifiersEndpoint < RestBase | ||
def get(request) | ||
if get_data(request, request.rest_path[0..3]) | ||
result = { | ||
:id => UUIDTools::UUID.parse_raw(request.rest_path[0..4].to_s).to_s.gsub('-',''), | ||
:authz_id => '0'*32, | ||
:org_id => UUIDTools::UUID.parse_raw(request.rest_path[0..1].to_s).to_s.gsub('-','') } | ||
json_response(200, result) | ||
else | ||
raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}") | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'ffi_yajl' | ||
require 'chef_zero/rest_base' | ||
|
||
module ChefZero | ||
module Endpoints | ||
module OrganizationUserBase | ||
|
||
def self.get(obj, request, &block) | ||
result = obj.list_data(request).map(&block) | ||
obj.json_response(200, result) | ||
end | ||
|
||
def self.post(obj, request, key) | ||
json = FFI_Yajl::Parser.parse(request.body, :create_additions => false) | ||
username = json[key] | ||
orgname = request.rest_path[1] | ||
id = "#{username}-#{orgname}" | ||
|
||
if obj.exists_data?(request, [ 'organizations', orgname, 'users', username ]) | ||
raise RestErrorResponse.new(409, "User #{username} is already in organization #{orgname}") | ||
end | ||
|
||
obj.create_data(request, request.rest_path, username, '{}') | ||
obj.json_response(201, { "uri" => obj.build_uri(request.base_uri, request.rest_path + [ id ]) }) | ||
end | ||
|
||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,29 +20,7 @@ def delete(request) | |
json_response(200, ChefData::DataNormalizer.normalize_user(user, request.rest_path[3], ['username'], server.options[:osc_compat])) | ||
end | ||
|
||
def post(request) | ||
orgname = request.rest_path[1] | ||
username = request.rest_path[3] | ||
|
||
users = get_data(request, [ 'organizations', orgname, 'groups', 'users' ]) | ||
users = FFI_Yajl::Parser.parse(users, :create_additions => false) | ||
|
||
create_data(request, [ 'organizations', orgname, 'users' ], username, '{}') | ||
|
||
# /organizations/ORG/association_requests/USERNAME-ORG | ||
begin | ||
delete_data(request, [ 'organizations', orgname, 'association_requests', username], :data_store_exceptions) | ||
rescue DataStore::DataNotFoundError | ||
end | ||
|
||
# Add the user to the users group if it isn't already there | ||
if !users['users'] || !users['users'].include?(username) | ||
users['users'] ||= [] | ||
users['users'] |= [ username ] | ||
set_data(request, [ 'organizations', orgname, 'groups', 'users' ], FFI_Yajl::Encoder.encode(users, :pretty => true)) | ||
end | ||
json_response(200, {}) | ||
end | ||
# Note: post to a named org user is not permitted, alllow invalid method handling (405) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than removing this I think we need to move it and slightly change this code. The actual endpoint that does this is: POST /organizations/ORGNAME/users with a body of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the Chef Server support both endpoints? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current chef server only support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've moved this in andrewjamesbrown@0447018 which is part of #146 |
||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super confusing branching logic - I would expect to see
actor_endpoint_spec.rb
updated. Unless all the testing is through pedant?