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,11 +1,11 @@
1
- require 'chef_zero/solr/solr_parser'
2
- require 'chef_zero/solr/solr_doc'
1
+ require "chef_zero/solr/solr_parser"
2
+ require "chef_zero/solr/solr_doc"
3
3
 
4
4
  describe ChefZero::Solr::SolrParser do
5
5
  let (:all_docs) do
6
6
  docs = []
7
- [{'foo' => 'a'},
8
- {'foo' => 'd'}].each_with_index do |h, i|
7
+ [{ "foo" => "a" },
8
+ { "foo" => "d" }].each_with_index do |h, i|
9
9
  docs.push ChefZero::Solr::SolrDoc.new(h, i)
10
10
  end
11
11
  docs
@@ -13,24 +13,24 @@ describe ChefZero::Solr::SolrParser do
13
13
 
14
14
  def search_for(query)
15
15
  q = ChefZero::Solr::SolrParser.new(query).parse
16
- all_docs.select {|doc| q.matches_doc?(doc) }
16
+ all_docs.select { |doc| q.matches_doc?(doc) }
17
17
  end
18
18
 
19
19
  it "handles terms" do
20
- search_for('foo:d').size.should eq(1)
20
+ search_for("foo:d").size.should eq(1)
21
21
  end
22
22
 
23
23
  it "handles ranges" do
24
- search_for('foo:[a TO c]').size.should eq(1)
24
+ search_for("foo:[a TO c]").size.should eq(1)
25
25
  end
26
26
 
27
27
  it "handles -" do
28
- search_for('-foo:a').size.should eq(1)
28
+ search_for("-foo:a").size.should eq(1)
29
29
  end
30
30
 
31
31
  it "handles wildcard ranges" do
32
- search_for('foo:[* TO c]').size.should eq(1)
33
- search_for('foo:[c TO *]').size.should eq(1)
34
- search_for('foo:[* TO *]').size.should eq(2)
32
+ search_for("foo:[* TO c]").size.should eq(1)
33
+ search_for("foo:[c TO *]").size.should eq(1)
34
+ search_for("foo:[* TO *]").size.should eq(2)
35
35
  end
36
36
  end
@@ -1,9 +1,9 @@
1
- require 'chef_zero/server'
2
- require 'net/http'
3
- require 'uri'
1
+ require "chef_zero/server"
2
+ require "net/http"
3
+ require "uri"
4
4
 
5
5
  describe ChefZero::Server do
6
- context 'with a server bound to port 8889' do
6
+ context "with a server bound to port 8889" do
7
7
  before :each do
8
8
  @server = ChefZero::Server.new(:port => 8889)
9
9
  @server.start_background
@@ -12,84 +12,84 @@ describe ChefZero::Server do
12
12
  @server.stop
13
13
  end
14
14
 
15
- it 'a second server bound to port 8889 throws EADDRINUSE' do
15
+ it "a second server bound to port 8889 throws EADDRINUSE" do
16
16
  expect { ChefZero::Server.new(:port => 8889).start }.to raise_error Errno::EADDRINUSE
17
17
  end
18
18
 
19
- it 'a server bound to range 8889-9999 binds to a port > 8889' do
19
+ it "a server bound to range 8889-9999 binds to a port > 8889" do
20
20
  server = ChefZero::Server.new(:port => 8889.upto(9999))
21
21
  server.start_background
22
22
  expect(server.port).to be > 8889
23
23
  expect(URI(server.url).port).to be > 8889
24
24
  end
25
25
 
26
- it 'a server bound to range 8889-8889 throws an exception' do
26
+ it "a server bound to range 8889-8889 throws an exception" do
27
27
  expect { ChefZero::Server.new(:port => 8889.upto(8889)).start_background }.to raise_error Errno::EADDRINUSE
28
28
  end
29
29
 
30
- it 'has a very patient request timeout' do
30
+ it "has a very patient request timeout" do
31
31
  expect(@server.server.config[:RequestTimeout]).to eq 300
32
32
  end
33
33
 
34
- context 'accept headers' do
34
+ context "accept headers" do
35
35
  def get_nodes(accepts)
36
36
  uri = URI(@server.url)
37
37
  httpcall = Net::HTTP.new(uri.host, uri.port)
38
- httpcall.get('/nodes', 'Accept' => accepts)
38
+ httpcall.get("/nodes", "Accept" => accepts)
39
39
  end
40
40
 
41
41
  def get_version
