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
@@ -1,5 +1,5 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
3
 
4
4
  module ChefZero
5
5
  module Endpoints
@@ -7,18 +7,18 @@ module ChefZero
7
7
  class OrganizationAuthenticateUserEndpoint < RestBase
8
8
  def post(request)
9
9
  request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
10
- name = request_json['name']
11
- password = request_json['password']
10
+ name = request_json["name"]
11
+ password = request_json["password"]
12
12
  begin
13
- user = data_store.get(request.rest_path[0..-2] + ['users', name])
13
+ user = data_store.get(request.rest_path[0..-2] + ["users", name])
14
14
  user = FFI_Yajl::Parser.parse(user, :create_additions => false)
15
- verified = user['password'] == password
15
+ verified = user["password"] == password
16
16
  rescue DataStore::DataNotFoundError
17
17
  verified = false
18
18
  end
19
19
  json_response(200, {
20
- 'name' => name,
21
- 'verified' => !!verified
20
+ "name" => name,
21
+ "verified" => !!verified,
22
22
  })
23
23
  end
24
24
  end
@@ -1,37 +1,37 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
3
 
4
4
  module ChefZero
5
5
  module Endpoints
6
6
  # /organizations/NAME
7
7
  class OrganizationEndpoint < RestBase
8
8
  def get(request)
9
- org = get_data(request, request.rest_path + [ 'org' ])
9
+ org = get_data(request, request.rest_path + [ "org" ])
10
10
  already_json_response(200, populate_defaults(request, org))
11
11
  end
12
12
 
13
13
  def put(request)
14
- org = FFI_Yajl::Parser.parse(get_data(request, request.rest_path + [ 'org' ]), :create_additions => false)
14
+ org = FFI_Yajl::Parser.parse(get_data(request, request.rest_path + [ "org" ]), :create_additions => false)
15
15
  new_org = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
16
16
  new_org.each do |key, value|
17
17
  org[key] = value
18
18
  end
19
19
  save_org = FFI_Yajl::Encoder.encode(org, :pretty => true)
20
- if new_org['name'] != request.rest_path[-1]
20
+ if new_org["name"] != request.rest_path[-1]
21
21
  # This is a rename
22
22
  return error(400, "Cannot rename org #{request.rest_path[-1]} to #{new_org['name']}: rename not supported for orgs")
23
23
  end
24
- set_data(request, request.rest_path + [ 'org' ], save_org)
24
+ set_data(request, request.rest_path + [ "org" ], save_org)
25
25
  json_response(200, {
26
26
  "uri" => "#{build_uri(request.base_uri, request.rest_path)}",
27
- "name" => org['name'],
28
- "org_type" => org['org_type'],
29
- "full_name" => org['full_name']
27
+ "name" => org["name"],
28
+ "org_type" => org["org_type"],
29
+ "full_name" => org["full_name"],
30
30
  })
31
31
  end
32
32
 
33
33
  def delete(request)
34
- org = get_data(request, request.rest_path + [ 'org' ])
34
+ org = get_data(request, request.rest_path + [ "org" ])
35
35
  delete_data_dir(request, request.rest_path, :recursive)
36
36
  already_json_response(200, populate_defaults(request, org))
37
37
  end
@@ -1,5 +1,5 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
3
 
4
4
  module ChefZero
5
5
  module Endpoints
@@ -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,5 +1,5 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
3
 
4
4
  module ChefZero
5
5
  module Endpoints
@@ -8,16 +8,16 @@ module ChefZero
8
8
  def get(request)
9
9
  username = request.rest_path[3]
10
10
  get_data(request) # 404 if user is not in org
11
- user = get_data(request, [ 'users', username ])
11
+ user = get_data(request, [ "users", username ])
12
12
  user = FFI_Yajl::Parser.parse(user, :create_additions => false)
13
- json_response(200, ChefData::DataNormalizer.normalize_user(user, username, ['username'], server.options[:osc_compat], request.method))
13
+ json_response(200, ChefData::DataNormalizer.normalize_user(user, username, ["username"], server.options[:osc_compat], request.method))
14
14
  end
15
15
 
16
16
  def delete(request)
17
17
  user = get_data(request)
18
18
  delete_data(request)
