Debian Codegraph @

spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb

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