chef 11.14.0.alpha.4-x86-mingw32 → 11.14.0.rc.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/CONTRIBUTING.md +0 -4
  2. data/README.md +1 -1
  3. data/distro/common/man/man1/chef-shell.1 +4 -4
  4. data/distro/common/man/man1/knife-bootstrap.1 +14 -11
  5. data/distro/common/man/man1/knife-client.1 +14 -11
  6. data/distro/common/man/man1/knife-configure.1 +7 -7
  7. data/distro/common/man/man1/knife-cookbook-site.1 +23 -23
  8. data/distro/common/man/man1/knife-cookbook.1 +23 -23
  9. data/distro/common/man/man1/knife-data-bag.1 +13 -13
  10. data/distro/common/man/man1/knife-delete.1 +9 -9
  11. data/distro/common/man/man1/knife-deps.1 +9 -9
  12. data/distro/common/man/man1/knife-diff.1 +10 -10
  13. data/distro/common/man/man1/knife-download.1 +9 -9
  14. data/distro/common/man/man1/knife-edit.1 +7 -7
  15. data/distro/common/man/man1/knife-environment.1 +10 -10
  16. data/distro/common/man/man1/knife-exec.1 +7 -7
  17. data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
  18. data/distro/common/man/man1/knife-list.1 +12 -12
  19. data/distro/common/man/man1/knife-node.1 +12 -9
  20. data/distro/common/man/man1/knife-raw.1 +7 -7
  21. data/distro/common/man/man1/knife-recipe-list.1 +1 -1
  22. data/distro/common/man/man1/knife-role.1 +8 -8
  23. data/distro/common/man/man1/knife-search.1 +9 -9
  24. data/distro/common/man/man1/knife-serve.1 +109 -0
  25. data/distro/common/man/man1/knife-show.1 +8 -8
  26. data/distro/common/man/man1/knife-ssh.1 +9 -9
  27. data/distro/common/man/man1/knife-ssl-check.1 +9 -9
  28. data/distro/common/man/man1/knife-ssl-fetch.1 +10 -10
  29. data/distro/common/man/man1/knife-status.1 +9 -9
  30. data/distro/common/man/man1/knife-tag.1 +7 -7
  31. data/distro/common/man/man1/knife-upload.1 +10 -10
  32. data/distro/common/man/man1/knife-user.1 +9 -9
  33. data/distro/common/man/man1/knife-xargs.1 +7 -7
  34. data/distro/common/man/man1/knife.1 +118 -14
  35. data/distro/common/man/man8/chef-client.8 +13 -10
  36. data/distro/common/man/man8/chef-solo.8 +13 -14
  37. data/distro/common/markdown/man1/knife.mkd +1 -1
  38. data/lib/chef/application/knife.rb +1 -1
  39. data/lib/chef/application/windows_service.rb +0 -1
  40. data/lib/chef/chef_fs/file_system.rb +6 -2
  41. data/lib/chef/config.rb +3 -2
  42. data/lib/chef/config_fetcher.rb +1 -1
  43. data/lib/chef/cookbook/metadata.rb +20 -14
  44. data/lib/chef/cookbook/synchronizer.rb +24 -13
  45. data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
  46. data/lib/chef/encrypted_data_bag_item/encryptor.rb +2 -2
  47. data/lib/chef/exceptions.rb +1 -0
  48. data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
  49. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
  50. data/lib/chef/http.rb +6 -1
  51. data/lib/chef/http/http_request.rb +9 -1
  52. data/lib/chef/http/simple.rb +2 -1
  53. data/lib/chef/json_compat.rb +5 -16
  54. data/lib/chef/knife/bootstrap.rb +2 -0
  55. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  56. data/lib/chef/knife/core/object_loader.rb +3 -1
  57. data/lib/chef/knife/ssh.rb +14 -7
  58. data/lib/chef/mixin/convert_to_class_name.rb +1 -0
  59. data/lib/chef/mixin/windows_architecture_helper.rb +24 -4
  60. data/lib/chef/platform/provider_mapping.rb +13 -0
  61. data/lib/chef/provider/env/windows.rb +3 -6
  62. data/lib/chef/provider/git.rb +1 -2
  63. data/lib/chef/provider/log.rb +15 -1
  64. data/lib/chef/provider/package/apt.rb +3 -3
  65. data/lib/chef/provider/package/dpkg.rb +35 -16
  66. data/lib/chef/provider/package/paludis.rb +91 -0
  67. data/lib/chef/provider/package/rpm.rb +3 -2
  68. data/lib/chef/provider/package/yum-dump.py +6 -6
  69. data/lib/chef/provider/package/yum.rb +2 -0
  70. data/lib/chef/provider/registry_key.rb +4 -5
  71. data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
  72. data/lib/chef/provider/service/solaris.rb +1 -1
  73. data/lib/chef/provider/service/upstart.rb +2 -1
  74. data/lib/chef/provider/service/windows.rb +37 -9
  75. data/lib/chef/provider/user/pw.rb +1 -1
  76. data/lib/chef/provider/user/useradd.rb +1 -1
  77. data/lib/chef/provider/windows_script.rb +2 -1
  78. data/lib/chef/providers.rb +1 -0
  79. data/lib/chef/resource.rb +10 -0
  80. data/lib/chef/resource/file.rb +0 -9
  81. data/lib/chef/resource/package.rb +14 -4
  82. data/lib/chef/resource/paludis_package.rb +33 -0
  83. data/lib/chef/resource/registry_key.rb +62 -3
  84. data/lib/chef/resource/service.rb +21 -4
  85. data/lib/chef/resource_reporter.rb +10 -0
  86. data/lib/chef/resources.rb +1 -0
  87. data/lib/chef/role.rb +14 -10
  88. data/lib/chef/shell.rb +8 -0
  89. data/lib/chef/shell/shell_session.rb +3 -3
  90. data/lib/chef/user.rb +12 -11
  91. data/lib/chef/util/selinux.rb +1 -1
  92. data/lib/chef/version.rb +1 -1
  93. data/lib/chef/version_constraint.rb +6 -5
  94. data/lib/chef/win32/api/process.rb +1 -0
  95. data/lib/chef/win32/api/system.rb +14 -0
  96. data/lib/chef/win32/error.rb +1 -1
  97. data/lib/chef/win32/security.rb +5 -5
  98. data/lib/chef/win32/version.rb +6 -2
  99. data/spec/data/trusted_certs/opscode.pem +57 -35
  100. data/spec/functional/application_spec.rb +2 -2
  101. data/spec/functional/resource/mount_spec.rb +3 -1
  102. data/spec/functional/shell_spec.rb +10 -0
  103. data/spec/functional/tiny_server_spec.rb +2 -2
  104. data/spec/support/chef_helpers.rb +1 -1
  105. data/spec/support/shared/functional/securable_resource.rb +11 -2
  106. data/spec/support/shared/functional/securable_resource_with_reporting.rb +13 -2
  107. data/spec/tiny_server.rb +1 -1
  108. data/spec/unit/config_spec.rb +5 -0
  109. data/spec/unit/cookbook/metadata_spec.rb +24 -0
  110. data/spec/unit/environment_spec.rb +6 -0
  111. data/spec/unit/http/http_request_spec.rb +91 -0
  112. data/spec/unit/http_spec.rb +23 -0
  113. data/spec/unit/knife/bootstrap_spec.rb +2 -2
  114. data/spec/unit/knife/ssh_spec.rb +7 -13
  115. data/spec/unit/knife_spec.rb +1 -1
  116. data/spec/unit/mixin/convert_to_class_name_spec.rb +4 -0
  117. data/spec/unit/provider/git_spec.rb +2 -2
  118. data/spec/unit/provider/log_spec.rb +18 -0
  119. data/spec/unit/provider/mount/solaris_spec.rb +3 -1
  120. data/spec/unit/provider/package/apt_spec.rb +85 -40
  121. data/spec/unit/provider/package/dpkg_spec.rb +24 -48
  122. data/spec/unit/provider/package/paludis_spec.rb +135 -0
  123. data/spec/unit/provider/package/rpm_spec.rb +40 -32
  124. data/spec/unit/provider/package/yum_spec.rb +11 -4
  125. data/spec/unit/provider/registry_key_spec.rb +67 -53
  126. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +10 -1
  127. data/spec/unit/provider/service/solaris_smf_service_spec.rb +23 -2
  128. data/spec/unit/provider/service/upstart_service_spec.rb +7 -0
  129. data/spec/unit/provider/service/windows_spec.rb +72 -0
  130. data/spec/unit/provider/user/pw_spec.rb +21 -4
  131. data/spec/unit/provider/user/useradd_spec.rb +10 -0
  132. data/spec/unit/resource/package_spec.rb +26 -18
  133. data/spec/unit/resource/registry_key_spec.rb +28 -0
  134. data/spec/unit/resource/service_spec.rb +14 -0
  135. data/spec/unit/resource_reporter_spec.rb +37 -12
  136. data/spec/unit/resource_spec.rb +41 -6
  137. data/spec/unit/rest_spec.rb +2 -2
  138. data/spec/unit/role_spec.rb +46 -28
  139. data/spec/unit/shell/shell_session_spec.rb +42 -2
  140. data/spec/unit/shell_spec.rb +1 -1
  141. data/spec/unit/user_spec.rb +12 -0
  142. data/spec/unit/util/selinux_spec.rb +4 -4
  143. data/spec/unit/version_constraint_spec.rb +14 -2
  144. metadata +223 -167
  145. checksums.yaml +0 -7
