summaryrefslogtreecommitdiff
path: root/spec/scripts
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-10-24 15:50:16 -0700
committerdanielsdeleo <dan@opscode.com>2013-10-24 16:26:14 -0700
commit1df91de7319e7f02ada6ce78b836dd837de738e9 (patch)
treecbdba2204d1d63bc80e33f0857137b14c2e5fe7e /spec/scripts
parent720e1afa1eb66a0a086cc159a14e4ce1147f825e (diff)
downloadchef-1df91de7319e7f02ada6ce78b836dd837de738e9.tar.gz
Add ssl-serve script for future manual test needs
Diffstat (limited to 'spec/scripts')
-rw-r--r--spec/scripts/ssl-serve.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb
new file mode 100644
index 0000000000..24ed70addc
--- /dev/null
+++ b/spec/scripts/ssl-serve.rb
@@ -0,0 +1,52 @@
+# ssl-serve.rb
+# USAGE: ruby ssl-serve.rb
+#
+# ssl-serve is a script that serves a local directory over SSL.
+# You can use it to test various HTTP behaviors in chef, like chef-client's
+# `-j` and `-c` options and remote_file with https connections.
+#
+require 'pp'
+require 'openssl'
+require 'webrick'
+require 'webrick/https'
+
+
+$ssl = true
+
+CHEF_SPEC_DATA = File.expand_path("../../data", __FILE__)
+cert_text = File.read(File.expand_path("ssl/chef-rspec.cert", CHEF_SPEC_DATA))
+cert = OpenSSL::X509::Certificate.new(cert_text)
+key_text = File.read(File.expand_path("ssl/chef-rspec.key", CHEF_SPEC_DATA))
+key = OpenSSL::PKey::RSA.new(key_text)
+
+server_opts = {}
+if $ssl
+server_opts.merge!( { :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => cert,
+ :SSLPrivateKey => key })
+end
+
+
+
+# 5 == debug, 3 == warning
+LOGGER = WEBrick::Log.new(STDOUT, 5)
+DEFAULT_OPTIONS = {
+ :server => 'webrick',
+ :Port => 9000,
+ :Host => 'localhost',
+ :environment => :none,
+ :Logger => LOGGER,
+ :DocumentRoot => File.expand_path("/tmp/chef-118-sampledata")
+ #:AccessLog => [] # Remove this option to enable the access log when debugging.
+}
+
+webrick_opts = DEFAULT_OPTIONS.merge(server_opts)
+pp :webrick_opts => webrick_opts
+
+server = WEBrick::HTTPServer.new(webrick_opts)
+trap 'INT' do server.shutdown end
+
+server.start
+
+