Imported puppetlabs-vcsrepo

This commit is contained in:
Ciaby 2014-07-16 13:58:34 -05:00
parent 0938a13fe6
commit 18d9aa4a23
152 changed files with 9191 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,51 @@
test_name "Installing Puppet and vcsrepo module" do
step 'install puppet' do
if @options[:provision]
# This will fail if puppet is already installed, ie --no-provision
if hosts.first.is_pe?
install_pe
else
install_puppet
on hosts, "mkdir -p #{hosts.first['distmoduledir']}"
end
end
end
step 'Ensure we can install our module' do
hosts.each do |host|
# We ask the host to interpolate it's distmoduledir because we don't
# actually know it on Windows until we've let it redirect us (depending
# on whether we're running as a 32/64 bit process on 32/64 bit Windows
moduledir = on(host, "echo #{host['distmoduledir']}").stdout.chomp
on host, "mkdir -p #{moduledir}"
end
end
step 'install module' do
hosts.each do |host|
proj_root = File.expand_path(File.join(File.dirname(__FILE__),'..','..'))
# This require beaker 1.15
copy_module_to(host, :source => proj_root, :module_name => 'vcsrepo')
case fact_on(host, 'osfamily')
when 'RedHat'
install_package(host, 'git')
when 'Debian'
install_package(host, 'git-core')
else
if !check_for_package(host, 'git')
puts "Git package is required for this module"
exit
end
end
gitconfig = <<-EOS
[user]
email = root@localhost
name = root
EOS
create_remote_file(host, "/root/.gitconfig", gitconfig)
end
end
end

View file

