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/postgresql_spec.rb
Views: 11766
1
# frozen_string_literal: true
2
3
require 'spec_helper'
4
require 'postgres/postgres-pr/connection'
5
6
RSpec.describe Msf::Sessions::PostgreSQL do
7
let(:client) { instance_double(Msf::Db::PostgresPR::Connection) }
8
let(:opts) { { client: client, platform: Msf::Platform::Linux.realname, arch: ARCH_X86_64 } }
9
let(:console_class) { Rex::Post::PostgreSQL::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) { 'postgresql' }
13
let(:log_source) { "session_#{name}" }
14
let(:type) { 'postgresql' }
15
let(:description) { 'PostgreSQL' }
16
let(:can_cleanup_files) { false }
17
let(:address) { '192.0.2.1' }
18
let(:port) { 5432 }
19
let(:peer_info) { "#{address}:#{port}" }
20
let(:current_database) { 'template1' }
21
22
before(:each) do
23
allow(user_input).to receive(:intrinsic_shell?).and_return(true)
24
allow(user_input).to receive(:output=)
25
allow(client).to receive(:peerinfo).and_return(peer_info)
26
allow(client).to receive(:peerhost).and_return(address)
27
allow(client).to receive(:peerport).and_return(port)
28
allow(client).to receive(:params).and_return({ 'database' => current_database })
29
allow(client).to receive(:current_database).and_return(current_database)
30
end
31
32
it_behaves_like 'client session'
33
end
34
35