From 5a858d68a54e895113e74a31476b964b966d700a Mon Sep 17 00:00:00 2001 From: wchen-r7 Date: Sat, 11 Jul 2015 21:11:31 -0500 Subject: [PATCH] Add rspec for browser_profile_manager --- .../remote/browser_profile_manager_spec.rb | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb diff --git a/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb b/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb new file mode 100644 index 0000000000..a771fff517 --- /dev/null +++ b/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb @@ -0,0 +1,51 @@ +require 'msf/core' + +describe Msf::Exploit::Remote::BrowserProfileManager do + + subject do + mod = Msf::Exploit::Remote.allocate + mod.extend described_class + mod + end + + let(:default_profile) do + { + 'PREFIX' => {'KEY'=>'VALUE'} + } + end + + before(:each) do + framework = double('framework') + allow(framework).to receive(:browser_profiles).and_return(default_profile) + allow_any_instance_of(described_class).to receive(:framework).and_return(framework) + end + + describe '#browser_profile_prefix' do + it 'raises a NoMethodError' do + expect{subject.browser_profile_prefix}.to raise_exception(NoMethodError) + end + end + + describe '#browser_profile' do + before(:each) do + allow(subject).to receive(:browser_profile_prefix).and_return('PREFIX') + end + + it 'returns a hash for the profile' do + expect(subject.browser_profile).to be_kind_of(Hash) + end + end + + describe '#clear_browser_profiles' do + before(:each) do + allow(subject).to receive(:browser_profile_prefix).and_return('PREFIX') + end + + it 'clears profile cache' do + expect(subject.browser_profile.length).to eq(1) + subject.clear_browser_profiles + expect(subject.browser_profile).to be_empty + end + end + +end \ No newline at end of file