42
42
  uri = URI(@server.url)
43
43
  httpcall = Net::HTTP.new(uri.host, uri.port)
44
- httpcall.get('/version', 'Accept' => 'text/plain, application/json')
44
+ httpcall.get("/version", "Accept" => "text/plain, application/json")
45
45
  end
46
46
 
47
- it 'accepts requests with no accept header' do
48
- request = Net::HTTP::Get.new('/nodes')
49
- request.delete('Accept')
47
+ it "accepts requests with no accept header" do
48
+ request = Net::HTTP::Get.new("/nodes")
49
+ request.delete("Accept")
50
50
  uri = URI(@server.url)
51
51
  response = Net::HTTP.new(uri.host, uri.port).request(request)
52
- expect(response.code).to eq '200'
52
+ expect(response.code).to eq "200"
53
53
  end
54
54
 
55
- it 'accepts requests with accept: application/json' do
56
- expect(get_nodes('application/json').code).to eq '200'
55
+ it "accepts requests with accept: application/json" do
56
+ expect(get_nodes("application/json").code).to eq "200"
57
57
  end
58
58
 
59
- it 'accepts requests with accept: application/*' do
60
- expect(get_nodes('application/*').code).to eq '200'
59
+ it "accepts requests with accept: application/*" do
60
+ expect(get_nodes("application/*").code).to eq "200"
61
61
  end
62
62
 
63
- it 'accepts requests with accept: application/*' do
64
- expect(get_nodes('*/*').code).to eq '200'
63
+ it "accepts requests with accept: application/*" do
64
+ expect(get_nodes("*/*").code).to eq "200"
65
65
  end
66
66
 
67
- it 'denies requests with accept: application/blah' do
68
- expect(get_nodes('application/blah').code).to eq '406'
67
+ it "denies requests with accept: application/blah" do
68
+ expect(get_nodes("application/blah").code).to eq "406"
69
69
  end
70
70
 
71
- it 'denies requests with accept: blah/json' do
72
- expect(get_nodes('blah/json').code).to eq '406'
71
+ it "denies requests with accept: blah/json" do
72
+ expect(get_nodes("blah/json").code).to eq "406"
73
73
  end
74
74
 
75
- it 'denies requests with accept: blah/*' do
76
- expect(get_nodes('blah/*').code).to eq '406'
75
+ it "denies requests with accept: blah/*" do
76
+ expect(get_nodes("blah/*").code).to eq "406"
77
77
  end
78
78
 
79
- it 'denies requests with accept: blah/*' do
80
- expect(get_nodes('blah/*').code).to eq '406'
79
+ it "denies requests with accept: blah/*" do
80
+ expect(get_nodes("blah/*").code).to eq "406"
81
81
  end
82
82
 
83
- it 'denies requests with accept: <empty string>' do
84
- expect(get_nodes('').code).to eq '406'
83
+ it "denies requests with accept: <empty string>" do
84
+ expect(get_nodes("").code).to eq "406"
85
85
  end
86
86
 
87
- it 'accepts requests with accept: a/b;a=b;c=d, application/json;a=b, application/xml;a=b' do
88
- expect(get_nodes('a/b;a=b;c=d, application/json;a=b, application/xml;a=b').code).to eq '200'
87
+ it "accepts requests with accept: a/b;a=b;c=d, application/json;a=b, application/xml;a=b" do
88
+ expect(get_nodes("a/b;a=b;c=d, application/json;a=b, application/xml;a=b").code).to eq "200"
89
89
  end
90
90
 
91
- it 'accepts /version' do
92
- expect(get_version.body.start_with?('chef-zero')).to be true
91
+ it "accepts /version" do
92
+ expect(get_version.body.start_with?("chef-zero")).to be true
93
93
  end
94
94
  end
95
95
  end
@@ -1,5 +1,4 @@
1
- require 'chef_zero/socketless_server_map'
2
-
1
+ require "chef_zero/socketless_server_map"
3
2
 
4
3
  describe "Socketless Mode" do
5
4
 
@@ -72,5 +71,4 @@ describe "Socketless Mode" do
72
71
  end
73
72
  end
74
73
 
75
-
76
74
  end
@@ -21,7 +21,7 @@
21
21
  ################################################################################
22
22
  # You MUST specify the address of the server the API requests will be
23
23
  # sent to. Only specify protocol, hostname, and port.
24
- chef_server 'http://127.0.0.1:8889'
24
+ chef_server "http://127.0.0.1:8889"
25
25
 
