summaryrefslogtreecommitdiff
path: root/spec/acceptance/beaker
diff options
context:
space:
mode:
Diffstat (limited to 'spec/acceptance/beaker')
-rw-r--r--spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb69
-rw-r--r--spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb77
-rw-r--r--spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb53
-rw-r--r--spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb48
-rw-r--r--spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb48
-rw-r--r--spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb53
-rw-r--r--spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb61
-rw-r--r--spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb68
-rw-r--r--spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb59
-rw-r--r--spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb59
-rw-r--r--spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb46
-rw-r--r--spec/acceptance/beaker/git/clone/clone_file.rb46
-rw-r--r--spec/acceptance/beaker/git/clone/clone_file_path.rb46
-rw-r--r--spec/acceptance/beaker/git/clone/clone_git.rb51
-rw-r--r--spec/acceptance/beaker/git/clone/clone_http.rb59
-rw-r--r--spec/acceptance/beaker/git/clone/clone_https.rb66
-rw-r--r--spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb49
-rw-r--r--spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb46
-rw-r--r--spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb46
-rw-r--r--spec/acceptance/beaker/git/clone/clone_scp.rb57
-rw-r--r--spec/acceptance/beaker/git/clone/clone_ssh.rb57
-rw-r--r--spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb47
-rw-r--r--spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb45
-rw-r--r--spec/acceptance/beaker/git/compression/compression_0_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/compression_1_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/compression_2_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/compression_3_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/compression_4_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/compression_5_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/compression_6_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb43
-rw-r--r--spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb40
-rw-r--r--spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb42
-rw-r--r--spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb38
-rw-r--r--spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb53
-rw-r--r--spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb53
-rw-r--r--spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb58
-rw-r--r--spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb66
-rw-r--r--spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb73
-rw-r--r--spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb64
-rw-r--r--spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb64
-rw-r--r--spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb51
-rw-r--r--spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb46
-rw-r--r--spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb53
-rw-r--r--spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb53
-rw-r--r--spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb58
-rw-r--r--spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb66
-rw-r--r--spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb74
-rw-r--r--spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb64
-rw-r--r--spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb64
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb43
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb44
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb55
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb43
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb45
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb47
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb52
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb68
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb58
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb58
-rw-r--r--spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb43
-rw-r--r--spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb47
-rw-r--r--spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb48
-rw-r--r--spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb48
-rw-r--r--spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb59
-rw-r--r--spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb67
-rw-r--r--spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb74
-rw-r--r--spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb65
-rw-r--r--spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb65
-rw-r--r--spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb51
-rw-r--r--spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb53
-rw-r--r--spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb53
-rw-r--r--spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb58
-rw-r--r--spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb66
-rw-r--r--spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb73
-rw-r--r--spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb64
-rw-r--r--spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb64
81 files changed, 4363 insertions, 0 deletions
diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb
new file mode 100644
index 0000000..421c5f0
--- /dev/null
+++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb
@@ -0,0 +1,69 @@
+test_name 'C3492 - checkout with basic auth (http protocol)'
+skip_test 'HTTP not supported yet for basic auth using git. See FM-1331'
+
+# Globals
+repo_name = 'testrepo_checkout'
+user = 'foo'
+password = 'bar'
+http_server_script = 'basic_auth_http_daemon.rb'
+
+hosts.each do |host|
+ ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby'
+ gem = '/opt/puppet/bin/gem' if host.is_pe? || 'gem'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start http server' do
+ script =<<-EOF
+ require 'sinatra'
+
+ set :bind, '0.0.0.0'
+ set :static, true
+ set :public_folder, '#{tmpdir}'
+
+
+ use Rack::Auth::Basic do |username, password|
+ username == '#{user}' && password == '#{password}'
+ end
+ EOF
+ create_remote_file(host, "#{tmpdir}/#{http_server_script}", script)
+ on(host, "#{gem} install sinatra")
+ on(host, "#{ruby} #{tmpdir}/#{http_server_script} &")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'checkout with puppet using basic auth' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:4567/testrepo.git",
+ provider => git,
+ basic_auth_username => '#{user}',
+ basic_auth_password => '#{password}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb
new file mode 100644
index 0000000..753e50c
--- /dev/null
+++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb
@@ -0,0 +1,77 @@
+test_name 'C3493 - checkout with basic auth (https protocol)'
+skip_test 'waiting for CA trust solution'
+
+# Globals
+repo_name = 'testrepo_checkout'
+user = 'foo'
+password = 'bar'
+http_server_script = 'basic_auth_https_daemon.rb'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start https server' do
+ script =<<-EOF
+ require 'webrick'
+ require 'webrick/https'
+
+ authenticate = Proc.new do |req, res|
+ WEBrick::HTTPAuth.basic_auth(req, res, '') do |user, password|
+ user == '#{user}' && password == '#{password}'
+ end
+ end
+
+ server = WEBrick::HTTPServer.new(
+ :Port => 8443,
+ :DocumentRoot => "#{tmpdir}",
+ :DocumentRootOptions=> {:HandlerCallback => authenticate},
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
+ :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, "#{tmpdir}/#{http_server_script}", script)
+ on(host, "#{ruby} #{tmpdir}/#{http_server_script}")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'checkout with puppet using basic auth' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:8443/testrepo.git",
+ provider => git,
+ basic_auth_username => '#{user}',
+ basic_auth_password => '#{password}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb
new file mode 100644
index 0000000..3b47c48
--- /dev/null
+++ b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb
@@ -0,0 +1,53 @@
+test_name 'C3494 - checkout with basic auth (git protocol)'
+
+# Globals
+repo_name = 'testrepo_checkout'
+user = 'foo'
+password = 'bar'
+http_server_script = 'basic_auth_http_daemon.rb'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start git daemon' do
+ install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
+ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'pkill -9 git-daemon ; sleep 1')
+ end
+
+ step 'checkout with puppet using basic auth' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "git://#{host}/testrepo.git",
+ provider => git,
+ basic_auth_username => '#{user}',
+ basic_auth_password => '#{password}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout (silent error for basic auth using git protocol)" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb
new file mode 100644
index 0000000..3d2131c
--- /dev/null
+++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb
@@ -0,0 +1,48 @@
+test_name 'C3438 - checkout a branch (file protocol)'
+
+# Globals
+repo_name = 'testrepo_branch_checkout'
+branch = 'a_branch'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout a branch with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{branch}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the #{branch} branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb
new file mode 100644
index 0000000..49b034e
--- /dev/null
+++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb
@@ -0,0 +1,48 @@
+test_name 'C3437 - checkout a branch (file path)'
+
+# Globals
+repo_name = 'testrepo_branch_checkout'
+branch = 'a_branch'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout a branch with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{branch}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the #{branch} branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb
new file mode 100644
index 0000000..9557de8
--- /dev/null
+++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb
@@ -0,0 +1,53 @@
+test_name 'C3436 - checkout a branch (git protocol)'
+
+# Globals
+repo_name = 'testrepo_branch_checkout'
+branch = 'a_branch'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start git daemon' do
+ install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
+ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'pkill -9 git-daemon ; sleep 1')
+ end
+
+ step 'checkout a branch with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "git://#{host}/testrepo.git",
+ provider => git,
+ revision => '#{branch}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the #{branch} branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb
new file mode 100644
index 0000000..fec60e2
--- /dev/null
+++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb
@@ -0,0 +1,61 @@
+test_name 'C3441 - checkout a branch (http protocol)'
+
+# Globals
+repo_name = 'testrepo_branch_checkout'
+branch = 'a_branch'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start http server' do
+ http_daemon =<<-EOF
+ require 'webrick'
+ server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
+ on(host, "#{ruby} /tmp/http_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'checkout a branch with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:8000/testrepo.git",
+ provider => git,
+ revision => '#{branch}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the #{branch} branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb
new file mode 100644
index 0000000..3474c73
--- /dev/null
+++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb
@@ -0,0 +1,68 @@
+test_name 'C3442 - checkout a branch (https protocol)'
+
+# Globals
+repo_name = 'testrepo_branch_checkout'
+branch = 'a_branch'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start https server' do
+ https_daemon =<<-EOF
+ require 'webrick'
+ require 'webrick/https'
+ server = WEBrick::HTTPServer.new(
+ :Port => 8443,
+ :DocumentRoot => "#{tmpdir}",
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
+ :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
+ #on(host, "#{ruby} /tmp/https_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'checkout a branch with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "https://github.com/johnduarte/testrepo.git",
+ provider => git,
+ revision => '#{branch}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the #{branch} branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb
new file mode 100644
index 0000000..493b3f4
--- /dev/null
+++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb
@@ -0,0 +1,59 @@
+test_name 'C3439 - checkout a branch (ssh protocol, scp syntax)'
+
+# Globals
+repo_name = 'testrepo_branch_checkout'
+branch = 'a_branch'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'checkout a branch with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "root@#{host}:#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{branch}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the #{branch} branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb
new file mode 100644
index 0000000..5195ab8
--- /dev/null
+++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb
@@ -0,0 +1,59 @@
+test_name 'C3440 - checkout a branch (ssh protocol)'
+
+# Globals
+repo_name = 'testrepo_branch_checkout'
+branch = 'a_branch'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'checkout a branch with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{branch}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the #{branch} branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb b/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb
new file mode 100644
index 0000000..7b9e64d
--- /dev/null
+++ b/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb
@@ -0,0 +1,46 @@
+test_name 'C3609 - checkout a branch that does not exist'
+
+# Globals
+repo_name = 'testrepo_branch_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout branch that does not exist with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => 'non_existent_branch',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :expect_failures => true)
+ end
+
+ step 'verify that master branch is checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_file.rb b/spec/acceptance/beaker/git/clone/clone_file.rb
new file mode 100644
index 0000000..45413a9
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_file.rb
@@ -0,0 +1,46 @@
+test_name 'C3427 - clone (file protocol)'
+
+# Globals
+repo_name = 'testrepo_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'clone with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the master branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_file_path.rb b/spec/acceptance/beaker/git/clone/clone_file_path.rb
new file mode 100644
index 0000000..a57e05a
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_file_path.rb
@@ -0,0 +1,46 @@
+test_name 'C3426 - clone (file path)'
+
+# Globals
+repo_name = 'testrepo_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'clone with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "#{tmpdir}/testrepo.git",
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the master branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_git.rb b/spec/acceptance/beaker/git/clone/clone_git.rb
new file mode 100644
index 0000000..3bceb5d
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_git.rb
@@ -0,0 +1,51 @@
+test_name 'C3425 - clone (git protocol)'
+
+# Globals
+repo_name = 'testrepo_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start git daemon' do
+ install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
+ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'pkill -9 git-daemon ; sleep 1')
+ end
+
+ step 'clone with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "git://#{host}/testrepo.git",
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the master branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_http.rb b/spec/acceptance/beaker/git/clone/clone_http.rb
new file mode 100644
index 0000000..f545dab
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_http.rb
@@ -0,0 +1,59 @@
+test_name 'C3430 - clone (http protocol)'
+
+# Globals
+repo_name = 'testrepo_clone'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start http server' do
+ http_daemon =<<-EOF
+ require 'webrick'
+ server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
+ on(host, "#{ruby} /tmp/http_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'clone with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:8000/testrepo.git",
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the master branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_https.rb b/spec/acceptance/beaker/git/clone/clone_https.rb
new file mode 100644
index 0000000..8758435
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_https.rb
@@ -0,0 +1,66 @@
+test_name 'C3431 - clone (https protocol)'
+
+# Globals
+repo_name = 'testrepo_clone'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start https server' do
+ https_daemon =<<-EOF
+ require 'webrick'
+ require 'webrick/https'
+ server = WEBrick::HTTPServer.new(
+ :Port => 8443,
+ :DocumentRoot => "#{tmpdir}",
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
+ :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
+ #on(host, "#{ruby} /tmp/https_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'clone with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "https://github.com/johnduarte/testrepo.git",
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the master branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb b/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb
new file mode 100644
index 0000000..3bc3e30
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb
@@ -0,0 +1,49 @@
+test_name 'C3511 - clone over an existing repo with force'
+
+# Globals
+repo_name = 'testrepo_already_exists'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ on(host, "mkdir #{tmpdir}/#{repo_name}")
+ on(host, "cd #{tmpdir}/#{repo_name} && git init")
+ on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'clone over existing repo with force using puppet' do
+ on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res|
+ @existing_sha = res.stdout
+ end
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ force => true,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify new repo has replaced old one' do
+ on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res|
+ fail_test('original repo not replaced by force') if res.stdout.include? "#{@existing_sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb
new file mode 100644
index 0000000..dec275f
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb
@@ -0,0 +1,46 @@
+test_name 'C3507 - clone repo with excludes in repo'
+
+# Globals
+repo_name = 'testrepo_with_excludes_in_repo'
+exclude1 = 'file1.txt'
+exclude2 ='file2.txt'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'clone repo with excludes in repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ excludes => [ '#{exclude1}', '#{exclude2}' ],
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify exludes are known to git' do
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res|
+ fail_test('exclude not found') unless res.stdout.include? "#{exclude1}"
+ fail_test('exclude not found') unless res.stdout.include? "#{exclude2}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb
new file mode 100644
index 0000000..ba37930
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb
@@ -0,0 +1,46 @@
+test_name 'C3508 - clone repo with excludes not in repo'
+
+# Globals
+repo_name = 'testrepo_with_excludes_not_in_repo'
+exclude1 = 'worh02o'
+exclude2 ='ho398b'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'clone repo with excludes not in repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ excludes => [ '#{exclude1}', '#{exclude2}' ],
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify exludes are known to git' do
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res|
+ fail_test('exclude not found') unless res.stdout.include? "#{exclude1}"
+ fail_test('exclude not found') unless res.stdout.include? "#{exclude2}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_scp.rb b/spec/acceptance/beaker/git/clone/clone_scp.rb
new file mode 100644
index 0000000..59370eb
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_scp.rb
@@ -0,0 +1,57 @@
+test_name 'C3428 - clone (ssh protocol, scp syntax)'
+
+# Globals
+repo_name = 'testrepo_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'clone with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "root@#{host}:#{tmpdir}/testrepo.git",
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the master branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/clone_ssh.rb b/spec/acceptance/beaker/git/clone/clone_ssh.rb
new file mode 100644
index 0000000..5bc06ec
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/clone_ssh.rb
@@ -0,0 +1,57 @@
+test_name 'C3429 - clone (ssh protocol)'
+
+# Globals
+repo_name = 'testrepo_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'clone with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is on the master branch" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb
new file mode 100644
index 0000000..1e3b4bb
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb
@@ -0,0 +1,47 @@
+test_name 'C3482 - clone over an existing repo'
+
+# Globals
+repo_name = 'testrepo_already_exists'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ on(host, "mkdir #{tmpdir}/#{repo_name}")
+ on(host, "cd #{tmpdir}/#{repo_name} && git init")
+ on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'clone over existing repo using puppet' do
+ on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res|
+ @existing_sha = res.stdout
+ end
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :expect_failures => true)
+ end
+
+ step 'verify original repo was not replaced' do
+ on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res|
+ fail_test('original repo was replaced without force') unless res.stdout.include? "#{@existing_sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb
new file mode 100644
index 0000000..9805355
--- /dev/null
+++ b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb
@@ -0,0 +1,45 @@
+test_name 'C3509 - clone repo with excludes not in repo'
+skip_test 'expectations not defined'
+
+# Globals
+repo_name = 'testrepo_with_excludes_not_in_repo'
+exclude1 = "`exec \"rm -rf /tmp\"`"
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'clone repo with excludes not in repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ excludes => [ '#{exclude1}' ],
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify excludes are known to git' do
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res|
+ fail_test('exclude not found') unless res.stdout.include? "#{exclude1}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/compression_0_checkout.rb b/spec/acceptance/beaker/git/compression/compression_0_checkout.rb
new file mode 100644
index 0000000..7ac4c4a
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/compression_0_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3495 - checkout with compression 0'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 0 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 0,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/compression_1_checkout.rb b/spec/acceptance/beaker/git/compression/compression_1_checkout.rb
new file mode 100644
index 0000000..8b7455d
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/compression_1_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3496 - checkout with compression 1'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 1 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/compression_2_checkout.rb b/spec/acceptance/beaker/git/compression/compression_2_checkout.rb
new file mode 100644
index 0000000..81d32c3
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/compression_2_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3497 - checkout with compression 2'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 2 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 2,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/compression_3_checkout.rb b/spec/acceptance/beaker/git/compression/compression_3_checkout.rb
new file mode 100644
index 0000000..12b60a3
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/compression_3_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3498 - checkout with compression 3'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 3 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 3,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/compression_4_checkout.rb b/spec/acceptance/beaker/git/compression/compression_4_checkout.rb
new file mode 100644
index 0000000..66d2d5e
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/compression_4_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3499 - checkout with compression 4'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 4 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 4,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/compression_5_checkout.rb b/spec/acceptance/beaker/git/compression/compression_5_checkout.rb
new file mode 100644
index 0000000..b60a9f7
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/compression_5_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3500 - checkout with compression 5'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 5 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 5,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/compression_6_checkout.rb b/spec/acceptance/beaker/git/compression/compression_6_checkout.rb
new file mode 100644
index 0000000..2f6b075
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/compression_6_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3501 - checkout with compression 6'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 6 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 6,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb
new file mode 100644
index 0000000..e74cca9
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3503 - checkout with compression 7'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 7 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 7,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb
new file mode 100644
index 0000000..59aaf21
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3505 - checkout with compression alpha'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression alpha with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => abcde,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb
new file mode 100644
index 0000000..b989e58
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3504 - checkout with compression 10-5'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression 10-5 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => 10-5,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb
new file mode 100644
index 0000000..e1373af
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3506 - checkout with compression exec'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression exec with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => "exec 'rm -rf /tmp'",
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb
new file mode 100644
index 0000000..1253db1
--- /dev/null
+++ b/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb
@@ -0,0 +1,43 @@
+test_name 'C3502 - checkout with compression -1'
+
+# Globals
+repo_name = 'testrepo_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout with compression -1 with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ compression => -1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify git repo was checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb b/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb
new file mode 100644
index 0000000..ccb8a70
--- /dev/null
+++ b/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb
@@ -0,0 +1,40 @@
+test_name 'C3472 - create bare repo that already exists'
+
+# Globals
+repo_name = 'testrepo_bare_repo_already_exists.git'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create bare repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ on(host, "mkdir #{tmpdir}/#{repo_name}")
+ on(host, "cd #{tmpdir}/#{repo_name} && git --bare init")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'create bare repo that already exists using puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => bare,
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify repo does not contain .git directory' do
+ on(host, "ls -al #{tmpdir}/#{repo_name}") do |res|
+ fail_test "found .git for #{repo_name}" if res.stdout.include? ".git"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb b/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb
new file mode 100644
index 0000000..8fb8543
--- /dev/null
+++ b/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb
@@ -0,0 +1,42 @@
+test_name 'C3470 - create repo that already exists'
+
+# Globals
+repo_name = 'testrepo_already_exists'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ on(host, "cd #{tmpdir} && git clone file://#{tmpdir}/testrepo.git #{repo_name}")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'create repo that already exists using puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify repo is on master branch' do
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ assert_match(/ref: refs\/heads\/master/, stdout, "Git checkout not on master on #{host}")
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb
new file mode 100644
index 0000000..5b789df
--- /dev/null
+++ b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb
@@ -0,0 +1,38 @@
+test_name 'C3473 - create bare repo specifying revision'
+
+# Globals
+repo_name = 'testrepo_bare.git'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'create bare repo specifying revision using puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => bare,
+ revision => master,
+ provider => git,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :expect_failures => true)
+ end
+
+ step 'verify repo does not contain .git directory' do
+ on(host, "ls -al #{tmpdir}") do |res|
+ fail_test "found repo for #{repo_name}" if res.stdout.include? repo_name
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb
new file mode 100644
index 0000000..beea7b8
--- /dev/null
+++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb
@@ -0,0 +1,53 @@
+test_name 'C3487 - checkout as a group (file protocol)'
+
+# Globals
+repo_name = 'testrepo_group_checkout'
+group = 'mygroup'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - create group' do
+ apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout as a group with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ group => '#{group}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is own by group #{group}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb
new file mode 100644
index 0000000..319a8e7
--- /dev/null
+++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb
@@ -0,0 +1,53 @@
+test_name 'C3486 - checkout as a group (file path)'
+
+# Globals
+repo_name = 'testrepo_group_checkout'
+group = 'mygroup'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - create group' do
+ apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout a group with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "#{tmpdir}/testrepo.git",
+ provider => git,
+ group => '#{group}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is own by group #{group}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb
new file mode 100644
index 0000000..e5b9cf2
--- /dev/null
+++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb
@@ -0,0 +1,58 @@
+test_name 'C3485 - checkout as a group (git protocol)'
+
+# Globals
+repo_name = 'testrepo_group_checkout'
+group = 'mygroup'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start git daemon' do
+ install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
+ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
+ end
+
+ step 'setup - create group' do
+ apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'pkill -9 git-daemon ; sleep 1')
+ apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout a group with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "git://#{host}/testrepo.git",
+ provider => git,
+ group => '#{group}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is own by group #{group}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb
new file mode 100644
index 0000000..bf86f2e
--- /dev/null
+++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb
@@ -0,0 +1,66 @@
+test_name 'C3490 - checkout as a group (http protocol)'
+
+# Globals
+repo_name = 'testrepo_group_checkout'
+group = 'mygroup'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start http server' do
+ http_daemon =<<-EOF
+ require 'webrick'
+ server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
+ on(host, "#{ruby} /tmp/http_daemon.rb")
+ end
+
+ step 'setup - create group' do
+ apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout a group with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:8000/testrepo.git",
+ provider => git,
+ group => '#{group}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is own by group #{group}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb
new file mode 100644
index 0000000..c4c645f
--- /dev/null
+++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb
@@ -0,0 +1,73 @@
+test_name 'C3491 - checkout as a group (https protocol)'
+
+# Globals
+repo_name = 'testrepo_group_checkout'
+group = 'mygroup'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start https server' do
+ https_daemon =<<-EOF
+ require 'webrick'
+ require 'webrick/https'
+ server = WEBrick::HTTPServer.new(
+ :Port => 8443,
+ :DocumentRoot => "#{tmpdir}",
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
+ :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
+ #on(host, "#{ruby} /tmp/https_daemon.rb")
+ end
+
+ step 'setup - create group' do
+ apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout as a group with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "https://github.com/johnduarte/testrepo.git",
+ provider => git,
+ group => '#{group}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is own by group #{group}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb
new file mode 100644
index 0000000..c65acc4
--- /dev/null
+++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb
@@ -0,0 +1,64 @@
+test_name 'C3488 - checkout as a group (ssh protocol, scp syntax)'
+
+# Globals
+repo_name = 'testrepo_group_checkout'
+group = 'mygroup'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ step 'setup - create group' do
+ apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout as a group with puppet (scp syntax)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "root@#{host}:#{tmpdir}/testrepo.git",
+ provider => git,
+ group => '#{group}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is own by group #{group}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb
new file mode 100644
index 0000000..cccad19
--- /dev/null
+++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb
@@ -0,0 +1,64 @@
+test_name 'C3489 - checkout as a group (ssh protocol)'
+
+# Globals
+repo_name = 'testrepo_group_checkout'
+group = 'mygroup'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ step 'setup - create group' do
+ apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout as a group with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
+ provider => git,
+ group => '#{group}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is own by group #{group}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb b/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb
new file mode 100644
index 0000000..081642d
--- /dev/null
+++ b/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb
@@ -0,0 +1,51 @@
+test_name 'C3484 - checkout as a group that is not on system'
+
+# Globals
+repo_name = 'testrepo_group_checkout'
+group = 'mygroup'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - delete group' do
+ apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout as a group with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ group => '#{group}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :expect_failures => true)
+ end
+
+ step "verify git checkout is NOT owned by group #{group}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by group') if res.stdout.include? ":#{group}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb b/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb
new file mode 100644
index 0000000..85f1fcc
--- /dev/null
+++ b/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb
@@ -0,0 +1,46 @@
+test_name 'C3614 - checkout a revision that does not exist'
+
+# Globals
+repo_name = 'testrepo_revision_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout revision that does not exist with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '11111111111111111',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :expect_failures => true)
+ end
+
+ step 'verify that master revision is checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('revision not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb
new file mode 100644
index 0000000..b17dc73
--- /dev/null
+++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb
@@ -0,0 +1,53 @@
+test_name 'C3452 - checkout a revision (file protocol)'
+
+# Globals
+repo_name = 'testrepo_revision_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'get revision sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a revision with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{@sha}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify repo is checked out to revision #{@sha}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('revision not found') unless res.stdout.include? "#{@sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb
new file mode 100644
index 0000000..c80eb81
--- /dev/null
+++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb
@@ -0,0 +1,53 @@
+test_name 'C3451 - checkout a revision (file path)'
+
+# Globals
+repo_name = 'testrepo_revision_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'get revision sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a revision with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{@sha}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify repo is checked out to revision #{@sha}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('revision not found') unless res.stdout.include? "#{@sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb
new file mode 100644
index 0000000..69a7fe2
--- /dev/null
+++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb
@@ -0,0 +1,58 @@
+test_name 'C3450 - checkout a revision (git protocol)'
+
+# Globals
+repo_name = 'testrepo_revision_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start git daemon' do
+ install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
+ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'pkill -9 git-daemon ; sleep 1')
+ end
+
+ step 'get revision sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a revision with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "git://#{host}/testrepo.git",
+ provider => git,
+ revision => '#{@sha}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is set to revision #{@sha}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('revision not found') unless res.stdout.include? "#{@sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb
new file mode 100644
index 0000000..7cac163
--- /dev/null
+++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb
@@ -0,0 +1,66 @@
+test_name 'C3455 - checkout a revision (http protocol)'
+
+# Globals
+repo_name = 'testrepo_revision_checkout'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start http server' do
+ http_daemon =<<-EOF
+ require 'webrick'
+ server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
+ on(host, "#{ruby} /tmp/http_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'get revision sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a revision with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:8000/testrepo.git",
+ provider => git,
+ revision => '#{@sha}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is set to revision #{@sha}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('revision not found') unless res.stdout.include? "#{@sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb
new file mode 100644
index 0000000..1c705a5
--- /dev/null
+++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb
@@ -0,0 +1,74 @@
+test_name 'C3456 - checkout a revision (https protocol)'
+
+# Globals
+repo_name = 'testrepo_revision_checkout'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start https server' do
+ https_daemon =<<-EOF
+ require 'webrick'
+ require 'webrick/https'
+ server = WEBrick::HTTPServer.new(
+ :Port => 8443,
+ :DocumentRoot => "#{tmpdir}",
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
+ :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
+ #on(host, "#{ruby} /tmp/https_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'get revision sha from repo' do
+ on(host, "git clone https://github.com/johnduarte/testrepo.git #{tmpdir}/foo")
+ on(host, "git --git-dir=#{tmpdir}/foo/.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a revision with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "https://github.com/johnduarte/testrepo.git",
+ provider => git,
+ revision => '#{@sha}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is set to revision #{@sha}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('revision not found') unless res.stdout.include? "#{@sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb
new file mode 100644
index 0000000..b5dbd24
--- /dev/null
+++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb
@@ -0,0 +1,64 @@
+test_name 'C3453 - checkout a revision (ssh protocol, scp syntax)'
+
+# Globals
+repo_name = 'testrepo_revision_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'get revision sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a revision with puppet (scp syntax)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "root@#{host}:#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{@sha}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is set to revision #{@sha}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('revision not found') unless res.stdout.include? "#{@sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb
new file mode 100644
index 0000000..222653e
--- /dev/null
+++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb
@@ -0,0 +1,64 @@
+test_name 'C3454 - checkout a revision (ssh protocol)'
+
+# Globals
+repo_name = 'testrepo_revision_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'get revision sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a revision with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{@sha}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout is set to revision #{@sha}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('revision not found') unless res.stdout.include? "#{@sha}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb
new file mode 100644
index 0000000..f01a488
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb
@@ -0,0 +1,43 @@
+test_name 'C3608 - shallow clone repo depth hostile input'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ depth => "exec 'rm -rf /tmp'",
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is NOT shallow' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow not found') if res.stdout.include? "shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb
new file mode 100644
index 0000000..47fb338
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb
@@ -0,0 +1,44 @@
+test_name 'C3475 - shallow clone repo minimal depth = 1 (file path protocol)'
+skip_test 'Not currently supported. See FM-1285'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'shallow clone repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "#{tmpdir}/testrepo.git",
+ provider => git,
+ depth => 1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'git does not support shallow clone via file path: verify checkout is NOT created' do
+ on(host, "ls #{tmpdir}") do |res|
+ fail_test('checkout found') if res.stdout.include? "#{repo_name}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb
new file mode 100644
index 0000000..723a0b6
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb
@@ -0,0 +1,55 @@
+test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start http server' do
+ http_daemon =<<-EOF
+ require 'webrick'
+ server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
+ on(host, "#{ruby} /tmp/http_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh ; sleep 1')
+ end
+
+ step 'shallow clone repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:8000/testrepo.git",
+ provider => git,
+ depth => 1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :expect_failures => true)
+ end
+
+ step 'git does not support shallow clone via HTTP: verify checkout is NOT created' do
+ on(host, "ls #{tmpdir}") do |res|
+ fail_test('checkout found') if res.stdout.include? "#{repo_name}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb
new file mode 100644
index 0000000..869620d
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb
@@ -0,0 +1,43 @@
+test_name 'C3607 - shallow clone repo depth = -1'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ depth => -1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is NOT shallow' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow not found') if res.stdout.include? "shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb
new file mode 100644
index 0000000..5da9fd7
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb
@@ -0,0 +1,45 @@
+test_name 'C3606 - shallow clone repo depth overflow 64bit integer'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+pending_test("The overflow can't be handled on some git versions")
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ depth => 18446744073709551616,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is NOT shallow' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow not found') if res.stdout.include? "shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb
new file mode 100644
index 0000000..9e2abe2
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb
@@ -0,0 +1,47 @@
+test_name 'C3476 - shallow clone repo minimal depth = 1 (file protocol)'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'shallow clone repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ depth => 1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is shallow and of the correct depth' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "shallow"
+ end
+
+ on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb
new file mode 100644
index 0000000..49683d2
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb
@@ -0,0 +1,52 @@
+test_name 'C3474 - shallow clone repo minimal depth = 1 (git protocol)'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start git daemon' do
+ install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
+ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'pkill -9 git-daemon ; sleep 1')
+ end
+
+ step 'shallow clone repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "git://#{host}/testrepo.git",
+ provider => git,
+ depth => 1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is shallow and of the correct depth' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "shallow"
+ end
+
+ on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb
new file mode 100644
index 0000000..2392728
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb
@@ -0,0 +1,68 @@
+test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)'
+skip_test 'Not currently supported. See FM-1286'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start https server' do
+ https_daemon =<<-EOF
+ require 'webrick'
+ require 'webrick/https'
+ server = WEBrick::HTTPServer.new(
+ :Port => 8443,
+ :DocumentRoot => "#{tmpdir}",
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
+ :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
+ #on(host, "#{ruby} /tmp/https_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh ; sleep 1')
+ end
+
+ step 'shallow clone repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "https://github.com/johnduarte/testrepo.git",
+ provider => git,
+ depth => 1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is shallow and of the correct depth' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "shallow"
+ end
+
+ on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb
new file mode 100644
index 0000000..1d5b35a
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb
@@ -0,0 +1,58 @@
+test_name 'C3478 - shallow clone repo minimal depth = 1 (ssh protocol, scp syntax)'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'shallow clone repo with puppet (scp syntax)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "root@#{host}:#{tmpdir}/testrepo.git",
+ provider => git,
+ depth => 1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is shallow and of the correct depth' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "shallow"
+ end
+
+ on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb
new file mode 100644
index 0000000..0f00b30
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb
@@ -0,0 +1,58 @@
+test_name 'C3477 - shallow clone repo minimal depth = 1 (ssh protocol)'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'shallow clone repo with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
+ provider => git,
+ depth => 1,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is shallow and of the correct depth' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "shallow"
+ end
+
+ on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
+ fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb
new file mode 100644
index 0000000..34c624f
--- /dev/null
+++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb
@@ -0,0 +1,43 @@
+test_name 'C3404 - shallow clone repo depth = 0 non shallow'
+
+# Globals
+repo_name = 'testrepo_shallow_clone'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'shallow clone repo with puppet (zero depth means not shallow)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ depth => 0,
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify checkout is NOT shallow' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('shallow found') if res.stdout.include? "shallow"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb b/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb
new file mode 100644
index 0000000..1849f02
--- /dev/null
+++ b/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb
@@ -0,0 +1,47 @@
+test_name 'C3612 - checkout a tag that does not exist'
+
+# Globals
+repo_name = 'testrepo_tag_checkout'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout tag that does not exist with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ tag => '11111111111111111',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step 'verify that master tag is checked out' do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('tag not found') unless res.stdout.include? "ref: refs/heads/master"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb
new file mode 100644
index 0000000..9c74485
--- /dev/null
+++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb
@@ -0,0 +1,48 @@
+test_name 'C3445 - checkout a tag (file protocol)'
+
+# Globals
+repo_name = 'testrepo_tag_checkout'
+tag = '0.0.2'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout a tag with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{tag}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout out tag is #{tag}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res|
+ fail_test('tag not found') unless res.stdout.include? "#{tag}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb
new file mode 100644
index 0000000..01f319c
--- /dev/null
+++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb
@@ -0,0 +1,48 @@
+test_name 'C3444 - checkout a tag (file path)'
+
+# Globals
+repo_name = 'testrepo_tag_checkout'
+tag = '0.0.2'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout a tag with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{tag}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout out tag is #{tag}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res|
+ fail_test('tag not found') unless res.stdout.include? "#{tag}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb
new file mode 100644
index 0000000..42e689c
--- /dev/null
+++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb
@@ -0,0 +1,59 @@
+test_name 'C3443 - checkout a tag (git protocol)'
+
+# Globals
+repo_name = 'testrepo_tag_checkout'
+tag = '0.0.2'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start git daemon' do
+ install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
+ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'pkill -9 git-daemon ; sleep 1')
+ end
+
+ step 'get tag sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a tag with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "git://#{host}/testrepo.git",
+ provider => git,
+ revision => '#{tag}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout out tag is #{tag}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res|
+ fail_test('tag not found') unless res.stdout.include? "#{tag}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb
new file mode 100644
index 0000000..3ea363c
--- /dev/null
+++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb
@@ -0,0 +1,67 @@
+test_name 'C3448 - checkout a tag (http protocol)'
+
+# Globals
+repo_name = 'testrepo_tag_checkout'
+tag = '0.0.2'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start http server' do
+ http_daemon =<<-EOF
+ require 'webrick'
+ server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
+ on(host, "#{ruby} /tmp/http_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'get tag sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a tag with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:8000/testrepo.git",
+ provider => git,
+ revision => '#{tag}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout out tag is #{tag}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res|
+ fail_test('tag not found') unless res.stdout.include? "#{tag}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb
new file mode 100644
index 0000000..d508c43
--- /dev/null
+++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb
@@ -0,0 +1,74 @@
+test_name 'C3449 - checkout a tag (https protocol)'
+
+# Globals
+repo_name = 'testrepo_tag_checkout'
+tag = '0.0.2'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start https server' do
+ https_daemon =<<-EOF
+ require 'webrick'
+ require 'webrick/https'
+ server = WEBrick::HTTPServer.new(
+ :Port => 8443,
+ :DocumentRoot => "#{tmpdir}",
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
+ :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
+ #on(host, "#{ruby} /tmp/https_daemon.rb")
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ end
+
+ step 'get tag sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a tag with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "https://github.com/johnduarte/testrepo.git",
+ provider => git,
+ revision => '#{tag}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout out tag is #{tag}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res|
+ fail_test('tag not found') unless res.stdout.include? "#{tag}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb
new file mode 100644
index 0000000..cb96b4e
--- /dev/null
+++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb
@@ -0,0 +1,65 @@
+test_name 'C3446 - checkout a tag (ssh protocol, scp syntax)'
+
+# Globals
+repo_name = 'testrepo_tag_checkout'
+tag = '0.0.2'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'get tag sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a tag with puppet (scp syntax)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "root@#{host}:#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{tag}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout out tag is #{tag}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res|
+ fail_test('tag not found') unless res.stdout.include? "#{tag}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb
new file mode 100644
index 0000000..bc416e8
--- /dev/null
+++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb
@@ -0,0 +1,65 @@
+test_name 'C3447 - checkout a tag (ssh protocol)'
+
+# Globals
+repo_name = 'testrepo_tag_checkout'
+tag = '0.0.2'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ end
+
+ step 'get tag sha from repo' do
+ on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
+ @sha = res.stdout.chomp
+ end
+ end
+
+ step 'checkout a tag with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
+ provider => git,
+ revision => '#{tag}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify checkout out tag is #{tag}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res|
+ fail_test('tag not found') unless res.stdout.include? "#{tag}"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb b/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb
new file mode 100644
index 0000000..245e175
--- /dev/null
+++ b/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb
@@ -0,0 +1,51 @@
+test_name 'C3483 - checkout as a user that is not on system'
+
+# Globals
+repo_name = 'testrepo_user_checkout'
+user = 'myuser'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - delete user' do
+ apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ end
+
+ step 'checkout as a user with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ owner => '#{user}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :expect_failures => true)
+ end
+
+ step "verify git checkout is NOT owned by user #{user}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by user') if res.stdout.include? "#{user}:"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb
new file mode 100644
index 0000000..ccd9ad4
--- /dev/null
+++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb
@@ -0,0 +1,53 @@
+test_name 'C3459 - checkout as a user (file protocol)'
+
+# Globals
+repo_name = 'testrepo_user_checkout'
+user = 'myuser'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - create user' do
+ apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout as a user with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "file://#{tmpdir}/testrepo.git",
+ provider => git,
+ owner => '#{user}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is owned by user #{user}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb
new file mode 100644
index 0000000..602769d
--- /dev/null
+++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb
@@ -0,0 +1,53 @@
+test_name 'C3458 - checkout as a user (file path)'
+
+# Globals
+repo_name = 'testrepo_user_checkout'
+user = 'myuser'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - create user' do
+ apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout a user with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "#{tmpdir}/testrepo.git",
+ provider => git,
+ owner => '#{user}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is owned by user #{user}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb
new file mode 100644
index 0000000..af2ffb7
--- /dev/null
+++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb
@@ -0,0 +1,58 @@
+test_name 'C3457 - checkout as a user (git protocol)'
+
+# Globals
+repo_name = 'testrepo_user_checkout'
+user = 'myuser'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start git daemon' do
+ install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
+ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
+ end
+
+ step 'setup - create user' do
+ apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, 'pkill -9 git-daemon ; sleep 1')
+ apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout a user with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "git://#{host}/testrepo.git",
+ provider => git,
+ owner => '#{user}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is owned by user #{user}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb
new file mode 100644
index 0000000..e8713e5
--- /dev/null
+++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb
@@ -0,0 +1,66 @@
+test_name 'C3462 - checkout as a user (http protocol)'
+
+# Globals
+repo_name = 'testrepo_user_checkout'
+user = 'myuser'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+
+ step 'setup - start http server' do
+ http_daemon =<<-EOF
+ require 'webrick'
+ server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
+ on(host, "#{ruby} /tmp/http_daemon.rb")
+ end
+
+ step 'setup - create user' do
+ apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout a user with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "http://#{host}:8000/testrepo.git",
+ provider => git,
+ owner => '#{user}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is owned by user #{user}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb
new file mode 100644
index 0000000..4e633d7
--- /dev/null
+++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb
@@ -0,0 +1,73 @@
+test_name 'C3463 - checkout as a user (https protocol)'
+
+# Globals
+repo_name = 'testrepo_user_checkout'
+user = 'myuser'
+
+hosts.each do |host|
+ ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - start https server' do
+ https_daemon =<<-EOF
+ require 'webrick'
+ require 'webrick/https'
+ server = WEBrick::HTTPServer.new(
+ :Port => 8443,
+ :DocumentRoot => "#{tmpdir}",
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
+ :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
+ WEBrick::Daemon.start
+ server.start
+ EOF
+ create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
+ #on(host, "#{ruby} /tmp/https_daemon.rb")
+ end
+
+ step 'setup - create user' do
+ apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
+ apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout as a user with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "https://github.com/johnduarte/testrepo.git",
+ provider => git,
+ owner => '#{user}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is owned by user #{user}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb
new file mode 100644
index 0000000..98efb46
--- /dev/null
+++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb
@@ -0,0 +1,64 @@
+test_name 'C3460 - checkout as a user (ssh protocol, scp syntax)'
+
+# Globals
+repo_name = 'testrepo_user_checkout'
+user = 'myuser'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ step 'setup - create user' do
+ apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout as a user with puppet (scp syntax)' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "root@#{host}:#{tmpdir}/testrepo.git",
+ provider => git,
+ owner => '#{user}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is owned by user #{user}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:"
+ end
+ end
+
+end
diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb
new file mode 100644
index 0000000..cfd521e
--- /dev/null
+++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb
@@ -0,0 +1,64 @@
+test_name 'C3461 - checkout as a user (ssh protocol)'
+
+# Globals
+repo_name = 'testrepo_user_checkout'
+user = 'myuser'
+
+hosts.each do |host|
+ tmpdir = host.tmpdir('vcsrepo')
+ step 'setup - create repo' do
+ git_pkg = 'git'
+ if host['platform'] =~ /ubuntu-10/
+ git_pkg = 'git-core'
+ end
+ install_package(host, git_pkg)
+ my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
+ scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+ on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+ end
+ step 'setup - establish ssh keys' do
+ # create ssh keys
+ on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
+ on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
+ on(host, 'chown -R root:root /root/.ssh')
+ end
+
+ step 'setup - create user' do
+ apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true)
+ end
+
+ teardown do
+ on(host, "rm -fr #{tmpdir}")
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
+ apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true)
+ end
+
+ step 'checkout as a user with puppet' do
+ pp = <<-EOS
+ vcsrepo { "#{tmpdir}/#{repo_name}":
+ ensure => present,
+ source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
+ provider => git,
+ owner => '#{user}',
+ }
+ EOS
+
+ apply_manifest_on(host, pp, :catch_failures => true)
+ apply_manifest_on(host, pp, :catch_changes => true)
+ end
+
+ step "verify git checkout is owned by user #{user}" do
+ on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
+ fail_test('checkout not found') unless res.stdout.include? "HEAD"
+ end
+
+ on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+ fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:"
+ end
+ end
+
+end