chef 11.14.0.alpha.3-x86-mingw32 → 11.14.0.alpha.4-x86-mingw32

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: x86-mingw32
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
@@ -1111,6 +1111,7 @@ files:
1111
1111
  - lib/chef/provider/mount.rb
1112
1112
  - lib/chef/provider/mount/aix.rb
1113
1113
  - lib/chef/provider/mount/mount.rb
1114
+ - lib/chef/provider/mount/solaris.rb
1114
1115
  - lib/chef/provider/mount/windows.rb
1115
1116
  - lib/chef/provider/ohai.rb
1116
1117
  - lib/chef/provider/package.rb
@@ -1277,6 +1278,7 @@ files:
1277
1278
  - lib/chef/util/diff.rb
1278
1279
  - lib/chef/util/editor.rb
1279
1280
  - lib/chef/util/file_edit.rb
1281
+ - lib/chef/util/path_helper.rb
1280
1282
  - lib/chef/util/selinux.rb
1281
1283
  - lib/chef/util/threaded_job_queue.rb
1282
1284
  - lib/chef/util/windows.rb
@@ -1563,6 +1565,7 @@ files:
1563
1565
  - spec/data/trusted_certs/intermediate.pem
1564
1566
  - spec/data/trusted_certs/opscode.pem
1565
1567
  - spec/data/trusted_certs/root.pem
1568
+ - spec/functional/application_spec.rb
1566
1569
  - spec/functional/assets/PkgA.1.0.0.0.bff
1567
1570
  - spec/functional/assets/PkgA.2.0.0.0.bff
1568
1571
  - spec/functional/assets/dummy-1-0.aix6.1.noarch.rpm
@@ -1730,6 +1733,7 @@ files:
1730
1733
  - spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb
1731
1734
  - spec/unit/handler/json_file_spec.rb
1732
1735
  - spec/unit/handler_spec.rb
1736
+ - spec/unit/http/basic_client_spec.rb
1733
1737
  - spec/unit/http/simple_spec.rb
1734
1738
  - spec/unit/http/ssl_policies_spec.rb
1735
1739
  - spec/unit/http/validate_content_length_spec.rb
@@ -1844,6 +1848,7 @@ files:
1844
1848
  - spec/unit/provider/deploy/timestamped_spec.rb
1845
1849
  - spec/unit/provider/deploy_spec.rb
1846
1850
  - spec/unit/provider/directory_spec.rb
1851
+ - spec/unit/provider/env/windows_spec.rb
1847
1852
  - spec/unit/provider/env_spec.rb
1848
1853
  - spec/unit/provider/erl_call_spec.rb
1849
1854
  - spec/unit/provider/execute_spec.rb
@@ -1868,6 +1873,7 @@ files:
1868
1873
  - spec/unit/provider/mdadm_spec.rb
1869
1874
  - spec/unit/provider/mount/aix_spec.rb
1870
1875
  - spec/unit/provider/mount/mount_spec.rb
1876
+ - spec/unit/provider/mount/solaris_spec.rb
1871
1877
  - spec/unit/provider/mount/windows_spec.rb
1872
1878
  - spec/unit/provider/mount_spec.rb
1873
1879
  - spec/unit/provider/ohai_spec.rb
@@ -2019,6 +2025,7 @@ files:
2019
2025
  - spec/unit/util/diff_spec.rb
2020
2026
  - spec/unit/util/editor_spec.rb
2021
2027
  - spec/unit/util/file_edit_spec.rb
2028
+ - spec/unit/util/path_helper_spec.rb
2022
2029
  - spec/unit/util/selinux_spec.rb
2023
2030
  - spec/unit/util/threaded_job_queue_spec.rb
2024
2031
  - spec/unit/version/platform_spec.rb