26
26
  # If you are doing development testing, you can specify the address of
27
27
  # the Solr server. The presence of this parameter will enable tests
@@ -54,7 +54,6 @@ search_server chef_server
54
54
  search_commit_url "/dummy"
55
55
  search_url_fmt "/dummy?fq=+X_CHEF_type_CHEF_X:%{type}&q=%{query}&wt=json"
56
56
 
57
-
58
57
  # We're starting to break tests up into groups based on different
59
58
  # criteria. The proper API tests (the results of which are viewable
60
59
  # to OPC customers) should be the only ones run by Pedant embedded in
@@ -69,10 +68,10 @@ search_url_fmt "/dummy?fq=+X_CHEF_type_CHEF_X:%{type}&q=%{query}&wt=json"
69
68
  # value.
70
69
  include_internal false
71
70
 
72
- key = 'spec/support/stickywicket.pem'
71
+ key = "spec/support/stickywicket.pem"
73
72
 
74
73
  org(name: "pedant-testorg",
75
- create_me: !ENV['CHEF_FS'],
74
+ create_me: !ENV["CHEF_FS"],
76
75
  validator_key: key)
77
76
 
78
77
  internal_account_url chef_server
@@ -85,15 +84,15 @@ delete_org true
85
84
  # are using pre-existing users, you must supply a ':key_file' key,
86
85
  # which should be the fully-qualified path /on the machine Pedant is
87
86
  # running on/ to a private key for that user.
88
- superuser_name 'pivotal'
87
+ superuser_name "pivotal"
89
88
  superuser_key key
90
89
  webui_key key
91
90
 
92
91
  def cheffs_or_else_user(value)
93
- ENV['CHEF_FS'] ? "pivotal" : value
92
+ ENV["CHEF_FS"] ? "pivotal" : value
94
93
  end
95
94
 
96
- keyfile_maybe = ENV['CHEF_FS'] ? { key_file: key } : { key_file: nil }
95
+ keyfile_maybe = ENV["CHEF_FS"] ? { key_file: key } : { key_file: nil }
97
96
 
98
97
  requestors({
99
98
  :clients => {
@@ -102,45 +101,45 @@ requestors({
102
101
  :name => "pedant_admin_client",
103
102
  :create_me => true,
104
103
  :create_knife => true,
105
- :admin => true
104
+ :admin => true,
106
105
  },
107
106
  :non_admin => {
108
- :name => 'pedant_client',
107
+ :name => "pedant_client",
109
108
  :create_me => true,
110
109
  :create_knife => true,
111
110
  },
112
111
  :bad => {
113
- :name => 'bad_client',
112
+ :name => "bad_client",
114
113
  :create_me => true,
115
114
  :create_knife => true,
116
- :bogus => true
117
- }
115
+ :bogus => true,
116
+ },
118
117
  },
119
118
 
120
119
  :users => {
121
120
  # An administrator in the testing organization
122
121
  :admin => {
123
122
  :name => cheffs_or_else_user("pedant_admin_user"),
124
- :create_me => !ENV['CHEF_FS'],
125
- :associate => !ENV['CHEF_FS'],
126
- :create_knife => true
123
+ :create_me => !ENV["CHEF_FS"],
124
+ :associate => !ENV["CHEF_FS"],
125
+ :create_knife => true,
127
126
  }.merge(keyfile_maybe),
128
127
 
129
128
  :non_admin => {
130
129
  :name => cheffs_or_else_user("pedant_user"),
131
- :create_me => !ENV['CHEF_FS'],
132
- :associate => !ENV['CHEF_FS'],
133
- :create_knife => true
130
+ :create_me => !ENV["CHEF_FS"],
131
+ :associate => !ENV["CHEF_FS"],
132
+ :create_knife => true,
134
133
  }.merge(keyfile_maybe),
135
134
 
136
135
  # A user that is not a member of the testing organization
137
136
  :bad => {
138
137
  :name => cheffs_or_else_user("pedant-nobody"),
139
- :create_me => !ENV['CHEF_FS'],
138
+ :create_me => !ENV["CHEF_FS"],
140
139
  :create_knife => true,
141
- :associate => false
140
+ :associate => false,
142
141
  }.merge(keyfile_maybe),
143
- }
142
+ },
144
143
  })
145
144
 
146
145
  self[:tags] = [:validation, :authentication, :authorization]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 4.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-log