From f9b6519e490e6fa3dd750035a5c72c1695938f39 Mon Sep 17 00:00:00 2001 From: us3r777 Date: Mon, 29 Sep 2014 23:45:40 +0200 Subject: [PATCH] Added spec to new methods in Jboss mixin --- spec/lib/msf/http/jboss/base_spec.rb | 68 ++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/spec/lib/msf/http/jboss/base_spec.rb b/spec/lib/msf/http/jboss/base_spec.rb index 7f8c211d58..d23ca01f73 100644 --- a/spec/lib/msf/http/jboss/base_spec.rb +++ b/spec/lib/msf/http/jboss/base_spec.rb @@ -58,4 +58,72 @@ describe Msf::HTTP::JBoss::Base do end end + describe "#query_serverinfo" do + before :each do + allow(subject).to receive(:send_request_cgi) do + if res_code.nil? + res = nil + else + res = Rex::Proto::Http::Response.new + res.code = res_code + end + + res + end + end + + context 'when server timeouts' do + let(:res_code) { nil } + it { expect(subject.query_serverinfo()).to be_nil } + end + + context 'when server returns 200' do + let(:res_code) { 200 } + it { expect(subject.query_serverinfo()).to be_kind_of Rex::Proto::Http::Response } + end + end + + describe "#detect_plateform" do + context "when server arch is Linux" do + res = Rex::Proto::Http::Response.new + res.body = "OSName: Linux" + it { expect(subject.detect_platform(res)).to eq "linux" } + end + + context "when server arch is Windows" do + res = Rex::Proto::Http::Response.new + res.body = "OSName: Windows" + it { expect(subject.detect_platform(res)).to eq "win" } + end + + context "return nil if no OS match" do + res = Rex::Proto::Http::Response.new + res.body = "OSName: Blah" + it { expect(subject.detect_platform(res)).to be_nil } + end + + context "return nil res is nil" do + res = nil + it { expect(subject.detect_platform(res)).to be_nil } + end + end + + describe "#detect_architecture" do + context "when server arch is x86" do + res = Rex::Proto::Http::Response.new + res.body = "OSArch: i386" + it { expect(subject.detect_architecture(res)).to eq ARCH_X86 } + end + + context "return nil if no architecture match" do + res = Rex::Proto::Http::Response.new + res.body = "OSArch: Blah" + it { expect(subject.detect_architecture(res)).to be_nil } + end + + context "return nil res is nil" do + res = nil + it { expect(subject.detect_architecture(res)).to be_nil } + end + end end