File tree Expand file tree Collapse file tree 1 file changed +86
-0
lines changed
spec/support/shared/examples/msf/module_manager Expand file tree Collapse file tree 1 file changed +86
-0
lines changed Original file line number Diff line number Diff line change 76
76
end
77
77
end
78
78
end
79
+
80
+ context '#on_module_load' do
81
+ def on_module_load
82
+ module_manager . on_module_load ( klass , type , reference_name , options )
83
+ end
84
+
85
+ let ( :annotated_class ) do
86
+ # stub out include? so calls in auto_subscribe_module work.
87
+ mock ( 'Annotated Class' , :include? => false )
88
+ end
89
+
90
+ let ( :klass ) do
91
+ Class . new ( Msf ::Auxiliary )
92
+ end
93
+
94
+ let ( :module_set ) do
95
+ module_manager . module_set ( type )
96
+ end
97
+
98
+ let ( :options ) do
99
+ {
100
+ 'files' => [
101
+ path
102
+ ] ,
103
+ 'paths' => [
104
+ reference_name
105
+ ] ,
106
+ 'type' => type
107
+ }
108
+ end
109
+
110
+ let ( :path ) do
111
+ type_directory = Mdm ::Module ::Detail ::DIRECTORY_BY_TYPE [ type ]
112
+
113
+ Metasploit ::Framework . root . join (
114
+ 'modules' ,
115
+ type_directory ,
116
+ "#{ reference_name } .rb"
117
+ ) . to_path
118
+ end
119
+
120
+ let ( :reference_name ) do
121
+ FactoryGirl . generate :mdm_module_detail_refname
122
+ end
123
+
124
+ let ( :type ) do
125
+ klass . type
126
+ end
127
+
128
+ it "should add module to type's module_set" do
129
+ module_set . should_receive ( :add_module ) . with (
130
+ klass ,
131
+ reference_name ,
132
+ options
133
+ ) . and_return ( annotated_class )
134
+
135
+ on_module_load
136
+ end
137
+
138
+ context 'annotated class' do
139
+ before ( :each ) do
140
+ module_set . stub ( :add_module ) . and_return ( annotated_class )
141
+ end
142
+
143
+ it 'should return annotated class from Msf::ModuleSet#add_module' do
144
+ on_module_load . should == annotated_class
145
+ end
146
+
147
+ it 'should pass annotated class to Msf::ModuleManager#auto_subscribe_module' do
148
+ module_manager . should_receive ( :auto_subscribe_module ) . with ( annotated_class )
149
+
150
+ on_module_load
151
+ end
152
+
153
+ it 'should fire on_module_load event' do
154
+ framework . events . should_receive ( :on_module_load ) . with (
155
+ reference_name ,
156
+ annotated_class
157
+ )
158
+
159
+ on_module_load
160
+ end
161
+ end
162
+
163
+
164
+ end
79
165
end
You can’t perform that action at this time.
0 commit comments