Debian Codegraph @

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

raw
1 test_name 'C3491 - checkout as a group (https 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 step 'setup - start https server' do
21 https_daemon =<<-EOF
22 require 'webrick'
23 require 'webrick/https'
24 server = WEBrick::HTTPServer.new(
25 :Port => 8443,
26 :DocumentRoot => "#{tmpdir}",
27 :SSLEnable => true,
28 :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
29 :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
30 :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
31 :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
32 WEBrick::Daemon.start
33 server.start
34 EOF
35 create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
36 #on(host, "#{ruby} /tmp/https_daemon.rb")
37 end
38
39 step 'setup - create group' do
40 apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
41 end
42
43 teardown do
44 on(host, "rm -fr #{tmpdir}")
45 on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
46 apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
47 end
48
49 step 'checkout as a group with puppet' do
50 pp = <<-EOS
51 vcsrepo { "#{tmpdir}/#{repo_name}":
52 ensure => present,
53 source => "https://github.com/johnduarte/testrepo.git",
54 provider => git,
55 group => '#{group}',
56 }
57 EOS
58
59 apply_manifest_on(host, pp, :catch_failures => true)
60 apply_manifest_on(host, pp, :catch_changes => true)
61 end
62
63 step "verify git checkout is own by group #{group}" do
64 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
65 fail_test('checkout not found') unless res.stdout.include? "HEAD"
66 end
67
68 on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
69 fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
70 end
71 end
72
73 end