16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
##2014-07-10 - Supported Release 1.2.5
###Summary

This release has bugfixes and test improvements.

####Features
- Update tests to use RSpec 2.99 syntax

####Bugfixes
- Remove broken support for puppet:// files.
- Remove incorrect statment of windows support from metadata.json.
- Fix path issue for openssl on solaris 11.

####Known Bugs
* No known bugs

##2014-06-04 - Release 1.2.4
###Summary

Expand Down
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :development, :test do
gem 'rake'
gem 'rspec', :require => false
gem 'mocha', :require => false
gem 'mocha'
gem 'puppet-lint', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'beaker-rspec','~> 2.2', :require => false
gem 'rspec','~> 2.99', :require => false
gem 'serverspec', :require => false
end

Expand Down
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'puppetlabs-java_ks'
version '1.2.4'
version '1.2.5'

author 'puppetlabs'
license 'ASL 2.0'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ This resource manages the entries in a java keystore, and uses composite namevar

#### `certificate`

An already-signed certificate to place in the keystore. Accepts local file paths or `puppet://` uri paths.
An already-signed certificate to place in the keystore. This file must be present on the node before java_ks{} is run.

To have a java application server use a specific certificate for incoming connections, you will need to simultaneously import the private key accompanying the signed certificate you want to use. As long as you provide the path to the key and the certificate, the provider will do the conversion for you.

#### `chain`

Some java applications do not properly send intermediary certificate authorities. In these cases, you can bundle them with the server certificate using this chain parameter. Accepts local file paths or `puppet://` uri paths.
Some java applications do not properly send intermediary certificate authorities. In these cases, you can bundle them with the server certificate using this chain parameter. This file must be present on the node before java_ks{} is run.

