chef 11.8.4.ohai7.0-x86-mingw32 → 11.10.0.alpha.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/distro/common/html/chef-client.8.html +3 -3
  3. data/distro/common/html/chef-expander.8.html +3 -3
  4. data/distro/common/html/chef-expanderctl.8.html +3 -3
  5. data/distro/common/html/chef-server-webui.8.html +3 -3
  6. data/distro/common/html/chef-server.8.html +3 -3
  7. data/distro/common/html/chef-shell.1.html +3 -3
  8. data/distro/common/html/chef-solo.8.html +3 -3
  9. data/distro/common/html/chef-solr.8.html +4 -4
  10. data/distro/common/html/knife-bootstrap.1.html +3 -3
  11. data/distro/common/html/knife-client.1.html +3 -3
  12. data/distro/common/html/knife-configure.1.html +3 -3
  13. data/distro/common/html/knife-cookbook-site.1.html +3 -3
  14. data/distro/common/html/knife-cookbook.1.html +3 -3
  15. data/distro/common/html/knife-data-bag.1.html +3 -3
  16. data/distro/common/html/knife-environment.1.html +3 -3
  17. data/distro/common/html/knife-exec.1.html +3 -3
  18. data/distro/common/html/knife-index.1.html +3 -3
  19. data/distro/common/html/knife-node.1.html +3 -3
  20. data/distro/common/html/knife-role.1.html +3 -3
  21. data/distro/common/html/knife-search.1.html +3 -3
  22. data/distro/common/html/knife-ssh.1.html +3 -3
  23. data/distro/common/html/knife-status.1.html +3 -3
  24. data/distro/common/html/knife-tag.1.html +3 -3
  25. data/distro/common/html/knife.1.html +3 -3
  26. data/distro/common/man/man8/chef-client.8 +3 -3
  27. data/distro/common/man/man8/chef-solo.8 +5 -2
  28. data/lib/chef.rb +2 -0
  29. data/lib/chef/application.rb +7 -2
  30. data/lib/chef/application/apply.rb +6 -0
  31. data/lib/chef/application/client.rb +3 -1
  32. data/lib/chef/application/knife.rb +2 -0
  33. data/lib/chef/application/solo.rb +1 -1
  34. data/lib/chef/client.rb +14 -11
  35. data/lib/chef/config.rb +4 -1
  36. data/lib/chef/cookbook_uploader.rb +14 -7
  37. data/lib/chef/encrypted_data_bag_item.rb +6 -303
  38. data/lib/chef/encrypted_data_bag_item/decryption_failure.rb +22 -0
  39. data/lib/chef/encrypted_data_bag_item/decryptor.rb +201 -0
  40. data/lib/chef/encrypted_data_bag_item/encryptor.rb +142 -0
  41. data/lib/chef/encrypted_data_bag_item/unacceptable_encrypted_data_bag_item_format.rb +22 -0
  42. data/lib/chef/encrypted_data_bag_item/unsupported_cipher.rb +22 -0
  43. data/lib/chef/encrypted_data_bag_item/unsupported_encrypted_data_bag_item_format.rb +22 -0
  44. data/lib/chef/exceptions.rb +1 -0
  45. data/lib/chef/formatters/doc.rb +19 -3
  46. data/lib/chef/http/basic_client.rb +1 -1
  47. data/lib/chef/http/http_request.rb +7 -0
  48. data/lib/chef/knife.rb +8 -1
  49. data/lib/chef/knife/bootstrap.rb +1 -1
  50. data/lib/chef/knife/cookbook_site_share.rb +2 -2
  51. data/lib/chef/knife/cookbook_upload.rb +7 -1
  52. data/lib/chef/knife/core/subcommand_loader.rb +2 -2
  53. data/lib/chef/knife/data_bag_create.rb +7 -0
  54. data/lib/chef/knife/environment_compare.rb +127 -0
  55. data/lib/chef/mixin/command.rb +11 -12
  56. data/lib/chef/mixin/deep_merge.rb +4 -4
  57. data/lib/chef/monkey_patches/net_http.rb +34 -0
  58. data/lib/chef/monkey_patches/uri.rb +70 -0
  59. data/lib/chef/platform/provider_mapping.rb +1 -0
  60. data/lib/chef/provider/cookbook_file.rb +8 -0
  61. data/lib/chef/provider/cron.rb +1 -1
  62. data/lib/chef/provider/directory.rb +7 -0
  63. data/lib/chef/provider/file.rb +17 -4
  64. data/lib/chef/provider/git.rb +23 -5
  65. data/lib/chef/provider/group.rb +30 -11
  66. data/lib/chef/provider/group/dscl.rb +26 -4
  67. data/lib/chef/provider/group/gpasswd.rb +14 -19
  68. data/lib/chef/provider/group/groupadd.rb +41 -1
  69. data/lib/chef/provider/group/groupmod.rb +46 -36
  70. data/lib/chef/provider/group/pw.rb +59 -16
  71. data/lib/chef/provider/group/suse.rb +16 -13
  72. data/lib/chef/provider/group/usermod.rb +38 -15
  73. data/lib/chef/provider/group/windows.rb +13 -6
  74. data/lib/chef/provider/ohai.rb +5 -6
  75. data/lib/chef/provider/remote_file.rb +8 -0
  76. data/lib/chef/provider/template.rb +8 -0
  77. data/lib/chef/provider/user.rb +5 -1
  78. data/lib/chef/provider/user/useradd.rb +7 -0
  79. data/lib/chef/provider/whyrun_safe_ruby_block.rb +30 -0
  80. data/lib/chef/providers.rb +1 -0
  81. data/lib/chef/resource/deploy.rb +18 -0
  82. data/lib/chef/resource/group.rb +11 -0
  83. data/lib/chef/resource/scm.rb +18 -0
  84. data/lib/chef/resource/whyrun_safe_ruby_block.rb +31 -0
  85. data/lib/chef/resources.rb +1 -0
  86. data/lib/chef/run_context.rb +11 -0
  87. data/lib/chef/shell/ext.rb +1 -1
  88. data/lib/chef/util/windows/net_group.rb +5 -1
  89. data/lib/chef/version.rb +1 -1
  90. data/spec/functional/resource/base.rb +3 -1
  91. data/spec/functional/resource/deploy_revision_spec.rb +1 -1
  92. data/spec/functional/resource/git_spec.rb +1 -1
  93. data/spec/functional/resource/group_spec.rb +257 -118
  94. data/spec/integration/client/client_spec.rb +82 -8
  95. data/spec/integration/client/ipv6_spec.rb +133 -0
  96. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +111 -0
  97. data/spec/scripts/ssl-serve.rb +52 -0
  98. data/spec/spec_helper.rb +7 -6
  99. data/spec/support/platform_helpers.rb +21 -0
  100. data/spec/support/shared/functional/windows_script.rb +2 -1
  101. data/spec/support/shared/unit/provider/file.rb +181 -43
  102. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +18 -0
  103. data/spec/unit/application/client_spec.rb +1 -0
  104. data/spec/unit/client_spec.rb +14 -1
  105. data/spec/unit/config_spec.rb +20 -0
  106. data/spec/unit/encrypted_data_bag_item_spec.rb +32 -18
  107. data/spec/unit/knife/cookbook_upload_spec.rb +14 -0
  108. data/spec/unit/knife/core/subcommand_loader_spec.rb +2 -2
  109. data/spec/unit/knife/data_bag_create_spec.rb +7 -0
  110. data/spec/unit/knife/environment_compare_spec.rb +112 -0
  111. data/spec/unit/knife_spec.rb +6 -1
  112. data/spec/unit/monkey_patches/uri_spec.rb +34 -0
  113. data/spec/unit/provider/cookbook_file_spec.rb +2 -1
  114. data/spec/unit/provider/cron_spec.rb +6 -0
  115. data/spec/unit/provider/file_spec.rb +3 -1
  116. data/spec/unit/provider/git_spec.rb +28 -4
  117. data/spec/unit/provider/group/dscl_spec.rb +1 -0
  118. data/spec/unit/provider/group/gpasswd_spec.rb +16 -9
  119. data/spec/unit/provider/group/groupadd_spec.rb +3 -4
  120. data/spec/unit/provider/group/groupmod_spec.rb +0 -1
  121. data/spec/unit/provider/group/pw_spec.rb +11 -14
  122. data/spec/unit/provider/group/usermod_spec.rb +19 -4
  123. data/spec/unit/provider/group/windows_spec.rb +0 -8
  124. data/spec/unit/provider/group_spec.rb +26 -4
  125. data/spec/unit/provider/ohai_spec.rb +1 -0
  126. data/spec/unit/provider/remote_file_spec.rb +4 -3
  127. data/spec/unit/provider/template_spec.rb +5 -3
  128. data/spec/unit/provider/user_spec.rb +6 -0
  129. data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +47 -0
  130. data/spec/unit/resource/scm_spec.rb +10 -0
  131. data/spec/unit/rest/auth_credentials_spec.rb +4 -1
  132. data/spec/unit/rest_spec.rb +12 -3
  133. metadata +69 -121
  134. data/spec/functional/resource/ohai_spec.rb +0 -65
