|
58 | 58 | end
|
59 | 59 | end
|
60 | 60 |
|
| 61 | + describe "#query_serverinfo" do |
| 62 | + before :each do |
| 63 | + allow(subject).to receive(:send_request_cgi) do |
| 64 | + if res_code.nil? |
| 65 | + res = nil |
| 66 | + else |
| 67 | + res = Rex::Proto::Http::Response.new |
| 68 | + res.code = res_code |
| 69 | + end |
| 70 | + |
| 71 | + res |
| 72 | + end |
| 73 | + end |
| 74 | + |
| 75 | + context 'when server timeouts' do |
| 76 | + let(:res_code) { nil } |
| 77 | + it { expect(subject.query_serverinfo()).to be_nil } |
| 78 | + end |
| 79 | + |
| 80 | + context 'when server returns 200' do |
| 81 | + let(:res_code) { 200 } |
| 82 | + it { expect(subject.query_serverinfo()).to be_kind_of Rex::Proto::Http::Response } |
| 83 | + end |
| 84 | + end |
| 85 | + |
| 86 | + describe "#detect_plateform" do |
| 87 | + context "when server arch is Linux" do |
| 88 | + res = Rex::Proto::Http::Response.new |
| 89 | + res.body = "<td>OSName: Linux</td>" |
| 90 | + it { expect(subject.detect_platform(res)).to eq "linux" } |
| 91 | + end |
| 92 | + |
| 93 | + context "when server arch is Windows" do |
| 94 | + res = Rex::Proto::Http::Response.new |
| 95 | + res.body = "<td>OSName: Windows</td>" |
| 96 | + it { expect(subject.detect_platform(res)).to eq "win" } |
| 97 | + end |
| 98 | + |
| 99 | + context "return nil if no OS match" do |
| 100 | + res = Rex::Proto::Http::Response.new |
| 101 | + res.body = "<td>OSName: Blah</td>" |
| 102 | + it { expect(subject.detect_platform(res)).to be_nil } |
| 103 | + end |
| 104 | + |
| 105 | + context "return nil res is nil" do |
| 106 | + res = nil |
| 107 | + it { expect(subject.detect_platform(res)).to be_nil } |
| 108 | + end |
| 109 | + end |
| 110 | + |
| 111 | + describe "#detect_architecture" do |
| 112 | + context "when server arch is x86" do |
| 113 | + res = Rex::Proto::Http::Response.new |
| 114 | + res.body = "<td>OSArch: i386</td>" |
| 115 | + it { expect(subject.detect_architecture(res)).to eq ARCH_X86 } |
| 116 | + end |
| 117 | + |
| 118 | + context "return nil if no architecture match" do |
| 119 | + res = Rex::Proto::Http::Response.new |
| 120 | + res.body = "<td>OSArch: Blah</td>" |
| 121 | + it { expect(subject.detect_architecture(res)).to be_nil } |
| 122 | + end |
| 123 | + |
| 124 | + context "return nil res is nil" do |
| 125 | + res = nil |
| 126 | + it { expect(subject.detect_architecture(res)).to be_nil } |
| 127 | + end |
| 128 | + end |
61 | 129 | end
|
0 commit comments