Path: blob/master/spec/lib/msf/base/sessions/postgresql_spec.rb
19534 views
# frozen_string_literal: true12require 'spec_helper'3require 'postgres/postgres-pr/connection'45RSpec.describe Msf::Sessions::PostgreSQL do6let(:client) { instance_double(Msf::Db::PostgresPR::Connection) }7let(:opts) { { client: client, platform: Msf::Platform::Linux.realname, arch: ARCH_X86_64 } }8let(:console_class) { Rex::Post::PostgreSQL::Ui::Console }9let(:user_input) { instance_double(Rex::Ui::Text::Input::Readline) }10let(:user_output) { instance_double(Rex::Ui::Text::Output::Stdio) }11let(:name) { 'postgresql' }12let(:log_source) { "session_#{name}" }13let(:type) { 'postgresql' }14let(:description) { 'PostgreSQL' }15let(:can_cleanup_files) { false }16let(:address) { '192.0.2.1' }17let(:port) { 5432 }18let(:peer_info) { "#{address}:#{port}" }19let(:current_database) { 'template1' }2021before(:each) do22allow(user_input).to receive(:intrinsic_shell?).and_return(true)23allow(user_input).to receive(:output=)24allow(client).to receive(:peerinfo).and_return(peer_info)25allow(client).to receive(:peerhost).and_return(address)26allow(client).to receive(:peerport).and_return(port)27allow(client).to receive(:params).and_return({ 'database' => current_database })28allow(client).to receive(:current_database).and_return(current_database)29end3031it_behaves_like 'client session'32end333435