@@ -22,19 +22,19 @@ EOM
22
22
  context 'and no config file' do
23
23
  it 'should complete with success when cwd is just above cookbooks and paths are not specified' do
24
24
  chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin"))
25
- result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to(''))
25
+ result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to(''))
26
26
  result.error!
27
27
  end
28
28
 
29
29
  it 'should complete with success when cwd is below cookbooks and paths are not specified' do
30
30
  chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin"))
31
- result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to('cookbooks/x'))
31
+ result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to('cookbooks/x'))
32
32
  result.error!
33
33
  end
34
34
 
35
35
  it 'should fail when cwd is below high above and paths are not specified' do
36
36
  chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin"))
37
- result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => File.expand_path('..', path_to('')))
37
+ result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => File.expand_path('..', path_to('')))
38
38
  result.exitstatus.should == 1
39
39
  end
40
40
  end
@@ -44,13 +44,14 @@ EOM
44
44
 
45
45
  it 'should load .chef/knife.rb when -z is specified' do
46
46
  chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin"))
47
- result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to(''))
48
- result.exitstatus.should == 2
47
+ result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to(''))
48
+ # FATAL: Configuration error NoMethodError: undefined method `xxx' for nil:NilClass
49
+ result.stdout.should include("xxx")
49
50
  end
