CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/msf/base/sessions/mysql_spec.rb
Views: 11766
1
# frozen_string_literal: true
2
3
require 'spec_helper'
4
require 'rex/proto/mysql/client'
5
6
RSpec.describe Msf::Sessions::MySQL do
7
let(:client) { instance_double(::Rex::Proto::MySQL::Client) }
8
let(:opts) { { client: client, platform: Msf::Platform::Linux.realname, arch: ARCH_X86_64 } }
9
let(:console_class) { Rex::Post::MySQL::Ui::Console }
10
let(:user_input) { instance_double(Rex::Ui::Text::Input::Readline) }
11
let(:user_output) { instance_double(Rex::Ui::Text::Output::Stdio) }
12
let(:name) { 'mysql' }
13
let(:log_source) { "session_#{name}" }
14
let(:type) { 'mysql' }
15
let(:description) { 'MySQL' }
16
let(:can_cleanup_files) { false }
17
let(:address) { '192.0.2.1' }
18
let(:port) { 3306 }
19
let(:peerinfo) { "#{address}:#{port}" }
20
let(:current_database) { 'database_name' }
21
22
before(:each) do
23
allow(user_input).to receive(:output=)
24
allow(user_input).to receive(:intrinsic_shell?).and_return(true)
25
allow(client).to receive(:peerinfo).and_return(peerinfo)
26
allow(client).to receive(:peerport).and_return(port)
27
allow(client).to receive(:peerhost).and_return(address)
28
allow(client).to receive(:current_database).and_return(current_database)
29
allow(::Rex::Proto::MySQL::Client).to receive(:connect).and_return(client)
30
end
31
32
it_behaves_like 'client session'
33
end
34
35