@@ -47,12 +47,12 @@ describe Chef::Application do
47
47
 
48
48
  it "saves built proxy to ENV which shell_out can use" do
49
49
  so = if windows?
50
- shell_out("echo $env:http_proxy")
50
+ shell_out("echo %http_proxy%")
51
51
  else
52
52
  shell_out("echo $http_proxy")
53
53
  end
54
54
 
55
- so.stdout.should == "http://proxy.example.org:8080\n"
55
+ so.stdout.chomp.should == "http://proxy.example.org:8080"
56
56
  end
57
57
  end
58
58
  end
@@ -164,7 +164,9 @@ describe Chef::Resource::Mount, :requires_root, :external => include_flag do
164
164
  end
165
165
 
166
166
  # don't run the remount tests on solaris2 (tmpfs does not support remount)
167
- describe "when the filesystem should be remounted and the resource supports remounting", :external => ohai[:platform] == "solaris2" do
167
+ # Need to make sure the platforms we've already excluded are considered:
168
+ skip_remount = include_flag || (ohai[:platform] == "solaris2")
169
+ describe "when the filesystem should be remounted and the resource supports remounting", :external => skip_remount do
168
170
  it "should remount the filesystem if it is mounted" do
169
171
  new_resource.run_action(:mount)
170
172
  mount_should_exist(new_resource.mount_point, new_resource.device)
