From 262e4b8c1346c084ee0764c465ccc25766d1d8d6 Mon Sep 17 00:00:00 2001 From: h00die Date: Sat, 21 Dec 2024 13:19:15 -0500 Subject: [PATCH] ignore sleeps --- spec/lib/msf/core/post/linux/busy_box_spec.rb | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/spec/lib/msf/core/post/linux/busy_box_spec.rb b/spec/lib/msf/core/post/linux/busy_box_spec.rb index 83e4cab5c1d1..fbd3e9d60770 100644 --- a/spec/lib/msf/core/post/linux/busy_box_spec.rb +++ b/spec/lib/msf/core/post/linux/busy_box_spec.rb @@ -1,6 +1,6 @@ # -*- coding: binary -*- -require 'spec_helper' +require 'spec_helper' RSpec.describe Msf::Post::Linux::BusyBox do subject do @@ -9,15 +9,15 @@ mod end - describe "#busy_box_file_exist?" do - describe "when file exists" do + describe '#busy_box_file_exist?' do + describe 'when file exists' do before :example do allow(subject).to receive(:read_file) do 'test data' end end - it "returns true" do + it 'returns true' do expect(subject.busy_box_file_exist?('/etc/passwd')).to be_truthy end end @@ -29,20 +29,21 @@ end end - it "returns false" do + it 'returns false' do expect(subject.busy_box_file_exist?('/etc/nonexistent')).to be_falsey end end end - describe "#busy_box_is_writable_dir?" do + describe '#busy_box_is_writable_dir?' do before :example do allow(subject).to receive(:cmd_exec) do '' end + allow(Rex).to receive(:sleep) end - describe "when dir is writable" do + describe 'when dir is writable' do before :example do allow(subject).to receive(:read_file) do "#{'A' * 16}XXX#{'A' * 16}" @@ -53,7 +54,7 @@ end end - it "returns true" do + it 'returns true' do expect(subject.busy_box_is_writable_dir?('/tmp/')).to be_truthy end end @@ -65,14 +66,13 @@ end end - it "returns false" do + it 'returns false' do expect(subject.busy_box_is_writable_dir?('/etc/')).to be_falsey end end end - - describe "#busy_box_writable_dir" do + describe '#busy_box_writable_dir' do before :example do allow(subject).to receive(:cmd_exec) do '' @@ -86,12 +86,12 @@ end end - it "returns nil" do + it 'returns nil' do expect(subject.busy_box_writable_dir).to be_nil end end - describe "when a writable directory exists" do + describe 'when a writable directory exists' do before :example do allow(subject).to receive(:read_file) do "#{'A' * 16}XXX#{'A' * 16}" @@ -102,18 +102,18 @@ end end - it "returns the writable dir path" do + it 'returns the writable dir path' do expect(subject.busy_box_writable_dir).to eq('/etc/') end end end - - describe "#busy_box_write_file" do + describe '#busy_box_write_file' do before :example do allow(subject).to receive(:cmd_exec) do '' end + allow(Rex).to receive(:sleep) end describe "when the file isn't writable" do @@ -123,12 +123,12 @@ end end - it "returns false" do + it 'returns false' do expect(subject.busy_box_write_file('/etc/passwd', 'test')).to be_falsey end end - describe "when the file is writable" do + describe 'when the file is writable' do before :example do allow(subject).to receive(:read_file) do "#{'A' * 16}XXX#{'A' * 16}" @@ -139,14 +139,14 @@ end end - it "returns true" do + it 'returns true' do expect(subject.busy_box_write_file('/tmp/test', 'test')).to be_truthy end end - describe "when prepend is true" do - describe "when there is a writable dir" do - describe "when the target file is writable" do + describe 'when prepend is true' do + describe 'when there is a writable dir' do + describe 'when the target file is writable' do before :example do allow(subject).to receive(:busy_box_writable_dir) do '/tmp/' @@ -161,7 +161,7 @@ end end - it "returns true" do + it 'returns true' do expect(subject.busy_box_write_file('/tmp/test', 'test', true)).to be_truthy end end @@ -173,12 +173,11 @@ nil end end - - it "returns false" do + + it 'returns false' do expect(subject.busy_box_write_file('/tmp/test', 'test', true)).to be_falsey end end end end - end