Skip to content

Commit 5a858d6

Browse files
committed
Add rspec for browser_profile_manager
1 parent b2d723e commit 5a858d6

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
require 'msf/core'
2+
3+
describe Msf::Exploit::Remote::BrowserProfileManager do
4+
5+
subject do
6+
mod = Msf::Exploit::Remote.allocate
7+
mod.extend described_class
8+
mod
9+
end
10+
11+
let(:default_profile) do
12+
{
13+
'PREFIX' => {'KEY'=>'VALUE'}
14+
}
15+
end
16+
17+
before(:each) do
18+
framework = double('framework')
19+
allow(framework).to receive(:browser_profiles).and_return(default_profile)
20+
allow_any_instance_of(described_class).to receive(:framework).and_return(framework)
21+
end
22+
23+
describe '#browser_profile_prefix' do
24+
it 'raises a NoMethodError' do
25+
expect{subject.browser_profile_prefix}.to raise_exception(NoMethodError)
26+
end
27+
end
28+
29+
describe '#browser_profile' do
30+
before(:each) do
31+
allow(subject).to receive(:browser_profile_prefix).and_return('PREFIX')
32+
end
33+
34+
it 'returns a hash for the profile' do
35+
expect(subject.browser_profile).to be_kind_of(Hash)
36+
end
37+
end
38+
39+
describe '#clear_browser_profiles' do
40+
before(:each) do
41+
allow(subject).to receive(:browser_profile_prefix).and_return('PREFIX')
42+
end
43+
44+
it 'clears profile cache' do
45+
expect(subject.browser_profile.length).to eq(1)
46+
subject.clear_browser_profiles
47+
expect(subject.browser_profile).to be_empty
48+
end
49+
end
50+
51+
end

0 commit comments

Comments
 (0)