metasploit-model 0.28.0 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +3 -1
  3. data/config/locales/en.yml +0 -171
  4. data/lib/metasploit/model.rb +0 -2
  5. data/lib/metasploit/model/spec.rb +0 -130
  6. data/lib/metasploit/model/version.rb +1 -1
  7. data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +4 -6
  8. data/spec/support/shared/examples/metasploit/model/translation.rb +1 -1
  9. data/spec/support/shared/examples/search_association.rb +1 -1
  10. data/spec/support/shared/examples/search_with.rb +4 -2
  11. metadata +3 -349
  12. data/app/models/metasploit/model/module/ancestor/spec/template.rb +0 -125
  13. data/app/models/metasploit/model/module/class/spec/template.rb +0 -92
  14. data/app/models/metasploit/model/module/instance/spec/template.rb +0 -97
  15. data/app/models/metasploit/model/spec/template.rb +0 -277
  16. data/app/validators/derivation_validator.rb +0 -17
  17. data/app/validators/dynamic_length_validator.rb +0 -45
  18. data/lib/metasploit/model/architecture.rb +0 -342
  19. data/lib/metasploit/model/author.rb +0 -54
  20. data/lib/metasploit/model/authority.rb +0 -141
  21. data/lib/metasploit/model/authority/bid.rb +0 -10
  22. data/lib/metasploit/model/authority/cve.rb +0 -10
  23. data/lib/metasploit/model/authority/msb.rb +0 -10
  24. data/lib/metasploit/model/authority/osvdb.rb +0 -10
  25. data/lib/metasploit/model/authority/pmasa.rb +0 -10
  26. data/lib/metasploit/model/authority/secunia.rb +0 -10
  27. data/lib/metasploit/model/authority/us_cert_vu.rb +0 -10
  28. data/lib/metasploit/model/authority/waraxe.rb +0 -31
  29. data/lib/metasploit/model/authority/zdi.rb +0 -10
  30. data/lib/metasploit/model/derivation.rb +0 -109
  31. data/lib/metasploit/model/derivation/full_name.rb +0 -19
  32. data/lib/metasploit/model/email_address.rb +0 -124
  33. data/lib/metasploit/model/module.rb +0 -20
  34. data/lib/metasploit/model/module/action.rb +0 -52
  35. data/lib/metasploit/model/module/ancestor.rb +0 -491
  36. data/lib/metasploit/model/module/ancestor/spec.rb +0 -6
  37. data/lib/metasploit/model/module/architecture.rb +0 -34
  38. data/lib/metasploit/model/module/author.rb +0 -40
  39. data/lib/metasploit/model/module/class.rb +0 -403
  40. data/lib/metasploit/model/module/class/spec.rb +0 -6
  41. data/lib/metasploit/model/module/handler.rb +0 -29
  42. data/lib/metasploit/model/module/instance.rb +0 -622
  43. data/lib/metasploit/model/module/instance/spec.rb +0 -6
  44. data/lib/metasploit/model/module/path.rb +0 -159
  45. data/lib/metasploit/model/module/platform.rb +0 -32
  46. data/lib/metasploit/model/module/rank.rb +0 -85
  47. data/lib/metasploit/model/module/reference.rb +0 -32
  48. data/lib/metasploit/model/module/stance.rb +0 -16
  49. data/lib/metasploit/model/module/target.rb +0 -78
  50. data/lib/metasploit/model/module/target/architecture.rb +0 -34
  51. data/lib/metasploit/model/module/target/platform.rb +0 -34
  52. data/lib/metasploit/model/module/type.rb +0 -38
  53. data/lib/metasploit/model/platform.rb +0 -246
  54. data/lib/metasploit/model/real_pathname.rb +0 -16
  55. data/lib/metasploit/model/reference.rb +0 -104
  56. data/spec/app/models/metasploit/model/module/ancestor/spec/template_spec.rb +0 -174
  57. data/spec/app/models/metasploit/model/module/class/spec/template_spec.rb +0 -222
  58. data/spec/app/models/metasploit/model/module/instance/spec/template_spec.rb +0 -201
  59. data/spec/app/models/metasploit/model/search/operator/deprecated/app_spec.rb +0 -62
  60. data/spec/app/models/metasploit/model/search/operator/deprecated/author_spec.rb +0 -197
  61. data/spec/app/models/metasploit/model/search/operator/deprecated/authority_spec.rb +0 -135
  62. data/spec/app/models/metasploit/model/search/operator/deprecated/platform_spec.rb +0 -124
  63. data/spec/app/models/metasploit/model/search/operator/deprecated/ref_spec.rb +0 -387
  64. data/spec/app/models/metasploit/model/search/operator/deprecated/text_spec.rb +0 -399
  65. data/spec/app/models/metasploit/model/spec/template_spec.rb +0 -23
  66. data/spec/app/validators/derivation_validator_spec.rb +0 -92
  67. data/spec/app/validators/dynamic_length_validator_spec.rb +0 -293
  68. data/spec/dummy/app/models/dummy/architecture.rb +0 -92
  69. data/spec/dummy/app/models/dummy/author.rb +0 -15
  70. data/spec/dummy/app/models/dummy/authority.rb +0 -130
  71. data/spec/dummy/app/models/dummy/email_address.rb +0 -27
  72. data/spec/dummy/app/models/dummy/module/action.rb +0 -25
  73. data/spec/dummy/app/models/dummy/module/ancestor.rb +0 -67
  74. data/spec/dummy/app/models/dummy/module/architecture.rb +0 -19
  75. data/spec/dummy/app/models/dummy/module/author.rb +0 -28
  76. data/spec/dummy/app/models/dummy/module/class.rb +0 -69
  77. data/spec/dummy/app/models/dummy/module/instance.rb +0 -209
  78. data/spec/dummy/app/models/dummy/module/path.rb +0 -64
  79. data/spec/dummy/app/models/dummy/module/platform.rb +0 -19
  80. data/spec/dummy/app/models/dummy/module/rank.rb +0 -44
  81. data/spec/dummy/app/models/dummy/module/reference.rb +0 -19
  82. data/spec/dummy/app/models/dummy/module/target.rb +0 -62
  83. data/spec/dummy/app/models/dummy/module/target/architecture.rb +0 -19
  84. data/spec/dummy/app/models/dummy/module/target/platform.rb +0 -19
  85. data/spec/dummy/app/models/dummy/platform.rb +0 -58
  86. data/spec/dummy/app/models/dummy/reference.rb +0 -31
  87. data/spec/dummy/spec/factories/dummy/architectures.rb +0 -13
  88. data/spec/dummy/spec/factories/dummy/authorities.rb +0 -32
  89. data/spec/dummy/spec/factories/dummy/authors.rb +0 -8
  90. data/spec/dummy/spec/factories/dummy/email_addresses.rb +0 -8
  91. data/spec/dummy/spec/factories/dummy/module/actions.rb +0 -13
  92. data/spec/dummy/spec/factories/dummy/module/ancestors.rb +0 -45
  93. data/spec/dummy/spec/factories/dummy/module/architectures.rb +0 -35
  94. data/spec/dummy/spec/factories/dummy/module/authors.rb +0 -10
  95. data/spec/dummy/spec/factories/dummy/module/classes.rb +0 -40
  96. data/spec/dummy/spec/factories/dummy/module/instances.rb +0 -86
  97. data/spec/dummy/spec/factories/dummy/module/paths.rb +0 -16
  98. data/spec/dummy/spec/factories/dummy/module/platforms.rb +0 -35
  99. data/spec/dummy/spec/factories/dummy/module/ranks.rb +0 -14
  100. data/spec/dummy/spec/factories/dummy/module/references.rb +0 -17
  101. data/spec/dummy/spec/factories/dummy/module/target/architectures.rb +0 -40
  102. data/spec/dummy/spec/factories/dummy/module/target/platforms.rb +0 -41
  103. data/spec/dummy/spec/factories/dummy/module/targets.rb +0 -46
  104. data/spec/dummy/spec/factories/dummy/platforms.rb +0 -3
  105. data/spec/dummy/spec/factories/dummy/references.rb +0 -26
  106. data/spec/factories/metasploit/model/architectures.rb +0 -6
  107. data/spec/factories/metasploit/model/authorities.rb +0 -28
  108. data/spec/factories/metasploit/model/authors.rb +0 -9
  109. data/spec/factories/metasploit/model/email_addresses.rb +0 -14
  110. data/spec/factories/metasploit/model/module/actions.rb +0 -9
  111. data/spec/factories/metasploit/model/module/ancestors.rb +0 -180
  112. data/spec/factories/metasploit/model/module/architectures.rb +0 -15
  113. data/spec/factories/metasploit/model/module/classes.rb +0 -47
  114. data/spec/factories/metasploit/model/module/handlers.rb +0 -3
  115. data/spec/factories/metasploit/model/module/instances.rb +0 -83
  116. data/spec/factories/metasploit/model/module/paths.rb +0 -51
  117. data/spec/factories/metasploit/model/module/platforms.rb +0 -15
  118. data/spec/factories/metasploit/model/module/ranks.rb +0 -9
  119. data/spec/factories/metasploit/model/module/references.rb +0 -11
  120. data/spec/factories/metasploit/model/module/stances.rb +0 -3
  121. data/spec/factories/metasploit/model/module/targets.rb +0 -22
  122. data/spec/factories/metasploit/model/module/types.rb +0 -5
  123. data/spec/factories/metasploit/model/references.rb +0 -88
  124. data/spec/lib/metasploit/model/architecture_spec.rb +0 -52
  125. data/spec/lib/metasploit/model/author_spec.rb +0 -6
  126. data/spec/lib/metasploit/model/authority/bid_spec.rb +0 -17
  127. data/spec/lib/metasploit/model/authority/cve_spec.rb +0 -17
  128. data/spec/lib/metasploit/model/authority/msb_spec.rb +0 -17
  129. data/spec/lib/metasploit/model/authority/osvdb_spec.rb +0 -17
  130. data/spec/lib/metasploit/model/authority/pmasa_spec.rb +0 -17
  131. data/spec/lib/metasploit/model/authority/secunia_spec.rb +0 -17
  132. data/spec/lib/metasploit/model/authority/us_cert_vu_spec.rb +0 -17
  133. data/spec/lib/metasploit/model/authority/waraxe_spec.rb +0 -51
  134. data/spec/lib/metasploit/model/authority/zdi_spec.rb +0 -21
  135. data/spec/lib/metasploit/model/authority_spec.rb +0 -10
  136. data/spec/lib/metasploit/model/derivation/full_name_spec.rb +0 -75
  137. data/spec/lib/metasploit/model/derivation_spec.rb +0 -217
  138. data/spec/lib/metasploit/model/email_address_spec.rb +0 -19
  139. data/spec/lib/metasploit/model/module/action_spec.rb +0 -6
  140. data/spec/lib/metasploit/model/module/ancestor_spec.rb +0 -6
  141. data/spec/lib/metasploit/model/module/architecture_spec.rb +0 -9
  142. data/spec/lib/metasploit/model/module/author_spec.rb +0 -6
  143. data/spec/lib/metasploit/model/module/class_spec.rb +0 -19
  144. data/spec/lib/metasploit/model/module/handler_spec.rb +0 -61
  145. data/spec/lib/metasploit/model/module/instance_spec.rb +0 -183
  146. data/spec/lib/metasploit/model/module/path_spec.rb +0 -6
  147. data/spec/lib/metasploit/model/module/platform_spec.rb +0 -9
  148. data/spec/lib/metasploit/model/module/rank_spec.rb +0 -29
  149. data/spec/lib/metasploit/model/module/reference_spec.rb +0 -9
  150. data/spec/lib/metasploit/model/module/stance_spec.rb +0 -30
  151. data/spec/lib/metasploit/model/module/target/architecture_spec.rb +0 -9
  152. data/spec/lib/metasploit/model/module/target/platform_spec.rb +0 -9
  153. data/spec/lib/metasploit/model/module/target_spec.rb +0 -9
  154. data/spec/lib/metasploit/model/module/type_spec.rb +0 -125
  155. data/spec/lib/metasploit/model/platform_spec.rb +0 -100
  156. data/spec/lib/metasploit/model/reference_spec.rb +0 -21
  157. data/spec/support/shared/contexts/metasploit/model/module/ancestor/contents/metasploit_module.rb +0 -12
  158. data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents.rb +0 -10
  159. data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents/metasploit_module.rb +0 -15
  160. data/spec/support/shared/examples/derives.rb +0 -115
  161. data/spec/support/shared/examples/metasploit/model/architecture.rb +0 -425
  162. data/spec/support/shared/examples/metasploit/model/architecture/seed.rb +0 -25
  163. data/spec/support/shared/examples/metasploit/model/author.rb +0 -27
  164. data/spec/support/shared/examples/metasploit/model/authority.rb +0 -124
  165. data/spec/support/shared/examples/metasploit/model/authority/seed.rb +0 -49
  166. data/spec/support/shared/examples/metasploit/model/email_address.rb +0 -220
  167. data/spec/support/shared/examples/metasploit/model/module/action.rb +0 -26
  168. data/spec/support/shared/examples/metasploit/model/module/ancestor.rb +0 -2004
  169. data/spec/support/shared/examples/metasploit/model/module/ancestor/payload_factory.rb +0 -63
  170. data/spec/support/shared/examples/metasploit/model/module/architecture.rb +0 -36
  171. data/spec/support/shared/examples/metasploit/model/module/author.rb +0 -29
  172. data/spec/support/shared/examples/metasploit/model/module/class.rb +0 -1514
  173. data/spec/support/shared/examples/metasploit/model/module/handler.rb +0 -21
  174. data/spec/support/shared/examples/metasploit/model/module/instance.rb +0 -1384
  175. data/spec/support/shared/examples/metasploit/model/module/instance/class_methods.rb +0 -537
  176. data/spec/support/shared/examples/metasploit/model/module/instance/is_not_stanced_with_module_type.rb +0 -22
  177. data/spec/support/shared/examples/metasploit/model/module/instance/is_stanced_with_module_type.rb +0 -38
  178. data/spec/support/shared/examples/metasploit/model/module/instance/validates/dynamic_length_of.rb +0 -131
  179. data/spec/support/shared/examples/metasploit/model/module/path.rb +0 -493
  180. data/spec/support/shared/examples/metasploit/model/module/platform.rb +0 -36
  181. data/spec/support/shared/examples/metasploit/model/module/rank.rb +0 -92
  182. data/spec/support/shared/examples/metasploit/model/module/reference.rb +0 -16
  183. data/spec/support/shared/examples/metasploit/model/module/target.rb +0 -29
  184. data/spec/support/shared/examples/metasploit/model/module/target/architecture.rb +0 -56
  185. data/spec/support/shared/examples/metasploit/model/module/target/platform.rb +0 -56
  186. data/spec/support/shared/examples/metasploit/model/platform.rb +0 -213
  187. data/spec/support/shared/examples/metasploit/model/real_pathname.rb +0 -29
  188. data/spec/support/shared/examples/metasploit/model/reference.rb +0 -410
  189. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/app.rb +0 -44
  190. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/authority.rb +0 -72
  191. data/spec/support/templates/metasploit/model/module/ancestors/_attributes.rb.erb +0 -9
  192. data/spec/support/templates/metasploit/model/module/ancestors/_methods.rb.erb +0 -8
  193. data/spec/support/templates/metasploit/model/module/ancestors/_validations.rb.erb +0 -6
  194. data/spec/support/templates/metasploit/model/module/ancestors/base.rb.erb +0 -3
  195. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_auxiliary.rb.erb +0 -1
  196. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_encoder.rb.erb +0 -1
  197. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_exploit.rb.erb +0 -1
  198. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_non_payload.rb.erb +0 -5
  199. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_nop.rb.erb +0 -1
  200. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_payload.rb.erb +0 -4
  201. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_post.rb.erb +0 -1
  202. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_handled.rb.erb +0 -20
  203. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_single.rb.erb +0 -1
  204. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stage.rb.erb +0 -0
  205. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stager.rb.erb +0 -1
  206. data/spec/support/templates/metasploit/model/module/classes/_methods.rb.erb +0 -9
@@ -1,222 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Module::Class::Spec::Template do
4
- subject(:template) do
5
- described_class.new(
6
- module_class: module_class
7
- )
8
- end
9
-
10
- let(:module_class) do
11
- FactoryGirl.build(
12
- :dummy_module_class
13
- )
14
- end
15
-
16
- context 'validations' do
17
- it { should validate_presence_of :module_class }
18
-
19
- context '#ancestor_templates_valid' do
20
- subject(:ancestor_templates_valid) do
21
- template.send(:ancestor_templates_valid)
22
- end
23
-
24
- #
25
- # let
26
- #
27
-
28
- let(:error) do
29
- I18n.translate!(:'errors.messages.invalid')
30
- end
31
-
32
- #
33
- # Callbacks
34
- #
35
-
36
- before(:each) do
37
- allow(template).to receive(:ancestor_templates).and_return(ancestor_templates)
38
- end
39
-
40
- context 'with ancestor_templates' do
41
- #
42
- # lets
43
- #
44
-
45
- let(:ancestor_templates) do
46
- Array.new(2) { |i|
47
- double("Ancestor Template #{i}")
48
- }
49
- end
50
-
51
- #
52
- # Callbacks
53
- #
54
-
55
- context 'with all valid' do
56
- before(:each) do
57
- ancestor_templates.each do |child|
58
- child.stub(valid?: true)
59
- end
60
- end
61
-
62
- it 'does not add error on :ancestor_templates' do
63
- template.valid?
64
-
65
- template.errors[:ancestor_templates].should_not include(error)
66
- end
67
- end
68
-
69
- context 'with later valid' do
70
- before(:each) do
71
- ancestor_templates.first.stub(valid?: false)
72
- ancestor_templates.second.stub(valid?: true)
73
- end
74
-
75
- it 'does not short-circuit and validates all ancestor_templates' do
76
- ancestor_templates.second.should_receive(:valid?).and_return(true)
77
-
78
- ancestor_templates_valid
79
- end
80
-
81
- it 'should add error on :ancestor_templates' do
82
- template.valid?
83
-
84
- template.errors[:ancestor_templates].should include(error)
85
- end
86
- end
87
- end
88
-
89
- context 'without ancestor_templates' do
90
- let(:ancestor_templates) do
91
- []
92
- end
93
-
94
- it 'does not add error on :ancestor_templates' do
95
- template.valid?
96
-
97
- template.errors[:ancestor_templates].should_not include(error)
98
- end
99
- end
100
- end
101
- end
102
-
103
- context '#ancestor_templates' do
104
- subject(:ancestor_templates) do
105
- template.ancestor_templates
106
- end
107
-
108
- it 'creates Metasploit::Model::Module::Ancestor::Spec::Template for each ancestor in module_class.ancestors' do
109
- template_module_ancestors = ancestor_templates.map(&:module_ancestor)
110
-
111
- expect(template_module_ancestors).to match_array(module_class.ancestors)
112
- end
113
-
114
- context 'Metasploit::Model::Module::Ancestor::Spec::Template' do
115
- context 'locals' do
116
- subject(:ancestor_template_locals) do
117
- ancestor_templates.map(&:locals)
118
- end
119
-
120
- context '[:module_class]' do
121
- subject(:local_module_classes) do
122
- ancestor_template_locals.collect { |locals|
123
- locals[:module_class]
124
- }
125
- end
126
-
127
- it 'is #module_class' do
128
- expect(
129
- local_module_classes.all? { |local_module_class|
130
- local_module_class == module_class
131
- }
132
- ).to be_true
133
- end
134
- end
135
- end
136
-
137
- context 'overwrite' do
138
- subject(:overwrites) do
139
- ancestor_templates.map(&:overwrite)
140
- end
141
-
142
- it 'is true so the the ancestor written templates will be overwritten by the class templates' do
143
- expect(
144
- overwrites.all? { |overwrite|
145
- overwrite == true
146
- }
147
- ).to be_true
148
- end
149
- end
150
-
151
- context 'search_pathnames' do
152
- subject(:search_pathnames) do
153
- ancestor_templates.map(&:search_pathnames)
154
- end
155
-
156
- it "has 'module/classes' before 'module/ancestors'" do
157
- expect(
158
- search_pathnames.all? { |template_search_pathnames|
159
- module_classes_index = template_search_pathnames.index(Pathname.new('module/classes'))
160
- module_ancestors_index = template_search_pathnames.index(Pathname.new('module/ancestors'))
161
-
162
- module_classes_index < module_ancestors_index
163
- }
164
- ).to be_true
165
- end
166
- end
167
- end
168
- end
169
-
170
- context 'write' do
171
- subject(:write) do
172
- described_class.write(attributes)
173
- end
174
-
175
- context 'with valid' do
176
- let(:attributes) do
177
- {
178
- module_class: module_class
179
- }
180
- end
181
-
182
- it { should be_true }
183
-
184
- it 'writes template' do
185
- # memoize attributes so any other writes besides the one under-test are already run.
186
- attributes
187
-
188
- described_class.any_instance.should_receive(:write)
189
-
190
- write
191
- end
192
- end
193
-
194
- context 'without valid' do
195
- let(:attributes) do
196
- {}
197
- end
198
-
199
- it { should be_false }
200
-
201
- it 'does not write template' do
202
- described_class.any_instance.should_not_receive(:write)
203
-
204
- write
205
- end
206
- end
207
- end
208
-
209
- context '#write' do
210
- subject(:write) do
211
- template.write
212
- end
213
-
214
- it 'writes each ancestor template' do
215
- template.ancestor_templates.each do |ancestor_template|
216
- expect(ancestor_template).to receive(:write)
217
- end
218
-
219
- write
220
- end
221
- end
222
- end
@@ -1,201 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Module::Instance::Spec::Template do
4
- subject(:template) do
5
- described_class.new(
6
- module_instance: module_instance
7
- )
8
- end
9
-
10
- let(:module_instance) do
11
- FactoryGirl.build(:dummy_module_instance)
12
- end
13
-
14
- context 'validations' do
15
- context '#class_template' do
16
- subject(:class_template_errors) do
17
- template.errors[:class_template]
18
- end
19
-
20
- context 'presence' do
21
- let(:error) do
22
- I18n.translate!('errors.messages.blank')
23
- end
24
-
25
- context 'with nil' do
26
- before(:each) do
27
- allow(template).to receive(:class_template).and_return(nil)
28
- template.valid?
29
- end
30
-
31
- it { should include error }
32
- end
33
-
34
- context 'without nil' do
35
- before(:each) do
36
- template.valid?
37
- end
38
-
39
- it { should_not include error }
40
- end
41
- end
42
-
43
- context '#class_template_valid' do
44
- let(:error) do
45
- I18n.translate!('errors.messages.invalid')
46
- end
47
-
48
- context 'with #class_template' do
49
- context 'with valid' do
50
- before(:each) do
51
- template.valid?
52
- end
53
-
54
- it { should_not include(error) }
55
- end
56
-
57
- context 'without valid' do
58
- before(:each) do
59
- expect(template.class_template).to receive(:valid?).and_return(false)
60
- template.valid?
61
- end
62
-
63
- it { should include(error) }
64
- end
65
- end
66
-
67
- context 'without #class_template' do
68
- before(:each) do
69
- allow(template).to receive(:class_template).and_return(nil)
70
- template.valid?
71
- end
72
-
73
- it { should_not include(error) }
74
- end
75
- end
76
- end
77
-
78
- it { should validate_presence_of :module_instance }
79
- end
80
-
81
- context '#class_template' do
82
- subject(:class_template) do
83
- template.class_template
84
- end
85
-
86
- context 'with #module_instance' do
87
- it { should be_a Metasploit::Model::Module::Class::Spec::Template }
88
-
89
- context '#ancestor_templates' do
90
- subject(:ancestor_templates) do
91
- class_template.ancestor_templates
92
- end
93
-
94
- context 'locals' do
95
- subject(:ancestor_template_locals) do
96
- ancestor_templates.map(&:locals)
97
- end
98
-
99
- context '[:module_instance]' do
100
- subject(:module_instances) do
101
- ancestor_template_locals.collect { |locals|
102
- locals[:module_instance]
103
- }
104
- end
105
-
106
- it 'is #module_instance' do
107
- expect(
108
- module_instances.all? { |actual_module_instance|
109
- actual_module_instance == module_instance
110
- }
111
- ).to be_true
112
- end
113
- end
114
- end
115
-
116
- context 'search_pathnames' do
117
- subject(:search_pathnames) do
118
- ancestor_templates.map(&:search_pathnames)
119
- end
120
-
121
- it "has 'module/instances', then 'module/classes', then 'module/ancestors'" do
122
- search_pathnames.each do |actual_search_pathnames|
123
- module_instances_index = actual_search_pathnames.index(Pathname.new('module/instances'))
124
- module_classes_index = actual_search_pathnames.index(Pathname.new('module/classes'))
125
- module_ancestors_index = actual_search_pathnames.index(Pathname.new('module/ancestors'))
126
-
127
- expect(module_instances_index).to be < module_classes_index
128
- expect(module_classes_index).to be < module_ancestors_index
129
- end
130
- end
131
- end
132
- end
133
-
134
- context '#module_class' do
135
- it 'is module_instance.module_class' do
136
- expect(class_template.module_class).to eq(module_instance.module_class)
137
- end
138
- end
139
- end
140
-
141
- context 'without #module_instance' do
142
- let(:module_instance) do
143
- nil
144
- end
145
-
146
- it { should be_nil }
147
- end
148
- end
149
-
150
- context 'write' do
151
- subject(:write) do
152
- described_class.write(attributes)
153
- end
154
-
155
- context 'with valid' do
156
- let(:attributes) do
157
- {
158
- module_instance: module_instance
159
- }
160
- end
161
-
162
- it { should be_true }
163
-
164
- it 'writes template' do
165
- # memoize attributes so any other writes besides the one under-test are already run.
166
- attributes
167
-
168
- described_class.any_instance.should_receive(:write)
169
-
170
- write
171
- end
172
- end
173
-
174
- context 'without valid' do
175
- let(:attributes) do
176
- {}
177
- end
178
-
179
- it { should be_false }
180
-
181
- it 'does not write template' do
182
- described_class.any_instance.should_not_receive(:write)
183
-
184
- write
185
- end
186
- end
187
- end
188
-
189
- context '#write' do
190
- subject(:write) do
191
- template.write
192
- end
193
-
194
- it 'delegates to #class_template' do
195
- expected = double('#write')
196
-
197
- expect(template.class_template).to receive(:write).and_return(expected)
198
- expect(write).to eq(expected)
199
- end
200
- end
201
- end
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operator::Deprecated::App do
4
- subject(:operator) do
5
- described_class.new(
6
- :klass => klass
7
- )
8
- end
9
-
10
- let(:klass) do
11
- Class.new
12
- end
13
-
14
- it { should be_a Metasploit::Model::Search::Operator::Delegation }
15
-
16
- context 'CONSTANTS' do
17
- context 'STANCE_BY_APP' do
18
- subject(:stance_by_app) do
19
- described_class::STANCE_BY_APP
20
- end
21
-
22
- its(['client']) { should == 'passive' }
23
- its(['server']) { should == 'aggressive' }
24
- end
25
- end
26
-
27
- context '#operate_on' do
28
- subject(:operation) do
29
- operator.operate_on(formatted_value)
30
- end
31
-
32
- let(:stance_operator) do
33
- Metasploit::Model::Search::Operator::Attribute.new(
34
- :attribute => :stance,
35
- :klass => klass,
36
- :type => :string
37
- )
38
- end
39
-
40
- before(:each) do
41
- operator.stub(:operator).with('stance').and_return(stance_operator)
42
- end
43
-
44
- context 'with client' do
45
- let(:formatted_value) do
46
- 'client'
47
- end
48
-
49
- its('operator.name') { should == :stance }
50
- its(:value) { should == 'passive' }
51
- end
52
-
53
- context 'with server' do
54
- let(:formatted_value) do
55
- 'server'
56
- end
57
-
58
- its('operator.name') { should == :stance }
59
- its(:value) { should == 'aggressive' }
60
- end
61
- end
62
- end