Browse Source

changing how and where files are declared, updating tests

master
Aaron Hicks 6 years ago
parent
commit
6e6c5669e2
2 changed files with 48 additions and 15 deletions
  1. 22
    15
      manifests/keymaster/setup.pp
  2. 26
    0
      spec/classes/setup_spec.rb

+ 22
- 15
manifests/keymaster/setup.pp View File

@@ -31,11 +31,18 @@ define gpg::keymaster::setup(
$secret_file = "${key_dir}/${title}_secret.gpg"
$public_file = "${key_dir}/${title}_public.gpg"

$secret_content = file($secret_file,'/dev/null')
if $secret_content {
if $ensure == 'present' {
# Remove existing key pair, if;
# $force is true
file { $key_dir:
ensure => directory,
mode => 644;
}

if $ensure == 'present' {
# Remove existing key pair, if;
# $force is true

$secret_content = file($secret_file,'/dev/null')
if $secret_content {


if $force {
$reason = 'force is true'
@@ -47,18 +54,18 @@ define gpg::keymaster::setup(
before => Exec["Create GPG keygen file for ${title}","Create GPG key pair for ${title}"]
}
}

# Putting some of the key parameters in the comment
$comment = "${keytype} ${keylength} ${subkeytype} ${subkeylength}"

# Create the GPG key gen file for using gpg in batch mode
$keygen_content = template('gpg/keygen.txt.erb')
generate('echo',"'${keygen_content}'",'>',$keygen_file)

# Create the GPG key pair

}
}
# Check certificate expiry

# Putting some of the key parameters in the comment
$comment = "${keytype} ${keylength} ${subkeytype} ${subkeylength}"

# Create the GPG key gen file for using gpg in batch mode
file{$keygen_file:
ensure => $ensure,
content => template('gpg/keygen.txt.erb')
}

# Create the GPG key pair
}

+ 26
- 0
spec/classes/setup_spec.rb View File

@@ -0,0 +1,26 @@
require 'spec_helper'

describe 'gpg::keymaster::setup', :type => :class do
context "on a Debian OS" do
let :facts do
{
:osfamily => 'Debian'
}
end
let(:params) {{:title => 'test'}}
it { should include_class("gpg::params")}
it { should contain_file("/var/lib/puppet-keymaster/gpg/test")}
it { should contain_file("/var/lib/puppet-keymaster/gpg/test/keygen.txt")}
end
context "on a RedHat OS" do
let :facts do
{
:osfamily => 'RedHat'
}
end
let(:params) {{:title => 'test'}}
it { should include_class("gpg::params")}
it { should contain_file("/var/lib/puppet-keymaster/gpg/test")}
it { should contain_file("/var/lib/puppet-keymaster/gpg/test/keygen.txt")}
end
end

Loading…
Cancel
Save