Debian Codegraph @

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

raw
1 test_name 'C3440 - checkout a branch (ssh protocol)'
2
3 # Globals
4 repo_name = 'testrepo_branch_checkout'
5 branch = 'a_branch'
6
7 hosts.each do |host|
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 - establish ssh keys' do
20 # create ssh keys
21 on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
22
23 # copy public key to authorized_keys
24 on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
25 on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
26 on(host, 'chown -R root:root /root/.ssh')
27 end
28
29 teardown do
30 on(host, "rm -fr #{tmpdir}")
31 apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
32 apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
33 end
34
35 step 'checkout a branch with puppet' do
36 pp = <<-EOS
37 vcsrepo { "#{tmpdir}/#{repo_name}":
38 ensure => present,
39 source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
40 provider => git,
41 revision => '#{branch}',
42 }
43 EOS
44
45 apply_manifest_on(host, pp, :catch_failures => true)
46 apply_manifest_on(host, pp, :catch_changes => true)
47 end
48
49 step "verify checkout is on the #{branch} branch" do
50 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
51 fail_test('checkout not found') unless res.stdout.include? "HEAD"
52 end
53
54 on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
55 fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
56 end
57 end
58
59 end