-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
280 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
default_set: 'centos-64-x64' | ||
sets: | ||
'centos-59-x64': | ||
nodes: | ||
"main.foo.vm": | ||
prefab: 'centos-59-x64' | ||
'centos-64-x64': | ||
nodes: | ||
"main.foo.vm": | ||
prefab: 'centos-64-x64' | ||
'debian-607-x64': | ||
nodes: | ||
"main.foo.vm": | ||
prefab: 'debian-607-x64' | ||
'debian-70rc1-x64': | ||
nodes: | ||
"main.foo.vm": | ||
prefab: 'debian-70rc1-x64' | ||
'ubuntu-server-10044-x64': | ||
nodes: | ||
"main.foo.vm": | ||
prefab: 'ubuntu-server-10044-x64' | ||
'ubuntu-server-12042-x64': | ||
nodes: | ||
"main.foo.vm": | ||
prefab: 'ubuntu-server-12042-x64' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
require 'rubygems' | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'rspec-system/rake_task' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require 'rspec-system/spec_helper' | ||
require 'rspec-system-puppet/helpers' | ||
require 'rspec-system-serverspec/helpers' | ||
require 'tempfile' | ||
|
||
include Serverspec::Helper::RSpecSystem | ||
include Serverspec::Helper::DetectOS | ||
include RSpecSystemPuppet::Helpers | ||
|
||
class String | ||
# Provide ability to remove indentation from strings, for the purpose of | ||
# left justifying heredoc blocks. | ||
def unindent | ||
gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "") | ||
end | ||
end | ||
|
||
module LocalHelpers | ||
include RSpecSystem::Util | ||
|
||
def gpg(gpg_cmd, user = 'root', &block) | ||
gpg = "gpg #{gpg_cmd}" | ||
shell("su #{shellescape(user)} -c #{shellescape(gpg)}", &block) | ||
end | ||
end | ||
|
||
RSpec.configure do |c| | ||
# Project root | ||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||
|
||
# Enable colour | ||
c.tty = true | ||
|
||
# Include in our local helpers, because some puppet images run | ||
# as diffrent users | ||
c.include ::LocalHelpers | ||
|
||
# Puppet helpers | ||
c.include RSpecSystemPuppet::Helpers | ||
c.extend RSpecSystemPuppet::Helpers | ||
|
||
# This is where we 'setup' the nodes before running our tests | ||
c.before :suite do | ||
# Install puppet | ||
puppet_install | ||
|
||
# Install my module from the current working copy | ||
puppet_module_install(:source => proj_root, :module_name => 'gnupg') | ||
shell 'whoami' | ||
shell 'puppet module list' | ||
|
||
# disable hiera warnings | ||
file = Tempfile.new('foo') | ||
begin | ||
file.write(<<-EOS) | ||
--- | ||
:logger: noop | ||
EOS | ||
file.close | ||
rcp(:sp => file.path, :dp => '/etc/puppet/hiera.yaml') | ||
ensure | ||
file.unlink | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
require 'spec_helper_system' | ||
|
||
describe 'gnupg_key install' do | ||
|
||
before :all do | ||
puppet_apply("class {'gnupg': } ") do |r| | ||
r.exit_code.should == 0 | ||
end | ||
end | ||
|
||
it 'should install a key from a URL address' do | ||
pp = <<-EOS.unindent | ||
gnupg_key { 'jenkins_key': | ||
ensure => present, | ||
user => 'root', | ||
key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', | ||
key_id => 'D50582E6', | ||
} | ||
EOS | ||
|
||
puppet_apply(pp) do |r| | ||
r.exit_code.should == 2 | ||
r.refresh | ||
r.exit_code.should == 0 | ||
end | ||
|
||
# check that gnupg installed the key | ||
gpg("--list-keys D50582E6") do |r| | ||
r.stdout.should =~ /D50582E6/ | ||
r.stderr.should == '' | ||
r.exit_code == 0 | ||
end | ||
end | ||
|
||
it 'should install a key from a key server' do | ||
pp = <<-EOS.unindent | ||
gnupg_key { 'root_key_foo': | ||
ensure => present, | ||
user => 'root', | ||
key_server => 'hkp://pgp.mit.edu/', | ||
key_id => '20BC0A86', | ||
} | ||
EOS | ||
|
||
puppet_apply(pp) do |r| | ||
r.exit_code.should == 2 | ||
r.refresh | ||
r.exit_code.should == 0 | ||
end | ||
|
||
# check that gnupg installed the key | ||
gpg("--list-keys 20BC0A86") do |r| | ||
r.stdout.should =~ /20BC0A86/ | ||
r.stderr.should == '' | ||
r.exit_code == 0 | ||
end | ||
end | ||
|
||
it 'should remove key 20BC0A86' do | ||
pp = <<-EOS.unindent | ||
gnupg_key { 'bye_bye_key': | ||
ensure => absent, | ||
key_id => 20BC0A86, | ||
user => root, | ||
} | ||
EOS | ||
|
||
puppet_apply(pp) do |r| | ||
r.exit_code.should == 2 | ||
r.refresh | ||
r.exit_code.should == 0 | ||
end | ||
end | ||
|
||
it 'should install key from the puppet fileserver/module repository' do | ||
pp = <<-EOS.unindent | ||
gnupg_key {'add_key_by_remote_source': | ||
ensure => present, | ||
key_id => 20BC0A86, | ||
user => root, | ||
key_source => "puppet:///modules/gnupg/random.key", | ||
} | ||
EOS | ||
|
||
puppet_apply(pp) do |r| | ||
r.exit_code.should == 2 | ||
r.refresh | ||
r.exit_code.should == 0 | ||
end | ||
|
||
# check that gnupg installed the key | ||
gpg("--list-keys 20BC0A86") do |r| | ||
r.stdout.should =~ /20BC0A86/ | ||
r.stderr.should == '' | ||
r.exit_code == 0 | ||
end | ||
end | ||
|
||
it 'should not install a key, because local resource does not exists' do | ||
pp = <<-EOS.unindent | ||
gnupg_key { 'jenkins_key': | ||
ensure => present, | ||
user => 'root', | ||
key_source => '/santa/claus/does/not/exists/org/sorry/kids.key', | ||
key_id => '40404040', | ||
} | ||
EOS | ||
|
||
puppet_apply(pp) do |r| | ||
r.exit_code.should == 4 | ||
end | ||
end | ||
|
||
it 'should fail because there is no content on the URL address' do | ||
pp = <<-EOS.unindent | ||
gnupg_key { 'jenkins_key': | ||
ensure => present, | ||
user => 'root', | ||
key_source => 'http://foo.com/key-not-there.key', | ||
key_id => '40404040', | ||
} | ||
EOS | ||
|
||
puppet_apply(pp) do |r| | ||
r.exit_code.should == 4 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'spec_helper_system' | ||
|
||
describe 'install gnupg:' do | ||
|
||
it 'test loading class with no arguments' do | ||
pp = <<-EOS.unindent | ||
class {'gnupg':} | ||
EOS | ||
|
||
puppet_apply(pp) do |r| | ||
r.exit_code.should == 0 | ||
r.refresh | ||
r.exit_code.should == 0 | ||
end | ||
end | ||
end |