Permalink
Browse files

Moving @cli and @ip to instance vars

  • Loading branch information...
1 parent caed599 commit 73f631437365a610f9c3a4fbd6561a6c80f42e37 @todb todb committed Feb 25, 2013
Showing with 54 additions and 40 deletions.
  1. +12 −0 Gemfile.lock
  2. +42 −40 spec/lib/rex/proto/http/client_spec.rb
View
@@ -28,15 +28,20 @@ GEM
coderay (1.0.8)
diff-lcs (1.1.3)
i18n (0.6.1)
+ json (1.7.7)
method_source (0.8.1)
+ msgpack (0.5.2)
multi_json (1.0.4)
+ nokogiri (1.5.6)
+ pcaprub (0.11.3)
pg (0.14.1)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.3.1)
rake (10.0.2)
redcarpet (2.2.2)
+ robots (0.10.1)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
@@ -57,10 +62,17 @@ PLATFORMS
ruby
DEPENDENCIES
+ activerecord
activesupport (>= 3.0.0)
+ json
metasploit_data_models!
+ msgpack
+ nokogiri
+ pcaprub
+ pg (>= 0.11)
rake
redcarpet
+ robots
rspec (>= 2.12)
simplecov (= 0.5.4)
yard
@@ -28,31 +28,33 @@ def excuse_needs_auth
end
- ip = "1.2.3.4"
+ before(:all) do
+ @ip = "1.2.3.4"
+ @cli = Rex::Proto::Http::Client.new(@ip)
+ end
- cli = Rex::Proto::Http::Client.new(ip)
it "should respond to intialize" do
- cli.should be
+ @cli.should be
end
it "should have a set of default instance variables" do
- cli.instance_variable_get(:@hostname).should == ip
- cli.instance_variable_get(:@port).should == 80
- cli.instance_variable_get(:@context).should == {}
- cli.instance_variable_get(:@ssl).should be_false
- cli.instance_variable_get(:@proxies).should be_nil
- # cli.instance_variable_get(:@username).should be_empty
- # cli.instance_variable_get(:@password).should be_empty
- cli.config.should be_a_kind_of Hash
- cli.config_types.should be_a_kind_of Hash
+ @cli.instance_variable_get(:@hostname).should == @ip
+ @cli.instance_variable_get(:@port).should == 80
+ @cli.instance_variable_get(:@context).should == {}
+ @cli.instance_variable_get(:@ssl).should be_false
+ @cli.instance_variable_get(:@proxies).should be_nil
+ # @cli.instance_variable_get(:@username).should be_empty
+ # @cli.instance_variable_get(:@password).should be_empty
+ @cli.config.should be_a_kind_of Hash
+ @cli.config_types.should be_a_kind_of Hash
end
it "should produce a raw HTTP request", :pending => "Waiting for PR #1500" do
- cli.request_raw.should be_a_kind_of Rex::Proto::Http::Request
+ @cli.request_raw.should be_a_kind_of Rex::Proto::Http::Request
end
it "should produce a CGI HTTP request", :pending => "Waiting for PR #1500" do
- cli.request_cgi.should be_a_kind_of Rex::Proto::Http::Request
+ @cli.request_cgi.should be_a_kind_of Rex::Proto::Http::Request
end
it "should attempt to connect to a server" do
@@ -61,7 +63,7 @@ def excuse_needs_auth
end
it "should be able to close a connection" do
- cli.close.should be_nil
+ @cli.close.should be_nil
end
it "should send a request and receive a response", :pending => excuse_needs_connection do
@@ -77,7 +79,7 @@ def excuse_needs_auth
end
it "should test for credentials" do
- # cli.should_not have_creds
+ # @cli.should_not have_creds
# this_cli = Rex::Proto::Http::Client.new("127.0.0.1", 1, {}, false, nil, nil, "user1", "pass1" )
# this_cli.should have_creds
pending "Should actually respond to :has_creds"
@@ -89,7 +91,7 @@ def excuse_needs_auth
u = "user1"
p = "pass1"
b64 = ["#{u}:#{p}"].pack("m*").strip
- cli.basic_auth_header("user1","pass1").should == "Basic #{b64}"
+ @cli.basic_auth_header("user1","pass1").should == "Basic #{b64}"
end
it "should perform digest authentication", :pending => excuse_needs_auth do
@@ -105,15 +107,15 @@ def excuse_needs_auth
end
it "should end a connection with a stop" do
- cli.stop.should be_nil
+ @cli.stop.should be_nil
end
it "should test if a connection is valid" do
- cli.conn?.should be_false
+ @cli.conn?.should be_false
end
it "should tell if pipelining is enabled" do
- cli.pipelining?.should be_false
+ @cli.pipelining?.should be_false
this_cli = Rex::Proto::Http::Client.new("127.0.0.1", 1)
this_cli.pipeline = true
this_cli.pipelining?.should be_true
@@ -166,7 +168,7 @@ def excuse_needs_auth
end
it "should set and return padding after the URI" do
- cli.set_uri_append.should be_empty
+ @cli.set_uri_append.should be_empty
end
it "should set and return the host header", :pending => excuse_lazy(:set_host_header) do
@@ -210,30 +212,30 @@ def excuse_needs_auth
end
it "should respond to its various accessors" do
- cli.should respond_to :config
- cli.should respond_to :config_types
- cli.should respond_to :pipeline
- cli.should respond_to :local_host
- cli.should respond_to :local_port
- cli.should respond_to :conn
- cli.should respond_to :context
- cli.should respond_to :proxies
- # cli.should respond_to :username
- # cli.should respond_to :password
- cli.should respond_to :junk_pipeline
+ @cli.should respond_to :config
+ @cli.should respond_to :config_types
+ @cli.should respond_to :pipeline
+ @cli.should respond_to :local_host
+ @cli.should respond_to :local_port
+ @cli.should respond_to :conn
+ @cli.should respond_to :context
+ @cli.should respond_to :proxies
+ # @cli.should respond_to :username
+ # @cli.should respond_to :password
+ @cli.should respond_to :junk_pipeline
# These are supposed to be protected
- cli.should respond_to :ssl
- cli.should respond_to :ssl_version
- cli.should respond_to :hostname
- cli.should respond_to :port
+ @cli.should respond_to :ssl
+ @cli.should respond_to :ssl_version
+ @cli.should respond_to :hostname
+ @cli.should respond_to :port
end
# Not super sure why these are protected...
it "should refuse access to its protected accessors" do
- expect {cli.ssl}.to raise_error NoMethodError
- expect {cli.ssl_version}.to raise_error NoMethodError
- expect {cli.hostname}.to raise_error NoMethodError
- expect {cli.port}.to raise_error NoMethodError
+ expect {@cli.ssl}.to raise_error NoMethodError
+ expect {@cli.ssl_version}.to raise_error NoMethodError
+ expect {@cli.hostname}.to raise_error NoMethodError
+ expect {@cli.port}.to raise_error NoMethodError
end
end

0 comments on commit 73f6314

Please sign in to comment.