Skip to content

Commit 73f6314

Browse files
committed
Moving @cli and @ip to instance vars
1 parent caed599 commit 73f6314

File tree

2 files changed

+54
-40
lines changed

2 files changed

+54
-40
lines changed

Gemfile.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,20 @@ GEM
2828
coderay (1.0.8)
2929
diff-lcs (1.1.3)
3030
i18n (0.6.1)
31+
json (1.7.7)
3132
method_source (0.8.1)
33+
msgpack (0.5.2)
3234
multi_json (1.0.4)
35+
nokogiri (1.5.6)
36+
pcaprub (0.11.3)
3337
pg (0.14.1)
3438
pry (0.9.10)
3539
coderay (~> 1.0.5)
3640
method_source (~> 0.8)
3741
slop (~> 3.3.1)
3842
rake (10.0.2)
3943
redcarpet (2.2.2)
44+
robots (0.10.1)
4045
rspec (2.12.0)
4146
rspec-core (~> 2.12.0)
4247
rspec-expectations (~> 2.12.0)
@@ -57,10 +62,17 @@ PLATFORMS
5762
ruby
5863

5964
DEPENDENCIES
65+
activerecord
6066
activesupport (>= 3.0.0)
67+
json
6168
metasploit_data_models!
69+
msgpack
70+
nokogiri
71+
pcaprub
72+
pg (>= 0.11)
6273
rake
6374
redcarpet
75+
robots
6476
rspec (>= 2.12)
6577
simplecov (= 0.5.4)
6678
yard

spec/lib/rex/proto/http/client_spec.rb

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,33 @@ def excuse_needs_auth
2828

2929
end
3030

31-
ip = "1.2.3.4"
31+
before(:all) do
32+
@ip = "1.2.3.4"
33+
@cli = Rex::Proto::Http::Client.new(@ip)
34+
end
3235

33-
cli = Rex::Proto::Http::Client.new(ip)
3436
it "should respond to intialize" do
35-
cli.should be
37+
@cli.should be
3638
end
3739

3840
it "should have a set of default instance variables" do
39-
cli.instance_variable_get(:@hostname).should == ip
40-
cli.instance_variable_get(:@port).should == 80
41-
cli.instance_variable_get(:@context).should == {}
42-
cli.instance_variable_get(:@ssl).should be_false
43-
cli.instance_variable_get(:@proxies).should be_nil
44-
# cli.instance_variable_get(:@username).should be_empty
45-
# cli.instance_variable_get(:@password).should be_empty
46-
cli.config.should be_a_kind_of Hash
47-
cli.config_types.should be_a_kind_of Hash
41+
@cli.instance_variable_get(:@hostname).should == @ip
42+
@cli.instance_variable_get(:@port).should == 80
43+
@cli.instance_variable_get(:@context).should == {}
44+
@cli.instance_variable_get(:@ssl).should be_false
45+
@cli.instance_variable_get(:@proxies).should be_nil
46+
# @cli.instance_variable_get(:@username).should be_empty
47+
# @cli.instance_variable_get(:@password).should be_empty
48+
@cli.config.should be_a_kind_of Hash
49+
@cli.config_types.should be_a_kind_of Hash
4850
end
4951

5052
it "should produce a raw HTTP request", :pending => "Waiting for PR #1500" do
51-
cli.request_raw.should be_a_kind_of Rex::Proto::Http::Request
53+
@cli.request_raw.should be_a_kind_of Rex::Proto::Http::Request
5254
end
5355

5456
it "should produce a CGI HTTP request", :pending => "Waiting for PR #1500" do
55-
cli.request_cgi.should be_a_kind_of Rex::Proto::Http::Request
57+
@cli.request_cgi.should be_a_kind_of Rex::Proto::Http::Request
5658
end
5759

5860
it "should attempt to connect to a server" do
@@ -61,7 +63,7 @@ def excuse_needs_auth
6163
end
6264

6365
it "should be able to close a connection" do
64-
cli.close.should be_nil
66+
@cli.close.should be_nil
6567
end
6668

