39
39
subject . should respond_to :from_r
40
40
end
41
41
42
+ context "A String TLV" do
43
+ it "should return the correct TLV type" do
44
+ subject . type . should == Rex ::Post ::Meterpreter ::TLV_TYPE_STRING
45
+ end
46
+
47
+ it "should return the correct value" do
48
+ subject . value . should == "test"
49
+ end
50
+
51
+ context "the type? method" do
52
+ it "should return true for STRING" do
53
+ subject . type? ( Rex ::Post ::Meterpreter ::TLV_TYPE_STRING ) . should == true
54
+ end
55
+
56
+ it "should return false for UINT" do
57
+ subject . type? ( Rex ::Post ::Meterpreter ::TLV_TYPE_UINT ) . should == false
58
+ end
59
+ end
60
+
61
+ context "the value? method" do
62
+ it "should return true for the correct value" do
63
+ subject . value? ( "test" ) . should == true
64
+ end
65
+
66
+ it "should return false for an incorrect value" do
67
+ subject . value? ( "fake" ) . should == false
68
+ end
69
+ end
70
+
71
+ context "the inspect method" do
72
+ it "should return a string representation of the TLV" do
73
+ tlv_to_s = "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\" test\" >"
74
+ subject . inspect . should == tlv_to_s
75
+ end
76
+ end
77
+
78
+ context "the to_r method" do
79
+ it "should return the raw bytes of the TLV to send over the wire" do
80
+ tlv_bytes = "\x00 \x00 \x00 \r \x00 \x01 \x00 \n test\x00 "
81
+ subject . to_r . should == tlv_bytes
82
+ end
83
+ end
84
+
85
+ context "the from_r method" do
86
+ it "should adjust the tlv attributes from the given raw bytes" do
87
+ subject . from_r ( "\x00 \x00 \x00 \r \x00 \x01 \x00 \n tes2\x00 " )
88
+ subject . value . should == "tes2"
89
+ end
90
+ end
91
+ end
92
+
42
93
end
0 commit comments