19
19
  user = FFI_Yajl::Parser.parse(user, :create_additions => false)
20
- json_response(200, ChefData::DataNormalizer.normalize_user(user, request.rest_path[3], ['username'], server.options[:osc_compat]))
20
+ json_response(200, ChefData::DataNormalizer.normalize_user(user, request.rest_path[3], ["username"], server.options[:osc_compat]))
21
21
  end
22
22
 
23
23
  # Note: post to a named org user is not permitted, alllow invalid method handling (405)
@@ -1,5 +1,5 @@
1
- require 'chef_zero/rest_base'
2
- require 'chef_zero/endpoints/actor_keys_endpoint'
1
+ require "chef_zero/rest_base"
2
+ require "chef_zero/endpoints/actor_keys_endpoint"
3
3
 
4
4
  module ChefZero
5
5
  module Endpoints
@@ -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/rest_base'
3
- require 'chef_zero/endpoints/organization_user_base'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
+ require "chef_zero/endpoints/organization_user_base"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -9,28 +9,28 @@ module ChefZero
9
9
  def post(request)
10
10
  orgname = request.rest_path[1]
11
11
  json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
12
- username = json['username']
12
+ username = json["username"]
13
13
 
14
- if exists_data?(request, [ 'organizations', orgname, 'users', username ])
14
+ if exists_data?(request, [ "organizations", orgname, "users", username ])
15
15
  raise RestErrorResponse.new(409, "User #{username} is already in organization #{orgname}")
16
16
  end
17
17
 
18
- users = get_data(request, [ 'organizations', orgname, 'groups', 'users' ])
18
+ users = get_data(request, [ "organizations", orgname, "groups", "users" ])
19
19
  users = FFI_Yajl::Parser.parse(users, :create_additions => false)
20
20
 
21
- create_data(request, request.rest_path, username, '{}')
21
+ create_data(request, request.rest_path, username, "{}")
22
22
 
23
23
  # /organizations/ORG/association_requests/USERNAME-ORG
24
24
  begin
25
- delete_data(request, [ 'organizations', orgname, 'association_requests', username], :data_store_exceptions)
25
+ delete_data(request, [ "organizations", orgname, "association_requests", username], :data_store_exceptions)
26
26
  rescue DataStore::DataNotFoundError
27
27
  end
28
28
 
29
29
  # Add the user to the users group if it isn't already there
30
- if !users['users'] || !users['users'].include?(username)
31
- users['users'] ||= []
32
- users['users'] |= [ username ]
33
- set_data(request, [ 'organizations', orgname, 'groups', 'users' ], FFI_Yajl::Encoder.encode(users, :pretty => true))
30
+ if !users["users"] || !users["users"].include?(username)
31
+ users["users"] ||= []
32
+ users["users"] |= [ username ]
33
+ set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, :pretty => true))
34
34
  end
35
35
  json_response(201, { "uri" => build_uri(request.base_uri, request.rest_path + [ username ]) })
36
36
  end
@@ -1,6 +1,6 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
3
- require 'uuidtools'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
+ require "uuidtools"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -8,12 +8,12 @@ module ChefZero
8
8
  class OrganizationValidatorKeyEndpoint < RestBase
9
9
  def post(request)
10
10
  org_name = request.rest_path[-2]
11
- validator_path = [ 'organizations', org_name, 'clients', "#{org_name}-validator"]
11
+ validator_path = [ "organizations", org_name, "clients", "#{org_name}-validator"]
12
12
  validator = FFI_Yajl::Parser.parse(get_data(request, validator_path), :create_additions => false)
13
13
  private_key, public_key = server.gen_key_pair
14
- validator['public_key'] = public_key
14
+ validator["public_key"] = public_key
15
15
  set_data(request, validator_path, FFI_Yajl::Encoder.encode(validator, :pretty => true))
16
- json_response(200, { 'private_key' => private_key })
16
+ json_response(200, { "private_key" => private_key })
17
17
  end
18
18
  end
19
19
  end
@@ -1,6 +1,6 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
3
- require 'uuidtools'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
+ require "uuidtools"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -16,8 +16,8 @@ module ChefZero
16
16
 
17
17
  def post(request)
18
18
  contents = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
