chef 11.14.0.alpha.3 → 11.14.0.alpha.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +140 -99
  3. data/lib/chef/application.rb +80 -2
  4. data/lib/chef/application/apply.rb +1 -0
  5. data/lib/chef/application/client.rb +5 -0
  6. data/lib/chef/application/knife.rb +4 -0
  7. data/lib/chef/application/windows_service.rb +1 -0
  8. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +6 -4
  9. data/lib/chef/config.rb +5 -3
  10. data/lib/chef/exceptions.rb +2 -0
  11. data/lib/chef/http/basic_client.rb +1 -0
  12. data/lib/chef/knife.rb +1 -0
  13. data/lib/chef/platform/provider_mapping.rb +7 -0
  14. data/lib/chef/provider/env/windows.rb +2 -0
  15. data/lib/chef/provider/group/usermod.rb +1 -1
  16. data/lib/chef/provider/mount/solaris.rb +233 -0
  17. data/lib/chef/provider/package/apt.rb +9 -0
  18. data/lib/chef/provider/package/windows.rb +3 -0
  19. data/lib/chef/providers.rb +1 -0
  20. data/lib/chef/resource/mount.rb +6 -1
  21. data/lib/chef/util/path_helper.rb +94 -0
  22. data/lib/chef/version.rb +1 -1
  23. data/spec/functional/application_spec.rb +58 -0
  24. data/spec/functional/resource/mount_spec.rb +14 -11
  25. data/spec/integration/client/client_spec.rb +11 -0
  26. data/spec/integration/knife/common_options_spec.rb +9 -0
  27. data/spec/unit/application_spec.rb +157 -0
  28. data/spec/unit/http/basic_client_spec.rb +42 -0
  29. data/spec/unit/provider/env/windows_spec.rb +67 -0
  30. data/spec/unit/provider/group/usermod_spec.rb +2 -1
  31. data/spec/unit/provider/mount/mount_spec.rb +3 -3
  32. data/spec/unit/provider/mount/solaris_spec.rb +646 -0
  33. data/spec/unit/provider/package/apt_spec.rb +5 -0
  34. data/spec/unit/provider/package/windows_spec.rb +6 -0
  35. data/spec/unit/resource_reporter_spec.rb +2 -2
  36. data/spec/unit/util/path_helper_spec.rb +136 -0
  37. metadata +23 -16
@@ -169,6 +169,11 @@ SHOWPKG_STDOUT
169
169
  @provider.load_current_resource
170
170
  end
171
171
 
172
+ it "raises an exception if a source is specified (CHEF-5113)" do
173
+ @new_resource.source "pluto"
174
+ @provider.define_resource_requirements
175
+ expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
176
+ end
172
177
  end
173
178
 
174
179
  context "after loading the current resource" do
@@ -27,6 +27,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
27
27
 
28
28
  describe "load_current_resource" do
29
29
  before(:each) do
30
+ Chef::Util::PathHelper.stub(:validate_path)
30
31
  provider.stub(:package_provider).and_return(double('package_provider',
31
32
  :installed_version => "1.0", :package_version => "2.0"))
32
33
  end
@@ -46,6 +47,11 @@ describe Chef::Provider::Package::Windows, :windows_only do
46
47
  provider.load_current_resource
47
48
  expect(provider.new_resource.version).to eql("2.0")
48
49
  end
50
+
51
+ it "checks that the source path is valid" do
52
+ expect(Chef::Util::PathHelper).to receive(:validate_path)
53
+ provider.load_current_resource
54
+ end
49
55
  end
50
56
 
51
57
  describe "package_provider" do
@@ -436,7 +436,7 @@ describe Chef::ResourceReporter do
436
436
  @backtrace = ["foo.rb:1 in `foo!'","bar.rb:2 in `bar!","'baz.rb:3 in `baz!'"]
437
437
  @node = Chef::Node.new
438
438
  @node.name("spitfire")
439
- @exception = double("ArgumentError")
439
+ @exception = ArgumentError.new
440
440
  @exception.stub(:inspect).and_return("Net::HTTPServerException")
441
441
  @exception.stub(:message).and_return("Object not found")
442
442
  @exception.stub(:backtrace).and_return(@backtrace)
