spec/network/tcp/tcp_spec.rb in ronin-support-0.5.0.rc2 vs spec/network/tcp/tcp_spec.rb in ronin-support-0.5.0

- old
+ new

@@ -75,16 +75,18 @@ describe "#tcp_connect_and_send" do let(:data) { "HELO ronin\n" } let(:local_port) { 1024 + rand(65535 - 1024) } + let(:expected_response) { "250 mx.google.com at your service\r\n" } + it "should connect and then send data" do socket = subject.tcp_connect_and_send(data,host,port) banner = socket.readline response = socket.readline - response.start_with?('250').should be_true + response.should == expected_response socket.close end it "should bind to a local host and port" do @@ -102,11 +104,11 @@ socket = subject.tcp_connect_and_send(data,host,port) do |socket| banner = socket.readline response = socket.readline end - response.start_with?('250').should be_true + response.should == expected_response socket.close end end @@ -134,34 +136,35 @@ bound_port.should == local_port end end describe "#tcp_banner" do - let(:host) { 'smtp.gmail.com' } - let(:port) { 25 } - + let(:host) { 'smtp.gmail.com' } + let(:port) { 25 } let(:local_port) { 1024 + rand(65535 - 1024) } - it "should read the service banner" do + let(:expected_banner) { /^220 mx\.google\.com ESMTP/ } + + it "should return the read service banner" do banner = subject.tcp_banner(host,port) - banner.start_with?('220').should be_true + banner.should =~ expected_banner end it "should bind to a local host and port" do banner = subject.tcp_banner(host,port,nil,local_port) - banner.start_with?('220').should be_true + banner.should =~ expected_banner end it "should yield the banner" do banner = nil subject.tcp_banner(host,port) do |yielded_banner| banner = yielded_banner end - banner.start_with?('220').should be_true + banner.should =~ expected_banner end end describe "#tcp_send" do let(:server) { TCPServer.new(server_host,0) }