chef 11.6.0.hotfix.1 → 11.6.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +15 -0
  2. data/distro/common/html/chef-client.8.html +4 -4
  3. data/distro/common/html/chef-expander.8.html +4 -4
  4. data/distro/common/html/chef-expanderctl.8.html +4 -4
  5. data/distro/common/html/chef-server-webui.8.html +4 -4
  6. data/distro/common/html/chef-server.8.html +4 -4
  7. data/distro/common/html/chef-shell.1.html +4 -4
  8. data/distro/common/html/chef-solo.8.html +4 -4
  9. data/distro/common/html/chef-solr.8.html +4 -4
  10. data/distro/common/html/knife-bootstrap.1.html +4 -4
  11. data/distro/common/html/knife-client.1.html +4 -4
  12. data/distro/common/html/knife-configure.1.html +4 -4
  13. data/distro/common/html/knife-cookbook-site.1.html +4 -4
  14. data/distro/common/html/knife-cookbook.1.html +4 -4
  15. data/distro/common/html/knife-data-bag.1.html +4 -4
  16. data/distro/common/html/knife-environment.1.html +4 -4
  17. data/distro/common/html/knife-exec.1.html +4 -4
  18. data/distro/common/html/knife-index.1.html +4 -4
  19. data/distro/common/html/knife-node.1.html +4 -4
  20. data/distro/common/html/knife-role.1.html +4 -4
  21. data/distro/common/html/knife-search.1.html +4 -4
  22. data/distro/common/html/knife-ssh.1.html +4 -4
  23. data/distro/common/html/knife-status.1.html +4 -4
  24. data/distro/common/html/knife-tag.1.html +4 -4
  25. data/distro/common/html/knife.1.html +4 -4
  26. data/distro/common/man/man1/chef-shell.1 +1 -1
  27. data/distro/common/man/man1/knife-bootstrap.1 +1 -1
  28. data/distro/common/man/man1/knife-client.1 +1 -1
  29. data/distro/common/man/man1/knife-configure.1 +1 -1
  30. data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
  31. data/distro/common/man/man1/knife-cookbook.1 +1 -1
  32. data/distro/common/man/man1/knife-data-bag.1 +1 -1
  33. data/distro/common/man/man1/knife-environment.1 +1 -1
  34. data/distro/common/man/man1/knife-exec.1 +1 -1
  35. data/distro/common/man/man1/knife-index.1 +1 -1
  36. data/distro/common/man/man1/knife-node.1 +1 -1
  37. data/distro/common/man/man1/knife-role.1 +1 -1
  38. data/distro/common/man/man1/knife-search.1 +1 -1
  39. data/distro/common/man/man1/knife-ssh.1 +1 -1
  40. data/distro/common/man/man1/knife-status.1 +1 -1
  41. data/distro/common/man/man1/knife-tag.1 +1 -1
  42. data/distro/common/man/man1/knife.1 +1 -1
  43. data/distro/common/man/man8/chef-client.8 +1 -1
  44. data/distro/common/man/man8/chef-expander.8 +1 -1
  45. data/distro/common/man/man8/chef-expanderctl.8 +1 -1
  46. data/distro/common/man/man8/chef-server-webui.8 +1 -1
  47. data/distro/common/man/man8/chef-server.8 +1 -1
  48. data/distro/common/man/man8/chef-solo.8 +1 -1
  49. data/distro/common/man/man8/chef-solr.8 +1 -1
  50. data/lib/chef/application/client.rb +2 -0
  51. data/lib/chef/application/solo.rb +1 -0
  52. data/lib/chef/application/windows_service.rb +1 -0
  53. data/lib/chef/client.rb +6 -28
  54. data/lib/chef/config.rb +1 -1
  55. data/lib/chef/cookbook/cookbook_version_loader.rb +19 -10
  56. data/lib/chef/cookbook/file_system_file_vendor.rb +7 -4
  57. data/lib/chef/cookbook/metadata.rb +10 -1
  58. data/lib/chef/cookbook/syntax_check.rb +4 -4
  59. data/lib/chef/cookbook_uploader.rb +1 -1
  60. data/lib/chef/cookbook_version.rb +10 -6
  61. data/lib/chef/deprecation/provider/template.rb +1 -1
  62. data/lib/chef/exceptions.rb +0 -2
  63. data/lib/chef/formatters/error_descriptor.rb +4 -5
  64. data/lib/chef/knife/cookbook_site_share.rb +0 -1
  65. data/lib/chef/knife/cookbook_test.rb +0 -1
  66. data/lib/chef/provider/file.rb +1 -2
  67. data/lib/chef/provider/package/yum.rb +1 -2
  68. data/lib/chef/provider/remote_file/cache_control_data.rb +6 -12
  69. data/lib/chef/resource/file.rb +0 -2
  70. data/lib/chef/resource_reporter.rb +2 -5
  71. data/lib/chef/scan_access_control.rb +1 -6
  72. data/lib/chef/util/diff.rb +5 -31
  73. data/lib/chef/version.rb +1 -1
  74. data/lib/chef/win32/api/file.rb +0 -7
  75. data/spec/data/cookbooks/not-nginx/attributes/default.rb +1 -0
  76. data/spec/data/cookbooks/not-nginx/metadata.rb +1 -0
  77. data/spec/data/kitchen/no-really-not-nginx/attributes/default.rb +1 -0
  78. data/spec/data/kitchen/no-really-not-nginx/metadata.rb +1 -0
  79. data/spec/functional/knife/exec_spec.rb +2 -2
  80. data/spec/functional/resource/user_spec.rb +14 -6
  81. data/spec/spec_helper.rb +0 -32
  82. data/spec/support/platform_helpers.rb +0 -12
  83. data/spec/support/shared/functional/file_resource.rb +10 -87
  84. data/spec/support/shared/unit/provider/file.rb +2 -4
  85. data/spec/unit/cookbook/metadata_spec.rb +56 -50
  86. data/spec/unit/cookbook_loader_spec.rb +22 -1
  87. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  88. data/spec/unit/provider/package/yum_spec.rb +36 -17
  89. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +0 -50
  90. data/spec/unit/resource_reporter_spec.rb +1 -52
  91. data/spec/unit/scan_access_control_spec.rb +2 -4
  92. data/spec/unit/util/diff_spec.rb +11 -351
  93. metadata +9 -93
  94. data/spec/data/apt/chef-integration-test-1.0/debian/changelog +0 -5
  95. data/spec/data/apt/chef-integration-test-1.0/debian/compat +0 -1
  96. data/spec/data/apt/chef-integration-test-1.0/debian/control +0 -13
  97. data/spec/data/apt/chef-integration-test-1.0/debian/copyright +0 -34
  98. data/spec/data/apt/chef-integration-test-1.0/debian/files +0 -1
  99. data/spec/data/apt/chef-integration-test-1.0/debian/rules +0 -13
  100. data/spec/data/apt/chef-integration-test-1.0/debian/source/format +0 -1
  101. data/spec/data/apt/chef-integration-test-1.1/debian/changelog +0 -11
  102. data/spec/data/apt/chef-integration-test-1.1/debian/compat +0 -1
  103. data/spec/data/apt/chef-integration-test-1.1/debian/control +0 -13
  104. data/spec/data/apt/chef-integration-test-1.1/debian/copyright +0 -34
  105. data/spec/data/apt/chef-integration-test-1.1/debian/files +0 -1
  106. data/spec/data/apt/chef-integration-test-1.1/debian/rules +0 -13
  107. data/spec/data/apt/chef-integration-test-1.1/debian/source/format +0 -1
  108. data/spec/data/apt/chef-integration-test_1.0-1_amd64.changes +0 -22
  109. data/spec/data/apt/chef-integration-test_1.0-1_amd64.deb +0 -0
  110. data/spec/data/apt/chef-integration-test_1.0.orig.tar.gz +0 -0
  111. data/spec/data/apt/chef-integration-test_1.1-1_amd64.changes +0 -22
  112. data/spec/data/apt/chef-integration-test_1.1-1_amd64.deb +0 -0
  113. data/spec/data/apt/chef-integration-test_1.1.orig.tar.gz +0 -0
  114. data/spec/data/apt/var/www/apt/conf/distributions +0 -7
  115. data/spec/data/apt/var/www/apt/conf/incoming +0 -4
  116. data/spec/data/apt/var/www/apt/conf/pulls +0 -3
  117. data/spec/data/apt/var/www/apt/db/checksums.db +0 -0
  118. data/spec/data/apt/var/www/apt/db/contents.cache.db +0 -0
  119. data/spec/data/apt/var/www/apt/db/packages.db +0 -0
  120. data/spec/data/apt/var/www/apt/db/references.db +0 -0
  121. data/spec/data/apt/var/www/apt/db/release.caches.db +0 -0
  122. data/spec/data/apt/var/www/apt/db/version +0 -4
  123. data/spec/data/apt/var/www/apt/dists/sid/Release +0 -19
  124. data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages +0 -16
  125. data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages.gz +0 -0
  126. data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Release +0 -5
  127. data/spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages +0 -0
  128. data/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.deb +0 -0
  129. data/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb +0 -0
  130. data/spec/data/cookbooks/preseed/files/default/preseed-file.seed +0 -1
  131. data/spec/data/cookbooks/preseed/templates/default/preseed-template.seed +0 -1
  132. data/spec/functional/provider/remote_file/cache_control_data_spec.rb +0 -101
  133. data/spec/functional/resource/package_spec.rb +0 -297