java_ks { 'broker.example.com:/etc/activemq/broker.jks':
ensure => latest,
Expand Down Expand Up @@ -103,7 +103,7 @@ The search path used for command (keytool, openssl) execution. Paths can be spec

#### `private_key`

If you want an application to be a server and encrypt traffic, you will need a private key. Private key entries in a keystore must be accompanied by a signed certificate for the keytool provider. Accepts local file paths or `puppet://` uri paths.
If you want an application to be a server and encrypt traffic, you will need a private key. Private key entries in a keystore must be accompanied by a signed certificate for the keytool provider. This file must be present on the node before java_ks{} is run.

#### `target`

Expand Down
14 changes: 3 additions & 11 deletions lib/puppet/provider/java_ks/keytool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,15 @@ def update
end

def certificate
file_path @resource[:certificate]
@resource[:certificate]
end

def private_key
file_path @resource[:private_key]
@resource[:private_key]
end

def chain
file_path @resource[:chain]
end

def file_path(path)
return path unless path and path.start_with? 'puppet://'

served_file = Puppet::FileServing::Metadata.indirection.find(path, :environment => @resource.catalog.environment)
self.fail "Could not retrieve information for #{path}" unless served_file
served_file.full_path
@resource[:chain]
end

def run_command(cmd, target=false, stdinfile=false, env={})
Expand Down
13 changes: 1 addition & 12 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-java_ks",
"version": "1.2.4",
"version": "1.2.5",
"source": "https://github.com/puppetlabs/puppetlabs-java_ks",
"author": "Puppet Labs",
"license": "Apache-2.0",
Expand Down Expand Up @@ -67,20 +67,9 @@
"11"
]
},
{
"operatingsystem": "Windows",
"operatingsystemrelease": [
"Server 2003 R2",
"Server 2008 R2",
"Server 2012",
"Server 2012 R2",
"7"
]
},
{
"operatingsystem": "AIX",
"operatingsystemrelease": [
"5.3",
"6.1",
"7.1"
]
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/keystore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
case fact('osfamily')
when "Solaris"
keytool_path = '/usr/java/bin/'
resource_path = "['/usr/java/bin/','/opt/puppet/bin/']"
resource_path = "['/usr/java/bin/','/opt/puppet/bin/','/usr/bin/']"
when "AIX"
keytool_path = '/usr/java6/bin/'
resource_path = "['/usr/java6/bin/','/usr/bin/']"
Expand Down
53 changes: 1 addition & 52 deletions spec/acceptance/private_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
case fact('osfamily')
when "Solaris"
keytool_path = '/usr/java/bin/'
resource_path = "['/usr/java/bin/','/opt/puppet/bin/']"
resource_path = "['/usr/java/bin/','/opt/puppet/bin/','/usr/bin/']"
when "AIX"
keytool_path = '/usr/java6/bin/'
resource_path = "['/usr/java6/bin/','/usr/bin/']"
Expand Down Expand Up @@ -37,55 +37,4 @@
expect(r.stdout).to match(/CN=Puppet CA/)
end
end

describe 'from a puppet:// uri' do
it 'puts a key in a module' do
pp = <<-EOS
file { [
"#{modulepath}/keys",
"#{modulepath}/keys/files",
]:
ensure => directory,
}
file { "#{modulepath}/keys/files/ca.pem":
ensure => file,
source => "${settings::ssldir}/certs/ca.pem",
}
file { "#{modulepath}/keys/files/certificate.pem":
ensure => file,
source => "${settings::ssldir}/certs/#{hostname}.pem",
}
file { "#{modulepath}/keys/files/private_key.pem":
ensure => file,
source => "${settings::ssldir}/private_keys/#{hostname}.pem",
}
EOS

apply_manifest(pp, :catch_failures => true)
end

it 'creates a keystore' do
pp = <<-EOS
java_ks { 'uri.example.com:/etc/uri_key.ks':
ensure => latest,
certificate => 'puppet:///modules/keys/certificate.pem',
private_key => 'puppet:///modules/keys/private_key.pem',
chain => 'puppet:///modules/keys/ca.pem',
password => 'puppet',
path => #{resource_path},
}
EOS

apply_manifest(pp, :catch_failures => true)
end

it 'verifies the private key' do
shell("#{keytool_path}keytool -list -v -keystore /etc/uri_key.ks -storepass puppet") do |r|
expect(r.exit_code).to be_zero
expect(r.stdout).to match(/Alias name: uri\.example\.com/)
expect(r.stdout).to match(/Entry type: (keyEntry|PrivateKeyEntry)/)
expect(r.stdout).to match(/CN=Puppet CA/)
end
end
end
end
2 changes: 1 addition & 1 deletion spec/acceptance/truststore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
case fact('osfamily')
when "Solaris"
keytool_path = '/usr/java/bin/'
resource_path = "['/usr/java/bin/','/opt/puppet/bin/']"
resource_path = "['/usr/java/bin/','/opt/puppet/bin/','/usr/bin/']"
when "AIX"
keytool_path = '/usr/java6/bin/'
resource_path = "['/usr/java6/bin/','/usr/bin/']"
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/unsupported_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
case fact('osfamily')
when "Solaris"
keytool_path = '/usr/java/bin/'
resource_path = "['/usr/java/bin/','/opt/puppet/bin/']"
resource_path = "['/usr/java/bin/','/opt/puppet/bin/','/usr/bin/']"
when "AIX"
keytool_path = '/usr/java6/bin/'
resource_path = "['/usr/java6/bin/','/opt/puppet/bin/']"
Expand Down
2 changes: 1 addition & 1 deletion spec/hosts/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

describe 'default' do
it 'should work' do
should contain_java_ks('puppetca:truststore')
is_expected.to contain_java_ks('puppetca:truststore')
end
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
require 'puppetlabs_spec_helper/module_spec_helper'

RSpec.configure do |config|
config.mock_framework = :mocha
end
36 changes: 18 additions & 18 deletions spec/unit/puppet/type/java_ks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
end

it 'should default to being present' do
Puppet::Type.type(:java_ks).new(@app_example_com)[:ensure].should == :present
expect(Puppet::Type.type(:java_ks).new(@app_example_com)[:ensure]).to eq(:present)
end

describe 'when validating attributes' do

[:name, :target, :private_key, :certificate, :password, :password_file, :trustcacerts].each do |param|
it "should have a #{param} parameter" do
Puppet::Type.type(:java_ks).attrtype(param).should == :param
expect(Puppet::Type.type(:java_ks).attrtype(param)).to eq(:param)
end
end

[:ensure].each do |prop|
it "should have a #{prop} property" do
Puppet::Type.type(:java_ks).attrtype(prop).should == :property
expect(Puppet::Type.type(:java_ks).attrtype(prop)).to eq(:property)
end
end
end
Expand All @@ -51,38 +51,38 @@
it "first half of title should map to name parameter" do
jks = jks_resource.dup
jks.delete(:name)
Puppet::Type.type(:java_ks).new(jks)[:name].should == jks_resource[:name]
expect(Puppet::Type.type(:java_ks).new(jks)[:name]).to eq(jks_resource[:name])
end

it "second half of title should map to target parameter when no target is supplied" do
jks = jks_resource.dup
jks.delete(:target)
Puppet::Type.type(:java_ks).new(jks)[:target].should == jks_resource[:target]
expect(Puppet::Type.type(:java_ks).new(jks)[:target]).to eq(jks_resource[:target])
end

it "second half of title should not map to target parameter when target is supplied" do
jks = jks_resource.dup
jks[:target] = '/tmp/some_other_app.jks'
Puppet::Type.type(:java_ks).new(jks)[:target].should_not == jks_resource[:target]
Puppet::Type.type(:java_ks).new(jks)[:target].should == '/tmp/some_other_app.jks'
expect(Puppet::Type.type(:java_ks).new(jks)[:target]).not_to eq(jks_resource[:target])
expect(Puppet::Type.type(:java_ks).new(jks)[:target]).to eq('/tmp/some_other_app.jks')
end

it 'title components should map to namevar parameters' do
jks = jks_resource.dup
jks.delete(:name)
jks.delete(:target)
Puppet::Type.type(:java_ks).new(jks)[:name].should == jks_resource[:name]
Puppet::Type.type(:java_ks).new(jks)[:target].should == jks_resource[:target]
expect(Puppet::Type.type(:java_ks).new(jks)[:name]).to eq(jks_resource[:name])
expect(Puppet::Type.type(:java_ks).new(jks)[:target]).to eq(jks_resource[:target])
end

it 'should downcase :name values' do
jks = jks_resource.dup
jks[:name] = 'APP.EXAMPLE.COM'
Puppet::Type.type(:java_ks).new(jks)[:name].should == jks_resource[:name]
expect(Puppet::Type.type(:java_ks).new(jks)[:name]).to eq(jks_resource[:name])
end

it 'should have :false value to :trustcacerts when parameter not provided' do
Puppet::Type.type(:java_ks).new(jks_resource)[:trustcacerts].should == :false
expect(Puppet::Type.type(:java_ks).new(jks_resource)[:trustcacerts]).to eq(:false)
end

it 'should fail if both :password and :password_file are provided' do
Expand Down Expand Up @@ -116,21 +116,21 @@
jks[:ensure] = :latest
@provider.stubs(:latest).returns('AF:61:1C:FF:C7:C0:B2:C6:37:C5:D1:6E:00:AB:7A:B2')
@provider.stubs(:current).returns('B4:54:EB:55:86:41:84:2E:22:A0:6A:36:1B:28:47:76')
Puppet::Type.type(:java_ks).new(jks).property(:ensure).insync?(:present).should be_false
expect(Puppet::Type.type(:java_ks).new(jks).property(:ensure).insync?(:present)).to be_falsey
end

it 'insync? should return false if state is :absent' do
jks = jks_resource.dup
jks[:ensure] = :latest
Puppet::Type.type(:java_ks).new(jks).property(:ensure).insync?(:absent).should be_false
expect(Puppet::Type.type(:java_ks).new(jks).property(:ensure).insync?(:absent)).to be_falsey
end

it 'insync? should return true if md5 fingerprints match and state is :present' do
jks = jks_resource.dup
jks[:ensure] = :latest
@provider.stubs(:latest).returns('AF:61:1C:FF:C7:C0:B2:C6:37:C5:D1:6E:00:AB:7A:B2')
@provider.stubs(:current).returns('AF:61:1C:FF:C7:C0:B2:C6:37:C5:D1:6E:00:AB:7A:B2')
Puppet::Type.type(:java_ks).new(jks).property(:ensure).insync?(:present).should be_true
expect(Puppet::Type.type(:java_ks).new(jks).property(:ensure).insync?(:present)).to be_truthy
end
end

Expand All @@ -150,8 +150,8 @@
end

rel = test_jks.autorequire[0]
rel.source.ref.should == test_file.ref
rel.target.ref.should == test_jks.ref
expect(rel.source.ref).to eq(test_file.ref)
expect(rel.target.ref).to eq(test_jks.ref)
end
end

Expand All @@ -164,8 +164,8 @@
end

rel = test_jks.autorequire[0]
rel.source.ref.should == test_file.ref
rel.target.ref.should == test_jks.ref
expect(rel.source.ref).to eq(test_file.ref)
expect(rel.target.ref).to eq(test_jks.ref)
end
end
end