Imported puppetlabs-vcsrepo
This commit is contained in:
parent
0938a13fe6
commit
18d9aa4a23
152 changed files with 9191 additions and 0 deletions
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
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, :catch_failures => true)
|
||||
apply_manifest_on(host, pp, :catch_changes => 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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue