Showing with 42 additions and 12 deletions.
  1. +8 −6 CHANGELOG.md
  2. +1 −0 lib/puppet/functions/azure_key_vault/secret.rb
  3. +1 −1 metadata.json
  4. +32 −5 spec/functions/azure_key_vault_secret_spec.rb
14 changes: 8 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [1.0.0](https://github.com/tragiccode/tragiccode-azure_key_vault/tree/1.0.0) (2018-10-25)

[Full Changelog](https://github.com/tragiccode/tragiccode-azure_key_vault/compare/0.4.0...1.0.0)

### Added

- \(GH-12\) Added Better Unit Tests to puppet function [\#25](https://github.com/TraGicCode/tragiccode-azure_key_vault/pull/25) ([TraGicCode](https://github.com/TraGicCode))

## [0.4.0](https://github.com/tragiccode/tragiccode-azure_key_vault/tree/0.4.0) (2018-10-24)

[Full Changelog](https://github.com/tragiccode/tragiccode-azure_key_vault/compare/0.3.0...0.4.0)
Expand All @@ -10,12 +18,6 @@ All notable changes to this project will be documented in this file. The format

- Add a Hiera backend [\#13](https://github.com/TraGicCode/tragiccode-azure_key_vault/pull/13) ([hbuckle](https://github.com/hbuckle))

### UNCATEGORIZED PRS; GO LABEL THEM

- \(GH-20\) Update pdk template to latest [\#22](https://github.com/TraGicCode/tragiccode-azure_key_vault/pull/22) ([TraGicCode](https://github.com/TraGicCode))
- \(GH-14\) Adding tags to metadata.json [\#18](https://github.com/TraGicCode/tragiccode-azure_key_vault/pull/18) ([TraGicCode](https://github.com/TraGicCode))
- \(GH-15\) Fix forge link for reference.md [\#16](https://github.com/TraGicCode/tragiccode-azure_key_vault/pull/16) ([TraGicCode](https://github.com/TraGicCode))

## [0.3.0](https://github.com/tragiccode/tragiccode-azure_key_vault/tree/0.3.0) (2018-09-26)

[Full Changelog](https://github.com/tragiccode/tragiccode-azure_key_vault/compare/0.2.0...0.3.0)
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/functions/azure_key_vault/secret.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def secret(vault_name, secret_name, api_versions_hash, secret_version = '')
access_token,
secret_version,
)

Puppet::Pops::Types::PSensitiveType::Sensitive.new(secret_value)
end
end
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tragiccode-azure_key_vault",
"version": "0.4.0",
"version": "1.0.0",
"author": "tragiccode",
"summary": "The azure_key_vault module allows you to easily fetch secrets securely within your puppet manifests.",
"license": "Apache-2.0",
Expand Down
37 changes: 32 additions & 5 deletions spec/functions/azure_key_vault_secret_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,49 @@
}
end

let(:vault_name) { 'production-vault' }
let(:secret_name) { 'super-secret' }
let(:secret_value) { 'super-secret-value' }
let(:access_token) { 'random-access-token' }
let(:secret_version) { 'a7f7es9a7d' }

it { is_expected.not_to eq(nil) }

context 'when passed the wrong number of arguments' do
it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects between 3 and 4 arguments}i) }
end

context 'when getting the latest version of a secret' do
# it { is_expected.to run.with_params('production-vault', 'super-secret', api_versions_hash).and_return('https://production-vault.vault.azure.net/secrets/super-secret') }
pending
it 'defaults to using an empty string as the latest version' do
expect(TragicCode::Azure).to receive(:get_access_token).with(api_versions_hash['metadata_api_version']).and_return(access_token)
expect(TragicCode::Azure).to receive(:get_secret).with(vault_name, secret_name, api_versions_hash['vault_api_version'], access_token, '')

is_expected.to run.with_params(vault_name, secret_name, api_versions_hash)
end
end

context 'when getting a specific version of a secret' do
pending
it 'uses the secret version when retreiving the secret' do
expect(TragicCode::Azure).to receive(:get_access_token).with(api_versions_hash['metadata_api_version']).and_return(access_token)
expect(TragicCode::Azure).to receive(:get_secret).with(vault_name, secret_name, api_versions_hash['vault_api_version'], access_token, secret_version)

is_expected.to run.with_params(vault_name, secret_name, api_versions_hash, secret_version)
end
end

context 'when passing a malformed api-version' do
pending
# rubocop:disable RSpec/NamedSubject
it 'returns the secret' do
expect(TragicCode::Azure).to receive(:get_access_token).with(api_versions_hash['metadata_api_version']).and_return(access_token)
expect(TragicCode::Azure).to receive(:get_secret).with(vault_name, secret_name, api_versions_hash['vault_api_version'], access_token, '').and_return(secret_value)

expect(subject.execute(vault_name, secret_name, api_versions_hash).unwrap).to eq secret_value
end

it 'returns the secret wrapped in the sensitive data type' do
expect(TragicCode::Azure).to receive(:get_access_token).with(api_versions_hash['metadata_api_version']).and_return(access_token)
expect(TragicCode::Azure).to receive(:get_secret).with(vault_name, secret_name, api_versions_hash['vault_api_version'], access_token, '').and_return(secret_value)

expect(subject.execute(vault_name, secret_name, api_versions_hash)).to be_an_instance_of(Puppet::Pops::Types::PSensitiveType::Sensitive)
end
# rubocop:enable RSpec/NamedSubject
end