| 1 |
test_name 'C3431 - clone (https protocol)' |
| 2 |
|
| 3 |
# Globals |
| 4 |
repo_name = 'testrepo_clone' |
| 5 |
|
| 6 |
hosts.each do |host| |
| 7 |
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' |
| 8 |
tmpdir = host.tmpdir('vcsrepo') |
| 9 |
step 'setup - create repo' do |
| 10 |
git_pkg = 'git' |
| 11 |
if host['platform'] =~ /ubuntu-10/ |
| 12 |
git_pkg = 'git-core' |
| 13 |
end |
| 14 |
install_package(host, git_pkg) |
| 15 |
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) |
| 16 |
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) |
| 17 |
on(host, "cd #{tmpdir} && ./create_git_repo.sh") |
| 18 |
end |
| 19 |
step 'setup - start https server' do |
| 20 |
https_daemon =<<-EOF |
| 21 |
require 'webrick' |
| 22 |
require 'webrick/https' |
| 23 |
server = WEBrick::HTTPServer.new( |
| 24 |
:Port => 8443, |
| 25 |
:DocumentRoot => "#{tmpdir}", |
| 26 |
:SSLEnable => true, |
| 27 |
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, |
| 28 |
:SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), |
| 29 |
:SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), |
| 30 |
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) |
| 31 |
WEBrick::Daemon.start |
| 32 |
server.start |
| 33 |
EOF |
| 34 |
create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) |
| 35 |
#on(host, "#{ruby} /tmp/https_daemon.rb") |
| 36 |
end |
| 37 |
|
| 38 |
teardown do |
| 39 |
on(host, "rm -fr #{tmpdir}") |
| 40 |
on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") |
| 41 |
end |
| 42 |
|
| 43 |
step 'clone with puppet' do |
| 44 |
pp = <<-EOS |
| 45 |
vcsrepo { "#{tmpdir}/#{repo_name}": |
| 46 |
ensure => present, |
| 47 |
source => "https://github.com/johnduarte/testrepo.git", |
| 48 |
provider => git, |
| 49 |
} |
| 50 |
EOS |
| 51 |
|
| 52 |
apply_manifest_on(host, pp, :catch_failures => true) |
| 53 |
apply_manifest_on(host, pp, :catch_changes => true) |
| 54 |
end |
| 55 |
|
| 56 |
step "verify checkout is on the master branch" do |
| 57 |
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| |
| 58 |
fail_test('checkout not found') unless res.stdout.include? "HEAD" |
| 59 |
end |
| 60 |
|
| 61 |
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| |
| 62 |
fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" |
| 63 |
end |
| 64 |
end |
| 65 |
|
| 66 |
end |