Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pdk Templates
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
puppet-infra
Pdk Templates
Commits
0b5b39b6
Unverified
Commit
0b5b39b6
authored
5 years ago
by
Jesse Scott
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #286 from rodjek/gh-283
(#283) Unwrap password in transport object template
parents
6b5ed922
364956f2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
object_templates/transport.erb
+1
-1
1 addition, 1 deletion
object_templates/transport.erb
object_templates/transport_spec.erb
+3
-2
3 additions, 2 deletions
object_templates/transport_spec.erb
with
4 additions
and
3 deletions
object_templates/transport.erb
+
1
−
1
View file @
0b5b39b6
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
object_templates/transport_spec.erb
+
3
−
2
View file @
0b5b39b6
...
@@ -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}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment