| 1 |
test_name 'C3492 - checkout with basic auth (http protocol)' |
| 2 |
skip_test 'HTTP not supported yet for basic auth using git. See FM-1331' |
| 3 |
|
| 4 |
# Globals |
| 5 |
repo_name = 'testrepo_checkout' |
| 6 |
user = 'foo' |
| 7 |
password = 'bar' |
| 8 |
http_server_script = 'basic_auth_http_daemon.rb' |
| 9 |
|
| 10 |
hosts.each do |host| |
| 11 |
ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' |
| 12 |
gem = '/opt/puppet/bin/gem' if host.is_pe? || 'gem' |
| 13 |
tmpdir = host.tmpdir('vcsrepo') |
| 14 |
step 'setup - create repo' do |
| 15 |
git_pkg = 'git' |
| 16 |
if host['platform'] =~ /ubuntu-10/ |
| 17 |
git_pkg = 'git-core' |
| 18 |
end |
| 19 |
install_package(host, git_pkg) |
| 20 |
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) |
| 21 |
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) |
| 22 |
on(host, "cd #{tmpdir} && ./create_git_repo.sh") |
| 23 |
end |
| 24 |
|
| 25 |
step 'setup - start http server' do |
| 26 |
script =<<-EOF |
| 27 |
require 'sinatra' |
| 28 |
|
| 29 |
set :bind, '0.0.0.0' |
| 30 |
set :static, true |
| 31 |
set :public_folder, '#{tmpdir}' |
| 32 |
|
| 33 |
|
| 34 |
use Rack::Auth::Basic do |username, password| |
| 35 |
username == '#{user}' && password == '#{password}' |
| 36 |
end |
| 37 |
EOF |
| 38 |
create_remote_file(host, "#{tmpdir}/#{http_server_script}", script) |
| 39 |
on(host, "#{gem} install sinatra") |
| 40 |
on(host, "#{ruby} #{tmpdir}/#{http_server_script} &") |
| 41 |
end |
| 42 |
|
| 43 |
teardown do |
| 44 |
on(host, "rm -fr #{tmpdir}") |
| 45 |
on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") |
| 46 |
end |
| 47 |
|
| 48 |
step 'checkout with puppet using basic auth' do |
| 49 |
pp = <<-EOS |
| 50 |
vcsrepo { "#{tmpdir}/#{repo_name}": |
| 51 |
ensure => present, |
| 52 |
source => "http://#{host}:4567/testrepo.git", |
| 53 |
provider => git, |
| 54 |
basic_auth_username => '#{user}', |
| 55 |
basic_auth_password => '#{password}', |
| 56 |
} |
| 57 |
EOS |
| 58 |
|
| 59 |
apply_manifest_on(host, pp, :catch_failures => true) |
| 60 |
apply_manifest_on(host, pp, :catch_changes => true) |
| 61 |
end |
| 62 |
|
| 63 |
step "verify checkout" do |
| 64 |
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| |
| 65 |
fail_test('checkout not found') unless res.stdout.include? "HEAD" |
| 66 |
end |
| 67 |
end |
| 68 |
|
| 69 |
end |