36
36
described_class . new ( framework )
37
37
end
38
38
39
+ it_should_behave_like 'Msf::ModuleManager::Loading'
39
40
it_should_behave_like 'Msf::ModuleManager::ModulePaths'
40
-
41
- context '#file_changed?' do
42
- let ( :module_basename ) do
43
- [ basename_prefix , '.rb' ]
44
- end
45
-
46
- it 'should return true if module info is not cached' do
47
- Tempfile . open ( module_basename ) do |tempfile |
48
- module_path = tempfile . path
49
-
50
- subject . send ( :module_info_by_path ) [ module_path ] . should be_nil
51
- subject . file_changed? ( module_path ) . should be_true
52
- end
53
- end
54
-
55
- it 'should return true if the cached type is Msf::MODULE_PAYLOAD' do
56
- Tempfile . open ( module_basename ) do |tempfile |
57
- module_path = tempfile . path
58
- modification_time = File . mtime ( module_path )
59
-
60
- subject . send ( :module_info_by_path ) [ module_path ] = {
61
- # :modification_time must match so that it is the :type that is causing the `true` and not the
62
- # :modification_time causing the `true`.
63
- :modification_time => modification_time ,
64
- :type => Msf ::MODULE_PAYLOAD
65
- }
66
-
67
- subject . file_changed? ( module_path ) . should be_true
68
- end
69
- end
70
-
71
- context 'with cache module info and not a payload module' do
72
- it 'should return true if the file does not exist on the file system' do
73
- tempfile = Tempfile . new ( module_basename )
74
- module_path = tempfile . path
75
- modification_time = File . mtime ( module_path ) . to_i
76
-
77
- subject . send ( :module_info_by_path ) [ module_path ] = {
78
- :modification_time => modification_time
79
- }
80
-
81
- tempfile . unlink
82
-
83
- File . exist? ( module_path ) . should be_false
84
- subject . file_changed? ( module_path ) . should be_true
85
- end
86
-
87
- it 'should return true if modification time does not match the cached modification time' do
88
- Tempfile . open ( module_basename ) do |tempfile |
89
- module_path = tempfile . path
90
- modification_time = File . mtime ( module_path ) . to_i
91
- cached_modification_time = ( modification_time * rand ) . to_i
92
-
93
- subject . send ( :module_info_by_path ) [ module_path ] = {
94
- :modification_time => cached_modification_time
95
- }
96
-
97
- cached_modification_time . should_not == modification_time
98
- subject . file_changed? ( module_path ) . should be_true
99
- end
100
- end
101
-
102
- it 'should return false if modification time does match the cached modification time' do
103
- Tempfile . open ( module_basename ) do |tempfile |
104
- module_path = tempfile . path
105
- modification_time = File . mtime ( module_path ) . to_i
106
- cached_modification_time = modification_time
107
-
108
- subject . send ( :module_info_by_path ) [ module_path ] = {
109
- :modification_time => cached_modification_time
110
- }
111
-
112
- cached_modification_time . should == modification_time
113
- subject . file_changed? ( module_path ) . should be_false
114
- end
115
- end
116
- end
117
- end
118
41
end
0 commit comments