@@ -463,7 +463,7 @@ describe Chef::ResourceReporter do
463
463
 
464
464
  it "includes the error inspector output in the event data" do
465
465
  @report["data"]["exception"].should have_key("description")
466
- @report["data"]["exception"]["description"].should include({"title"=>"Error expanding the run_list:", "sections"=>[{"Unexpected Error:" => "RSpec::Mocks::Mock: Object not found"}]})
466
+ @report["data"]["exception"]["description"].should include({"title"=>"Error expanding the run_list:", "sections"=>[{"Unexpected Error:" => "ArgumentError: Object not found"}]})
467
467
  end
468
468
 
469
469
  end
@@ -0,0 +1,136 @@
1
+ #
2
+ # Author:: Bryan McLellan <btm@loftninjas.org>
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 'chef/util/path_helper'
20
+ require 'spec_helper'
21
+
22
+ describe Chef::Util::PathHelper do
23
+ let(:path_helper) { Chef::Util::PathHelper }
24
+
25
+ describe "validate_path" do
26
+ context "on windows" do
27
+ before(:each) do
28
+ # pass by default
29
+ Chef::Platform.stub(:windows?).and_return(true)
30
+ path_helper.stub(:printable?).and_return(true)
31
+ path_helper.stub(:windows_max_length_exceeded?).and_return(false)
32
+ end
33
+
34
+ it "returns the path if the path passes the tests" do
35
+ expect(path_helper.validate_path("C:\\ThisIsRigged")).to eql("C:\\ThisIsRigged")
36
+ end
37
+
38
+ it "does not raise an error if everything looks great" do
39
+ expect { path_helper.validate_path("C:\\cool path\\dude.exe") }.not_to raise_error
40
+ end
41
+
42
+ it "raises an error if the path has invalid characters" do
43
+ path_helper.stub(:printable?).and_return(false)
44
+ expect { path_helper.validate_path("Newline!\n") }.to raise_error(Chef::Exceptions::ValidationFailed)
45
+ end
46
+
47
+ it "Adds the \\\\?\\ prefix if the path exceeds MAX_LENGTH and does not have it" do
48
+ long_path = "C:\\" + "a" * 250 + "\\" + "b" * 250
49
+ prefixed_long_path = "\\\\?\\" + long_path
50
+ path_helper.stub(:windows_max_length_exceeded?).and_return(true)
51
+ expect(path_helper.validate_path(long_path)).to eql(prefixed_long_path)
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "windows_max_length_exceeded?" do
57
+ it "returns true if the path is too long (259 + NUL) for the API" do
58
+ expect(path_helper.windows_max_length_exceeded?("C:\\" + "a" * 250 + "\\" + "b" * 6)).to be_true
59
+ end
60
+
61
+ it "returns false if the path is not too long (259 + NUL) for the standard API" do
62
+ expect(path_helper.windows_max_length_exceeded?("C:\\" + "a" * 250 + "\\" + "b" * 5)).to be_false
63
+ end
64
+
65
+ it "returns false if the path is over 259 characters but uses the \\\\?\\ prefix" do
66
+ expect(path_helper.windows_max_length_exceeded?("\\\\?\\C:\\" + "a" * 250 + "\\" + "b" * 250)).to be_false
67
+ end
68
+ end
69
+
70
+ describe "printable?" do
71
+ it "returns true if the string contains no non-printable characters" do
72
+ expect(path_helper.printable?("C:\\Program Files (x86)\\Microsoft Office\\Files.lst")).to be_true
73
+ end
74
+
75
+ it "returns true when given 'abc' in unicode" do
76
+ expect(path_helper.printable?("\u0061\u0062\u0063")).to be_true
77
+ end
78
+
79
+ it "returns true when given japanese unicode" do
80
+ expect(path_helper.printable?("\uff86\uff87\uff88")).to be_true
81
+ end
82
+
83
+ it "returns false if the string contains a non-printable character" do
84
+ expect(path_helper.printable?("\my files\work\notes.txt")).to be_false
85
+ end
86
+
87
+ # This isn't necessarily a requirement, but here to be explicit about functionality.
88
+ it "returns false if the string contains a newline or tab" do
89
+ expect(path_helper.printable?("\tThere's no way,\n\t *no* way,\n\t that you came from my loins.\n")).to be_false
90
+ end
91
+ end
92
+
93
+ describe "canonical_path" do
94
+ context "on windows", :windows_only do
95
+ it "returns an absolute path with backslashes instead of slashes" do
96
+ expect(path_helper.canonical_path("\\\\?\\C:/windows/win.ini")).to eq("\\\\?\\c:\\windows\\win.ini")
97
+ end
98
+
99
+ it "adds the \\\\?\\ prefix if it is missing" do
100
+ expect(path_helper.canonical_path("C:/windows/win.ini")).to eq("\\\\?\\c:\\windows\\win.ini")
101
+ end
102
+
103
+ it "returns a lowercase path" do
104
+ expect(path_helper.canonical_path("\\\\?\\C:\\CASE\\INSENSITIVE")).to eq("\\\\?\\c:\\case\\insensitive")
105
+ end
106
+ end
107
+
108
+ context "not on windows", :unix_only do
109
+ context "ruby is at least 1.9", :ruby_gte_19_only do
110
+ it "returns a canonical path" do
111
+ expect(path_helper.canonical_path("/etc//apache.d/sites-enabled/../sites-available/default")).to eq("/etc/apache.d/sites-available/default")
112
+ end
113
+ end
114
+
115
+ context "ruby is less than 1.9", :ruby_18_only do
116
+ it "returns a canonical path" do
117
+ expect { path_helper.canonical_path("/etc//apache.d/sites-enabled/../sites-available/default") }.to raise_error(NotImplementedError)
118
+ end
119
+ end
120
+ end
121
+ end
122
+
123
+ describe "paths_eql?" do
124
+ it "returns true if the paths are the same" do
125
+ path_helper.stub(:canonical_path).with("bandit").and_return("c:/bandit/bandit")
126
+ path_helper.stub(:canonical_path).with("../bandit/bandit").and_return("c:/bandit/bandit")
127
+ expect(path_helper.paths_eql?("bandit", "../bandit/bandit")).to be_true
128
+ end
129
+
130
+ it "returns false if the paths are different" do
131
+ path_helper.stub(:canonical_path).with("bandit").and_return("c:/Bo/Bandit")
132
+ path_helper.stub(:canonical_path).with("../bandit/bandit").and_return("c:/bandit/bandit")
133
+ expect(path_helper.paths_eql?("bandit", "../bandit/bandit")).to be_false
134
+ end
135
+ end
136
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.14.0.alpha.3
4
+ version: 11.14.0.alpha.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-30 00:00:00.000000000 Z
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-config
@@ -279,47 +279,47 @@ dependencies:
279
279
  - !ruby/object:Gem::Version
