-
Notifications
You must be signed in to change notification settings - Fork 97
/
keystore_spec.rb
65 lines (57 loc) · 1.89 KB
/
keystore_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'spec_helper_acceptance'
describe 'managing java keystores', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
include_context 'common variables'
case fact('osfamily')
when 'windows'
target = 'c:/tmp/keystore.ks'
else
target = '/etc/keystore.ks'
end
it 'creates a keystore' do
pp = <<-EOS
java_ks { 'puppetca:keystore':
ensure => #{@ensure_ks},
certificate => "#{@temp_dir}ca.pem",
target => '#{target}',
password => 'puppet',
trustcacerts => true,
path => #{@resource_path},
}
EOS
apply_manifest(pp, :catch_failures => true)
end
it 'verifies the keystore' do
shell("#{@keytool_path}keytool -list -v -keystore #{target} -storepass puppet") do |r|
expect(r.exit_code).to be_zero
expect(r.stdout).to match(/Your keystore contains 1 entry/)
expect(r.stdout).to match(/Alias name: puppetca/)
expect(r.stdout).to match(/CN=Test CA/)
end
end
it 'uses password_file' do
pp = <<-EOS
file { '#{@temp_dir}password':
ensure => file,
content => 'puppet',
}
java_ks { 'puppetca2:keystore':
ensure => latest,
certificate => "#{@temp_dir}ca2.pem",
target => '#{target}',
password_file => '#{@temp_dir}password',
trustcacerts => true,
path => #{@resource_path},
require => File['#{@temp_dir}password']
}
EOS
apply_manifest(pp, :catch_failures => true)
end
it 'verifies the keystore' do
shell("#{@keytool_path}keytool -list -v -keystore #{target} -storepass puppet") do |r|
expect(r.exit_code).to be_zero
expect(r.stdout).to match(/Your keystore contains 2 entries/)
expect(r.stdout).to match(/Alias name: puppetca2/)
expect(r.stdout).to match(/CN=Test CA/)
end
end
end