Skip to content

Commit

Permalink
Merge pull request #243 from bastelfreak/pfx
Browse files Browse the repository at this point in the history
openssl::export::pem_key: Add acceptance tests
  • Loading branch information
bastelfreak authored Feb 10, 2025
2 parents 084efb7 + 67a023f commit bda0310
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
43 changes: 43 additions & 0 deletions examples/export_pem_from_pkcs12.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
openssl::certificate::x509 { 'export_pem_from_pkcs12.example.com':
ensure => present,
country => 'CH',
organization => 'Example.com',
commonname => 'export_pem_from_pkcs12.example.com',
base_dir => '/tmp',
owner => 'nobody',
# This is just to speed up CI - use 2048 or more in production
key_size => 1024,
}
-> openssl::export::pkcs12 { 'export1_pem_from_pkcs12.pkcs12':
ensure => 'present',
basedir => '/tmp',
pkey => '/tmp/export_pem_from_pkcs12.example.com.key',
cert => '/tmp/export_pem_from_pkcs12.example.com.crt',
out_pass => 'mahje1Qu',
}
-> openssl::export::pkcs12 { 'export2_pem_from_pkcs12.pkcs12':
ensure => 'present',
basedir => '/tmp',
pkey => '/tmp/export_pem_from_pkcs12.example.com.key',
cert => '/tmp/export_pem_from_pkcs12.example.com.crt',
}
# import pkcs12 without pass, generate pem with pass
-> openssl::export::pem_key { '/tmp/export1_pem_from_pkcs12.pem':
pfx_cert => '/tmp/export2_pem_from_pkcs12.pkcs12.p12',
out_pass => 'mahje1Qu',
}
# import pkcs12 with pass, generate pem with pass
-> openssl::export::pem_key { '/tmp/export2_pem_from_pkcs12.pem':
pfx_cert => '/tmp/export1_pem_from_pkcs12.pkcs12.p12',
in_pass => 'mahje1Qu',
out_pass => 'mahje1Qu',
}
# import pkcs12 with pass, generate pem without pass
-> openssl::export::pem_key { '/tmp/export3_pem_from_pkcs12.pem':
pfx_cert => '/tmp/export1_pem_from_pkcs12.pkcs12.p12',
in_pass => 'mahje1Qu',
}
# import pkcs12 without pass, generate pem without pass
-> openssl::export::pem_key { '/tmp/export4_pem_from_pkcs12.pem':
pfx_cert => '/tmp/export2_pem_from_pkcs12.pkcs12.p12',
}
31 changes: 31 additions & 0 deletions spec/acceptance/export_pem_from_pkcs12.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'pkcs12 example' do
it_behaves_like 'the example', 'export_pem_from_pkcs12.pp' do
it { expect(file('/tmp/export_pem_from_pkcs12.example.com.crt')).to be_file.and(have_attributes(owner: 'nobody', group: 'root')) }
it { expect(file('/tmp/export_pem_from_pkcs12.example.com.key')).to be_file.and(have_attributes(owner: 'nobody', group: 'root')) }
it { expect(file('/tmp/export1_pem_from_pkcs12.pkcs12.p12')).to be_file.and(have_attributes(owner: 'root', group: 'root')) }
it { expect(file('/tmp/export2_pem_from_pkcs12.pkcs12.p12')).to be_file.and(have_attributes(owner: 'root', group: 'root')) }
it { expect(file('/tmp/export3_pem_from_pkcs12.pkcs12.p12')).to be_file.and(have_attributes(owner: 'root', group: 'root')) }
it { expect(file('/tmp/export4_pem_from_pkcs12.pkcs12.p12')).to be_file.and(have_attributes(owner: 'root', group: 'root')) }
end
# rubocop:disable RSpec/RepeatedExampleGroupBody
describe file('/tmp/export1_pem_from_pkcs12.pkcs12.p12') do
its(:size) { is_expected.to be > 0 }
end

describe file('/tmp/export2_pem_from_pkcs12.pkcs12.p12') do
its(:size) { is_expected.to be > 0 }
end

describe file('/tmp/export3_pem_from_pkcs12.pkcs12.p12') do
its(:size) { is_expected.to be > 0 }
end

describe file('/tmp/export4_pem_from_pkcs12.pkcs12.p12') do
its(:size) { is_expected.to be > 0 }
end
# rubocop:enable RSpec/RepeatedExampleGroupBody
end

0 comments on commit bda0310

Please sign in to comment.