Skip to content

Commit 7cf812e

Browse files
committed
add rspec test for inspect on all TLV_TYPE objects
1 parent 677d070 commit 7cf812e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,27 @@
8181
end
8282
end
8383

84+
context "Any non group TLV_TYPE" do
85+
subject(:tlv_types){
86+
excludedTypes = ["TLV_TYPE_ANY", "TLV_TYPE_EXCEPTION", "TLV_TYPE_CHANNEL_DATA_GROUP", "TLV_TYPE_TRANS_GROUP", "TLV_TYPE_CIPHER_PARAMETERS"]
87+
typeList = []
88+
Rex::Post::Meterpreter.constants.each do |type|
89+
typeList << type.to_s if type.to_s.include?("TLV_TYPE") && !excludedTypes.include?(type.to_s)
90+
end
91+
typeList
92+
}
93+
94+
it "will not raise error on inspect" do
95+
tlv_types.each do |type|
96+
inspectable = Rex::Post::Meterpreter::Tlv.new(
97+
Rex::Post::Meterpreter.const_get(type),
98+
"test"
99+
)
100+
expect(inspectable.inspect).to be_a_kind_of String
101+
end
102+
end
103+
end
104+
84105
context "#to_r" do
85106
it "should return the raw bytes of the TLV to send over the wire" do
86107
tlv_bytes = "\x00\x00\x00\r\x00\x01\x00\ntest\x00"

0 commit comments

Comments
 (0)