@@ -118,5 +118,15 @@ describe Shell do
118
118
  output.should include("===fatal===")
119
119
  expect(exitstatus).to eq(0)
120
120
  end
121
+
122
+ it "sets the override_runlist from the command line" do
123
+ output, exitstatus = run_chef_shell_with("-o 'override::foo,override::bar'") do |out, keyboard|
124
+ show_recipes_code = %q[puts "#{node.recipes.inspect}"]
125
+ keyboard.puts(show_recipes_code)
126
+ read_until(out, show_recipes_code)
127
+ end
128
+ output.should include(%q{["override::foo", "override::bar"]})
129
+ expect(exitstatus).to eq(0)
130
+ end
121
131
  end
122
132
  end
@@ -54,8 +54,8 @@ describe TinyServer::API do
54
54
  response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => '/no_such_thing')
55
55
  response[0].should == 404
56
56
  response[1].should == {'Content-Type' => 'application/json'}
57
- response[2].should be_a_kind_of(String)
58
- response_obj = Chef::JSONCompat.from_json(response[2])
57
+ response[2].should be_a_kind_of(Array)
58
+ response_obj = Chef::JSONCompat.from_json(response[2].first)
59
59
  response_obj["message"].should == "no data matches the request for /no_such_thing"
60
60
  response_obj["available_routes"].should == {"GET"=>[], "PUT"=>[], "POST"=>[], "DELETE"=>[]}
61
61
  response_obj["request"].should == {"REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"/no_such_thing"}
@@ -20,10 +20,10 @@ Chef::Config[:log_level] = :fatal
20
20
  Chef::Config[:persistent_queue] = false
21
21
  Chef::Config[:file_backup_path] = CHEF_SPEC_BACKUP_PATH
22
22
 
23
+ Chef::Log.init(StringIO.new)
23
24
  Chef::Log.level(Chef::Config.log_level)
24
25
  Chef::Config.solo(false)
25
26
 
26
- Chef::Log.logger = Logger.new(StringIO.new)
27
27
 
28
28
  def sha256_checksum(path)
29
29
  Digest::SHA256.hexdigest(File.read(path))
@@ -19,6 +19,7 @@
19
19
  #
20
20
 
21
21
  require 'etc'
22
+ require 'functional/resource/base'
22
23
 
23
24
  shared_context "setup correct permissions" do
24
25
  if windows?
@@ -36,7 +37,11 @@ shared_context "setup correct permissions" do
36
37
 
37
38
  # Root only context.
38
39
  before :each, :unix_only, :requires_root do
39
- File.chown(Etc.getpwnam('nobody').uid, 1337, path)
40
+ if ohai[:platform] == "aix"
41
+ File.chown(Etc.getpwnam('guest').uid, 1337, path)
42
+ else
43
+ File.chown(Etc.getpwnam('nobody').uid, 1337, path)
44
+ end
40
45
  end
41
46
 
42
47
  before :each, :windows_only do
@@ -149,7 +154,11 @@ shared_examples_for "a securable resource with existing target" do
149
154
  include_context "diff disabled"
150
155
 
151
156
  context "on Unix", :unix_only do
152
- let(:expected_user_name) { 'nobody' }
157
+ if ohai[:platform] == "aix"
158
+ let(:expected_user_name) { 'guest' }
159
+ else
160
+ let(:expected_user_name) { 'nobody' }
161
+ end
153
162
  let(:expected_uid) { Etc.getpwnam(expected_user_name).uid }
154
163
  let(:desired_gid) { 1337 }
155
164
  let(:expected_gid) { 1337 }
@@ -1,4 +1,6 @@
1
1
 
2
+ require 'functional/resource/base'
3
+
2
4
  ALL_EXPANDED_PERMISSIONS = ["generic read",
3
5
  "generic write",
4
6
  "generic execute",
@@ -72,7 +74,12 @@ shared_examples_for "a securable resource with reporting" do
72
74
  context "and owner is specified with a String (username) in new_resource", :requires_root => true do
73
75
 
74
76
  # TODO/bug: duplicated from the "securable resource" tests
75
- let(:expected_user_name) { 'nobody' }
77
+
78
+ if ohai[:platform] == "aix"
79
+ let(:expected_user_name) { 'guest' }
80
+ else
81
+ let(:expected_user_name) { 'nobody' }
82
+ end
76
83
 
77
84
  before do
78
85
  resource.owner(expected_user_name)
@@ -88,7 +95,11 @@ shared_examples_for "a securable resource with reporting" do
88
95
  context "and owner is specified with an Integer (uid) in new_resource", :requires_root => true do
89
96
 
90
97
  # TODO: duplicated from "securable resource"
91
- let(:expected_user_name) { 'nobody' }
98
+ if ohai[:platform] == "aix"
99
+ let(:expected_user_name) { 'guest' }
100
+ else
101
+ let(:expected_user_name) { 'nobody' }
102
+ end
92
103
  let(:expected_uid) { Etc.getpwnam(expected_user_name).uid }
93
104
  let(:desired_gid) { 1337 }
94
105
  let(:expected_gid) { 1337 }
@@ -152,7 +152,7 @@ module TinyServer
152
152
  :available_routes => @routes, :request => env}
153
153
  # Uncomment me for glorious debugging
154
154
  # pp :not_found => debug_info
155
- [404, {'Content-Type' => 'application/json'}, debug_info.to_json]
155
+ [404, {'Content-Type' => 'application/json'}, [ debug_info.to_json ]]
156
156
  end
157
157
  end
158
158
 
@@ -341,6 +341,11 @@ describe Chef::Config do
341
341
  Chef::Config.stub(:env).and_return({ 'USERPROFILE' => "/users/kitten" })
342
342
  Chef::Config[:user_home].should == "/users/kitten"
343
343
  end
344
+
345
+ it "falls back to the current working directory when HOME and USERPROFILE is not set" do
346
+ Chef::Config.stub(:env).and_return({})
347
+ Chef::Config[:user_home].should == Dir.pwd
348
+ end
344
349
  end
345
350
 
346
351
  describe "Chef::Config[:encrypted_data_bag_secret]" do
@@ -178,6 +178,7 @@ describe Chef::Cookbook::Metadata do
178
178
  end
179
179
 
180
180
  describe "describing dependencies" do
181
+
181
182
  dep_types = {
182
183
  :depends => [ :dependencies, "foo::bar", "> 0.2" ],
183
184
  :recommends => [ :recommendations, "foo::bar", ">= 0.2" ],
@@ -199,6 +200,28 @@ describe Chef::Cookbook::Metadata do
199
200
  end
200
201
  end
201
202
 
203
+ dep_types = {
204
+ :depends => [ :dependencies, "foo::bar", ">0.2", "> 0.2" ],
205
+ :recommends => [ :recommendations, "foo::bar", ">=0.2", ">= 0.2" ],
206
+ :suggests => [ :suggestions, "foo::bar", ">0.2", "> 0.2" ],
207
+ :conflicts => [ :conflicting, "foo::bar", "~>0.2", "~> 0.2" ],
208
+ :provides => [ :providing, "foo::bar", "<=0.2", "<= 0.2" ],
209
+ :replaces => [ :replacing, "foo::bar", "=0.2.1", "= 0.2.1" ],
210
+ }
211
+ dep_types.sort { |a,b| a.to_s <=> b.to_s }.each do |dep, dep_args|
212
+ check_with = dep_args.shift
213
+ normalized_version = dep_args.pop
214
+ describe dep do
215
+ it "should be set-able and normalized via #{dep}" do
216
+ @meta.send(dep, *dep_args).should == normalized_version
217
+ end
218
+ it "should be get-able and normalized via #{check_with}" do
219
+ @meta.send(dep, *dep_args)
220
+ @meta.send(check_with).should == { dep_args[0] => normalized_version }
221
+ end
222
+ end
223
+ end
224
+
202
225
 
203
226
  describe "in the obsoleted format" do
204
227
  dep_types = {
@@ -546,6 +569,7 @@ describe Chef::Cookbook::Metadata do
546
569
  @meta.long_description "I have a long arm!"
547
570
  @meta.supports :ubuntu, "> 8.04"
548
571
  @meta.depends "bobo", "= 1.0"
572
+ @meta.depends "bubu", "=1.0"
549
573
  @meta.depends "bobotclown", "= 1.1"
550
574
  @meta.recommends "snark", "< 3.0"
551
575
  @meta.suggests "kindness", "> 2.0"
@@ -263,7 +263,9 @@ describe Chef::Environment do
263
263
  describe "self.validate_cookbook_version" do
264
264
  it "should validate correct version numbers" do
265
265
  Chef::Environment.validate_cookbook_version("= 1.2.3").should == true
266
+ Chef::Environment.validate_cookbook_version("=1.2.3").should == true
266
267
  Chef::Environment.validate_cookbook_version(">= 0.0.3").should == true
268
+ Chef::Environment.validate_cookbook_version(">=0.0.3").should == true
267
269
  # A lone version is allowed, interpreted as implicit '='
268
270
  Chef::Environment.validate_cookbook_version("1.2.3").should == true
269
271
  end
@@ -271,9 +273,13 @@ describe Chef::Environment do
271
273
  it "should return false when an invalid version is given" do
272
274
  Chef::Environment.validate_cookbook_version(Chef::CookbookVersion.new("meta")).should == false
273
275
  Chef::Environment.validate_cookbook_version("= 1.2.3a").should == false
276
+ Chef::Environment.validate_cookbook_version("=1.2.3a").should == false
274
277
  Chef::Environment.validate_cookbook_version("= 1").should == false
278
+ Chef::Environment.validate_cookbook_version("=1").should == false
275
279
  Chef::Environment.validate_cookbook_version("= a").should == false
280
+ Chef::Environment.validate_cookbook_version("=a").should == false
276
281
  Chef::Environment.validate_cookbook_version("= 1.2.3.4").should == false
282
+ Chef::Environment.validate_cookbook_version("=1.2.3.4").should == false
277
283
  end
278
284
 
279
285
  describe "in solo mode" do
@@ -0,0 +1,91 @@
1
+ #
2
+ # Author:: Klaas Jan Wierenga (<k.j.wierenga@gmail.com>)
3
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+
21
+ describe Chef::HTTP::HTTPRequest do
22
+
23
+ context "with HTTP url scheme" do
24
+
25
+ it "should not include port 80 in Host header" do
26
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com'), '')
27
+
28
+ request.headers['Host'].should eql('dummy.com')
29
+ end
30
+
31
+ it "should not include explicit port 80 in Host header" do
32
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:80'), '')
33
+
34
+ request.headers['Host'].should eql('dummy.com')
35
+ end
36
+
37
+ it "should include explicit port 8000 in Host header" do
38
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '')
39
+
40
+ request.headers['Host'].should eql('dummy.com:8000')
41
+ end
42
+
43
+ it "should include explicit 443 port in Host header" do
44
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:443'), '')
45
+
46
+ request.headers['Host'].should eql('dummy.com:443')
47
+ end
48
+
49
+ it "should pass on explicit Host header unchanged" do
50
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '', { 'Host' => 'yourhost.com:8888' })
51
+
52
+ request.headers['Host'].should eql('yourhost.com:8888')
53
+ end
54
+
55
+ end
56
+
57
+ context "with HTTPS url scheme" do
58
+
59
+ it "should not include port 443 in Host header" do
60
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com'), '')
61
+
62
+ request.headers['Host'].should eql('dummy.com')
63
+ end
64
+
65
+ it "should include explicit port 80 in Host header" do
66
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:80'), '')
67
+
68
+ request.headers['Host'].should eql('dummy.com:80')
69
+ end
70
+
71
+ it "should include explicit port 8000 in Host header" do
72
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:8000'), '')
73
+
74
+ request.headers['Host'].should eql('dummy.com:8000')
75
+ end
76
+
77
+ it "should not include explicit port 443 in Host header" do
78
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:443'), '')
79
+
80
+ request.headers['Host'].should eql('dummy.com')
81
+ end
82
+
83
+ end
84
+
85
+ it "should pass on explicit Host header unchanged" do
86
+ request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '', { 'Host' => 'myhost.com:80' })
87
+
88
+ request.headers['Host'].should eql('myhost.com:80')
89
+ end
90
+
91
+ end
@@ -21,8 +21,31 @@ require 'spec_helper'
21
21
  require 'chef/http'
