Skip to content
Snippets Groups Projects
Unverified Commit 0b5b39b6 authored by Jesse Scott's avatar Jesse Scott Committed by GitHub
Browse files

Merge pull request #286 from rodjek/gh-283

(#283) Unwrap password in transport object template
parents 6b5ed922 364956f2
Branches
Tags
No related merge requests found
...@@ -16,7 +16,7 @@ module Puppet::Transport ...@@ -16,7 +16,7 @@ module Puppet::Transport
context.debug("Checking connection to #{@connection_info[:host]}:#{@connection_info[:port]}") context.debug("Checking connection to #{@connection_info[:host]}:#{@connection_info[:port]}")
# in a real world implementation, the password would be checked by connecting # in a real world implementation, the password would be checked by connecting
# to the target device or checking that an existing connection is still alive # to the target device or checking that an existing connection is still alive
raise 'authentication error' if @connection_info[:password] == 'invalid' raise 'authentication error' if @connection_info[:password].unwrap == 'invalid'
end end
# Retrieve facts from the target and return in a hash # Retrieve facts from the target and return in a hash
......
...@@ -6,11 +6,12 @@ RSpec.describe Puppet::Transport::<%= transport_class %> do ...@@ -6,11 +6,12 @@ RSpec.describe Puppet::Transport::<%= transport_class %> do
subject(:transport) { described_class.new(context, connection_info) } subject(:transport) { described_class.new(context, connection_info) }
let(:context) { instance_double('Puppet::ResourceApi::BaseContext', 'context') } let(:context) { instance_double('Puppet::ResourceApi::BaseContext', 'context') }
let(:password) { 'aih6cu6ohvohpahN' }
let(:connection_info) do let(:connection_info) do
{ {
host: 'api.example.com', host: 'api.example.com',
user: 'admin', user: 'admin',
password: 'aih6cu6ohvohpahN', password: Puppet::Pops::Types::PSensitiveType::Sensitive.new(password),
} }
end end
...@@ -30,7 +31,7 @@ RSpec.describe Puppet::Transport::<%= transport_class %> do ...@@ -30,7 +31,7 @@ RSpec.describe Puppet::Transport::<%= transport_class %> do
end end
context 'with invalid credentials' do context 'with invalid credentials' do
let(:connection_info) { super().merge(password: 'invalid') } let(:password) { 'invalid' }
it 'raises an error' do it 'raises an error' do
expect { transport.verify(context) }.to raise_error RuntimeError, %r{authentication error} expect { transport.verify(context) }.to raise_error RuntimeError, %r{authentication error}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment