Skip to content

Commit aaa8716

Browse files
David MaloneyDavid Maloney
authored andcommitted
minor cleanup as per egypt
1 parent c952ed0 commit aaa8716

File tree

1 file changed

+43
-19
lines changed

1 file changed

+43
-19
lines changed

spec/lib/rex/post/meterpreter/packet_spec.rb

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
require 'rex/post/meterpreter/packet'
22

33
describe Rex::Post::Meterpreter::Tlv do
4-
subject{Rex::Post::Meterpreter::Tlv.new(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test")}
4+
subject{
5+
Rex::Post::Meterpreter::Tlv.new(
6+
Rex::Post::Meterpreter::TLV_TYPE_STRING,
7+
"test"
8+
)
9+
}
510

611
it "should respond to type" do
712
subject.should respond_to :type
@@ -48,7 +53,7 @@
4853
subject.value.should == "test"
4954
end
5055

51-
context "the type? method" do
56+
context "#type?" do
5257
it "should return true for STRING" do
5358
subject.type?(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == true
5459
end
@@ -58,7 +63,7 @@
5863
end
5964
end
6065

61-
context "the value? method" do
66+
context "#value?" do
6267
it "should return true for the correct value" do
6368
subject.value?("test").should == true
6469
end
@@ -68,21 +73,21 @@
6873
end
6974
end
7075

71-
context "the inspect method" do
76+
context "#inspect" do
7277
it "should return a string representation of the TLV" do
7378
tlv_to_s = "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test\">"
7479
subject.inspect.should == tlv_to_s
7580
end
7681
end
7782

78-
context "the to_r method" do
83+
context "#to_r" do
7984
it "should return the raw bytes of the TLV to send over the wire" do
8085
tlv_bytes = "\x00\x00\x00\r\x00\x01\x00\ntest\x00"
8186
subject.to_r.should == tlv_bytes
8287
end
8388
end
8489

85-
context "the from_r method" do
90+
context "#from_r" do
8691
it "should adjust the tlv attributes from the given raw bytes" do
8792
subject.from_r("\x00\x00\x00\r\x00\x01\x00\ntes2\x00")
8893
subject.value.should == "tes2"
@@ -91,8 +96,13 @@
9196
end
9297

9398
context "A Method TLV" do
94-
subject{Rex::Post::Meterpreter::Tlv.new(Rex::Post::Meterpreter::TLV_TYPE_METHOD,"test")}
95-
it "should return true when checked for a meta type of String" do
99+
subject{
100+
Rex::Post::Meterpreter::Tlv.new(
101+
Rex::Post::Meterpreter::TLV_TYPE_METHOD,
102+
"test"
103+
)
104+
}
105+
it "should have a meta type of String" do
96106
subject.meta_type?(Rex::Post::Meterpreter::TLV_META_TYPE_STRING).should == true
97107
end
98108

@@ -112,7 +122,11 @@
112122
end
113123

114124
describe Rex::Post::Meterpreter::GroupTlv do
115-
subject{Rex::Post::Meterpreter::GroupTlv.new(Rex::Post::Meterpreter::TLV_TYPE_CHANNEL_DATA_GROUP)}
125+
subject{
126+
Rex::Post::Meterpreter::GroupTlv.new(
127+
Rex::Post::Meterpreter::TLV_TYPE_CHANNEL_DATA_GROUP
128+
)
129+
}
116130

117131
it "should respond to tlvs" do
118132
subject.should respond_to :tlvs
@@ -178,7 +192,7 @@
178192
subject.tlvs.should == []
179193
end
180194

181-
context "the add_tlv method" do
195+
context "#add_tlv" do
182196
it "should add to the tlvs array when given basic tlv paramaters" do
183197
subject.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test")
184198
subject.tlvs.first.type.should == Rex::Post::Meterpreter::TLV_TYPE_STRING
@@ -200,7 +214,7 @@
200214
end
201215
end
202216

203-
context "the add_tlvs method" do
217+
context "#add_tlvs" do
204218
it "should be able to add an array of type-value hashes" do
205219
tlv_array = [
206220
{'type' => Rex::Post::Meterpreter::TLV_TYPE_STRING, 'value' => "test"},
@@ -254,7 +268,7 @@
254268
end
255269

256270

257-
context "the from_r method" do
271+
context "#from_r" do
258272
it "should build the TLV group when given the propper raw bytes" do
259273
subject.reset
260274
subject.from_r( @raw_group)
@@ -265,7 +279,7 @@
265279
end
266280

267281

268-
context "the get_tlvs method" do
282+
context "#get_tlvs" do
269283
it "should return all TLVs of the supplied type" do
270284
tlvs = subject.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_STRING)
271285
tlvs.count.should == 2
@@ -287,7 +301,7 @@
287301
end
288302
end
289303

290-
context "the get tlv_method" do
304+
context "#get_tlv" do
291305
it "should return the first TLV of the specified type by default" do
292306
subject.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == subject.tlvs.first
293307
subject.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_UINT).should == subject.tlvs.last
@@ -306,7 +320,7 @@
306320
end
307321
end
308322

309-
context "the get_tlv_value method" do
323+
context "#get_tlv_value" do
310324
it "should return the value of the first TLV with the given type" do
311325
subject.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == subject.tlvs.first.value
312326
end
@@ -324,7 +338,7 @@
324338
end
325339
end
326340

327-
context "the get_tlv_values method" do
341+
context "#get_tlv_values" do
328342
it "should return an array of values for the designated TLV types" do
329343
subject.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == ["test", "test2"]
330344
end
@@ -334,7 +348,7 @@
334348
end
335349
end
336350

337-
context "the has_tlv? method" do
351+
context "#has_tlv?" do
338352
it "should return true if the TLV Type is present" do
339353
subject.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == true
340354
end
@@ -348,7 +362,12 @@
348362

349363
describe Rex::Post::Meterpreter::Packet do
350364
context "Request Packet" do
351-
subject{Rex::Post::Meterpreter::Packet.new(Rex::Post::Meterpreter::PACKET_TYPE_REQUEST, "test_method")}
365+
subject{
366+
Rex::Post::Meterpreter::Packet.new(
367+
Rex::Post::Meterpreter::PACKET_TYPE_REQUEST,
368+
"test_method"
369+
)
370+
}
352371

353372
it "should respond to created_at" do
354373
subject.should respond_to :created_at
@@ -426,7 +445,12 @@
426445
end
427446

428447
context "a response packet" do
429-
subject{Rex::Post::Meterpreter::Packet.new(Rex::Post::Meterpreter::PACKET_TYPE_RESPONSE, "test_method")}
448+
subject{
449+
Rex::Post::Meterpreter::Packet.new(
450+
Rex::Post::Meterpreter::PACKET_TYPE_RESPONSE,
451+
"test_method"
452+
)
453+
}
430454
before(:all) do
431455
subject.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_RESULT, "a-ok")
432456
end

0 commit comments

Comments
 (0)