Debian Codegraph @

spec/acceptance/beaker/git/clone/clone_scp.rb

raw
1 test_name 'C3428 - clone (ssh protocol, scp syntax)'
2
3 # Globals
4 repo_name = 'testrepo_clone'
5
6 hosts.each do |host|
7 tmpdir = host.tmpdir('vcsrepo')
8 step 'setup - create repo' do
9 git_pkg = 'git'
10 if host['platform'] =~ /ubuntu-10/
11 git_pkg = 'git-core'
12 end
13 install_package(host, git_pkg)
14 my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
15 scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
16 on(host, "cd #{tmpdir} && ./create_git_repo.sh")
17 end
18 step 'setup - establish ssh keys' do
19 # create ssh keys
20 on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
21
22 # copy public key to authorized_keys
23 on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
24 on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
25 on(host, 'chown -R root:root /root/.ssh')
26 end
27
28 teardown do
29 on(host, "rm -fr #{tmpdir}")
30 apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
31 apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
32 end
33
34 step 'clone with puppet' do
35 pp = <<-EOS
36 vcsrepo { "#{tmpdir}/#{repo_name}":
37 ensure => present,
38 source => "root@#{host}:#{tmpdir}/testrepo.git",
39 provider => git,
40 }
41 EOS
42
43 apply_manifest_on(host, pp, :catch_failures => true)
44 apply_manifest_on(host, pp, :catch_changes => true)
45 end
46
47 step "verify checkout is on the master branch" do
48 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
49 fail_test('checkout not found') unless res.stdout.include? "HEAD"
50 end
51
52 on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
53 fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
54 end
55 end
56
57 end