Path: blob/master/spec/lib/rex/proto/http/packet_spec.rb
19778 views
1require 'spec_helper'23RSpec.describe Rex::Proto::Http::Packet do4it_behaves_like "hash with insensitive keys"56describe "#parse" do7let :body do8"Super body"9end10subject do11s = described_class.new12s.parse packet_str1314s15end16context "with a request packet" do17let :packet_str do18"GET / HTTP/1.0\r\n" \19"Foo: Bar\r\n" \20"Content-Length: #{body.length}\r\n" \21"\r\n" \22"#{body}"23end2425it "should have correct headers" do26expect(subject["foo"]).to eq "Bar"27expect(subject["Content-Length"]).to eq body.length.to_s28expect(subject.cmd_string).to eq "GET / HTTP/1.0\r\n"29expect(subject.body).to eq body30end31end3233context "with a response packet" do34let :packet_str do35"HTTP/1.0 200 OK\r\n" \36"Foo: Bar\r\n" \37"Content-Length: #{body.length}\r\n" \38"\r\n" \39"#{body}"40end4142it "should have correct headers" do43expect(subject["foo"]).to eq "Bar"44expect(subject["Content-Length"]).to eq body.length.to_s45expect(subject.cmd_string).to eq "HTTP/1.0 200 OK\r\n"46expect(subject.body).to eq body47end48end4950end51end525354