Debian Codegraph @

spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb

raw
1 test_name 'C3489 - checkout as a group (ssh protocol)'
2
3 # Globals
4 repo_name = 'testrepo_group_checkout'
5 group = 'mygroup'
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 step 'setup - create group' do
30 apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
31 end
32
33 teardown do
34 on(host, "rm -fr #{tmpdir}")
35 apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
36 apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
37 apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
38 end
39
40 step 'checkout as a group with puppet' do
41 pp = <<-EOS
42 vcsrepo { "#{tmpdir}/#{repo_name}":
43 ensure => present,
44 source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
45 provider => git,
46 group => '#{group}',
47 }
48 EOS
49
50 apply_manifest_on(host, pp, :catch_failures => true)
51 apply_manifest_on(host, pp, :catch_changes => true)
52 end
53
54 step "verify git checkout is own by group #{group}" do
55 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
56 fail_test('checkout not found') unless res.stdout.include? "HEAD"
57 end
58
59 on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
60 fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
61 end
62 end
63
64 end