Extract logic for current target ssh user name:
Add Remote#user_name method, with code returning which user name will be used for SSH authentication.
This commit is contained in:
parent
868c502531
commit
9985fceb63
@ -11,7 +11,11 @@ module Producer
|
||||
end
|
||||
|
||||
def session
|
||||
@session ||= Net::SSH.start(@hostname, Etc.getlogin)
|
||||
@session ||= Net::SSH.start(@hostname, user_name)
|
||||
end
|
||||
|
||||
def user_name
|
||||
Etc.getlogin
|
||||
end
|
||||
|
||||
def fs
|
||||
|
@ -12,8 +12,8 @@ module Producer::Core
|
||||
end
|
||||
|
||||
describe '#session' do
|
||||
it 'builds a new SSH session to the remote host' do
|
||||
expect(Net::SSH).to receive(:start).with(hostname, Etc.getlogin)
|
||||
it 'builds a new SSH session to the remote host with #user_name' do
|
||||
expect(Net::SSH).to receive(:start).with(hostname, remote.user_name)
|
||||
remote.session
|
||||
end
|
||||
|
||||
@ -29,6 +29,12 @@ module Producer::Core
|
||||
end
|
||||
end
|
||||
|
||||
describe '#user_name' do
|
||||
it 'returns the name of the user currently logged in' do
|
||||
expect(remote.user_name).to eq Etc.getlogin
|
||||
end
|
||||
end
|
||||
|
||||
describe '#fs' do
|
||||
it 'builds a new FS' do
|
||||
expect(Remote::FS).to receive(:new)
|
||||
|
Loading…
x
Reference in New Issue
Block a user