34
34
end
35
35
end
36
36
end
37
+
38
+ describe 'managing non existent java chain keys in noop' , :unless => UNSUPPORTED_PLATFORMS . include? ( fact ( 'operatingsystem' ) ) do
39
+ include_context 'common variables'
40
+
41
+ case fact ( 'osfamily' )
42
+ when "windows"
43
+ target = 'c:/noop_chain_key.ks'
44
+ temp_dir = 'C:/tmp/'
45
+ else
46
+ target = '/etc/noop_chain_key.ks'
47
+ temp_dir = '/tmp/'
48
+ end
49
+ it 'does not create a new keystore in noop' do
50
+ pp = <<-EOS
51
+ $filenames = ["#{ temp_dir } noop_ca.pem",
52
+ "#{ temp_dir } noop_chain.pem",
53
+ "#{ temp_dir } noop_privkey.pem"]
54
+ file { $filenames:
55
+ ensure => file,
56
+ content => 'content',
57
+ } ->
58
+ java_ks { 'broker.example.com:#{ target } ':
59
+ ensure => latest,
60
+ certificate => "#{ temp_dir } noop_ca.pem",
61
+ chain => "#{ temp_dir } noop_chain.pem",
62
+ private_key => "#{ temp_dir } noop_privkey.pem",
63
+ password => 'puppet',
64
+ path => #{ @resource_path } ,
65
+ }
66
+ EOS
67
+
68
+ # in noop mode, when the dependent certificate files are not present in the system,
69
+ # java_ks will not invoke openssl to validate their status, thus noop will succeed
70
+ apply_manifest ( pp , :catch_failures => true , :noop => true )
71
+ end
72
+
73
+ # verifies the dependent files are missing
74
+ [ "#{ temp_dir } noop_ca.pem" , "#{ temp_dir } noop_chain.pem" , "#{ temp_dir } noop_privkey.pem" ] . each do |filename |
75
+ describe file ( "#{ filename } " ) do
76
+ it { should_not be_file }
77
+ end
78
+ end
79
+
80
+ # verifies the keystore is not created
81
+ describe file ( "#{ target } " ) do
82
+ it { should_not be_file }
83
+ end
84
+ end
85
+
86
+ describe 'managing existing java chain keys in noop' , :unless => UNSUPPORTED_PLATFORMS . include? ( fact ( 'operatingsystem' ) ) do
87
+ include_context 'common variables'
88
+
89
+ case fact ( 'osfamily' )
90
+ when "windows"
91
+ target = 'c:/noop2_chain_key.ks'
92
+ else
93
+ target = '/etc/noop2_chain_key.ks'
94
+ end
95
+ it 'does not create a new keystore in noop' do
96
+ pp = <<-EOS
97
+ java_ks { 'broker.example.com:#{ target } ':
98
+ ensure => latest,
99
+ certificate => "#{ @temp_dir } ca.pem",
100
+ chain => "#{ @temp_dir } chain.pem",
101
+ private_key => "#{ @temp_dir } privkey.pem",
102
+ password => 'puppet',
103
+ path => #{ @resource_path } ,
104
+ }
105
+ EOS
106
+
107
+ apply_manifest ( pp , :catch_failures => true , :noop => true )
108
+ end
109
+
110
+ # in noop mode, when the dependent certificate files are present in the system,
111
+ # java_ks will invoke openssl to validate their status, but will not create the keystore
112
+ describe file ( "#{ target } " ) do
113
+ it { should_not be_file }
114
+ end
115
+ end
0 commit comments