adding scenarios for booting msfconsole without a db

This commit is contained in:
darkbushido 2014-08-20 11:02:11 -05:00
parent f80fd68480
commit 15a7ed0031
No known key found for this signature in database
GPG Key ID: 3922EB70FB80E8DD
6 changed files with 66 additions and 4 deletions

2
.gitignore vendored
View File

@ -52,6 +52,8 @@ tags
# Rails log directory
/log
# Rails tmp directory
/tmp
# ignore release/debug folders for exploits
external/source/exploits/**/Debug

View File

@ -2,5 +2,5 @@
##YAML Template
---
<% common = "--tags ~@wip --strict --tags ~@targets" %>
default: <%= common %> features
boot: <%= common %> --format html --out=features_report.html features
default: <%= common %> --tags ~@boot features
boot: <%= common %> --tags @boot features

View File

@ -1,7 +1,7 @@
@msfconsole
Feature: Help command
Scenario: The Help commands output
Scenario: The 'help' command's output
When I type "help"
And I type "exit"
Then the output should contain:

View File

@ -0,0 +1,42 @@
@boot
Feature: Launching `msfconsole`
@no-database-yml
Scenario: Starting `msfconsole` without a database.yml
Given I run `msfconsole` interactively
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp"
When I type "db_status"
And I type "exit"
Then the output should contain "[*] postgresql selected, no connection"
@no-database-yml
Scenario: Starting `msfconsole` with an invalid database.yml
Given a file named "database.yml" with:
"""
development: &pgsql
adapter: postgresql
database: metasploit_framework_development
username: postgres
port: 6543
pool: 5
timeout: 5
production:
<<: *pgsql
test:
<<: *pgsql
database: metasploit_framework_test
"""
Given I run `msfconsole -y database.yml` interactively
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp"
When I type "db_status"
And I type "exit"
Then the output should contain "[-] Failed to connect to the database: could not connect to server"
Then the output should contain "[*] postgresql selected, no connection"

View File

@ -9,3 +9,21 @@ end
Before('@targets') do
step 'targets are loaded'
end
Before('@no-database-yml') do
if File.exists?('config/database.yml') && File.exists?('config/database.yml.local')
FileUtils.rm('config/database.yml.local')
FileUtils.mv('config/database.yml', 'config/database.yml.local')
elsif File.exists?('config/database.yml')
FileUtils.mv('config/database.yml', 'config/database.yml.local')
end
end
After('@no-database-yml') do
if File.exists?('config/database.yml') && File.exists?('config/database.yml.local')
FileUtils.rm('config/database.yml')
FileUtils.mv('config/database.yml.local', 'config/database.yml')
elsif File.exists?('config/database.yml.local')
FileUtils.mv('config/database.yml.local', 'config/database.yml')
end
end

View File

@ -10,7 +10,7 @@ begin
namespace :features do
Cucumber::Rake::Task.new(:boot) do |t|
t.profile = 'startup'
t.profile = 'boot'
end
end