22
22
  require 'chef/http/basic_client'
23
23
 
24
+ class Chef::HTTP
25
+ public :create_url
26
+ end
27
+
24
28
  describe Chef::HTTP do
25
29
 
30
+ describe "create_url" do
31
+
32
+ it 'should return a correctly formatted url 1/3 CHEF-5261' do
33
+ http = Chef::HTTP.new('http://www.getchef.com')
34
+ http.create_url('api/endpoint').should eql(URI.parse('http://www.getchef.com/api/endpoint'))
35
+ end
36
+
37
+ it 'should return a correctly formatted url 2/3 CHEF-5261' do
38
+ http = Chef::HTTP.new('http://www.getchef.com/')
39
+ http.create_url('/organization/org/api/endpoint/').should eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint/'))
40
+ end
41
+
42
+ it 'should return a correctly formatted url 3/3 CHEF-5261' do
43
+ http = Chef::HTTP.new('http://www.getchef.com/organization/org///')
44
+ http.create_url('///api/endpoint?url=http://foo.bar').should eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint?url=http://foo.bar'))
45
+ end
46
+
47
+ end # create_url
48
+
26
49
  describe "head" do
27
50
 
28
51
  it 'should return nil for a "200 Success" response (CHEF-4762)' do
@@ -94,8 +94,8 @@ describe Chef::Knife::Bootstrap do
94
94
  @knife.instance_variable_set("@template_file", @knife.config[:template_file])
