Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/rex/proto/mysql/client_spec.rb
Views: 11788
# -*- coding: binary -*-12require 'spec_helper'3require 'rex/proto/mysql/client'45RSpec.describe Rex::Proto::MySQL::Client do6let(:host) { '127.0.0.1' }7let(:port) { 1234 }8let(:info) { "#{host}:#{port}" }9let(:db_name) { 'my_db_name' }1011subject do12addr_info = instance_double(Addrinfo, ip_address: host, ip_port: port)13socket = instance_double(Socket, remote_address: addr_info)14client = described_class.new(io: socket)15allow(client).to receive(:session_track).and_return({ 1 => [db_name] })16client17end1819it { is_expected.to be_a ::Mysql }2021it_behaves_like 'session compatible SQL client'2223describe '#current_database' do24context 'we have not selected a database yet' do25before(:each) do26allow(subject).to receive(:session_track).and_return({})27end2829it 'returns an empty database name' do30expect(subject.current_database).to eq('')31end32end33end3435describe '#map_compile_os_to_platform' do36[37{ info: 'linux', expected: Msf::Platform::Linux.realname },38{ info: 'linux2.6', expected: Msf::Platform::Linux.realname },39{ info: 'debian-linux-gnu', expected: Msf::Platform::Linux.realname },40{ info: 'win', expected: Msf::Platform::Windows.realname },41{ info: 'windows', expected: Msf::Platform::Windows.realname },42{ info: 'darwin', expected: Msf::Platform::OSX.realname },43{ info: 'osx', expected: Msf::Platform::OSX.realname },44{ info: 'macos', expected: Msf::Platform::OSX.realname },45{ info: 'unix', expected: Msf::Platform::Unix.realname },46{ info: 'solaris', expected: Msf::Platform::Solaris.realname },47{ info: '', expected: '' },48{ info: 'blank', expected: 'blank' },49{ info: nil, expected: '' },50].each do |test|51it "correctly identifies '#{test[:info]}' as '#{test[:expected]}'" do52expect(subject.map_compile_os_to_platform(test[:info])).to eq(test[:expected])53end54end55end5657describe '#map_compile_arch_to_architecture' do58[59{ info: 'x86_64', expected: ARCH_X86_64 },60{ info: 'x86_x64', expected: ARCH_X86_64 },61{ info: 'x64', expected: ARCH_X86_64 },62{ info: '64', expected: ARCH_X86_64 },63{ info: 'x86', expected: ARCH_X86 },64{ info: '86', expected: ARCH_X86 },65{ info: 'i686', expected: ARCH_X86 },66{ info: 'arm64', expected: ARCH_AARCH64 },67{ info: 'arm', expected: ARCH_ARMLE },68{ info: 'sparc', expected: ARCH_SPARC },69{ info: 'sparc64', expected: ARCH_SPARC64 },70{ info: '', expected: '' },71{ info: 'blank', expected: 'blank' },72{ info: nil, expected: '' },73].each do |test|74it "correctly identifies '#{test[:info]}' as '#{test[:expected]}'" do75expect(subject.map_compile_arch_to_architecture(test[:info])).to eq(test[:expected])76end77end78end79end808182