Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) Remove ruby requirement for creating certs #129

Merged
merged 1 commit into from
Aug 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ group :system_tests do
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
gem 'beaker-puppet_install_helper', '~> 0.3', :require => false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be bound this tightly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it needs to be at least 0.3 as that is when we added install_ca_certs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but seems like >= 0.3.0 would cause fewer future issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More so it protects us from what may happen in 1.0 but anything up until 1.0

end


Expand All @@ -45,4 +45,8 @@ else
gem 'puppet', :require => false
end

if File.exists? "#{__FILE__}.local"
eval(File.read("#{__FILE__}.local"), binding)
end

# vim:ft=ruby
40 changes: 11 additions & 29 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,23 @@
require 'beaker/puppet_install_helper'

run_puppet_install_helper
install_ca_certs_on default if default['platform'] =~ /windows/i

UNSUPPORTED_PLATFORMS = []

def create_keys_for_test(host)
# Generate private key and CA for keystore

if host['platform'] =~ /windows/i
cmd = 'env PATH="$( [ -d "/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/sys/ruby/bin" ]'
cmd += ' && echo "/cygdrive/c/Program Files (x86)" || echo "/cygdrive/c/Program Files" )/Puppet Labs/Puppet/sys/ruby/bin:${PATH}" ruby -e'
temp_dir = 'C:\\tmp\\'
on host, 'mkdir /cygdrive/c/tmp'
else
path = '${PATH}'
path = "/opt/puppetlabs/puppet/bin:/opt/csw/bin:#{path}" # Need ruby's path on solaris 10 (foss)
if host.is_pe?
path = "#{host['puppetbindir']}:#{path}" # But try PE's ruby first
end
cmd = "PATH=#{path} ruby -e"
temp_dir = '/tmp/'
end
# Need to check for ruby path on puppet install, use vendor ruby and add it to the path durring execution
tmp_privky = "#{temp_dir}privkey.pem"
tmp_ca = "#{temp_dir}ca.pem"
tmp_ca2 = "#{temp_dir}ca2.pem"
tmp_chain = "#{temp_dir}chain.pem"
opensslscript =<<EOS

create_certs(host, temp_dir)
end

def create_certs(host, tmpdir)
require 'openssl'
key = OpenSSL::PKey::RSA.new 1024
ca = OpenSSL::X509::Certificate.new
Expand Down Expand Up @@ -62,14 +53,13 @@ def create_keys_for_test(host)
chain.not_after = chain.not_before + 360
chain.sign(key, OpenSSL::Digest::SHA256.new)

File.open('#{tmp_privky}', 'w') { |f| f.write key.to_pem }
File.open('#{tmp_ca}', 'w') { |f| f.write ca.to_pem }
File.open('#{tmp_ca2}', 'w') { |f| f.write ca2.to_pem }
File.open('#{tmp_chain}', 'w') { |f| f.write chain.to_pem }
EOS
on host, "#{cmd} \"#{opensslscript}\""
create_remote_file(host, "#{tmpdir}/privkey.pem", key.to_pem)
create_remote_file(host, "#{tmpdir}/ca.pem", ca.to_pem)
create_remote_file(host, "#{tmpdir}/ca2.pem", ca2.to_pem)
create_remote_file(host, "#{tmpdir}/chain.pem", chain.to_pem)
end


RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
Expand All @@ -81,18 +71,10 @@ def create_keys_for_test(host)
c.before :suite do
# Install module and dependencies
hosts.each do |host|

create_keys_for_test(host)
copy_module_to(host, :source => proj_root, :module_name => 'java_ks')
#install java if windows
if host['platform'] =~ /windows/i
exec_puppet = <<EOS
exec{'Download':
command => 'powershell.exe -command "Invoke-WebRequest https://forge.puppetlabs.com"',
path => ['c:\\windows\\sysnative\\WindowsPowershell\\v1.0','c:\\windows\\system32\\WindowsPowershell\\v1.0'],
}
EOS
on host, apply_manifest(exec_puppet)
on host, puppet('module install cyberious-windows_java')
else
on host, puppet('module', 'install', 'puppetlabs-java'), {:acceptable_exit_codes => [0, 1]}
Expand Down