6769
it "should send a request and receive a response", :pending => excuse_needs_connection do
@@ -77,7 +79,7 @@ def excuse_needs_auth
7779
end
7880

7981
it "should test for credentials" do
80-
# cli.should_not have_creds
82+
# @cli.should_not have_creds
8183
# this_cli = Rex::Proto::Http::Client.new("127.0.0.1", 1, {}, false, nil, nil, "user1", "pass1" )
8284
# this_cli.should have_creds
8385
pending "Should actually respond to :has_creds"
@@ -89,7 +91,7 @@ def excuse_needs_auth
8991
u = "user1"
9092
p = "pass1"
9193
b64 = ["#{u}:#{p}"].pack("m*").strip
92-
cli.basic_auth_header("user1","pass1").should == "Basic #{b64}"
94+
@cli.basic_auth_header("user1","pass1").should == "Basic #{b64}"
9395
end
9496

9597
it "should perform digest authentication", :pending => excuse_needs_auth do
@@ -105,15 +107,15 @@ def excuse_needs_auth
105107
end
106108

107109
it "should end a connection with a stop" do
108-
cli.stop.should be_nil
110+
@cli.stop.should be_nil
109111
end
110112

111113
it "should test if a connection is valid" do
112-
cli.conn?.should be_false
114+
@cli.conn?.should be_false
113115
end
114116

115117
it "should tell if pipelining is enabled" do
116-
cli.pipelining?.should be_false
118+
@cli.pipelining?.should be_false
117119
this_cli = Rex::Proto::Http::Client.new("127.0.0.1", 1)
118120
this_cli.pipeline = true
119121
this_cli.pipelining?.should be_true
@@ -166,7 +168,7 @@ def excuse_needs_auth
166168
end
167169

168170
it "should set and return padding after the URI" do
169-
cli.set_uri_append.should be_empty
171+
@cli.set_uri_append.should be_empty
170172
end
171173

172174
it "should set and return the host header", :pending => excuse_lazy(:set_host_header) do
@@ -210,30 +212,30 @@ def excuse_needs_auth
210212
end
211213

212214
it "should respond to its various accessors" do
213-
cli.should respond_to :config
214-
cli.should respond_to :config_types
215-
cli.should respond_to :pipeline
216-
cli.should respond_to :local_host
217-
cli.should respond_to :local_port
218-
cli.should respond_to :conn
219-
cli.should respond_to :context
220-
cli.should respond_to :proxies
221-
# cli.should respond_to :username
222-
# cli.should respond_to :password
223-
cli.should respond_to :junk_pipeline
215+
@cli.should respond_to :config
216+
@cli.should respond_to :config_types
217+
@cli.should respond_to :pipeline
218+
@cli.should respond_to :local_host
219+
@cli.should respond_to :local_port
220+
@cli.should respond_to :conn
221+
@cli.should respond_to :context
222+
@cli.should respond_to :proxies
223+
# @cli.should respond_to :username
224+
# @cli.should respond_to :password
225+
@cli.should respond_to :junk_pipeline
224226
# These are supposed to be protected
225-
cli.should respond_to :ssl
226-
cli.should respond_to :ssl_version
227-
cli.should respond_to :hostname
228-
cli.should respond_to :port
227+
@cli.should respond_to :ssl
228+
@cli.should respond_to :ssl_version
229+
@cli.should respond_to :hostname
230+
@cli.should respond_to :port
229231
end
230232

231233
# Not super sure why these are protected...
232234
it "should refuse access to its protected accessors" do
233-
expect {cli.ssl}.to raise_error NoMethodError
234-
expect {cli.ssl_version}.to raise_error NoMethodError
235-
expect {cli.hostname}.to raise_error NoMethodError
236-
expect {cli.port}.to raise_error NoMethodError
235+
expect {@cli.ssl}.to raise_error NoMethodError
236+
expect {@cli.ssl_version}.to raise_error NoMethodError
237+
expect {@cli.hostname}.to raise_error NoMethodError
238+
expect {@cli.port}.to raise_error NoMethodError
237239
end
238240

239241
end

0 commit comments

Comments
 (0)