@@ -68,7 +68,8 @@ describe Chef::CookbookLoader do
68
68
  seen[2].should == "borken"
69
69
  seen[3].should == "ignorken"
70
70
  seen[4].should == "java"
71
- seen[5].should == "openldap"
71
+ seen[5].should == "nginx"
72
+ seen[6].should == "openldap"
72
73
  end
73
74
  end
74
75
 
@@ -155,6 +156,26 @@ describe Chef::CookbookLoader do
155
156
  end
156
157
  @cookbook_loader.load_cookbooks
157
158
  end
159
+
160
+ it "should index cookbooks by name, not pathname" do
161
+ @cookbook_loader.should_not have_key(:'not-nginx')
162
+ @cookbook_loader.should_not have_key(:'no-really-not-nginx')
163
+ @cookbook_loader.should have_key(:nginx)
164
+ end
165
+
166
+ it "should shadow cookbooks by name, not pathname" do
167
+ @cookbook_loader[:nginx].attribute_filenames.detect { |f|
168
+ f =~ /cookbooks\/not-nginx\/attributes\/default.rb/
169
+ }.should_not eql(nil)
170
+ @cookbook_loader[:nginx].attribute_filenames.detect { |f|
171
+ f =~ /kitchen\/no-really-not-nginx\/attributes\/default.rb/
172
+ }.should eql(nil)
173
+ end
174
+
175
+ it "should emit deprecation warning if name is not in metadata" do
176
+ Chef::Log.should_receive(:warn).at_least(:once).with(/Inferring cookbook name from directory name \([^)]+\) is deprecated, please set a name in the metadata./)
177
+ @cookbook_loader.load_cookbooks
178
+ end
158
179
  end # load_cookbooks
