|
41 | 41 | it { should be_grouped_into 'root' } |
42 | 42 | end |
43 | 43 |
|
44 | | - describe command("keytool -list -keystore #{truststore_path} -storepass:file #{truststore_password_file}") do |
| 44 | + describe command("keytool -list -keystore #{truststore_path} -storepass testpassword") do |
45 | 45 | its(:exit_status) { should eq 0 } |
46 | 46 | its(:stdout) { should match(/^Keystore type: PKCS12$/i) } |
47 | 47 | its(:stdout) { should match(/^Your keystore contains 0 entries$/) } |
|
87 | 87 | its(:stdout) { should match(/^Owner: CN=#{host_inventory['fqdn']}$/) } |
88 | 88 | its(:stdout) { should match(/^Issuer: CN=#{host_inventory['fqdn']}$/) } |
89 | 89 | end |
| 90 | + |
| 91 | + describe 'changing password' do |
| 92 | + describe 'apply puppet' do |
| 93 | + let(:manifest) do |
| 94 | + <<-PUPPET |
| 95 | + $truststore_password_file = '/etc/pki/truststore_password-file' |
| 96 | +
|
| 97 | + package { 'java-11-openjdk-headless': |
| 98 | + ensure => installed, |
| 99 | + } |
| 100 | +
|
| 101 | + file { $truststore_password_file: |
| 102 | + ensure => file, |
| 103 | + content => 'other-password', |
| 104 | + owner => 'root', |
| 105 | + group => 'root', |
| 106 | + mode => '0440', |
| 107 | + show_diff => false, |
| 108 | + } |
| 109 | +
|
| 110 | + truststore { "/etc/pki/truststore": |
| 111 | + ensure => present, |
| 112 | + password_file => $truststore_password_file, |
| 113 | + owner => 'root', |
| 114 | + group => 'root', |
| 115 | + mode => '0640', |
| 116 | + } |
| 117 | + PUPPET |
| 118 | + end |
| 119 | + |
| 120 | + it 'applies changes with no errors' do |
| 121 | + apply_manifest_on(default, manifest, expect_changes: true) |
| 122 | + end |
| 123 | + |
| 124 | + it 'applies a second time without changes' do |
| 125 | + apply_manifest_on(default, manifest, catch_changes: true) |
| 126 | + end |
| 127 | + end |
| 128 | + |
| 129 | + describe command("keytool -list -keystore #{truststore_path} -storepass other-password") do |
| 130 | + its(:exit_status) { should eq 0 } |
| 131 | + its(:stdout) { should match(/^Keystore type: PKCS12$/i) } |
| 132 | + its(:stdout) { should match(/^Your keystore contains 0 entries$/) } |
| 133 | + end |
| 134 | + end |
| 135 | + |
| 136 | + describe 'noop' do |
| 137 | + describe 'change password file' do |
| 138 | + let(:manifest) do |
| 139 | + <<-PUPPET |
| 140 | + file { '/etc/pki/truststore_password-file': |
| 141 | + ensure => file, |
| 142 | + content => 'wrong-password', |
| 143 | + owner => 'root', |
| 144 | + group => 'root', |
| 145 | + mode => '0440', |
| 146 | + show_diff => false, |
| 147 | + } |
| 148 | + PUPPET |
| 149 | + end |
| 150 | + |
| 151 | + it 'applies changes with no errors' do |
| 152 | + apply_manifest_on(default, manifest, catch_failures: true) |
| 153 | + end |
| 154 | + end |
| 155 | + |
| 156 | + describe 'run in noop mode with wrong password' do |
| 157 | + let(:manifest) do |
| 158 | + <<-PUPPET |
| 159 | + $truststore_password_file = '/etc/pki/truststore_password-file' |
| 160 | +
|
| 161 | + package { 'java-11-openjdk-headless': |
| 162 | + ensure => installed, |
| 163 | + } |
| 164 | +
|
| 165 | + file { $truststore_password_file: |
| 166 | + ensure => file, |
| 167 | + content => 'other-password', |
| 168 | + owner => 'root', |
| 169 | + group => 'root', |
| 170 | + mode => '0440', |
| 171 | + show_diff => false, |
| 172 | + } |
| 173 | +
|
| 174 | + truststore { "/etc/pki/truststore": |
| 175 | + ensure => present, |
| 176 | + password_file => $truststore_password_file, |
| 177 | + owner => 'root', |
| 178 | + group => 'root', |
| 179 | + mode => '0640', |
| 180 | + } |
| 181 | + PUPPET |
| 182 | + end |
| 183 | + |
| 184 | + it 'applies changes with no errors' do |
| 185 | + apply_manifest_on(default, manifest, noop: true) |
| 186 | + end |
| 187 | + end |
| 188 | + |
| 189 | + describe file(truststore_path) do |
| 190 | + it { is_expected.to be_file } |
| 191 | + end |
| 192 | + |
| 193 | + # Should still be readable with the old password |
| 194 | + describe command("keytool -list -keystore #{truststore_path} -storepass other-password") do |
| 195 | + its(:exit_status) { should eq 0 } |
| 196 | + its(:stdout) { should match(/^Keystore type: PKCS12$/i) } |
| 197 | + its(:stdout) { should match(/^Your keystore contains 0 entries$/) } |
| 198 | + end |
| 199 | + end |
90 | 200 | end |
91 | 201 | end |
0 commit comments