From 2951b4942924267e9cd9be555679bcbe97683de1 Mon Sep 17 00:00:00 2001 From: Dean Welch Date: Wed, 28 Feb 2024 12:26:42 +0000 Subject: [PATCH] add missing mocks for smb session tests --- .../rex/post/smb/ui/console/command_dispatcher/core_spec.rb | 6 ++++++ .../post/smb/ui/console/command_dispatcher/shares_spec.rb | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/spec/lib/rex/post/smb/ui/console/command_dispatcher/core_spec.rb b/spec/lib/rex/post/smb/ui/console/command_dispatcher/core_spec.rb index 5860974dbdf19..24e90eeabe2dc 100644 --- a/spec/lib/rex/post/smb/ui/console/command_dispatcher/core_spec.rb +++ b/spec/lib/rex/post/smb/ui/console/command_dispatcher/core_spec.rb @@ -5,6 +5,9 @@ RSpec.describe Rex::Post::SMB::Ui::Console::CommandDispatcher::Core do let(:client) { instance_double(RubySMB::Client) } + let(:simple_client) { instance_double(Rex::Proto::SMB::SimpleClient) } + let(:dispatcher) { instance_double(RubySMB::Dispatcher::Socket) } + let(:socket) { instance_double(IO) } let(:session) { Msf::Sessions::SMB.new(nil, { client: client }) } let(:console) do console = Rex::Post::SMB::Ui::Console.new(session) @@ -13,6 +16,9 @@ end before(:each) do + allow(client).to receive(:dispatcher).and_return(dispatcher) + allow(dispatcher).to receive(:tcp_socket).and_return(socket) + allow(Rex::Proto::SMB::SimpleClient).to receive(:new).and_return(simple_client) allow(session).to receive(:client).and_return(client) allow(session).to receive(:console).and_return(console) allow(session).to receive(:name).and_return('test client name') diff --git a/spec/lib/rex/post/smb/ui/console/command_dispatcher/shares_spec.rb b/spec/lib/rex/post/smb/ui/console/command_dispatcher/shares_spec.rb index 0fb75d734eec3..62cd5b5077c97 100644 --- a/spec/lib/rex/post/smb/ui/console/command_dispatcher/shares_spec.rb +++ b/spec/lib/rex/post/smb/ui/console/command_dispatcher/shares_spec.rb @@ -6,6 +6,9 @@ RSpec.describe Rex::Post::SMB::Ui::Console::CommandDispatcher::Shares do let(:client) { instance_double(RubySMB::Client) } + let(:simple_client) { instance_double(Rex::Proto::SMB::SimpleClient) } + let(:dispatcher) { instance_double(RubySMB::Dispatcher::Socket) } + let(:socket) { instance_double(IO) } let(:session) { Msf::Sessions::SMB.new(nil, { client: client }) } let(:console) do console = Rex::Post::SMB::Ui::Console.new(session) @@ -14,6 +17,9 @@ end before(:each) do + allow(client).to receive(:dispatcher).and_return(dispatcher) + allow(dispatcher).to receive(:tcp_socket).and_return(socket) + allow(Rex::Proto::SMB::SimpleClient).to receive(:new).and_return(simple_client) allow(session).to receive(:client).and_return(client) allow(session).to receive(:console).and_return(console) allow(session).to receive(:name).and_return('test client name')