159
180
 
160
181
  end # loading all cookbooks
@@ -256,7 +256,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
256
256
  it "determines the installed versions of gems from the source index (part2: the unmockening)" do
257
257
  $stdout.stub!(:write)
258
258
  path_to_gem = if windows?
259
- `where gem`.split[1]
259
+ `where gem`.split[-1]
260
260
  else
261
261
  `which gem`.strip
262
262
  end
@@ -39,6 +39,7 @@ describe Chef::Provider::Package::Yum do
39
39
  )
40
40
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
41
41
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
42
+ @stderr = StringIO.new
42
43
  @pid = mock("PID")
43
44
  end
44
45
 
@@ -541,7 +542,7 @@ describe Chef::Provider::Package::Yum do
541
542
  it "should call action_upgrade in the parent if the candidate version is nil" do
542
543
  @provider.load_current_resource
543
544
  @current_resource = Chef::Resource::Package.new('cups')
544
- @provider.candidate_version = nil
545
+ @provider.candidate_version = nil
545
546
  @provider.should_not_receive(:upgrade_package)
546
547
  @provider.action_upgrade
547
548
  end
@@ -1154,7 +1155,7 @@ describe Chef::Provider::Package::Yum::RPMDbPackage do
1154
1155
 
1155
1156
  describe "repoid" do
1156
1157
  it "should return the source repository repoid" do
1157
- @rpm_x.repoid.should be == "base"
1158
+ @rpm_x.repoid.should be == "base"
1158
1159
  @rpm_y.repoid.should be == "extras"
1159
1160
  @rpm_z.repoid.should be == "other"
1160
1161
  end
@@ -1543,10 +1544,7 @@ describe Chef::Provider::Package::Yum::YumCache do
1543
1544
  end
1544
1545
 
1545
1546
  before(:each) do
1546
- @stdin = mock("STDIN", :nil_object => true)
1547
- @stdout = mock("STDOUT", :nil_object => true)
1548
-
1549
- @stdout_good = <<EOF
1547
+ yum_dump_good_output = <<EOF
1550
1548
  [option installonlypkgs] kernel kernel-bigmem kernel-enterprise
1551
1549
  erlang-mochiweb 0 1.4.1 5.el5 x86_64 ['erlang-mochiweb = 1.4.1-5.el5', 'mochiweb = 1.4.1-5.el5'] i installed
1552
1550
  zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
@@ -1562,16 +1560,9 @@ znc-extra 0 0.098 1.el5 x86_64 [] a base
1562
1560
  znc-modtcl 0 0.098 1.el5 x86_64 [] a base
1563
1561
  znc-test.beta1 0 0.098 1.el5 x86_64 [] a extras
1564
1562
  znc-test.test.beta1 0 0.098 1.el5 x86_64 [] a base
1565
- EOF
1566
- @stdout_bad_type = <<EOF
1567
- zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
1568
- zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] c base
1569
- zlib-devel 0 1.2.3 3 i386 [] a extras
1570
- zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] bad installed
1571
- znc-modtcl 0 0.098 1.el5 x86_64 [] a base
1572
1563
  EOF
1573
1564
 
1574
- @stdout_bad_separators = <<EOF
1565
+ yum_dump_bad_output_separators = <<EOF
1575
1566
  zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
1576
1567
  zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] i base bad
1577
1568
  zlib-devel 0 1.2.3 3 i386 [] a extras
@@ -1579,13 +1570,41 @@ bad zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] i installed
1579
1570
  znc-modtcl 0 0.098 1.el5 x86_64 [] a base bad
1580
1571
  EOF
1581
1572
 
1582
- @stdout_no_output = ""
1573
+ yum_dump_bad_output_type = <<EOF
1574
+ zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
1575
+ zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] c base
1576
+ zlib-devel 0 1.2.3 3 i386 [] a extras
1577
+ zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] bad installed
1578
+ znc-modtcl 0 0.098 1.el5 x86_64 [] a base
1579
+ EOF
1583
1580
 
