| 1 |
test_name 'C3493 - checkout with basic auth (https protocol)' |
| 2 |
skip_test 'waiting for CA trust solution' |
| 3 |
|
| 4 |
# Globals |
| 5 |
repo_name = 'testrepo_checkout' |
| 6 |
user = 'foo' |
| 7 |
password = 'bar' |
| 8 |
http_server_script = 'basic_auth_https_daemon.rb' |
| 9 |
|
| 10 |
hosts.each do |host| |
| 11 |
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' |
| 12 |
tmpdir = host.tmpdir('vcsrepo') |
| 13 |
step 'setup - create repo' do |
| 14 |
git_pkg = 'git' |
| 15 |
if host['platform'] =~ /ubuntu-10/ |
| 16 |
git_pkg = 'git-core' |
| 17 |
end |
| 18 |
install_package(host, git_pkg) |
| 19 |
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) |
| 20 |
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) |
| 21 |
on(host, "cd #{tmpdir} && ./create_git_repo.sh") |
| 22 |
end |
| 23 |
|
| 24 |
step 'setup - start https server' do |
| 25 |
script =<<-EOF |
| 26 |
require 'webrick' |
| 27 |
require 'webrick/https' |
| 28 |
|
| 29 |
authenticate = Proc.new do |req, res| |
| 30 |
WEBrick::HTTPAuth.basic_auth(req, res, '') do |user, password| |
| 31 |
user == '#{user}' && password == '#{password}' |
| 32 |
end |
| 33 |
end |
| 34 |
|
| 35 |
server = WEBrick::HTTPServer.new( |
| 36 |
:Port => 8443, |
| 37 |
:DocumentRoot => "#{tmpdir}", |
| 38 |
:DocumentRootOptions=> {:HandlerCallback => authenticate}, |
| 39 |
:SSLEnable => true, |
| 40 |
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, |
| 41 |
:SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), |
| 42 |
:SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), |
| 43 |
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) |
| 44 |
WEBrick::Daemon.start |
| 45 |
server.start |
| 46 |
EOF |
| 47 |
create_remote_file(host, "#{tmpdir}/#{http_server_script}", script) |
| 48 |
on(host, "#{ruby} #{tmpdir}/#{http_server_script}") |
| 49 |
end |
| 50 |
|
| 51 |
teardown do |
| 52 |
on(host, "rm -fr #{tmpdir}") |
| 53 |
on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") |
| 54 |
end |
| 55 |
|
| 56 |
step 'checkout with puppet using basic auth' do |
| 57 |
pp = <<-EOS |
| 58 |
vcsrepo { "#{tmpdir}/#{repo_name}": |
| 59 |
ensure => present, |
| 60 |
source => "http://#{host}:8443/testrepo.git", |
| 61 |
provider => git, |
| 62 |
basic_auth_username => '#{user}', |
| 63 |
basic_auth_password => '#{password}', |
| 64 |
} |
| 65 |
EOS |
| 66 |
|
| 67 |
apply_manifest_on(host, pp, :catch_failures => true) |
| 68 |
apply_manifest_on(host, pp, :catch_changes => true) |
| 69 |
end |
| 70 |
|
| 71 |
step "verify checkout" do |
| 72 |
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| |
| 73 |
fail_test('checkout not found') unless res.stdout.include? "HEAD" |
| 74 |
end |
| 75 |
end |
| 76 |
|
| 77 |
end |