Skip to content

Commit

Permalink
x509 integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
  • Loading branch information
chris-rock committed Mar 22, 2017
1 parent 25a086f commit 9dcc3a1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/cookbooks/os_prepare/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
depends 'httpd', '~> 0.2'
depends 'windows'
depends 'ssh-hardening'
depends 'openssl'
1 change: 1 addition & 0 deletions test/cookbooks/os_prepare/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
include_recipe('os_prepare::registry_key')
include_recipe('os_prepare::iis_site')
include_recipe('os_prepare::iptables') unless node['osprepare']['docker']
include_recipe('os_prepare::x509')

# config file parsing
include_recipe('os_prepare::json_yaml_csv_ini')
Expand Down
15 changes: 15 additions & 0 deletions test/cookbooks/os_prepare/recipes/x509.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if node['platform_family'] != 'windows'

openssl_x509 '/tmp/mycert.pem' do
common_name 'www.f00bar.com'
org 'Foo Bar'
org_unit 'Lab'
country 'US'
expire 360
end

openssl_rsa_key '/tmp/server.key' do
key_length 2048
end

end
24 changes: 24 additions & 0 deletions test/integration/default/x509_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# encoding: utf-8

if os.windows?
STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on Linux.\033[0m"
return
end

describe x509_certificate('/tmp/mycert.pem') do
it { should be_certificate }
it { should be_valid }
its('signature_algorithm') { should eq 'sha256WithRSAEncryption' }
its('validity_in_days') { should_not be < 100 }
its('validity_in_days') { should be >= 100 }
its('subject_dn') { should eq '/C=US/O=Foo Bar/OU=Lab/CN=www.f00bar.com' }
its('subject.C') { should eq 'US' }
its('issuer_dn') { should eq '/C=US/O=Foo Bar/OU=Lab/CN=www.f00bar.com' }
its('key_length') { should be >= 2048 }
end

describe key_rsa('/tmp/server.key') do
it { should be_private }
it { should be_public }
its('key_length') { should eq 2048 }
end

0 comments on commit 9dcc3a1

Please sign in to comment.