@ -0,0 +1,508 @@
require 'spec_helper_acceptance'
tmpdir = default.tmpdir('vcsrepo')
describe 'clones a remote repo' do
before(:all) do
my_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
shell("mkdir -p #{tmpdir}") # win test
scp_to(default, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
shell("cd #{tmpdir} && ./create_git_repo.sh")
end
after(:all) do
shell("rm -rf #{tmpdir}/testrepo.git")
end
context 'get the current master HEAD' do
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo/.git") do
it { should be_directory }
end
describe file("#{tmpdir}/testrepo/.git/HEAD") do
it { should contain 'ref: refs/heads/master' }
end
end
context 'using a commit SHA' do
let (:sha) do
shell("git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1").stdout.chomp
end
after(:all) do
shell("rm -rf #{tmpdir}/testrepo_sha")
end
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_sha":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
revision => "#{sha}",
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_sha/.git") do
it { should be_directory }
end
describe file("#{tmpdir}/testrepo_sha/.git/HEAD") do
it { should contain sha }
end
end
context 'using a tag' do
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_tag":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
revision => '0.0.2',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_tag/.git") do
it { should be_directory }
end
it 'should have the tag as the HEAD' do
shell("git --git-dir=#{tmpdir}/testrepo_tag/.git name-rev HEAD | grep '0.0.2'")
end
end
context 'using a branch name' do
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_branch":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
revision => 'a_branch',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_branch/.git") do
it { should be_directory }
end
describe file("#{tmpdir}/testrepo_branch/.git/HEAD") do
it { should contain 'ref: refs/heads/a_branch' }
end
end
context 'ensure latest with branch specified' do
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_latest":
ensure => latest,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
revision => 'a_branch',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
it 'verifies the HEAD commit SHA on remote and local match' do
remote_commit = shell("git ls-remote file://#{tmpdir}/testrepo_latest HEAD | head -1").stdout
local_commit = shell("git --git-dir=#{tmpdir}/testrepo_latest/.git rev-parse HEAD").stdout.chomp
expect(remote_commit).to include(local_commit)
end
end
context 'ensure latest with branch unspecified' do
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_latest":
ensure => latest,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
it 'verifies the HEAD commit SHA on remote and local match' do
remote_commit = shell("git ls-remote file://#{tmpdir}/testrepo_latest HEAD | head -1").stdout
local_commit = shell("git --git-dir=#{tmpdir}/testrepo_latest/.git rev-parse HEAD").stdout.chomp
expect(remote_commit).to include(local_commit)
end
end
context 'with shallow clone' do
it 'does a shallow clone' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_shallow":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
depth => '1',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_shallow/.git/shallow") do
it { should be_file }
end
end
context 'path is not empty and not a repository' do
before(:all) do
shell("mkdir #{tmpdir}/not_a_repo", :acceptable_exit_codes => [0,1])
shell("touch #{tmpdir}/not_a_repo/file1.txt", :acceptable_exit_codes => [0,1])
end
it 'should raise an exception' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/not_a_repo":
ensure => present,
provider => git
source => "file://#{tmpdir}/testrepo.git",
}
EOS
apply_manifest(pp, :expect_failures => true)
end
end
context 'with an owner' do
pp = <<-EOS
user { 'vagrant':
ensure => present,
}
EOS
apply_manifest(pp, :catch_failures => true)
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_owner":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
owner => 'vagrant',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_owner") do
it { should be_directory }
it { should be_owned_by 'vagrant' }
end
end
context 'with a group' do
pp = <<-EOS
group { 'vagrant':
ensure => present,
}
EOS
apply_manifest(pp, :catch_failures => true)
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "/#{tmpdir}/testrepo_group":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
group => 'vagrant',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_group") do
it { should be_directory }
it { should be_grouped_into 'vagrant' }
end
end
context 'with excludes' do
it 'clones a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_excludes":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
excludes => ['exclude1.txt', 'exclude2.txt'],
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_excludes/.git/info/exclude") do
its(:content) { should match /exclude1.txt/ }
its(:content) { should match /exclude2.txt/ }
end
end
context 'with force' do
before(:all) do
shell("mkdir -p #{tmpdir}/testrepo_force/folder")
shell("touch #{tmpdir}/testrepo_force/temp.txt")
end
it 'applies the manifest' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_force":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
force => true,
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_force/folder") do
it { should_not be_directory }
end
describe file("#{tmpdir}/testrepo_force/temp.txt") do
it { should_not be_file }
end
describe file("#{tmpdir}/testrepo_force/.git") do
it { should be_directory }
end
context 'and noop' do
let(:repo_name) do
'testrepo_already_exists'
end
before(:all) do
shell("mkdir #{tmpdir}/#{repo_name}")
shell("cd #{tmpdir}/#{repo_name} && git init")
shell("cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'")
end
after(:all) do
shell("rm -rf #{tmpdir}/#{repo_name}")
end
it 'applies the manifest' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
force => true,
noop => true,
}
EOS
apply_manifest(pp, :catch_changes => true) do |r|
expect(r.stdout).to match(/Noop Mode/)
end
end
end
end
context 'as a user' do
before(:all) do
shell("chmod 707 #{tmpdir}")
pp = <<-EOS
group { 'testuser':
ensure => present,
}
user { 'testuser':
ensure => present,
groups => 'testuser',
}
EOS
apply_manifest(pp, :catch_failures => true)
end
it 'applies the manifest' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_user":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
user => 'testuser',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_user") do
it { should be_directory }
it { should be_owned_by 'testuser' }
end
describe file("#{tmpdir}/testrepo_user") do
it { should be_directory }
it { should be_grouped_into 'testuser' }
end
end
context 'non-origin remote name' do
it 'applies the manifest' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_remote":
ensure => present,
provider => git,
source => "file://#{tmpdir}/testrepo.git",
remote => 'testorigin',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
it 'remote name is "testorigin"' do
shell("git --git-dir=#{tmpdir}/testrepo_remote/.git remote | grep 'testorigin'")
end
after(:all) do
pp = 'user { "testuser": ensure => absent }'
apply_manifest(pp, :catch_failures => true)
end
end
context 'as a user with ssh' do
before(:all) do
# create user
pp = <<-EOS
group { 'testuser-ssh':
ensure => present,
}
user { 'testuser-ssh':
ensure => present,
groups => 'testuser-ssh',
managehome => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
# create ssh keys
shell('mkdir -p /home/testuser-ssh/.ssh')
shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys')
shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config')
shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh')
end
it 'applies the manifest' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_user_ssh":
ensure => present,
provider => git,
source => "testuser-ssh@localhost:#{tmpdir}/testrepo.git",
user => 'testuser-ssh',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
after(:all) do
pp = <<-EOS
user { 'testuser-ssh':
ensure => absent,
managehome => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
end
context 'using an identity file' do
before(:all) do
# create user
pp = <<-EOS
user { 'testuser-ssh':
ensure => present,
managehome => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
# create ssh keys
shell('mkdir -p /home/testuser-ssh/.ssh')
shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys')
shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config')
shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh')
end
it 'applies the manifest' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_user_ssh_id":
ensure => present,
provider => git,
source => "testuser-ssh@localhost:#{tmpdir}/testrepo.git",
identity => '/home/testuser-ssh/.ssh/id_rsa',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
end
end

View file

@ -0,0 +1,73 @@
require 'spec_helper_acceptance'
tmpdir = default.tmpdir('vcsrepo')
describe 'create a repo' do
context 'without a source' do
it 'creates a blank repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_blank_repo":
ensure => present,
provider => git,
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_blank_repo/") do
it 'should have zero files' do
shell("ls -1 #{tmpdir}/testrepo_blank_repo | wc -l") do |r|
expect(r.stdout).to match(/^0\n$/)
end
end
end
describe file("#{tmpdir}/testrepo_blank_repo/.git") do
it { should be_directory }
end
end
context 'bare repo' do
it 'creates a bare repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_bare_repo":
ensure => bare,
provider => git,
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{tmpdir}/testrepo_bare_repo/config") do
it { should contain 'bare = true' }
end
describe file("#{tmpdir}/testrepo_bare_repo/.git") do
it { should_not be_directory }
end
end
context 'bare repo with a revision' do
it 'does not create a bare repo when a revision is defined' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_bare_repo_rev":
ensure => bare,
provider => git,
revision => 'master',
}
EOS
apply_manifest(pp, :expect_failures => true)
end
describe file("#{tmpdir}/testrepo_bare_repo_rev") do
it { should_not be_directory }
end
end
end

View file

@ -0,0 +1,39 @@
#!/bin/bash
mkdir testrepo
cd testrepo
touch file1.txt file2.txt file3.txt
git init
echo 'change 1' > file1.txt
git add file1.txt
git commit -m 'add file1'
git tag 0.0.1
echo 'change 2' > file2.txt
git add file2.txt
git commit -m 'add file2'
git tag 0.0.2
echo 'change 3' > file3.txt
git add file3.txt
git commit -m 'add file3'
git tag 0.0.3
git checkout -b a_branch
echo 'change 4' > file4.txt
git add file4.txt
git commit -m 'add file4'
echo 'change 5' > file5.txt
git add file5.txt
git commit -m 'add file5'
echo 'change 6' > file6.txt
git add file6.txt
git commit -m 'add file6'
git checkout master
cd ..
git --git-dir=testrepo/.git config core.bare true
cp -r testrepo/.git testrepo.git
rm -rf testrepo
cd testrepo.git
touch git-daemon-export-ok
git update-server-info

View file

@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIICATCCAWoCCQCS3fQotV10LzANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
cyBQdHkgTHRkMB4XDTE0MDQyMzIyMzEyM1oXDTE1MDQyMzIyMzEyM1owRTELMAkG
A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0
IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyRTv
uX6328aQ5Auc8PI+xNaCiE0UZNYcs+xq3AEkR/Tnz0HGXdx3+PnFG7MIRSS65hXA
VGenZk3wP4vNIe9gu+G9jtOFTJOgoOBUnJ/Hcs79Zgcmz3cAWQpqww+CZpyngUDS
msZ5HoEbNS+qaIron3IrYCgPsy1BHFs5ze7JrtcCAwEAATANBgkqhkiG9w0BAQUF
AAOBgQA2uLvdc1cf+nt7d8Lmu0SdaoIsCzh6DjVscCpFJKXdDjGT2Ys40iKbLRnY
Tt98wa6uRzEhSKfx+zVi8n3PSkQHlER7jzKFXMVx8NEt2/O/APKXVizmLFjk5WcT
FvGmmbkqX+Nj9TUTuSRZEmF776r5k8U5ABu/VarxvAzyoXAhqA==
-----END CERTIFICATE-----

View file

@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDJFO+5frfbxpDkC5zw8j7E1oKITRRk1hyz7GrcASRH9OfPQcZd
3Hf4+cUbswhFJLrmFcBUZ6dmTfA/i80h72C74b2O04VMk6Cg4FScn8dyzv1mBybP
dwBZCmrDD4JmnKeBQNKaxnkegRs1L6poiuifcitgKA+zLUEcWznN7smu1wIDAQAB
AoGAQPnD8OOyk5DZVuctwmn0wHQ0X8jQczkAs18MtKSlzZ6knUM6zy+jkM9c0vOK
E5Wn0xtqN5v66sL6g/4vvex1DA5Q6YsXvZ48VpVliZXXK/1pdTv0qwMyHdlBhmgJ
MhnZbyNy61QHdOTsWDR1YrELpDyFMJ9cZZD0NOnsuhd2DbECQQDq7W/zlJBZPWNR
ab2dP+HLpm/PiEBT13SuEEskh3GEEfZlwz/cGu0Z8DHA4E3Z60KFjwgnc92GNFMg
m0t3hHtpAkEA2x5PsDxBk9sWwdIvu57vjQLdotvAfyb+W9puIaZS1JRSVLTsUVEj
Y0KxgsPHtcjrVoN//zGymn4ePxWOzlrQPwJBAN5thEuZY7o6dyiD9zVFYKGSqdZS
aKV5H04Wuy6Q1pd28lWTMYlSLR8b3d+B//PN3SPbMps4BoukSvhaUG+OjdECQFzF
KZIBAPa7pJftCH6UHPIDy5ifF5H+DWUQRt6CT8FnBrCMZR1MkAH/g65Me6pwZYsc
Y73E6cxVJzMoSmz9r/sCQQCOhPflFCxZ23ocsuRBo9O/mMUDaLoHZXWuJ2DqAUN2
mS6UUR/lpyc7Cmy0VOyhS8783D7MUfji5ddfVxb5tWgm
-----END RSA PRIVATE KEY-----

View file

@ -0,0 +1,89 @@
require 'spec_helper_acceptance'
tmpdir = default.tmpdir('vcsrepo')
describe 'MODULES-660' do
before(:all) do
# Create testrepo.git
my_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
shell("mkdir -p #{tmpdir}") # win test
scp_to(default, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
shell("cd #{tmpdir} && ./create_git_repo.sh")
# Configure testrepo.git as upstream of testrepo
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo":
ensure => present,
provider => git,
revision => 'a_branch',
source => "file://#{tmpdir}/testrepo.git",
}
EOS
apply_manifest(pp, :catch_failures => true)
end
after(:all) do
shell("rm -rf #{tmpdir}/testrepo.git")
end
shared_examples 'switch to branch/tag/sha' do
it 'pulls the new branch commits' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo":
ensure => latest,
provider => git,
revision => 'a_branch',
source => "file://#{tmpdir}/testrepo.git",
}
EOS
apply_manifest(pp, :expect_changes => true)
apply_manifest(pp, :catch_changes => true)
end
it 'checks out the tag' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo":
ensure => latest,
provider => git,
revision => '0.0.3',
source => "file://#{tmpdir}/testrepo.git",
}
EOS
apply_manifest(pp, :expect_changes => true)
apply_manifest(pp, :catch_changes => true)
end
it 'checks out the sha' do
sha = shell("cd #{tmpdir}/testrepo && git rev-parse origin/master").stdout.chomp
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo":
ensure => latest,
provider => git,
revision => '#{sha}',
source => "file://#{tmpdir}/testrepo.git",
}
EOS
apply_manifest(pp, :expect_changes => true)
apply_manifest(pp, :catch_changes => true)
end
end
context 'on branch' do
before :each do
shell("cd #{tmpdir}/testrepo && git checkout a_branch")
shell("cd #{tmpdir}/testrepo && git reset --hard 0.0.2")
end
it_behaves_like 'switch to branch/tag/sha'
end
context 'on tag' do
before :each do
shell("cd #{tmpdir}/testrepo && git checkout 0.0.1")
end
it_behaves_like 'switch to branch/tag/sha'
end
context 'on detached head' do
before :each do
shell("cd #{tmpdir}/testrepo && git checkout 0.0.2")
shell("cd #{tmpdir}/testrepo && git checkout HEAD~1")
end
it_behaves_like 'switch to branch/tag/sha'
end
end