95
95
  template_string = @knife.read_template
96
96
  @knife.parse_options(["-j", '{"foo":{"bar":"baz"}}'])
97
- expected_hash = Yajl::Parser.new.parse('{"foo":{"bar":"baz"},"run_list":[]}')
98
- actual_hash = Yajl::Parser.new.parse(@knife.render_template(template_string))
97
+ expected_hash = FFI_Yajl::Parser.new.parse('{"foo":{"bar":"baz"},"run_list":[]}')
98
+ actual_hash = FFI_Yajl::Parser.new.parse(@knife.render_template(template_string))
99
99
  actual_hash.should == expected_hash
100
100
  end
101
101
 
@@ -52,7 +52,7 @@ describe Chef::Knife::Ssh do
52
52
  def self.should_return_specified_attributes
53
53
  it "returns an array of the attributes specified on the command line OR config file, if only one is set" do
54
54
  @knife.config[:attribute] = "ipaddress"
55
- @knife.config[:override_attribute] = "ipaddress"
55
+ @knife.config[:attribute_from_cli] = "ipaddress"
56
56
  configure_query([@node_foo, @node_bar])
57
57
  @knife.should_receive(:session_from_list).with([['10.0.0.1', nil], ['10.0.0.2', nil]])
58
58
  @knife.configure_session
