diff options
Diffstat (limited to 'spec/acceptance')
-rw-r--r-- | spec/acceptance/beaker/git/clone/clone_file.rb | 42 | ||||
-rw-r--r-- | spec/acceptance/beaker/git/clone/clone_file_path.rb | 42 | ||||
-rw-r--r-- | spec/acceptance/beaker/git/clone/clone_git.rb | 47 | ||||
-rw-r--r-- | spec/acceptance/beaker/git/clone/clone_http.rb | 55 | ||||
-rw-r--r-- | spec/acceptance/beaker/git/clone/clone_https.rb | 62 | ||||
-rw-r--r-- | spec/acceptance/beaker/git/clone/clone_scp.rb | 52 | ||||
-rw-r--r-- | spec/acceptance/beaker/git/clone/clone_ssh.rb | 52 | ||||
-rw-r--r-- | spec/acceptance/git_clone_protocols_spec.rb | 230 |
8 files changed, 352 insertions, 230 deletions
diff --git a/spec/acceptance/beaker/git/clone/clone_file.rb b/spec/acceptance/beaker/git/clone/clone_file.rb new file mode 100644 index 0000000..dc3a503 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_file.rb @@ -0,0 +1,42 @@ +test_name 'C3427 - clone (file protocol)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + 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) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_file_path.rb b/spec/acceptance/beaker/git/clone/clone_file_path.rb new file mode 100644 index 0000000..b76e9b9 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_file_path.rb @@ -0,0 +1,42 @@ +test_name 'C3426 - clone (file path)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + 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) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_git.rb b/spec/acceptance/beaker/git/clone/clone_git.rb new file mode 100644 index 0000000..01d2ce9 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_git.rb @@ -0,0 +1,47 @@ +test_name 'C3425 - clone (git protocol)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + 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') + 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') + 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) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_http.rb b/spec/acceptance/beaker/git/clone/clone_http.rb new file mode 100644 index 0000000..664ab10 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_http.rb @@ -0,0 +1,55 @@ +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 + install_package(host, 'git') + 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") + 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) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_https.rb b/spec/acceptance/beaker/git/clone/clone_https.rb new file mode 100644 index 0000000..4e41c99 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_https.rb @@ -0,0 +1,62 @@ +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 + install_package(host, 'git') + 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") + 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) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_scp.rb b/spec/acceptance/beaker/git/clone/clone_scp.rb new file mode 100644 index 0000000..ba8d519 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_scp.rb @@ -0,0 +1,52 @@ +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 + install_package(host, 'git') + 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, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to 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 }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => 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) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_ssh.rb b/spec/acceptance/beaker/git/clone/clone_ssh.rb new file mode 100644 index 0000000..fcc85e3 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_ssh.rb @@ -0,0 +1,52 @@ +test_name 'C3429 - clone (ssh protocol)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + 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, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to 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 }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => 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) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb deleted file mode 100644 index 4d9129e..0000000 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ /dev/null @@ -1,230 +0,0 @@ -require 'spec_helper_acceptance' - -hosts.each do |host| - - describe 'clones a repo with git' do - tmpdir = host.tmpdir('vcsrepo') - - before(:all) do - # {{{ setup - apply_manifest_on(host, "user{'testuser': ensure => present, managehome => true }") - apply_manifest_on(host, "user{'vagrant': ensure => present, }") - # install git - install_package(host, 'git') - install_package(host, 'git-daemon') - # create ssh keys - on(host, 'mkdir -p /home/testuser/.ssh') - on(host, '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 >> /home/testuser/.ssh/authorized_keys') - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /home/testuser/.ssh/config') - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - on(host, 'chown -R testuser:testuser /home/testuser/.ssh') - on(host, 'chown -R root:root /root/.ssh') - - # create git repo - 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") - - # copy ssl keys - scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) - scp_to(host, "#{my_root}/acceptance/files/server.key", tmpdir) - # }}} - end - - after(:all) do - # {{{ teardown - apply_manifest_on(host, "user{'testuser': ensure => absent, managehome => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - # }}} - end - - - #--------------- TESTS ----------------------# - - context 'using local protocol (file URL)' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - end - - it 'should have HEAD pointing to master' 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_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - end - - context 'using local protocol (file path)' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - end - - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "#{tmpdir}/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - end - - context 'using git protocol' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") - end - - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "git://#{host}/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - after(:all) do - on(host, 'pkill -9 git') - end - end - - context 'using http protocol' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/daemon.rb', daemon) - on(host, "ruby /tmp/daemon.rb") - end - - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "http://#{host}:8000/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - after(:all) do - on(host, 'pkill -9 ruby') - end - end - - context 'using https protocol' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - 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/daemon.rb', daemon) - on(host, "ruby /tmp/daemon.rb") - end - - it 'should have HEAD pointing to master' do - # howto whitelist ssl cert - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "https://#{host}:8443/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - after(:all) do - on(host, 'pkill -9 ruby') - end - end - - context 'using ssh protocol' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - end - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "ssh://root@#{host}#{tmpdir}/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - end - - end -end |