19
- name = contents['name']
20
- full_name = contents['full_name']
19
+ name = contents["name"]
20
+ full_name = contents["full_name"]
21
21
  if name.nil?
22
22
  error(400, "Must specify 'name' in JSON")
23
23
  elsif full_name.nil?
@@ -28,32 +28,31 @@ module ChefZero
28
28
  create_data_dir(request, request.rest_path, name, :requestor => request.requestor)
29
29
 
30
30
  org = {
31
- "guid" => UUIDTools::UUID.random_create.to_s.gsub('-', ''),
32
- "assigned_at" => Time.now.to_s
31
+ "guid" => UUIDTools::UUID.random_create.to_s.delete("-"),
32
+ "assigned_at" => Time.now.to_s,
33
33
  }.merge(contents)
34
34
  org_path = request.rest_path + [ name ]
35
- set_data(request, org_path + [ 'org' ], FFI_Yajl::Encoder.encode(org, :pretty => true))
35
+ set_data(request, org_path + [ "org" ], FFI_Yajl::Encoder.encode(org, :pretty => true))
36
36
 
37
37
  if server.generate_real_keys?
38
38
  # Create the validator client
39
39
  validator_name = "#{name}-validator"
40
- validator_path = org_path + [ 'clients', validator_name ]
40
+ validator_path = org_path + [ "clients", validator_name ]
41
41
  private_key, public_key = server.gen_key_pair
42
42
  validator = FFI_Yajl::Encoder.encode({
43
- 'validator' => true,
44
- 'public_key' => public_key
43
+ "validator" => true,
44
+ "public_key" => public_key,
45
45
  }, :pretty => true)
46
46
  set_data(request, validator_path, validator)
47
47
  end
48
48
 
49
-
50
49
  json_response(201, {
51
50
  "uri" => "#{build_uri(request.base_uri, org_path)}",
52
51
  "name" => name,
53
52
  "org_type" => org["org_type"],
54
53
  "full_name" => full_name,
55
54
  "clientname" => validator_name,
56
- "private_key" => private_key
55
+ "private_key" => private_key,
57
56
  })
58
57
  end
59
58
  end
@@ -1,4 +1,4 @@
1
- require 'chef_zero/chef_data/data_normalizer'
1
+ require "chef_zero/chef_data/data_normalizer"
2
2
 
3
3
  module ChefZero
4
4
  module Endpoints
@@ -15,7 +15,7 @@ module ChefZero
15
15
 
16
16
  response_data[policy_name] = {
17
17
  uri: policy_uri,
18
- revisions: hashify_list(revisions)
18
+ revisions: hashify_list(revisions),
19
19
  }
20
20
  end
21
21
 
@@ -1,4 +1,4 @@
1
- require 'chef_zero/chef_data/data_normalizer'
1
+ require "chef_zero/chef_data/data_normalizer"
2
2
 
3
3
  module ChefZero
4
4
  module Endpoints
@@ -1,6 +1,6 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
3
- require 'chef_zero/chef_data/data_normalizer'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
+ require "chef_zero/chef_data/data_normalizer"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -11,7 +11,7 @@ module ChefZero
11
11
  def get(request)
12
12
  data = {
13
13
  uri: build_uri(request.base_uri, request.rest_path),
14
- policies: get_policy_group_policies(request)
14
+ policies: get_policy_group_policies(request),
15
15
  }
16
16
  json_response(200, data)
17
17
  end
@@ -24,7 +24,7 @@ module ChefZero
24
24
  policy_names = list_data(request, policies_path)
25
25
  policy_names.each do |policy_name|
26
26
  revision = parse_json(get_data(request, policies_path + [policy_name]))
27
- policies_revisions[policy_name] = { revision_id: revision}
27
+ policies_revisions[policy_name] = { revision_id: revision }
28
28
  end
29
29
 
30
30
  policies_revisions
@@ -37,7 +37,7 @@ module ChefZero
37
37
 
38
38
  data = {
39
39
  uri: build_uri(request.base_uri, request.rest_path),
40
- policies: policy_group_policies
40
+ policies: policy_group_policies,
41
41
  }
42
42
  json_response(200, data)
43
43
  end
