Skip to content

Commit 188f5d0

Browse files
committed
Add scenario for no database.yml
MSP-11153
1 parent 7453f6f commit 188f5d0

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

features/msfconsole/database_yml.feature

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,24 @@ Feature: `msfconsole` `database.yml`
135135
When I run `msfconsole --environment test` interactively
136136
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp"
137137
And I type "exit"
138-
Then the output should contain "project_metasploit_framework_test"
138+
Then the output should contain "project_metasploit_framework_test"
139+
140+
141+
Scenario: Without --yaml, MSF_DATABASE_CONFIG, ~/.msf4/database.yml, or project "database.yml", no database connection
142+
Given I unset the environment variables:
143+
| variable |
144+
| MSF_DATABASE_CONFIG |
145+
And a directory named "home"
146+
And I cd to "home"
147+
And a mocked home directory
148+
And I cd to "../.."
149+
And the project "database.yml" does not exist
150+
When I run `msfconsole --environment test` interactively
151+
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp"
152+
And I type "db_status"
153+
And I type "exit"
154+
Then the output should not contain "command_line_metasploit_framework_test"
155+
And the output should not contain "environment_metasploit_framework_test"
156+
And the output should not contain "user_metasploit_framework_test"
157+
And the output should not contain "project_metasploit_framework_test"
158+
And the output should contain "[*] postgresql selected, no connection"

features/step_definitions/project.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
end
88
end
99

10+
Given /^the project "database.yml" does not exist$/ do
11+
if File.exist?(project_database_yaml_path)
12+
File.rename(project_database_yaml_path, backup_project_database_yaml_path)
13+
end
14+
end
15+
1016
Given /^the project "database.yml" exists with:$/ do |file_content|
1117
if File.exist?(project_database_yaml_path)
1218
File.rename(project_database_yaml_path, backup_project_database_yaml_path)

0 commit comments

Comments
 (0)