50
51
 
51
52
  it 'fails to load .chef/knife.rb when -z is specified and --config-file-jail does not include the .chef/knife.rb' do
52
53
  chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin"))
53
- result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('roles')}\"", :cwd => path_to(''))
54
+ result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('roles')}\"", :cwd => path_to(''))
54
55
  result.error!
55
56
  end
56
57
  end
@@ -100,14 +101,87 @@ EOM
100
101
  it "should complete with success even with a client key" do
101
102
  file 'config/client.rb', <<EOM
102
103
  local_mode true
103
- client_key "#{path_to('mykey.pem')}"
104
- cookbook_path "#{path_to('cookbooks')}"
104
+ client_key #{path_to('mykey.pem').inspect}
105
+ cookbook_path #{path_to('cookbooks').inspect}
105
106
  EOM
106
107
 
107
108
  chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin")
108
109
  result = shell_out("chef-client -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
109
110
  result.error!
110
111
  end
112
+
113
+ it "should run recipes specified directly on the command line" do
114
+ file 'config/client.rb', <<EOM
115
+ local_mode true
116
+ client_key #{path_to('mykey.pem').inspect}
117
+ cookbook_path #{path_to('cookbooks').inspect}
118
+ EOM
119
+
120
+ file 'arbitrary.rb', <<EOM
121
+ file #{path_to('tempfile.txt').inspect} do
122
+ content '1'
123
+ end
124
+ EOM
125
+
126
+ file 'arbitrary2.rb', <<EOM
127
+ file #{path_to('tempfile2.txt').inspect} do
128
+ content '2'
129
+ end
130
+ EOM
131
+
132
+ chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin")
133
+ result = shell_out("chef-client -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", :cwd => chef_dir)
134
+ result.error!
135
+
136
+ IO.read(path_to('tempfile.txt')).should == '1'
137
+ IO.read(path_to('tempfile2.txt')).should == '2'
138
+ end
139
+
140
+ it "should run recipes specified as relative paths directly on the command line" do
141
+ file 'config/client.rb', <<EOM
142
+ local_mode true
143
+ client_key #{path_to('mykey.pem').inspect}
144
+ cookbook_path #{path_to('cookbooks').inspect}
145
+ EOM
146
+
147
+ file 'arbitrary.rb', <<EOM
148
+ file #{path_to('tempfile.txt').inspect} do
149
+ content '1'
150
+ end
151
+ EOM
152
+
153
+ chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin")
154
+ result = shell_out("#{chef_dir}/chef-client -c \"#{path_to('config/client.rb')}\" arbitrary.rb", :cwd => path_to(''))
155
+ result.error!
156
+
157
+ IO.read(path_to('tempfile.txt')).should == '1'
158
+ end
159
+
160
+ it "should run recipes specified directly on the command line AFTER recipes in the run list" do
161
+ file 'config/client.rb', <<EOM
162
+ local_mode true
163
+ client_key #{path_to('mykey.pem').inspect}
164
+ cookbook_path #{path_to('cookbooks').inspect}
165
+ EOM
166
+
167
+ file 'cookbooks/x/recipes/constant_definition.rb', <<EOM
168
+ class ::Blah
169
+ THECONSTANT = '1'
170
+ end
171
+ EOM
172
+ file 'arbitrary.rb', <<EOM
173
+ file #{path_to('tempfile.txt').inspect} do
174
+ content ::Blah::THECONSTANT
175
+ end
176
+ EOM
177
+
178
+ chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin")
179
+ result = shell_out("#{chef_dir}/chef-client -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", :cwd => path_to(''))
180
+ result.error!
181
+
182
+ IO.read(path_to('tempfile.txt')).should == '1'
183
+ end
184
+
111
185
  end
112
186
 
113
187
  it "should complete with success when passed the -z flag" do
@@ -0,0 +1,133 @@
1
+ #
2
+ # Author:: Daniel DeLeo (<dan@opscode.com>)
3
+ # Copyright:: Copyright (c) 2013 Opscode, 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
+ require 'support/shared/integration/integration_helper'
19
+ require 'chef/mixin/shell_out'
20
+
21
+ describe "chef-client" do
22
+ extend IntegrationSupport
23
+ include Chef::Mixin::ShellOut
24
+
25
+ let(:chef_zero_opts) { {:host => "::1"} }
26
+
27
+ let(:validation_pem) do
28
+ <<-END_VALIDATION_PEM
29
+ -----BEGIN RSA PRIVATE KEY-----
30
+ MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
31
+ 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
32
+ NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
33
+ 0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
34
+ AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
35
+ HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
36
+ 8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
37
+ zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
38
+ k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
39
+ i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
40
+ G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
41
+ ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
42
+ awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
43
+ 7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
44
+ g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
45
+ Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
46
+ HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
47
+ V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
48
+ fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
49
+ lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
50
+ c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
51
+ fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
52
+ YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
53
+ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
54
+ +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
55
+ -----END RSA PRIVATE KEY-----
56
+ END_VALIDATION_PEM
57
+ end
58
+
59
+ let(:cache_path) do
60
+ Dir.mktmpdir
61
+ end
62
+
63
+ let(:basic_config_file) do
64
+ <<-END_CLIENT_RB
65
+ chef_server_url "http://[::1]:8889"
66
+ validation_key '#{path_to('config/validator.pem')}'
67
+ cache_path '#{cache_path}'
68
+ client_key '#{cache_path}/client.pem'
69
+ END_CLIENT_RB
70
+ end
71
+
72
+ let(:client_rb_content) do
73
+ basic_config_file
74
+ end
75
+
76
+
77
+ let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
78
+
79
+ let(:chef_client_cmd) { %Q[chef-client -c "#{path_to('config/client.rb')}" -lwarn] }
80
+
81
+ after do
82
+ FileUtils.rm_rf(cache_path)
83
+ end
84
+
85
+ # Some Solaris test platforms are too old for IPv6. These tests should not
86
+ # otherwise be platform dependent, so exclude solaris
87
+ when_the_chef_server "is running on IPv6", :not_supported_on_solaris do
88
+
89
+ when_the_repository "has a cookbook with a no-op recipe" do
90
+ cookbook 'noop', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }, "recipes" => {"default.rb" => "#raise 'foo'"}
91
+ before do
92
+ file 'config/client.rb', client_rb_content
93
+ file 'config/validator.pem', validation_pem
94
+ end
95
+
96
+ it "should complete with success" do
97
+ result = shell_out("#{chef_client_cmd} -o 'noop::default'", :cwd => chef_dir)
98
+ result.error!
99
+ end
100
+
101
+ end
102
+
103
+ when_the_repository "has a cookbook that hits server APIs" do
104
+
105
+ recipe=<<-END_RECIPE
106
+ actual_item = data_bag_item("expect_bag", "expect_item")
107
+ if actual_item.key?("expect_key") and actual_item["expect_key"] == "expect_value"
108
+ Chef::Log.info "lookin good"
109
+ else
110
+ Chef::Log.error("!" * 80)
111
+ raise "unexpected data bag item content \#{actual_item.inspect}"
112
+ Chef::Log.error("!" * 80)
113
+ end
114
+
115
+ END_RECIPE
116
+
117
+ data_bag('expect_bag', { 'expect_item' => {"expect_key" => "expect_value"} })
118
+
119
+ cookbook 'api-smoke-test', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }, "recipes" => {"default.rb" => recipe}
120
+
121
+ before do
122
+ file 'config/client.rb', client_rb_content
123
+ file 'config/validator.pem', validation_pem
124
+ end
125
+
126
+ it "should complete with success" do
127
+ result = shell_out("#{chef_client_cmd} -o 'api-smoke-test::default'", :cwd => chef_dir)
128
+ result.error!
129
+ end
130
+
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,111 @@
1
+ #
2
+ # Author:: Daniel DeLeo (<dan@opscode.com>)
3
+ # Copyright:: Copyright (c) 2013 Opscode, 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
+ require 'support/shared/integration/integration_helper'
19
+ require 'chef/mixin/shell_out'
20
+
21
+ describe "Knife cookbook API integration with IPv6" do
22
+ extend IntegrationSupport
23
+ include Chef::Mixin::ShellOut
24
+
25
+ when_the_chef_server "is bound to IPv6" do
26
+ let(:chef_zero_opts) { {:host => "::1"} }
27
+
28
+ let(:client_key) do
29
+ <<-END_VALIDATION_PEM
30
+ -----BEGIN RSA PRIVATE KEY-----
31
+ MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf
32
+ 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk
33
+ NftHhTgO9/RFvCbmKZ1RKNob1YzLrFpxBHaSh9po+DGWhApcd+I+op+ZzvDgXhNn
34
+ 0nauZu3rZmApI/r7EEAOjFedAXs7VPNXhhtZAiLSAVIrwU3ZajtSzgXOxbNzgj5O
35
+ AAAMmThK+71qPdffAdO4J198H6/MY04qgtFo7vumzCq0UCaGZfmeI1UNE4+xQWwP
36
+ HJ3pDAP61C6Ebx2snI2kAd9QMx9Y78nIedRHPwIDAQABAoIBAHssRtPM1GacWsom
37
+ 8zfeN6ZbI4KDlbetZz0vhnqDk9NVrpijWlcOP5dwZXVNitnB/HaqCqFvyPDY9JNB
38
+ zI/pEFW4QH59FVDP42mVEt0keCTP/1wfiDDGh1vLqVBYl/ZphscDcNgDTzNkuxMx
39
+ k+LFVxKnn3w7rGc59lALSkpeGvbbIDjp3LUMlUeCF8CIFyYZh9ZvXe4OCxYdyjxb
40
+ i8tnMLKvJ4Psbh5jMapsu3rHQkfPdqzztQUz8vs0NYwP5vWge46FUyk+WNm/IhbJ
41
+ G3YM22nwUS8Eu2bmTtADSJolATbCSkOwQ1D+Fybz/4obfYeGaCdOqB05ttubhenV
42
+ ShsAb7ECgYEA20ecRVxw2S7qA7sqJ4NuYOg9TpfGooptYNA1IP971eB6SaGAelEL
43
+ awYkGNuu2URmm5ElZpwJFFTDLGA7t2zB2xI1FeySPPIVPvJGSiZoFQOVlIg9WQzK
44
+ 7jTtFQ/tOMrF+bigEUJh5bP1/7HzqSpuOsPjEUb2aoCTp+tpiRGL7TUCgYEAwtns
45
+ g3ysrSEcTzpSv7fQRJRk1lkBhatgNd0oc+ikzf74DaVLhBg1jvSThDhiDCdB59mr
46
+ Jh41cnR1XqE8jmdQbCDRiFrI1Pq6TPaDZFcovDVE1gue9x86v3FOH2ukPG4d2/Xy
47
+ HevXjThtpMMsWFi0JYXuzXuV5HOvLZiP8sN3lSMCgYANpdxdGM7RRbE9ADY0dWK2
48
+ V14ReTLcxP7fyrWz0xLzEeCqmomzkz3BsIUoouu0DCTSw+rvAwExqcDoDylIVlWO
49
+ fAifz7SeZHbcDxo+3TsXK7zwnLYsx7YNs2+aIv6hzUUbMNmNmXMcZ+IEwx+mRMTN
50
+ lYmZdrA5mr0V83oDFPt/jQKBgC74RVE03pMlZiObFZNtheDiPKSG9Bz6wMh7NWMr
51
+ c37MtZLkg52mEFMTlfPLe6ceV37CM8WOhqe+dwSGrYhOU06dYqUR7VOZ1Qr0aZvo
52
+ fsNPu/Y0+u7rMkgv0fs1AXQnvz7kvKaF0YITVirfeXMafuKEtJoH7owRbur42cpV
53
+ YCAtAoGAP1rHOc+w0RUcBK3sY7aErrih0OPh9U5bvJsrw1C0FIZhCEoDVA+fNIQL
54
+ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
55
+ +vFmf54y9YdnLXaqv+FhJT6B6V7WX7IpU9BMqJY1cJYXHuHG2KA=
56
+ -----END RSA PRIVATE KEY-----
57
+ END_VALIDATION_PEM
58
+ end
59
+
60
+ let(:cache_path) do
61
+ Dir.mktmpdir
62
+ end
63
+
64
+ let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
65
+
66
+ let(:knife_config_flag) { "-c '#{path_to("config/knife.rb")}'" }
67
+
68
+ # Some Solaris test platforms are too old for IPv6. These tests should not
69
+ # otherwise be platform dependent, so exclude solaris
70
+ context "and the chef_server_url contains an IPv6 literal", :not_supported_on_solaris do
71
+
72
+ # This provides helper functions we need such as #path_to()
73
+ when_the_repository "has the cookbook to be uploaded" do
74
+
75
+ let(:knife_rb_content) do
76
+ <<-END_CLIENT_RB
77
+ chef_server_url "http://[::1]:8889"
78
+ syntax_check_cache_path '#{cache_path}'
79
+ client_key '#{path_to('config/knifeuser.pem')}'
80
+ node_name 'whoisthisis'
81
+ cookbook_path '#{CHEF_SPEC_DATA}/cookbooks'
82
+ END_CLIENT_RB
83
+ end
84
+
85
+ before do
86
+ file 'config/knife.rb', knife_rb_content
87
+ file 'config/knifeuser.pem', client_key
88
+ end
89
+
90
+ it "successfully uploads a cookbook" do
91
+ shell_out!("knife cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
92
+ versions_list_json = Chef::HTTP::Simple.new("http://[::1]:8889").get("/cookbooks/apache2", "accept" => "application/json")
93
+ versions_list = Chef::JSONCompat.from_json(versions_list_json)
94
+ versions_list["apache2"]["versions"].should_not be_empty
95
+ end
96
+
97
+ context "and the cookbook has been uploaded to the server" do
98
+ before do
99
+ shell_out!("knife cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
100
+ end
101
+
102
+ it "downloads the cookbook" do
103
+ s = shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", :cwd => chef_dir)
104
+ Dir["#{cache_path}/*"].map {|entry| File.basename(entry)}.should include("apache2-0.0.0")
105
+ end
106
+ end
107
+
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,52 @@
1
+ # ssl-serve.rb
2
+ # USAGE: ruby ssl-serve.rb
3
+ #
4
+ # ssl-serve is a script that serves a local directory over SSL.
5
+ # You can use it to test various HTTP behaviors in chef, like chef-client's
6
+ # `-j` and `-c` options and remote_file with https connections.
7
+ #
8
+ require 'pp'
9
+ require 'openssl'
10
+ require 'webrick'
11
+ require 'webrick/https'
12
+
13
+
14
+ $ssl = true
15
+
16
+ CHEF_SPEC_DATA = File.expand_path("../../data", __FILE__)
17
+ cert_text = File.read(File.expand_path("ssl/chef-rspec.cert", CHEF_SPEC_DATA))
18
+ cert = OpenSSL::X509::Certificate.new(cert_text)
19
+ key_text = File.read(File.expand_path("ssl/chef-rspec.key", CHEF_SPEC_DATA))
20
+ key = OpenSSL::PKey::RSA.new(key_text)
21
+
22
+ server_opts = {}
23
+ if $ssl
24
+ server_opts.merge!( { :SSLEnable => true,
25
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
26
+ :SSLCertificate => cert,
27
+ :SSLPrivateKey => key })
28
+ end
29
+
30
+
31
+
32
+ # 5 == debug, 3 == warning
33
+ LOGGER = WEBrick::Log.new(STDOUT, 5)
34
+ DEFAULT_OPTIONS = {
35
+ :server => 'webrick',
36
+ :Port => 9000,
37
+ :Host => 'localhost',
38
+ :environment => :none,
39
+ :Logger => LOGGER,
40
+ :DocumentRoot => File.expand_path("/tmp/chef-118-sampledata")
41
+ #:AccessLog => [] # Remove this option to enable the access log when debugging.
42
+ }
43
+
44
+ webrick_opts = DEFAULT_OPTIONS.merge(server_opts)
45
+ pp :webrick_opts => webrick_opts
46
+
47
+ server = WEBrick::HTTPServer.new(webrick_opts)
48
+ trap 'INT' do server.shutdown end
49
+
50
+ server.start
51
+
52
+
@@ -87,7 +87,8 @@ Dir["spec/support/**/*.rb"].
87
87
 
88
88
 
89
89
  OHAI_SYSTEM = Ohai::System.new
90
- OHAI_SYSTEM.all_plugins("platform")
90
+ OHAI_SYSTEM.require_plugin("os")
91
+ OHAI_SYSTEM.require_plugin("platform")
91
92
  TEST_PLATFORM = OHAI_SYSTEM["platform"].dup.freeze
92
93
  TEST_PLATFORM_VERSION = OHAI_SYSTEM["platform_version"].dup.freeze
93
94
 
@@ -101,15 +102,15 @@ RSpec.configure do |config|
101
102
 
102
103
  # Add jruby filters here
103
104
  config.filter_run_excluding :windows_only => true unless windows?
105
+ config.filter_run_excluding :not_supported_on_mac_osx_106 => true if mac_osx_106?
104
106
  config.filter_run_excluding :not_supported_on_win2k3 => true if windows_win2k3?
105
107
  config.filter_run_excluding :not_supported_on_solaris => true if solaris?
106
108
  config.filter_run_excluding :win2k3_only => true unless windows_win2k3?
107
109
  config.filter_run_excluding :windows64_only => true unless windows64?
108
110
  config.filter_run_excluding :windows32_only => true unless windows32?
111
+ config.filter_run_excluding :solaris_only => true unless solaris?
109
112
  config.filter_run_excluding :system_windows_service_gem_only => true unless system_windows_service_gem?
110
113
  config.filter_run_excluding :unix_only => true unless unix?
111
- # Remove this filter once these issues are fixed: OC-9764, OC-9765, OC-9766, OC-9767
112
- config.filter_run_excluding :unsupported_group_provider_platform => true if (os_x? or solaris? or freebsd? or suse?)
113
114
  config.filter_run_excluding :supports_cloexec => true unless supports_cloexec?
114
115
  config.filter_run_excluding :selinux_only => true unless selinux_enabled?
115
116
  config.filter_run_excluding :ruby_18_only => true unless ruby_18?
@@ -117,9 +118,9 @@ RSpec.configure do |config|
117
118
  config.filter_run_excluding :ruby_gte_19_only => true unless ruby_gte_19?
118
119
  config.filter_run_excluding :ruby_20_only => true unless ruby_20?
119
120
  config.filter_run_excluding :ruby_gte_20_only => true unless ruby_gte_20?
120
- config.filter_run_excluding :requires_root => true unless ENV['USER'] == 'root' || ENV['LOGIN'] == 'root'
121
- config.filter_run_excluding :requires_root_or_running_windows => true unless (ENV['USER'] == 'root' or windows?)
122
- config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root'
121
+ config.filter_run_excluding :requires_root => true unless root?
122
+ config.filter_run_excluding :requires_root_or_running_windows => true unless (root? || windows?)
123
+ config.filter_run_excluding :requires_unprivileged_user => true if root?
123
124
  config.filter_run_excluding :uses_diff => true unless has_diff?
124
125
 
125
126
  running_platform_arch = `uname -m`.strip