| 1 |
test_name 'C3459 - checkout as a user (file protocol)' |
| 2 |
|
| 3 |
# Globals |
| 4 |
repo_name = 'testrepo_user_checkout' |
| 5 |
user = 'myuser' |
| 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 |
|
| 20 |
step 'setup - create user' do |
| 21 |
apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true) |
| 22 |
end |
| 23 |
|
| 24 |
teardown do |
| 25 |
on(host, "rm -fr #{tmpdir}") |
| 26 |
apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) |
| 27 |
end |
| 28 |
|
| 29 |
step 'checkout as a user with puppet' do |
| 30 |
pp = <<-EOS |
| 31 |
vcsrepo { "#{tmpdir}/#{repo_name}": |
| 32 |
ensure => present, |
| 33 |
source => "file://#{tmpdir}/testrepo.git", |
| 34 |
provider => git, |
| 35 |
owner => '#{user}', |
| 36 |
} |
| 37 |
EOS |
| 38 |
|
| 39 |
apply_manifest_on(host, pp, :catch_failures => true) |
| 40 |
apply_manifest_on(host, pp, :catch_changes => true) |
| 41 |
end |
| 42 |
|
| 43 |
step "verify git checkout is owned by user #{user}" do |
| 44 |
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| |
| 45 |
fail_test('checkout not found') unless res.stdout.include? "HEAD" |
| 46 |
end |
| 47 |
|
| 48 |
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| |
| 49 |
fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" |
| 50 |
end |
| 51 |
end |
| 52 |
|
| 53 |
end |