-
Notifications
You must be signed in to change notification settings - Fork 98
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
Implement APIv1 behaviors #201
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,22 @@ def get(request) | |
end | ||
end | ||
if json | ||
json_response(200, { | ||
principal_data = { | ||
'name' => name, | ||
'type' => type, | ||
'public_key' => FFI_Yajl::Parser.parse(json)['public_key'] || PUBLIC_KEY, | ||
'authz_id' => '0'*32, | ||
'org_member' => org_member | ||
}) | ||
} | ||
|
||
response_data = | ||
if request.api_v0? | ||
principal_data | ||
else | ||
{ "principals" => [ principal_data ] } | ||
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. If there is both a user and a client with the given name, should we return them both? 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. Yeah, that's correct, according to my reading of the code here: https://github.com/chef/chef-server/blob/218579549024b26b3b97c9958503ff3651e3fb16/src/oc_erchef/apps/oc_chef_wm/src/chef_wm_named_principal.erl#L92-L102 OTOH, there's no pedant test for that, and it's an existing bug, and I probably won't have time to fix all that. So my inclination is to leave it as is until the problem comes up again. |
||
end | ||
|
||
json_response(200, response_data) | ||
else | ||
error(404, 'Principal not found') | ||
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.
FWIW RestBase defines
parse_json
andto_json
helpers. (I discovered this too late for my last PR).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.
Nice catch.