Debian Codegraph @

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

raw
1 test_name 'C3490 - checkout as a group (http protocol)'
2
3 # Globals
4 repo_name = 'testrepo_group_checkout'
5 group = 'mygroup'
6
7 hosts.each do |host|
8 ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
9 tmpdir = host.tmpdir('vcsrepo')
10 step 'setup - create repo' do
11 git_pkg = 'git'
12 if host['platform'] =~ /ubuntu-10/
13 git_pkg = 'git-core'
14 end
15 install_package(host, git_pkg)
16 my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
17 scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
18 on(host, "cd #{tmpdir} && ./create_git_repo.sh")
19 end
20
21 step 'setup - start http server' do
22 http_daemon =<<-EOF
23 require 'webrick'
24 server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
25 WEBrick::Daemon.start
26 server.start
27 EOF
28 create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
29 on(host, "#{ruby} /tmp/http_daemon.rb")
30 end
31
32 step 'setup - create group' do
33 apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
34 end
35
36 teardown do
37 on(host, "rm -fr #{tmpdir}")
38 on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
39 apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
40 end
41
42 step 'checkout a group with puppet' do
43 pp = <<-EOS
44 vcsrepo { "#{tmpdir}/#{repo_name}":
45 ensure => present,
46 source => "http://#{host}:8000/testrepo.git",
47 provider => git,
48 group => '#{group}',
49 }
50 EOS
51
52 apply_manifest_on(host, pp, :catch_failures => true)
53 apply_manifest_on(host, pp, :catch_changes => true)
54 end
55
56 step "verify git checkout is own by group #{group}" do
57 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
58 fail_test('checkout not found') unless res.stdout.include? "HEAD"
59 end
60
61 on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
62 fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
63 end
64 end
65
66 end