1584
- @stderr = <<EOF
1581
+ yum_dump_error = <<EOF
1585
1582
  yum-dump Config Error: File contains no section headers.
1586
1583
  file: file://///etc/yum.repos.d/CentOS-Base.repo, line: 12
1587
1584
  'qeqwewe\n'
1588
1585
  EOF
1586
+
1587
+ @stdin = mock("STDIN", :nil_object => true)
1588
+ @stdout = mock("STDOUT", :nil_object => true)
1589
+ @stdout_good = mock("STDOUT", :nil_object => true)
1590
+ s = @stdout_good.stub!(:each_line)
1591
+ yum_dump_good_output.split("\n").each do |line|
1592
+ s.and_yield(line)
1593
+ end
1594
+ @stdout_bad_type = mock("STDOUT", :nil_object => true)
1595
+ s = @stdout_bad_type.stub!(:each_line)
1596
+ yum_dump_bad_output_type.split("\n").each do |line|
1597
+ s.and_yield(line)
1598
+ end
1599
+ @stdout_bad_separators = mock("STDOUT", :nil_object => true)
1600
+ s = @stdout_bad_separators.stub!(:each_line)
1601
+ yum_dump_bad_output_separators.split("\n").each do |line|
1602
+ s.and_yield(line)
1603
+ end
1604
+ @stdout_no_output = mock("STDOUT", :nil_object => true)
1605
+ @stdout_no_output.stub!(:each_line).and_return(nil)
1606
+ @stderr = mock("STDERR", :nil_object => true)
1607
+ @stderr.stub!(:readlines).and_return(yum_dump_error.split("\n"))
1589
1608
  @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_good, :stderr => @stderr)
1590
1609
 
1591
1610
  # new singleton each time
@@ -1789,7 +1808,7 @@ EOF
1789
1808
  end
1790
1809
 
1791
1810
  it "should return nil when no match for package-version, no arch" do
1792
- @yc.package_repository("zisofs-tools", "pretend", nil).should be == nil
1811
+ @yc.package_repository("zisofs-tools", "pretend", nil).should be == nil
1793
1812
  @yc.package_repository("zisofs-tools", "pretend").should be == nil
1794
1813
  @yc.package_repository("pretend", "1.0.6-3.2.2").should be == nil
1795
1814
  end
@@ -19,15 +19,6 @@
19
19
  require 'spec_helper'
20
20
  require 'uri'
21
21
 
22
- CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH = 64
23
- CACHE_FILE_MD5_HEX_LENGTH = 32
24
- CACHE_FILE_JSON_FILE_EXTENSION_LENGTH = 5
25
- CACHE_FILE_PATH_LIMIT =
26
- CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH +
27
- 1 +
28
- CACHE_FILE_MD5_HEX_LENGTH +
29
- CACHE_FILE_JSON_FILE_EXTENSION_LENGTH # {friendly}-{md5hex}.json == 102
30
-
31
22
  describe Chef::Provider::RemoteFile::CacheControlData do
32
23
 
33
24
  let(:uri) { URI.parse("http://www.google.com/robots.txt") }
@@ -117,15 +108,6 @@ describe Chef::Provider::RemoteFile::CacheControlData do
117
108
  cache_control_data.mtime.should == mtime
118
109
  end
119
110
  end
120
-
121
- context "and the cached checksum data is corrupted" do
122
- let(:cache_json_data) { '{"foo",,"bar" []}' }
123
-
124
- it "returns empty cache control data" do
125
- cache_control_data.etag.should be_nil
126
- cache_control_data.mtime.should be_nil
127
- end
128
- end
129
111
  end
130
112
 
131
113
  describe "when saving to disk" do
@@ -173,38 +155,6 @@ describe Chef::Provider::RemoteFile::CacheControlData do
173
155
  cache_control_data.save
174
156
  end
175
157
  end
176
-
177
- # Cover the very long remote file path case -- see CHEF-4422 where
178
- # local cache file names generated from the long uri exceeded
179
- # local file system path limits resulting in exceptions from
180
- # file system API's on both Windows and Unix systems.
181
- context "and the URI results in a file cache path that exceeds #{CACHE_FILE_PATH_LIMIT} characters in length" do
182
- let(:long_remote_path) { "http://www.bing.com/" + ('0' * (CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH * 2 )) }
183
- let(:uri) { URI.parse(long_remote_path) }
184
- let(:truncated_remote_uri) { URI.parse(long_remote_path[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]) }
185
- let(:truncated_file_cache_path) do
186
- cache_control_data_truncated = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(truncated_remote_uri, current_file_checksum)
187
- cache_control_data_truncated.send('sanitized_cache_file_basename')[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]
188
- end
189
-
190
- it "truncates the file cache path to 102 characters" do
191
- normalized_cache_path = cache_control_data.send('sanitized_cache_file_basename')
192
-
193
- Chef::FileCache.should_receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data)
194
-
195
- cache_control_data.save
196
-
197
- normalized_cache_path.length.should == CACHE_FILE_PATH_LIMIT
198
- end
199
-
200
- it "uses a file cache path that starts with the first #{CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH} characters of the URI" do
201
- normalized_cache_path = cache_control_data.send('sanitized_cache_file_basename')
202
-
203
- truncated_file_cache_path.length.should == CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH
204
- normalized_cache_path.start_with?(truncated_file_cache_path).should == true
205
- end
206
- end
207
-
208
158
  end
