This repository has been archived by the owner on Jan 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add missing final newline to berskfile - Remove update suite from kitchen.yml, as this is now tested in Chefspec - Update test/recipes/lwrp_x509.rb to delete existing certificate files before creating new ones - Add explicit license to test recipes - Create serverspec suite to verify x509 lwrp
- Loading branch information
Charles Johnson
committed
Jun 20, 2015
1 parent
44c8dd3
commit 7d72d97
Showing
8 changed files
with
91 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# Cookbook Name:: test | ||
# Recipe:: default | ||
# | ||
# Copyright:: Copyright (c) 2014, Chef Software, Inc. <[email protected]> | ||
# Copyright:: Copyright (c) 2014-2015, Chef Software, Inc. <[email protected]> | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
# | ||
# Cookbook Name:: test | ||
# Recipe:: httpd | ||
# | ||
# Copyright:: Copyright (c) 2015, Chef Software, Inc. <[email protected]> | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
service('httpd') { action :nothing } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
# | ||
# Cookbook Name:: test | ||
# Recipe:: lwrp_x509 | ||
# | ||
# Copyright:: Copyright (c) 2015, Chef Software, Inc. <[email protected]> | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Ensure files are not present, so the lwrp makes new keys every time | ||
file '/etc/ssl_test/mycert.crt' do | ||
action :delete | ||
end | ||
|
||
file '/etc/ssl_test/mycert.key' do | ||
action :delete | ||
end | ||
|
||
# Create directory if not already present | ||
directory '/etc/ssl_test' do | ||
recursive true | ||
end | ||
|
||
# Generate new key and certificate | ||
openssl_x509 '/etc/ssl_test/mycert.crt' do | ||
common_name 'mycert.example.com' | ||
org 'Test Kitchen Example' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'serverspec' | ||
|
||
set :backend, :exec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
require 'openssl' | ||
|
||
describe 'test::lwrp_x509' do | ||
# Serverspec examples can be found at | ||
# http://serverspec.org/resource_types.html | ||
describe command('openssl rsa -in /etc/ssl_test/mycert.key -check -noout') do | ||
it 'generates a valid private key' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
describe command('openssl x509 -in /etc/ssl_test/mycert.crt -noout') do | ||
it 'generates a valid x509 cert' do | ||
expect(subject.exit_status).to eq 0 | ||
end | ||
end | ||
|
||
it 'The certificate is verifiable against the key file' do | ||
cert = OpenSSL::X509::Certificate.new File.read('/etc/ssl_test/mycert.crt') | ||
key = OpenSSL::PKey::RSA.new File.read('/etc/ssl_test/mycert.key') | ||
expect(cert.verify(key)).to be_truthy | ||
end | ||
end |