From 188f5d012a8197bd2262d331fc84ebdf390306f9 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Wed, 27 Aug 2014 22:02:16 -0500 Subject: [PATCH] Add scenario for no database.yml MSP-11153 --- features/msfconsole/database_yml.feature | 22 +++++++++++++++++++++- features/step_definitions/project.rb | 6 ++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/features/msfconsole/database_yml.feature b/features/msfconsole/database_yml.feature index 5ac2576cf2..1d163cd860 100644 --- a/features/msfconsole/database_yml.feature +++ b/features/msfconsole/database_yml.feature @@ -135,4 +135,24 @@ Feature: `msfconsole` `database.yml` When I run `msfconsole --environment test` interactively And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp" And I type "exit" - Then the output should contain "project_metasploit_framework_test" \ No newline at end of file + Then the output should contain "project_metasploit_framework_test" + + + Scenario: Without --yaml, MSF_DATABASE_CONFIG, ~/.msf4/database.yml, or project "database.yml", no database connection + Given I unset the environment variables: + | variable | + | MSF_DATABASE_CONFIG | + And a directory named "home" + And I cd to "home" + And a mocked home directory + And I cd to "../.." + And the project "database.yml" does not exist + When I run `msfconsole --environment test` interactively + And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp" + And I type "db_status" + And I type "exit" + Then the output should not contain "command_line_metasploit_framework_test" + And the output should not contain "environment_metasploit_framework_test" + And the output should not contain "user_metasploit_framework_test" + And the output should not contain "project_metasploit_framework_test" + And the output should contain "[*] postgresql selected, no connection" diff --git a/features/step_definitions/project.rb b/features/step_definitions/project.rb index 1f3cc6180d..1baaa488da 100644 --- a/features/step_definitions/project.rb +++ b/features/step_definitions/project.rb @@ -7,6 +7,12 @@ Before do end end +Given /^the project "database.yml" does not exist$/ do + if File.exist?(project_database_yaml_path) + File.rename(project_database_yaml_path, backup_project_database_yaml_path) + end +end + Given /^the project "database.yml" exists with:$/ do |file_content| if File.exist?(project_database_yaml_path) File.rename(project_database_yaml_path, backup_project_database_yaml_path)