209
159
 
210
160
  end
@@ -408,62 +408,11 @@ describe Chef::ResourceReporter do
408
408
 
409
409
  it "includes the error inspector output in the event data" do
410
410
  @report["data"]["exception"].should have_key("description")
411
- @report["data"]["exception"]["description"].should include({"title"=>"Error expanding the run_list:", "sections"=>[{"Unexpected Error:" => "RSpec::Mocks::Mock: Object not found"}]})
411
+ @report["data"]["exception"]["description"].should include({"title"=>"Error expanding the run_list:", "sections"=>[["Unexpected Error:", "RSpec::Mocks::Mock: Object not found"]]})
412
412
  end
413
413
 
414
414
  end
415
415
 
416
- context "when new_resource does not have a cookbook_name" do
417
- before do
418
- @bad_resource = Chef::Resource::File.new("/tmp/a-file.txt")
419
- @bad_resource.cookbook_name = nil
420
-
421
- @resource_reporter.resource_action_start(@bad_resource, :create)
422
- @resource_reporter.resource_current_state_loaded(@bad_resource, :create, @current_resource)
423
- @resource_reporter.resource_updated(@bad_resource, :create)
424
- @resource_reporter.resource_completed(@bad_resource)
425
- @run_status.stop_clock
426
- @report = @resource_reporter.prepare_run_data
427
- @first_update_report = @report["resources"].first
428
- end
429
-
430
- it "includes an updated resource's initial state" do
431
- @first_update_report["before"].should == @current_resource.state
432
- end
433
-
434
- it "includes an updated resource's final state" do
435
- @first_update_report["after"].should == @new_resource.state
436
- end
437
-
438
- it "includes the resource's name" do
439
- @first_update_report["name"].should == @new_resource.name
440
- end
441
-
442
- it "includes the resource's id attribute" do
443
- @first_update_report["id"].should == @new_resource.identity
444
- end
445
-
446
- it "includes the elapsed time for the resource to converge" do
447
- # TODO: API takes integer number of milliseconds as a string. This
448
- # should be an int.
449
- @first_update_report.should have_key("duration")
450
- @first_update_report["duration"].to_i.should be_within(100).of(0)
451
- end
452
-
453
- it "includes the action executed by the resource" do
454
- # TODO: rename as "action"
455
- @first_update_report["result"].should == "create"
456
- end
457
-
458
- it "does not include a cookbook name for the resource" do
459
- @first_update_report.should_not have_key("cookbook_name")
460
- end
461
-
462
- it "does not include a cookbook version for the resource" do
463
- @first_update_report.should_not have_key("cookbook_version")
464
- end
465
- end
466
-
467
416
  end
468
417
 
469
418
  describe "when updating resource history on the server" do
@@ -21,8 +21,7 @@ require 'chef/scan_access_control'
21
21
  describe Chef::ScanAccessControl do
22
22
 
23
23
  before do
24
- @new_resource = Chef::Resource::File.new("/tmp/foo/bar/baz/link")
25
- @real_file = "/tmp/foo/bar/real/file"
24
+ @new_resource = Chef::Resource::File.new("/tmp/foo/bar/baz/qux")
26
25
  @current_resource = Chef::Resource::File.new(@new_resource.path)
27
26
  @scanner = Chef::ScanAccessControl.new(@new_resource, @current_resource)
28
27
  end
@@ -50,8 +49,7 @@ describe Chef::ScanAccessControl do
50
49
 
51
50
  before do
52
51
  @stat = mock("File::Stat for #{@new_resource.path}", :uid => 0, :gid => 0, :mode => 00100644)
53
- File.should_receive(:realpath).with(@new_resource.path).and_return(@real_file)
54
- File.should_receive(:stat).with(@real_file).and_return(@stat)
52
+ File.should_receive(:stat).with(@new_resource.path).and_return(@stat)
55
53
  File.should_receive(:exist?).with(@new_resource.path).and_return(true)
56
54
  end
57
55
 
@@ -34,12 +34,6 @@ describe Chef::Util::Diff, :uses_diff => true do
34
34
  let!(:old_file) { old_tempfile.path }
35
35
  let!(:new_file) { new_tempfile.path }
36
36
 
