|
79 | 79 |
|
80 | 80 | module_type = 'payload'
|
81 | 81 |
|
82 |
| - include_context 'Msf::Simple::Framework' |
| 82 | + include_context 'Msf::Simple::Framework#modules loading' |
83 | 83 |
|
84 | 84 | #
|
85 | 85 | # lets
|
86 | 86 | #
|
87 | 87 |
|
88 |
| - let(:loader) { |
89 |
| - loader = framework.modules.send(:loaders).find { |loader| |
90 |
| - loader.loadable?(modules_path) |
91 |
| - } |
92 |
| - |
93 |
| - # Override load_error so that rspec will print it instead of going to framework log |
94 |
| - def loader.load_error(module_path, error) |
95 |
| - raise error |
96 |
| - end |
97 |
| - |
98 |
| - loader |
99 |
| - } |
100 |
| - |
101 |
| - let(:module_set) { |
102 |
| - framework.modules.module_set(module_type) |
103 |
| - } |
104 |
| - |
105 | 88 | context reference_name do
|
106 | 89 | ancestor_reference_names.each do |ancestor_reference_name|
|
107 | 90 | it "can load '#{module_type}/#{ancestor_reference_name}'" do
|
108 | 91 | @actual_ancestor_reference_name_set.add(ancestor_reference_name)
|
109 | 92 |
|
110 |
| - loaded = loader.load_module(modules_path, module_type, ancestor_reference_name) |
111 |
| - |
112 |
| - expect(loaded).to eq(true), "#{ancestor_reference_name} failed to load from #{modules_path}" |
| 93 | + expect_to_load_module_ancestor( |
| 94 | + ancestor_reference_name: ancestor_reference_name, |
| 95 | + module_type: module_type, |
| 96 | + modules_path: modules_path |
| 97 | + ) |
113 | 98 | end
|
114 | 99 | end
|
115 | 100 |
|
116 | 101 | it 'can be instantiated' do
|
117 |
| - ancestor_reference_names.each do |ancestor_reference_name| |
118 |
| - loaded = loader.load_module(modules_path, module_type, ancestor_reference_name) |
119 |
| - |
120 |
| - expect(loaded).to eq(true), "#{ancestor_reference_name} failed to load from #{modules_path}" |
121 |
| - end |
122 |
| - |
123 |
| - module_instance = nil |
124 |
| - |
125 |
| - expect { |
126 |
| - module_instance = module_set.create(reference_name) |
127 |
| - }.not_to raise_error |
128 |
| - |
129 |
| - expect(module_instance).not_to be_nil, "Could not instantiate #{module_type}/#{reference_name}" |
| 102 | + load_and_create_module( |
| 103 | + ancestor_reference_names: ancestor_reference_names, |
| 104 | + module_type: module_type, |
| 105 | + modules_path: modules_path, |
| 106 | + reference_name: reference_name |
| 107 | + ) |
130 | 108 | end
|
131 | 109 | end
|
132 | 110 | end
|
0 commit comments