Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/rex/proto/thrift/thrift_header_spec.rb
Views: 11789
RSpec.describe Rex::Proto::Thrift::ThriftHeader do1let(:value) { { version: 0x8001, message_type: 1, method_name: '', sequence_id: 1 } }2let(:binary_s) { "\x80\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01".b }3subject(:instance) { described_class.new }45it { should respond_to :version }6it { should respond_to :message_type }7it { should respond_to :method_name }8it { should respond_to :sequence_id }910it 'is big endian' do11expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :big12end1314it 'tracks the version in a Uint16 field' do15expect(instance.version).to be_a BinData::Uint16be16end1718it 'tracks the message type in a ThriftMessageType field' do19expect(instance.message_type).to be_a Rex::Proto::Thrift::ThriftMessageType20end2122it 'tracks the method name in a ThriftString field' do23expect(instance.method_name).to be_a Rex::Proto::Thrift::ThriftString24end2526it 'tracks the sequence ID in a Uint32 field' do27expect(instance.sequence_id).to be_a BinData::Uint32be28end2930it 'sets the version correctly by default' do31expect(instance.version).to eq 0x800132end3334describe '#to_binary_s' do35it 'should correctly encode' do36expect(described_class.new(value).to_binary_s).to eq binary_s37end38end3940describe '.read' do41it 'should correctly decode' do42expect(described_class.read(binary_s)).to eq value43end44end45end464748