Use SSH user name configured for a given target:
When a user is configured for the targeted host name, use it for SSH authentification instead of the name of current user logged in. * Modify Remote#user_name to use configured user name.
This commit is contained in:
22
features/ssh/config.feature
Normal file
22
features/ssh/config.feature
Normal file
@@ -0,0 +1,22 @@
|
||||
Feature: SSH settings
|
||||
|
||||
Background:
|
||||
Given a recipe with:
|
||||
"""
|
||||
target 'some_host.example'
|
||||
|
||||
puts env.remote.user_name
|
||||
"""
|
||||
|
||||
Scenario: uses current user login name as SSH user name by default
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain my current login name
|
||||
|
||||
Scenario: uses configured SSH user name for a given host
|
||||
Given an SSH config with:
|
||||
"""
|
||||
Host some_host.example
|
||||
User some_user
|
||||
"""
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "some_user"
|
5
features/steps/etc_steps.rb
Normal file
5
features/steps/etc_steps.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# FIXME: our monkey patch currently prevent us from using `must' in step
|
||||
# definitions.
|
||||
Then(/^the output should contain my current login name$/) do
|
||||
assert_partial_output(Etc.getlogin, all_output)
|
||||
end
|
6
features/steps/ssh_steps.rb
Normal file
6
features/steps/ssh_steps.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# FIXME: current home directory shouldn't be changed here, maybe we should use
|
||||
# a tag for features needing a fake home directory.
|
||||
Given(/^an SSH config with:$/) do |config|
|
||||
ENV['HOME'] = File.expand_path current_dir
|
||||
write_file '.ssh/config', config
|
||||
end
|
Reference in New Issue
Block a user