summaryrefslogtreecommitdiff
path: root/spec/acceptance
diff options
context:
space:
mode:
authorJohn Duarte <john.duarte@puppetlabs.com>2014-05-15 13:21:13 -0700
committerJohn Duarte <john.duarte@puppetlabs.com>2014-05-18 11:38:20 -0700
commit123fe4099e4e4fdda7b34a769458a1dcaad75aae (patch)
treee2ff2a06b096b8c885a6da8da3f9e9e81245dbee /spec/acceptance
parent97e64b52f63f3dd673dfa2fe92c71d4d9ddbcbc7 (diff)
Use sinatra to set up basic auth HTTP server
Diffstat (limited to 'spec/acceptance')
-rw-r--r--spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb25
1 files changed, 11 insertions, 14 deletions
diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb
index f2486cd..69e1941 100644
--- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb
+++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb
@@ -8,6 +8,7 @@ http_server_script = 'basic_auth_http_daemon.rb'
hosts.each do |host|
ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby'
+ gem = '/opt/puppet/bin/gem' if host.is_pe? || 'gem'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
install_package(host, 'git')
@@ -18,23 +19,19 @@ hosts.each do |host|
step 'setup - start http server' do
script =<<-EOF
- require 'webrick'
+ require 'sinatra'
+
+ set :bind, '0.0.0.0'
+ set :static, true
+ set :public_folder, '#{tmpdir}'
- authenticate = Proc.new do |req, res|
- WEBrick::HTTPAuth.basic_auth(req, res, '') do |user, password|
- user == '#{user}' && password == '#{password}'
- end
- end
- server = WEBrick::HTTPServer.new(
- :Port => 8000,
- :DocumentRoot => "#{tmpdir}",
- :DocumentRootOptions=> {:HandlerCallback => authenticate},
- )
- WEBrick::Daemon.start
- server.start
+ use Rack::Auth::Basic do |username, password|
+ username == '#{user}' && password == '#{password}'
+ end
EOF
create_remote_file(host, "#{tmpdir}/#{http_server_script}", script)
+ on(host, "#{gem} install sinatra")
on(host, "#{ruby} #{tmpdir}/#{http_server_script} &")
end
@@ -47,7 +44,7 @@ hosts.each do |host|
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
- source => "http://#{host}:8000/testrepo.git",
+ source => "http://#{host}:4567/testrepo.git",
provider => git,
basic_auth_username => '#{user}',
basic_auth_password => '#{password}',