@@ -28,31 +28,33 @@ def excuse_needs_auth
28
28
29
29
end
30
30
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
32
35
33
- cli = Rex ::Proto ::Http ::Client . new ( ip )
34
36
it "should respond to intialize" do
35
- cli . should be
37
+ @ cli. should be
36
38
end
37
39
38
40
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
48
50
end
49
51
50
52
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
52
54
end
53
55
54
56
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
56
58
end
57
59
58
60
it "should attempt to connect to a server" do
@@ -61,7 +63,7 @@ def excuse_needs_auth
61
63
end
62
64
63
65
it "should be able to close a connection" do
64
- cli . close . should be_nil
66
+ @ cli. close . should be_nil
65
67
end
66
68
67
69
it "should send a request and receive a response" , :pending => excuse_needs_connection do
@@ -77,7 +79,7 @@ def excuse_needs_auth
77
79
end
78
80
79
81
it "should test for credentials" do
80
- # cli.should_not have_creds
82
+ # @ cli.should_not have_creds
81
83
# this_cli = Rex::Proto::Http::Client.new("127.0.0.1", 1, {}, false, nil, nil, "user1", "pass1" )
82
84
# this_cli.should have_creds
83
85
pending "Should actually respond to :has_creds"
@@ -89,7 +91,7 @@ def excuse_needs_auth
89
91
u = "user1"
90
92
p = "pass1"
91
93
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 } "
93
95
end
94
96
95
97
it "should perform digest authentication" , :pending => excuse_needs_auth do
@@ -105,15 +107,15 @@ def excuse_needs_auth
105
107
end
106
108
107
109
it "should end a connection with a stop" do
108
- cli . stop . should be_nil
110
+ @ cli. stop . should be_nil
109
111
end
110
112
111
113
it "should test if a connection is valid" do
112
- cli . conn? . should be_false
114
+ @ cli. conn? . should be_false
113
115
end
114
116
115
117
it "should tell if pipelining is enabled" do
116
- cli . pipelining? . should be_false
118
+ @ cli. pipelining? . should be_false
117
119
this_cli = Rex ::Proto ::Http ::Client . new ( "127.0.0.1" , 1 )
118
120
this_cli . pipeline = true
119
121
this_cli . pipelining? . should be_true
@@ -166,7 +168,7 @@ def excuse_needs_auth
166
168
end
167
169
168
170
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
170
172
end
171
173
172
174
it "should set and return the host header" , :pending => excuse_lazy ( :set_host_header ) do
@@ -210,30 +212,30 @@ def excuse_needs_auth
210
212
end
211
213
212
214
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
224
226
# 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
229
231
end
230
232
231
233
# Not super sure why these are protected...
232
234
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
237
239
end
238
240
239
241
end
0 commit comments