37
- let(:plain_ascii) { "This is a text file.\nWith more than one line.\nAnd a \tTab.\nAnd lets make sure that other printable chars work too: ~!@\#$%^&*()`:\"<>?{}|_+,./;'[]\\-=\n" }
38
- # these are all byte sequences that are illegal in the other encodings... (but they may legally transcode)
39
- let(:utf_8) { "testing utf-8 unicode...\n\n\non a new line: \xE2\x80\x93\n" } # unicode em-dash
40
- let(:latin_1) { "It is more metal.\nif you have an \xFDmlaut.\n" } # NB: changed to y-with-diaresis, but i'm American so I don't know the difference
41
- let(:shift_jis) { "I have no idea what this character is:\n \x83\x80.\n" } # seriously, no clue, but \x80 is nice and illegal in other encodings
42
-
43
37
  let(:differ) do # subject
44
38
  differ = Chef::Util::Diff.new
45
39
  differ.diff(old_file, new_file)
@@ -120,200 +114,6 @@ describe Chef::Util::Diff, :uses_diff => true do
120
114
  end
121
115
  end
122
116
 
123
- describe "when the default external encoding is UTF-8", :ruby_gte_19_only do
124
-
125
- before do
126
- @saved_default_external = Encoding.default_external
127
- Encoding.default_external = Encoding::UTF_8
128
- end
129
-
130
- after do
131
- Encoding.default_external = @saved_default_external
132
- end
133
-
134
- describe "when a file has ASCII text" do
135
- before do
136
- new_tempfile.write(plain_ascii)
137
- new_tempfile.close
138
- end
139
- it "calling for_output should return a valid diff" do
140
- differ.for_output.join("\\n").should match(/\A--- .*\\n\+\+\+ .*\\n@@/m)
141
- end
142
- it "calling for_reporting should return a utf-8 string" do
143
- expect(differ.for_reporting.encoding).to equal(Encoding::UTF_8)
144
- end
145
- end
146
-
147
- describe "when a file has UTF-8 text" do
148
- before do
149
- new_tempfile.write(utf_8)
150
- new_tempfile.close
151
- end
152
- it "calling for_output should return a valid diff" do
153
- differ.for_output.join("\\n").should match(/\A--- .*\\n\+\+\+ .*\\n@@/m)
154
- end
155
- it "calling for_reporting should return a utf-8 string" do
156
- expect(differ.for_reporting.encoding).to equal(Encoding::UTF_8)
157
- end
158
- end
159
-
160
- describe "when a file has Latin-1 text" do
161
- before do
162
- new_tempfile.write(latin_1)
163
- new_tempfile.close
164
- end
165
- it "calling for_output should complain that the content is binary" do
166
- expect(differ.for_output).to eql( [ "(new content is binary, diff output suppressed)" ])
167
- end
168
- it "calling for_reporting should be nil" do
169
- expect(differ.for_reporting).to be_nil
170
- end
171
- end
172
-
173
- describe "when a file has Shift-JIS text" do
174
- before do
175
- new_tempfile.write(shift_jis)
176
- new_tempfile.close
177
- end
178
- it "calling for_output should complain that the content is binary" do
179
- expect(differ.for_output).to eql( [ "(new content is binary, diff output suppressed)" ])
180
- end
181
- it "calling for_reporting should be nil" do
182
- expect(differ.for_reporting).to be_nil
183
- end
184
- end
185
-
186
- end
187
-
188
- describe "when the default external encoding is Latin-1", :ruby_gte_19_only do
189
-
190
- before do
191
- @saved_default_external = Encoding.default_external
192
- Encoding.default_external = Encoding::ISO_8859_1
193
- end
194
-
195
- after do
196
- Encoding.default_external = @saved_default_external
197
- end
198
-
199
- describe "when a file has ASCII text" do
200
- before do
201
- new_tempfile.write(plain_ascii)
202
- new_tempfile.close
203
- end
204
- it "calling for_output should return a valid diff" do
205
- differ.for_output.join("\\n").should match(/\A--- .*\\n\+\+\+ .*\\n@@/m)
206
- end
207
- it "calling for_reporting should return a utf-8 string" do
208
- expect(differ.for_reporting.encoding).to equal(Encoding::UTF_8)
209
- end
210
- end
211
-
212
- describe "when a file has UTF-8 text" do
213
- before do
214
- new_tempfile.write(utf_8)
215
- new_tempfile.close
216
- end
217
- it "calling for_output should complain that the content is binary" do
218
- expect(differ.for_output).to eql( [ "(new content is binary, diff output suppressed)" ])
219
- end
220
- it "calling for_reporting should be nil" do
221
- expect(differ.for_reporting).to be_nil
222
- end
223
- end
224
-
225
- describe "when a file has Latin-1 text" do
226
- before do
227
- new_tempfile.write(latin_1)
228
- new_tempfile.close
229
- end
230
- it "calling for_output should return a valid diff" do
231
- differ.for_output.join("\\n").should match(/\A--- .*\\n\+\+\+ .*\\n@@/m)
232
- end
233
- it "calling for_reporting should return a utf-8 string" do
234
- expect(differ.for_reporting.encoding).to equal(Encoding::UTF_8)
235
- end
236
- end
237
-
238
- describe "when a file has Shift-JIS text" do
239
- before do
240
- new_tempfile.write(shift_jis)
241
- new_tempfile.close
242
- end
243
- it "calling for_output should complain that the content is binary" do
244
- expect(differ.for_output).to eql( [ "(new content is binary, diff output suppressed)" ])
245
- end
246
- it "calling for_reporting should be nil" do
247
- expect(differ.for_reporting).to be_nil
248
- end
249
- end
250
-
251
- end
252
- describe "when the default external encoding is Shift_JIS", :ruby_gte_19_only do
253
-
254
- before do
255
- @saved_default_external = Encoding.default_external
256
- Encoding.default_external = Encoding::Shift_JIS
257
- end
258
-
259
- after do
260
- Encoding.default_external = @saved_default_external
261
- end
262
-
263
- describe "when a file has ASCII text" do
264
- before do
265
- new_tempfile.write(plain_ascii)
266
- new_tempfile.close
267
- end
268
- it "calling for_output should return a valid diff" do
269
- differ.for_output.join("\\n").should match(/\A--- .*\\n\+\+\+ .*\\n@@/m)
270
- end
271
- it "calling for_reporting should return a utf-8 string" do
272
- expect(differ.for_reporting.encoding).to equal(Encoding::UTF_8)
273
- end
274
- end
275
-
276
- describe "when a file has UTF-8 text" do
277
- before do
278
- new_tempfile.write(utf_8)
279
- new_tempfile.close
280
- end
281
- it "calling for_output should complain that the content is binary" do
282
- expect(differ.for_output).to eql( [ "(new content is binary, diff output suppressed)" ])
283
- end
284
- it "calling for_reporting should be nil" do
285
- expect(differ.for_reporting).to be_nil
286
- end
287
- end
288
-
289
- describe "when a file has Latin-1 text" do
290
- before do
291
- new_tempfile.write(latin_1)
292
- new_tempfile.close
293
- end
294
- it "calling for_output should complain that the content is binary" do
295
- expect(differ.for_output).to eql( [ "(new content is binary, diff output suppressed)" ])
296
- end
297
- it "calling for_reporting should be nil" do
298
- expect(differ.for_reporting).to be_nil
299
- end
300
- end
301
-
302
- describe "when a file has Shift-JIS text" do
303
- before do
304
- new_tempfile.write(shift_jis)
305
- new_tempfile.close
306
- end
307
- it "calling for_output should return a valid diff" do
308
- differ.for_output.join("\\n").should match(/\A--- .*\\n\+\+\+ .*\\n@@/m)
309
- end
310
- it "calling for_reporting should return a utf-8 string" do
311
- expect(differ.for_reporting.encoding).to equal(Encoding::UTF_8)
312
- end
313
- end
314
-
315
- end
316
-
317
117
  describe "when testing the diff_filesize_threshold" do