@@ -1,6 +1,6 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
3
- require 'chef_zero/chef_data/data_normalizer'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
+ require "chef_zero/chef_data/data_normalizer"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -74,7 +74,6 @@ module ChefZero
74
74
  policy_path = request.rest_path[0..1] + ["policies", policy_name,
75
75
  "revisions", current_revision_id]
76
76
 
77
-
78
77
  full_policy_doc = parse_json(get_data(request, policy_path))
79
78
  full_policy_doc = ChefData::DataNormalizer.normalize_policy(full_policy_doc, policy_name, current_revision_id)
80
79
  return json_response(200, full_policy_doc)
@@ -1,6 +1,6 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero/rest_base'
3
- require 'chef_zero/chef_data/data_normalizer'
1
+ require "ffi_yajl"
2
+ require "chef_zero/rest_base"
3
+ require "chef_zero/chef_data/data_normalizer"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -26,7 +26,7 @@ module ChefZero
26
26
  end
27
27
 
28
28
  response_data[group_name] = {
29
- uri: build_uri(request.base_uri, group_path)
29
+ uri: build_uri(request.base_uri, group_path),
30
30
  }
31
31
  response_data[group_name][:policies] = policies unless policies.empty?
32
32
  end
@@ -1,4 +1,4 @@
1
- require 'chef_zero/chef_data/data_normalizer'
1
+ require "chef_zero/chef_data/data_normalizer"
2
2
 
3
3
  module ChefZero
4
4
  module Endpoints
@@ -1,4 +1,4 @@
1
- require 'chef_zero/chef_data/data_normalizer'
1
+ require "chef_zero/chef_data/data_normalizer"
2
2
 
3
3
  module ChefZero
4
4
  module Endpoints
@@ -1,6 +1,6 @@
1
- require 'ffi_yajl'
2
- require 'chef_zero'
3
- require 'chef_zero/rest_base'
1
+ require "ffi_yajl"
2
+ require "chef_zero"
3
+ require "chef_zero/rest_base"
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
@@ -9,33 +9,33 @@ module ChefZero
9
9
  def get(request)
10
10
  name = request.rest_path[-1]
11
11
  # If /organizations/ORG/users/NAME exists, use this user (only org members have precedence over clients). hey are an org member.
12
- json = get_data(request, request.rest_path[0..1] + [ 'users', name ], :nil)
12
+ json = get_data(request, request.rest_path[0..1] + [ "users", name ], :nil)
13
13
  if json
14
- type = 'user'
14
+ type = "user"
15
15
  org_member = true
16
16
  else
17
17
  # If /organizations/ORG/clients/NAME exists, use the client.
18
- json = get_data(request, request.rest_path[0..1] + [ 'clients', name ], :nil)
18
+ json = get_data(request, request.rest_path[0..1] + [ "clients", name ], :nil)
19
19
  if json
20
- type = 'client'
20
+ type = "client"
21
21
  org_member = true
22
22
  else
23
23
  # If there is no client with that name, check for a user (/users/NAME) and return that with
24
24
  # org_member = false.
25
- json = get_data(request, [ 'users', name ], :nil)
25
+ json = get_data(request, [ "users", name ], :nil)
26
26
  if json
27
- type = 'user'
27
+ type = "user"
28
28
  org_member = false
29
29
  end
30
30
  end
31
31
  end
32
32
  if json
33
33
  principal_data = {
34
- 'name' => name,
35
- 'type' => type,
36
- 'public_key' => FFI_Yajl::Parser.parse(json)['public_key'] || PUBLIC_KEY,
37
- 'authz_id' => '0'*32,
38
- 'org_member' => org_member
34
+ "name" => name,
35
+ "type" => type,
36
+ "public_key" => FFI_Yajl::Parser.parse(json)["public_key"] || PUBLIC_KEY,
37
+ "authz_id" => "0" * 32,
38
+ "org_member" => org_member,
39
39
  }
40
40
 
41
41
  response_data =
@@ -47,7 +47,7 @@ module ChefZero
47
47
 
48
48
  json_response(200, response_data)
49
49
  else
50
- error(404, 'Principal not found')
50
+ error(404, "Principal not found")
51
51
  end
52
52
  end
53
53
  end