summaryrefslogtreecommitdiff
path: root/spec/acceptance
diff options
context:
space:
mode:
authorJohn Duarte <john.duarte@puppetlabs.com>2014-05-05 17:54:22 -0700
committerJohn Duarte <john.duarte@puppetlabs.com>2014-05-18 11:38:18 -0700
commit30aa7738146921f0fb34e61ace82eed8dae1fc97 (patch)
tree12608b1eaf9ed79399cf7cfc1740e60686abc16d /spec/acceptance
parentbca6ff5c480d4aa129766ccac4cb385aef092fd9 (diff)
Add test for clone using git protocol
Diffstat (limited to 'spec/acceptance')
-rw-r--r--spec/acceptance/git_clone_protocols_spec.rb164
1 files changed, 83 insertions, 81 deletions
diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb
index 9663889..ec56625 100644
--- a/spec/acceptance/git_clone_protocols_spec.rb
+++ b/spec/acceptance/git_clone_protocols_spec.rb
@@ -2,93 +2,95 @@ require 'spec_helper_acceptance'
hosts.each do |host|
-describe 'clones a repo with git' do
- tmpdir = host.tmpdir('vcsrepo')
- before(:all) do
- pp = <<-EOS
- user { 'testuser':
- ensure => absent,
- managehome => true,
- }
- EOS
- on(host,apply_manifest(pp, :catch_failures => true))
- on(host,apply_manifest("file {'#{tmpdir}': ensure => absent}", :catch_failures => true))
- # {{{ setup
- # install git
- install_package(host, 'git')
-
- # create git repo
- my_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
- #shell("mkdir -p #{tmpdir}") # win test
- scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
- host.execute("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)
-
- # hack for non-vagrant deploys (deleteme)
- on(host,apply_manifest("user{'vagrant': ensure => present, }"))
-
- # create user
- pp = <<-EOS
- user { 'testuser':
- ensure => present,
- managehome => true,
- }
- EOS
- on(host,apply_manifest(pp, :catch_failures => true))
-
- # create ssh keys
- host.execute('mkdir -p /home/testuser/.ssh')
- host.execute('ssh-keygen -q -t rsa -f /home/testuser/.ssh/id_rsa -N ""')
-
- # copy public key to authorized_keys
- host.execute('cat /home/testuser/.ssh/id_rsa.pub > /home/testuser/.ssh/authorized_keys')
- host.execute('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser/.ssh/config')
- host.execute('chown -R testuser:testuser /home/testuser/.ssh')
- # }}}
- end
+ describe 'clones a repo with git' do
+ tmpdir = host.tmpdir('vcsrepo')
+
+ before(:all) do
+ # {{{ setup
+ on(host,apply_manifest("user{'testuser': ensure => present, }"))
+ on(host,apply_manifest("user{'vagrant': ensure => present, }"))
+ # install git
+ install_package(host, 'git')
+ install_package(host, 'git-daemon')
+ # create ssh keys
+ host.execute('mkdir -p /home/testuser/.ssh')
+ host.execute('ssh-keygen -q -t rsa -f /home/testuser/.ssh/id_rsa -N ""')
+
+ # copy public key to authorized_keys
+ host.execute('cat /home/testuser/.ssh/id_rsa.pub > /home/testuser/.ssh/authorized_keys')
+ host.execute('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser/.ssh/config')
+ host.execute('chown -R testuser:testuser /home/testuser/.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)
+ host.execute("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)
+
+ host.execute("nohup git daemon --detach --base-path=/#{tmpdir}")
+ # }}}
+ end
- after(:all) do
- # {{{ teardown
- pp = <<-EOS
- user { 'testuser':
- ensure => absent,
- managehome => true,
- }
- EOS
- on(host,apply_manifest(pp, :catch_failures => true))
- on(host,apply_manifest("file {'#{tmpdir}': ensure => absent}", :catch_failures => true))
- # }}}
- end
+ after(:all) do
+ # {{{ teardown
+ on(host,apply_manifest("user{'testuser': ensure => absent,}"))
+ # }}}
+ end
- after(:each) do
- on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => absent}", :catch_failures => true))
- end
- #--------------- TESTS ----------------------#
-
- context 'using local protocol (file URL)' do
- 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
- on(host,apply_manifest(pp, :catch_failures => true))
- on(host,apply_manifest(pp, :catch_changes => true))
+ #--------------- TESTS ----------------------#
+
+ context 'using local protocol (file URL)' do
+ before(:all) do
+ on(host,apply_manifest("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
+ on(host,apply_manifest(pp, :catch_failures => true))
+ on(host,apply_manifest(pp, :catch_changes => true))
+ end
+
+ describe file("#{tmpdir}/testrepo/.git/HEAD") do
+ it { should contain 'ref: refs/heads/master' }
+ end
+
end
- describe file("#{tmpdir}/testrepo/.git/HEAD") do
- it { should contain 'ref: refs/heads/master' }
+ context 'using git protocol' do
+ before(:all) do
+ on(host,apply_manifest("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 => "git://#{host}/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/HEAD") do
+ it { should contain 'ref: refs/heads/master' }
+ end
+
end
end
-
-end
end