280
280
  version: '0.9'
281
281
  - !ruby/object:Gem::Dependency
282
- name: rake
282
+ name: rack
283
283
  requirement: !ruby/object:Gem::Requirement
284
284
  requirements:
285
- - - "~>"
285
+ - - ">="
286
286
  - !ruby/object:Gem::Version
287
- version: 10.1.0
287
+ version: '0'
288
288
  type: :development
289
289
  prerelease: false
290
290
  version_requirements: !ruby/object:Gem::Requirement
291
291
  requirements:
292
- - - "~>"
292
+ - - ">="
293
293
  - !ruby/object:Gem::Version
294
- version: 10.1.0
294
+ version: '0'
295
295
  - !ruby/object:Gem::Dependency
296
- name: rack
296
+ name: rake
297
297
  requirement: !ruby/object:Gem::Requirement
298
298
  requirements:
299
- - - ">="
299
+ - - "~>"
300
300
  - !ruby/object:Gem::Version
301
- version: '0'
301
+ version: 10.1.0
302
302
  type: :development
303
303
  prerelease: false
304
304
  version_requirements: !ruby/object:Gem::Requirement
305
305
  requirements:
306
- - - ">="
306
+ - - "~>"
307
307
  - !ruby/object:Gem::Version
308
- version: '0'
308
+ version: 10.1.0
309
309
  - !ruby/object:Gem::Dependency
310
310
  name: rspec_junit_formatter
311
311
  requirement: !ruby/object:Gem::Requirement