318
118
  before do
319
119
  @diff_filesize_threshold_saved = Chef::Config[:diff_filesize_threshold]
@@ -365,11 +165,11 @@ describe Chef::Util::Diff, :uses_diff => true do
365
165
 
366
166
  it "calling for_output should return a unified diff" do
367
167
  differ.for_output.size.should eql(5)
368
- differ.for_output.join("\\n").should match(/\A--- .*\\n\+\+\+ .*\\n@@/m)
168
+ differ.for_output.join("\\n").should match(/^--- .*\\n\+\+\+ .*\\n@@ .* @@\\n-foo\\n\+bar$/)
369
169
  end
370
170
 
371
171
  it "calling for_reporting should return a unified diff" do
372
- differ.for_reporting.should match(/\A--- .*\\n\+\+\+ .*\\n@@/m)
172
+ differ.for_reporting.should match(/^--- .*\\n\+\+\+ .*\\n@@ .* @@\\n-foo\\n\+bar$/)
373
173
  end
374
174
 
375
175
  describe "when the diff output is too long" do
@@ -427,170 +227,30 @@ describe Chef::Util::Diff, :uses_diff => true do
427
227
  describe "when checking if files are binary or text" do
428
228
 
429
229
  it "should identify zero-length files as text" do
430
- Tempfile.open("chef-util-diff-spec") do |file|
431
- file.close
432
- differ.send(:is_binary?, file.path).should be_false
230
+ Tempfile.new("chef-util-diff-spec") do |file|
231
+ differ.is_binary?(file.path).should be_false
433
232
  end
434
233
  end
435
234
 
436
235
  it "should identify text files as text" do
437
- Tempfile.open("chef-util-diff-spec") do |file|
438
- file.write(plain_ascii)
236
+ Tempfile.new("chef-util-diff-spec") do |file|
237
+ file.write("This is a text file.")
238
+ file.write("With more than one line.")
239
+ file.write("And lets make sure that other printable chars work too: ~!@\#$%^&*()`:\"<>?{}|_+,./;'[]\\-=")
439
240
  file.close
440
- differ.send(:is_binary?, file.path).should be_false
241
+ differ.is_binary?(file.path).should be_false
441
242
  end
442
243
  end
443
244
 
444
245
  it "should identify a null-terminated string files as binary" do
445
- Tempfile.open("chef-util-diff-spec") do |file|
246
+ Tempfile.new("chef-util-diff-spec") do |file|
446
247
  file.write("This is a binary file.\0")
