From 195b405d69951a6be7ad790aa50a6b2c15b4a5b8 Mon Sep 17 00:00:00 2001 From: christopher lee Date: Thu, 26 Apr 2018 15:12:53 -0500 Subject: [PATCH] First pass at all test working, added travis ci build --- .travis.yml | 1 + spec/lib/msf/core/exploit/auto_target_spec.rb | 4 +++ .../ui/console/command_dispatcher/db_spec.rb | 25 +++++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index d16407093e..31c406b39a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ rvm: env: - CMD='bundle exec rake rspec-rerun:spec SPEC_OPTS="--tag content"' - CMD='bundle exec rake rspec-rerun:spec SPEC_OPTS="--tag ~content"' + - CMD='bundle exec rake rspec-rerun:spec REMOTE_DB=1' matrix: fast_finish: true diff --git a/spec/lib/msf/core/exploit/auto_target_spec.rb b/spec/lib/msf/core/exploit/auto_target_spec.rb index 84c5a4c5c5..5a00c9b842 100644 --- a/spec/lib/msf/core/exploit/auto_target_spec.rb +++ b/spec/lib/msf/core/exploit/auto_target_spec.rb @@ -2,6 +2,10 @@ require 'spec_helper' RSpec.describe Msf::Exploit::AutoTarget do + if ENV['REMOTE_DB'] + before {skip("Uses factory bot and doesn't directly test DB API")} + end + include_context 'Msf::DBManager' include_context 'Metasploit::Framework::Spec::Constants cleaner' diff --git a/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb index 4094b0ed28..11f413805e 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb @@ -212,7 +212,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do ] end end - describe "-S" do + describe "-p" do before(:example) do @services = [] @services << framework.db.report_service({host: '192.168.0.1', port: 1024, name: 'service1', proto: 'udp'}) @@ -230,7 +230,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do end it "should list services that are on a given port" do - db.cmd_services "-S", "1024|1025" + db.cmd_services "-p", "1024, 1025" expect(@output).to match_array [ "Services", "========", @@ -245,10 +245,21 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-np" do before(:example) do - framework.db.report_service({host: '192.168.0.1', port: 1024}) - framework.db.report_service({host: '192.168.0.1', port: 1025}) - framework.db.report_service({host: '192.168.0.1', port: 1026}) + @services = [] + @services << framework.db.report_service({host: '192.168.0.2', port: 1024}) + @services << framework.db.report_service({host: '192.168.0.2', port: 1025}) + @services << framework.db.report_service({host: '192.168.0.2', port: 1026}) end + + after(:example) do + ids = [] + @services.each{|service| + ids << service.id + } + + framework.db.delete_service({ids: ids}) + end + it "should list services that are not on a given port" do skip { db.cmd_services "-np", "1024" @@ -259,8 +270,8 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do "", "host port proto name state info", "---- ---- ----- ---- ----- ----", - "192.168.0.1 1025 snmp open ", - "192.168.0.1 1026 snmp open " + "192.168.0.2 1025 snmp open ", + "192.168.0.2 1026 snmp open " ] } end