312
312
  requirements:
313
- - - ">="
313
+ - - "~>"
314
314
  - !ruby/object:Gem::Version
315
- version: '0'
315
+ version: 0.1.0
316
316
  type: :development
317
317
  prerelease: false
318
318
  version_requirements: !ruby/object:Gem::Requirement
319
319
  requirements:
320
- - - ">="
320
+ - - "~>"
321
321
  - !ruby/object:Gem::Version
322
- version: '0'
322
+ version: 0.1.0
323
323
  - !ruby/object:Gem::Dependency
324
324
  name: rspec-core
325
325
  requirement: !ruby/object:Gem::Requirement
@@ -957,6 +957,7 @@ files:
957
957
  - lib/chef/provider/mount.rb
958
958
  - lib/chef/provider/mount/aix.rb
959
959
  - lib/chef/provider/mount/mount.rb
960
+ - lib/chef/provider/mount/solaris.rb
960
961
  - lib/chef/provider/mount/windows.rb
961
962
  - lib/chef/provider/ohai.rb
962
963
  - lib/chef/provider/package.rb
@@ -1123,6 +1124,7 @@ files:
1123
1124
  - lib/chef/util/diff.rb
1124
1125
  - lib/chef/util/editor.rb
1125
1126
  - lib/chef/util/file_edit.rb
1127
+ - lib/chef/util/path_helper.rb
1126
1128
  - lib/chef/util/selinux.rb
1127
1129
  - lib/chef/util/threaded_job_queue.rb
1128
1130
  - lib/chef/util/windows.rb
@@ -1409,6 +1411,7 @@ files:
1409
1411
  - spec/data/trusted_certs/intermediate.pem
1410
1412
  - spec/data/trusted_certs/opscode.pem
1411
1413
  - spec/data/trusted_certs/root.pem
1414
+ - spec/functional/application_spec.rb
1412
1415
  - spec/functional/assets/PkgA.1.0.0.0.bff
1413
1416
  - spec/functional/assets/PkgA.2.0.0.0.bff
1414
1417
  - spec/functional/assets/dummy-1-0.aix6.1.noarch.rpm
@@ -1576,6 +1579,7 @@ files:
1576
1579
  - spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
1577
1580
  - spec/unit/handler/json_file_spec.rb
1578
1581
  - spec/unit/handler_spec.rb
1582
+ - spec/unit/http/basic_client_spec.rb
1579
1583
  - spec/unit/http/simple_spec.rb
1580
1584
  - spec/unit/http/ssl_policies_spec.rb
1581
1585
  - spec/unit/http/validate_content_length_spec.rb
@@ -1690,6 +1694,7 @@ files:
1690
1694
  - spec/unit/provider/deploy/timestamped_spec.rb
1691
1695
  - spec/unit/provider/deploy_spec.rb
1692
1696
  - spec/unit/provider/directory_spec.rb
1697
+ - spec/unit/provider/env/windows_spec.rb
1693
1698
  - spec/unit/provider/env_spec.rb
1694
1699
  - spec/unit/provider/erl_call_spec.rb
1695
1700
  - spec/unit/provider/execute_spec.rb
@@ -1714,6 +1719,7 @@ files:
1714
1719
  - spec/unit/provider/mdadm_spec.rb
1715
1720
  - spec/unit/provider/mount/aix_spec.rb
1716
1721
  - spec/unit/provider/mount/mount_spec.rb
1722
+ - spec/unit/provider/mount/solaris_spec.rb
1717
1723
  - spec/unit/provider/mount/windows_spec.rb
1718
1724
  - spec/unit/provider/mount_spec.rb
1719
1725
  - spec/unit/provider/ohai_spec.rb
@@ -1865,6 +1871,7 @@ files:
1865
1871
  - spec/unit/util/diff_spec.rb
1866
1872
  - spec/unit/util/editor_spec.rb
1867
1873
  - spec/unit/util/file_edit_spec.rb
1874
+ - spec/unit/util/path_helper_spec.rb
1868
1875
  - spec/unit/util/selinux_spec.rb
1869
1876
  - spec/unit/util/threaded_job_queue_spec.rb
1870
1877
  - spec/unit/version/platform_spec.rb