View file

@ -0,0 +1,10 @@
HOSTS:
centos-59-x64:
roles:
- master
platform: el-5-x86_64
box : centos-59-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,12 @@
HOSTS:
centos-64-x64:
roles:
- master
- database
- dashboard
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: pe

View file

@ -0,0 +1,10 @@
HOSTS:
centos-64-x64:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
centos-65-x64:
roles:
- master
platform: el-6-x86_64
box : centos-65-x64-vbox436-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
debian-607-x64:
roles:
- master
platform: debian-6-amd64
box : debian-607-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
debian-73-x64:
roles:
- master
platform: debian-7-amd64
box : debian-73-x64-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
centos-64-x64:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-10044-x64:
roles:
- master
platform: ubuntu-10.04-amd64
box : ubuntu-server-10044-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-12042-x64:
roles:
- master
platform: ubuntu-12.04-amd64
box : ubuntu-server-12042-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,11 @@
HOSTS:
ubuntu-server-1404-x64:
roles:
- master
platform: ubuntu-14.04-amd64
box : puppetlabs/ubuntu-14.04-64-nocm
box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
hypervisor : vagrant
CONFIG:
log_level : debug
type: git

View file

@ -0,0 +1,30 @@
require 'spec_helper_acceptance'
tmpdir = default.tmpdir('vcsrepo')
describe 'remove a repo' do
it 'creates a blank repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_deleted":
ensure => present,
provider => git,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
it 'removes a repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_deleted":
ensure => absent,
provider => git,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe file("#{tmpdir}/testrepo_deleted") do
it { should_not be_directory }
end
end

View file

@ -0,0 +1,31 @@
require 'spec_helper_acceptance'
tmpdir = default.tmpdir('vcsrepo')
describe 'does not remove a repo if noop' do
it 'creates a blank repo' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_noop_deleted":
ensure => present,
provider => git,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
it 'does not remove a repo if noop' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_noop_deleted":
ensure => absent,
provider => git,
force => true,
}
EOS
apply_manifest(pp, :catch_failures => true, :noop => true, :verbose => false)
end
describe file("#{tmpdir}/testrepo_noop_deleted") do
it { should be_directory }
end
end

Some files were not shown because too many files have changed in this diff Show more