Add rspec coverage for get (and set/setg, in a way)
parent
da1c56a65d
commit
7f90b68cce
|
@ -106,13 +106,51 @@ describe Msf::Ui::Console::CommandDispatcher::Core do
|
||||||
@output.join.should =~ /Usage: get /
|
@output.join.should =~ /Usage: get /
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
describe "#cmd_getg" do
|
describe "with arguments" do
|
||||||
describe "without arguments" do
|
let(:name) { ::Rex::Text.rand_text_alpha(10).upcase }
|
||||||
it "should show a help message" do
|
|
||||||
core.cmd_getg
|
context "with an active module" do
|
||||||
@output.join.should =~ /Usage: getg /
|
let(:mod) do
|
||||||
|
mod = ::Msf::Module.new
|
||||||
|
mod.send(:initialize, {})
|
||||||
|
mod
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should show an empty value if not set in the framework or module" do
|
||||||
|
allow(core).to receive(:active_module).and_return(mod)
|
||||||
|
allow(driver).to receive(:on_variable_set).and_return(true)
|
||||||
|
core.cmd_get(name)
|
||||||
|
@output.join.should =~ /^#{name} => $/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should show no value when only the framework has this variable" do
|
||||||
|
allow(core).to receive(:active_module).and_return(mod)
|
||||||
|
allow(driver).to receive(:on_variable_set).and_return(true)
|
||||||
|
core.cmd_setg(name, 'FRAMEWORK')
|
||||||
|
@output = []
|
||||||
|
core.cmd_get(name)
|
||||||
|
@output.join.should =~ /^#{name} => $/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should show the module's value when only the module has this variable" do
|
||||||
|
allow(core).to receive(:active_module).and_return(mod)
|
||||||
|
allow(driver).to receive(:on_variable_set).and_return(true)
|
||||||
|
core.cmd_set(name, 'MODULE')
|
||||||
|
@output = []
|
||||||
|
core.cmd_get(name)
|
||||||
|
@output.join.should =~ /^#{name} => MODULE$/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should show the module's value when both the module and the framework have this variable" do
|
||||||
|
allow(core).to receive(:active_module).and_return(mod)
|
||||||
|
allow(driver).to receive(:on_variable_set).and_return(true)
|
||||||
|
core.cmd_setg(name, 'FRAMEWORK')
|
||||||
|
core.cmd_set(name, 'MODULE')
|
||||||
|
@output = []
|
||||||
|
core.cmd_get(name)
|
||||||
|
@output.join.should =~ /^#{name} => MODULE$/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue