1 test_name 'C3460 - checkout as a user (ssh protocol, scp syntax)'
4 repo_name = 'testrepo_user_checkout'
8 tmpdir = host.tmpdir('vcsrepo')
9 step 'setup - create repo' do
10 install_package(host, 'git')
11 my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
12 scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
13 on(host, "cd #{tmpdir} && ./create_git_repo.sh")
15 step 'setup - establish ssh keys' do
17 on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
19 # copy public key to authorized_keys
20 on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
21 on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
22 on(host, 'chown -R root:root /root/.ssh')
25 step 'setup - create user' do
26 apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true)
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 apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
36 step 'checkout as a user with puppet (scp syntax)' do
38 vcsrepo { "#{tmpdir}/#{repo_name}":
40 source => "root@#{host}:#{tmpdir}/testrepo.git",
46 apply_manifest_on(host, pp, :catch_failures => true)
47 apply_manifest_on(host, pp, :catch_changes => true)
50 step "verify git checkout is owned by user #{user}" do
51 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
52 fail_test('checkout not found') unless res.stdout.include? "HEAD"
55 on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
56 fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:"