Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/msf/db_manager/export_spec.rb
Views: 11704
require 'spec_helper'123RSpec.describe Msf::DBExport do4include_context 'Msf::DBManager'56subject(:export) do7described_class.new(workspace)8end910let(:active) do11true12end1314let(:workspace) do15FactoryBot.create(16:mdm_workspace17)18end1920context '#extract_module_detail_info' do21let(:report_file) do22StringIO.new23end2425subject(:extract_module_detail_info) do26export.extract_module_detail_info(report_file)27end2829context 'with Mdm::Module::Details' do30let(:document) do31Nokogiri::XML(report_file.string)32end3334let(:module_detail_count) do35236end3738let(:root) do39document.root40end4142let!(:module_details) do43FactoryBot.create_list(44:mdm_module_detail,45module_detail_count46)47end4849before(:example) do50report_file.write("<root>")51extract_module_detail_info52report_file.write("</root>")53end5455it 'should have module_detail tag for each Mdm::Module::Detail' do56nodes = root.xpath('module_detail')5758expect(nodes.length).to eq module_detail_count59end6061context 'module_detail' do62let(:module_detail) do63module_details.first64end6566subject(:module_detail_node) do67root.at_xpath('module_detail')68end6970it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'description'7172context '/disclosure-date' do73it 'should have Mdm::Module::Detail#disclosure_date present' do74expect(module_detail.disclosure_date).to be_present75end7677it 'should have Mdm::Module::Detail#disclosure_date from disclosure-date content' do78node = module_detail_node.at_xpath('disclosure-date')7980expect(DateTime.parse(node.content)).to eq module_detail.disclosure_date81end82end8384it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'file'85it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'fullname'86it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'license'87it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'mtime'88it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'mtype'89it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'name'90it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'privileged'91it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'rank'92it_should_behave_like 'Msf::DBExport#extract_module_detail_info module_detail child', 'refname'9394# @todo https://www.pivotaltracker.com/story/show/4845100195end96end9798context 'without Mdm::Module::Details' do99it 'should not write anything to report_file' do100extract_module_detail_info101102expect(report_file.string).to be_empty103end104end105end106end107108109