CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/proto/rmi/model/continuation_spec.rb
Views: 11791
1
# -*- coding:binary -*-
2
require 'spec_helper'
3
4
require 'stringio'
5
6
RSpec.describe Rex::Proto::Rmi::Model::Continuation do
7
8
subject(:continuation) do
9
described_class.new
10
end
11
12
let(:sample) do
13
"\x00\x0e\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32" +
14
"\x00\x00\x00\x00"
15
end
16
17
let(:sample_io) { StringIO.new(sample) }
18
19
describe "#decode" do
20
it "returns the Rex::Proto::Rmi::Model::Continuation decoded" do
21
expect(continuation.decode(sample_io)).to eq(continuation)
22
end
23
24
it "decodes length correctly" do
25
continuation.decode(sample_io)
26
expect(continuation.length).to eq(14)
27
end
28
29
it "decodes address correctly" do
30
continuation.decode(sample_io)
31
expect(continuation.address).to eq('172.16.158.132')
32
end
33
34
it "decodes port correctly" do
35
continuation.decode(sample_io)
36
expect(continuation.port).to eq(0)
37
end
38
end
39
40
describe "#encode" do
41
it "encodes the Continuation correctly" do
42
continuation.address = '172.16.158.132'
43
continuation.length = continuation.address.length
44
continuation.port = 0
45
46
expect(continuation.encode).to eq(sample)
47
end
48
end
49
end
50
51