447
248
  file.close
448
- differ.send(:is_binary?, file.path).should be_true
449
- end
450
- end
451
-
452
- it "should identify null-teriminated multi-line string files as binary" do
453
- Tempfile.open("chef-util-diff-spec") do |file|
454
- file.write("This is a binary file.\nNo Really\nit is\0")
455
- file.close
456
- differ.send(:is_binary?, file.path).should be_true
457
- end
458
- end
459
-
460
- describe "when the default external encoding is UTF-8", :ruby_gte_19_only do
461
-
462
- before do
463
- @saved_default_external = Encoding.default_external
464
- Encoding.default_external = Encoding::UTF_8
465
- end
466
-
467
- after do
468
- Encoding.default_external = @saved_default_external
469
- end
470
-
471
- it "should identify normal ASCII as text" do
472
- Tempfile.open("chef-util-diff-spec") do |file|
473
- file.write(plain_ascii)
474
- file.close
475
- differ.send(:is_binary?, file.path).should be_false
476
- end
477
- end
478
-
479
- it "should identify UTF-8 as text" do
480
- Tempfile.open("chef-util-diff-spec") do |file|
481
- file.write(utf_8)
482
- file.close
483
- differ.send(:is_binary?, file.path).should be_false
484
- end
485
- end
486
-
487
- it "should identify Latin-1 that is invalid UTF-8 as binary" do
488
- Tempfile.open("chef-util-diff-spec") do |file|
489
- file.write(latin_1)
490
- file.close
491
- differ.send(:is_binary?, file.path).should be_true
492
- end
493
- end
494
-
495
- it "should identify Shift-JIS that is invalid UTF-8 as binary" do
496
- Tempfile.open("chef-util-diff-spec") do |file|
497
- file.write(shift_jis)
498
- file.close
499
- differ.send(:is_binary?, file.path).should be_true
500
- end
501
- end
502
-
503
- end
504
-
505
- describe "when the default external encoding is Latin-1", :ruby_gte_19_only do
506
-
507
- before do
508
- @saved_default_external = Encoding.default_external
509
- Encoding.default_external = Encoding::ISO_8859_1
510
- end
511
-
512
- after do
513
- Encoding.default_external = @saved_default_external
514
- end
515
-
516
- it "should identify normal ASCII as text" do
517
- Tempfile.open("chef-util-diff-spec") do |file|
518
- file.write(plain_ascii)
519
- file.close
520
- differ.send(:is_binary?, file.path).should be_false
521
- end
522
- end
523
-
524
- it "should identify UTF-8 that is invalid Latin-1 as binary" do
525
- Tempfile.open("chef-util-diff-spec") do |file|
526
- file.write(utf_8)
527
- file.close
528
- differ.send(:is_binary?, file.path).should be_true
529
- end
530
- end
531
-
532
- it "should identify Latin-1 as text" do
533
- Tempfile.open("chef-util-diff-spec") do |file|
534
- file.write(latin_1)
535
- file.close
536
- differ.send(:is_binary?, file.path).should be_false
537
- end
538
- end
539
-
540
- it "should identify Shift-JIS that is invalid Latin-1 as binary" do
541
- Tempfile.open("chef-util-diff-spec") do |file|
542
- file.write(shift_jis)
543
- file.close
544
- differ.send(:is_binary?, file.path).should be_true
545
- end
249
+ differ.is_binary?(file.path).should be_false
546
250
  end
547
251
  end
548
252
 
549
- describe "when the default external encoding is Shift-JIS", :ruby_gte_19_only do
550
-
551
- before do
552
- @saved_default_external = Encoding.default_external
553
- Encoding.default_external = Encoding::Shift_JIS
554
- end
555
-
556
- after do
557
- Encoding.default_external = @saved_default_external
558
- end
559
-
560
- it "should identify normal ASCII as text" do
561
- Tempfile.open("chef-util-diff-spec") do |file|
562
- file.write(plain_ascii)
563
- file.close
564
- differ.send(:is_binary?, file.path).should be_false
565
- end
566
- end
567
- it "should identify UTF-8 that is invalid Shift-JIS as binary" do
568
- Tempfile.open("chef-util-diff-spec") do |file|
569
- file.write(utf_8)
570
- file.close
571
- differ.send(:is_binary?, file.path).should be_true
572
- end
573
- end
574
-
575
- it "should identify Latin-1 that is invalid Shift-JIS as binary" do
576
- Tempfile.open("chef-util-diff-spec") do |file|
577
- file.write(latin_1)
578
- file.close
579
- differ.send(:is_binary?, file.path).should be_true
580
- end
581
- end
582
-
583
- it "should identify Shift-JIS as text" do
584
- Tempfile.open("chef-util-diff-spec") do |file|
585
- file.write(shift_jis)
586
- file.close
587
- differ.send(:is_binary?, file.path).should be_false
588
- end
589
- end
590
-
591
- end
592
253
  end
593
254
 
594
255
  end
595
256
 
596
-