Skip to content

Commit 468f637

Browse files
David MaloneyDavid Maloney
authored andcommitted
basics for adding tlvs to GroupTlv
1 parent 5dcf573 commit 468f637

File tree

1 file changed

+88
-1
lines changed

1 file changed

+88
-1
lines changed

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

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,96 @@
118118
subject.should respond_to :tlvs
119119
end
120120

121+
it "should respond to each" do
122+
subject.should respond_to :each
123+
end
124+
125+
it "should respond to each_tlv" do
126+
subject.should respond_to :each_tlv
127+
end
128+
129+
it "should respond to each_with_index" do
130+
subject.should respond_to :each_with_index
131+
end
132+
133+
it "should respond to each_tlv_with_index" do
134+
subject.should respond_to :each_tlv_with_index
135+
end
136+
137+
it "should respond to get_tlvs" do
138+
subject.should respond_to :get_tlvs
139+
end
140+
141+
it "should respond to add_tlv" do
142+
subject.should respond_to :add_tlv
143+
end
144+
145+
it "should respond to add_tlvs" do
146+
subject.should respond_to :add_tlvs
147+
end
148+
149+
it "should respond to get_tlv" do
150+
subject.should respond_to :get_tlv
151+
end
152+
153+
it "should respond to get_tlv_value" do
154+
subject.should respond_to :get_tlv_value
155+
end
156+
157+
it "should respond to get_tlv_values" do
158+
subject.should respond_to :get_tlv_values
159+
end
160+
161+
it "should respond to has_tlv?" do
162+
subject.should respond_to :has_tlv?
163+
end
164+
165+
it "should respond to reset" do
166+
subject.should respond_to :reset
167+
end
168+
169+
it "should respond to to_r" do
170+
subject.should respond_to :to_r
171+
end
172+
173+
it "should respond to from_r" do
174+
subject.should respond_to :from_r
175+
end
176+
121177
it "should return an empty array for tlvs by default" do
122178
subject.tlvs.should == []
123179
end
124180

125-
181+
context "the add_tlv method" do
182+
it "should add to the tlvs array when given basic tlv paramaters" do
183+
subject.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test")
184+
subject.tlvs.first.type.should == Rex::Post::Meterpreter::TLV_TYPE_STRING
185+
subject.tlvs.first.value.should == "test"
186+
end
187+
188+
it "should replace any existing TLV of the same type when the replace flag is set to true" do
189+
subject.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test")
190+
subject.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test2", true)
191+
subject.tlvs.first.value.should == "test2"
192+
end
193+
194+
it "should add both if replace is set to false" do
195+
subject.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test")
196+
subject.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test2", false)
197+
subject.tlvs.first.value.should == "test"
198+
subject.tlvs.last.value.should == "test2"
199+
end
200+
end
201+
202+
context "the add_tlvs method" do
203+
204+
end
205+
206+
context "with TLVs added" do
207+
before(:all) do
208+
#subject.add_tlv
209+
end
210+
end
211+
212+
126213
end

0 commit comments

Comments
 (0)