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
|
end
|
||||||
|
|
||||||
def session
|
def session
|
||||||
@session ||= Net::SSH.start(@hostname, Etc.getlogin)
|
@session ||= Net::SSH.start(@hostname, user_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_name
|
||||||
|
Etc.getlogin
|
||||||
end
|
end
|
||||||
|
|
||||||
def fs
|
def fs
|
||||||
|
@ -12,8 +12,8 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#session' do
|
describe '#session' do
|
||||||
it 'builds a new SSH session to the remote host' do
|
it 'builds a new SSH session to the remote host with #user_name' do
|
||||||
expect(Net::SSH).to receive(:start).with(hostname, Etc.getlogin)
|
expect(Net::SSH).to receive(:start).with(hostname, remote.user_name)
|
||||||
remote.session
|
remote.session
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,6 +29,12 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
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
|
describe '#fs' do
|
||||||
it 'builds a new FS' do
|
it 'builds a new FS' do
|
||||||
expect(Remote::FS).to receive(:new)
|
expect(Remote::FS).to receive(:new)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user