@@ -60,7 +60,7 @@ describe Chef::Knife::Ssh do
60
60
 
61
61
  it "returns an array of the attributes specified on the command line even when a config value is set" do
62
62
  @knife.config[:attribute] = "config_file" # this value will be the config file
63
- @knife.config[:override_attribute] = "ipaddress" # this is the value of the command line via #configure_attribute
63
+ @knife.config[:attribute_from_cli] = "ipaddress" # this is the value of the command line via #configure_attribute
64
64
  configure_query([@node_foo, @node_bar])
65
65
  @knife.should_receive(:session_from_list).with([['10.0.0.1', nil], ['10.0.0.2', nil]])
66
66
  @knife.configure_session
@@ -155,25 +155,19 @@ describe Chef::Knife::Ssh do
155
155
  @knife.config[:attribute].should == "command_line"
156
156
  end
157
157
 
158
- it "should set override_attribute to the value of attribute from the command line" do
158
+ it "should set attribute_from_cli to the value of attribute from the command line" do
159
159
  @knife.config[:attribute] = "command_line"
160
160
  @knife.configure_attribute
161
161
  @knife.config[:attribute].should == "command_line"
162
- @knife.config[:override_attribute].should == "command_line"
162
+ @knife.config[:attribute_from_cli].should == "command_line"
163
163
  end
164
164
 
165
- it "should set override_attribute to the value of attribute from the config file" do
166
- Chef::Config[:knife][:ssh_attribute] = "config_file"
167
- @knife.configure_attribute
168
- @knife.config[:attribute].should == "config_file"
169
- @knife.config[:override_attribute].should == "config_file"
170
- end
171
-
172
- it "should prefer the command line over the config file for the value of override_attribute" do
165
+ it "should prefer the command line over the config file for the value of attribute_from_cli" do
173
166
  Chef::Config[:knife][:ssh_attribute] = "config_file"
174
167
  @knife.config[:attribute] = "command_line"
175
168
  @knife.configure_attribute
176
- @knife.config[:override_attribute].should == "command_line"
169
+ @knife.config[:attribute].should == "command_line"
170
+ @knife.config[:attribute_from_cli].should == "command_line"
177
171
  end
178
172
  end
179
173
 
@@ -150,7 +150,7 @@ describe Chef::Knife do
150
150
  let(:headers) {{"Accept"=>"application/json",
151
151
  "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
152
152
  'X-Chef-Version' => Chef::VERSION,
153
- "Host"=>"api.opscode.piab:443",
153
+ "Host"=>"api.opscode.piab",
154
154
  "X-REMOTE-REQUEST-ID"=>request_id}}
155
155
 
156
156
  let(:request_id) {"1234"}
@@ -47,4 +47,8 @@ describe Chef::Mixin::ConvertToClassName do
47
47
  it "interprets non-alphanumeric characters in snake case as word boundaries" do
48
48
  @convert.convert_to_class_name("now_camelized_without-hyphen").should == "NowCamelizedWithoutHyphen"
49
49
  end
50
+
51
+ it "interprets underscore" do
52
+ @convert.convert_to_class_name("_remove_leading_underscore").should == "RemoveLeadingUnderscore"
53
+ end
50
54
  end
@@ -459,7 +459,7 @@ SHAS
459
459
  it "syncs the code by updating the source when the repo has already been checked out" do
460
460
  ::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
461
461
  ::File.stub(:directory?).with("/my/deploy").and_return(true)
462
- @provider.should_receive(:find_current_revision).exactly(2).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
462
+ @provider.should_receive(:find_current_revision).exactly(1).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
463
463
  @provider.should_not_receive(:fetch_updates)
464
464
  @provider.should_receive(:add_remotes)
465
465
  @provider.run_action(:sync)
@@ -470,7 +470,7 @@ SHAS
470
470
  ::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
471
471
  ::File.stub(:directory?).with("/my/deploy").and_return(true)
472
472
  # invoked twice - first time from load_current_resource
473
- @provider.should_receive(:find_current_revision).exactly(2).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
473
+ @provider.should_receive(:find_current_revision).exactly(1).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
474
474
  @provider.stub(:target_revision).and_return('28af684d8460ba4793eda3e7ac238c864a5d029a')
475
475
  @provider.should_receive(:fetch_updates)
476
476
  @provider.should_receive(:enable_submodules)