ronin-support 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -1
- data/ChangeLog.md +28 -0
- data/Gemfile +6 -7
- data/README.md +53 -32
- data/Rakefile +1 -2
- data/gemspec.yml +16 -7
- data/lib/ronin/binary.rb +5 -5
- data/lib/ronin/binary/hexdump.rb +5 -5
- data/lib/ronin/binary/hexdump/parser.rb +5 -5
- data/lib/ronin/binary/struct.rb +5 -5
- data/lib/ronin/binary/template.rb +7 -7
- data/lib/ronin/extensions.rb +5 -5
- data/lib/ronin/extensions/enumerable.rb +5 -5
- data/lib/ronin/extensions/file.rb +37 -31
- data/lib/ronin/extensions/ip_addr.rb +6 -7
- data/lib/ronin/extensions/kernel.rb +5 -5
- data/lib/ronin/extensions/meta.rb +5 -5
- data/lib/ronin/extensions/regexp.rb +5 -5
- data/lib/ronin/extensions/resolv.rb +5 -5
- data/lib/ronin/extensions/string.rb +5 -5
- data/lib/ronin/formatting.rb +5 -5
- data/lib/ronin/formatting/binary.rb +5 -5
- data/lib/ronin/formatting/digest.rb +5 -5
- data/lib/ronin/formatting/extensions.rb +5 -5
- data/lib/ronin/formatting/extensions/binary.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/array.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/base64.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/file.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/float.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/string.rb +6 -6
- data/lib/ronin/formatting/extensions/digest.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
- data/lib/ronin/formatting/extensions/html.rb +5 -5
- data/lib/ronin/formatting/extensions/html/integer.rb +5 -5
- data/lib/ronin/formatting/extensions/html/string.rb +7 -7
- data/lib/ronin/formatting/extensions/http.rb +5 -5
- data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/http/string.rb +7 -7
- data/lib/ronin/formatting/extensions/sql.rb +5 -5
- data/lib/ronin/formatting/extensions/sql/string.rb +15 -13
- data/lib/ronin/formatting/extensions/text.rb +5 -5
- data/lib/ronin/formatting/extensions/text/array.rb +5 -5
- data/lib/ronin/formatting/extensions/text/string.rb +5 -5
- data/lib/ronin/formatting/html.rb +5 -5
- data/lib/ronin/formatting/http.rb +5 -5
- data/lib/ronin/formatting/sql.rb +5 -5
- data/lib/ronin/formatting/text.rb +5 -5
- data/lib/ronin/fuzzing.rb +5 -5
- data/lib/ronin/fuzzing/extensions.rb +5 -5
- data/lib/ronin/fuzzing/extensions/string.rb +5 -5
- data/lib/ronin/fuzzing/fuzzer.rb +5 -5
- data/lib/ronin/fuzzing/fuzzing.rb +7 -7
- data/lib/ronin/fuzzing/mutator.rb +5 -5
- data/lib/ronin/fuzzing/repeater.rb +5 -5
- data/lib/ronin/fuzzing/template.rb +5 -5
- data/lib/ronin/mixin.rb +2 -2
- data/lib/ronin/network.rb +5 -5
- data/lib/ronin/network/dns.rb +5 -5
- data/lib/ronin/network/esmtp.rb +5 -5
- data/lib/ronin/network/extensions.rb +5 -5
- data/lib/ronin/network/extensions/dns.rb +5 -5
- data/lib/ronin/network/extensions/dns/net.rb +5 -5
- data/lib/ronin/network/extensions/esmtp.rb +5 -5
- data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
- data/lib/ronin/network/extensions/http.rb +5 -5
- data/lib/ronin/network/extensions/http/net.rb +5 -5
- data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
- data/lib/ronin/network/extensions/imap.rb +5 -5
- data/lib/ronin/network/extensions/imap/net.rb +5 -5
- data/lib/ronin/network/extensions/pop3.rb +5 -5
- data/lib/ronin/network/extensions/pop3/net.rb +5 -5
- data/lib/ronin/network/extensions/smtp.rb +5 -5
- data/lib/ronin/network/extensions/smtp/net.rb +5 -5
- data/lib/ronin/network/extensions/ssl.rb +5 -5
- data/lib/ronin/network/extensions/ssl/net.rb +5 -5
- data/lib/ronin/network/extensions/tcp.rb +5 -5
- data/lib/ronin/network/extensions/tcp/net.rb +5 -5
- data/lib/ronin/network/extensions/telnet.rb +5 -5
- data/lib/ronin/network/extensions/telnet/net.rb +5 -5
- data/lib/ronin/network/extensions/udp.rb +5 -5
- data/lib/ronin/network/extensions/udp/net.rb +5 -5
- data/lib/ronin/network/ftp.rb +5 -5
- data/lib/ronin/network/http.rb +5 -5
- data/lib/ronin/network/http/exceptions.rb +5 -5
- data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
- data/lib/ronin/network/http/http.rb +52 -57
- data/lib/ronin/network/http/proxy.rb +5 -5
- data/lib/ronin/network/imap.rb +5 -5
- data/lib/ronin/network/mixins.rb +5 -5
- data/lib/ronin/network/mixins/dns.rb +5 -5
- data/lib/ronin/network/mixins/esmtp.rb +5 -5
- data/lib/ronin/network/mixins/ftp.rb +5 -5
- data/lib/ronin/network/mixins/http.rb +7 -7
- data/lib/ronin/network/mixins/imap.rb +5 -5
- data/lib/ronin/network/mixins/mixin.rb +5 -5
- data/lib/ronin/network/mixins/pop3.rb +5 -5
- data/lib/ronin/network/mixins/smtp.rb +5 -5
- data/lib/ronin/network/mixins/ssl.rb +5 -5
- data/lib/ronin/network/mixins/tcp.rb +5 -5
- data/lib/ronin/network/mixins/telnet.rb +5 -5
- data/lib/ronin/network/mixins/udp.rb +5 -5
- data/lib/ronin/network/mixins/unix.rb +5 -5
- data/lib/ronin/network/network.rb +5 -5
- data/lib/ronin/network/pop3.rb +5 -5
- data/lib/ronin/network/proxy.rb +5 -5
- data/lib/ronin/network/smtp.rb +5 -5
- data/lib/ronin/network/smtp/email.rb +6 -6
- data/lib/ronin/network/smtp/smtp.rb +5 -5
- data/lib/ronin/network/ssl.rb +7 -7
- data/lib/ronin/network/tcp.rb +5 -5
- data/lib/ronin/network/tcp/proxy.rb +5 -5
- data/lib/ronin/network/tcp/tcp.rb +32 -23
- data/lib/ronin/network/telnet.rb +7 -5
- data/lib/ronin/network/udp.rb +5 -5
- data/lib/ronin/network/udp/proxy.rb +5 -5
- data/lib/ronin/network/udp/udp.rb +28 -26
- data/lib/ronin/network/unix.rb +7 -7
- data/lib/ronin/path.rb +32 -36
- data/lib/ronin/spec/ui/output.rb +5 -5
- data/lib/ronin/support.rb +5 -5
- data/lib/ronin/support/inflector.rb +5 -5
- data/lib/ronin/support/support.rb +5 -5
- data/lib/ronin/support/version.rb +6 -6
- data/lib/ronin/templates.rb +5 -5
- data/lib/ronin/templates/erb.rb +5 -5
- data/lib/ronin/templates/template.rb +5 -5
- data/lib/ronin/ui/output.rb +5 -5
- data/lib/ronin/ui/output/helpers.rb +5 -5
- data/lib/ronin/ui/output/output.rb +17 -21
- data/lib/ronin/ui/output/terminal.rb +5 -5
- data/lib/ronin/ui/output/terminal/color.rb +5 -5
- data/lib/ronin/ui/output/terminal/raw.rb +5 -5
- data/lib/ronin/ui/shell.rb +5 -5
- data/lib/ronin/wordlist.rb +7 -7
- data/ronin-support.gemspec +1 -0
- data/spec/binary/hexdump/parser_spec.rb +22 -22
- data/spec/binary/struct_spec.rb +56 -56
- data/spec/binary/template_spec.rb +106 -104
- data/spec/extensions/enumerable_spec.rb +4 -4
- data/spec/extensions/file_spec.rb +12 -14
- data/spec/extensions/ip_addr_spec.rb +30 -30
- data/spec/extensions/kernel_spec.rb +7 -7
- data/spec/extensions/regexp_spec.rb +69 -69
- data/spec/extensions/resolv_spec.rb +2 -2
- data/spec/extensions/string_spec.rb +30 -29
- data/spec/formatting/binary/array_spec.rb +2 -2
- data/spec/formatting/binary/base64_spec.rb +8 -8
- data/spec/formatting/binary/float_spec.rb +6 -4
- data/spec/formatting/binary/integer_spec.rb +25 -25
- data/spec/formatting/binary/string_spec.rb +32 -30
- data/spec/formatting/digest/string_spec.rb +5 -5
- data/spec/formatting/html/integer_spec.rb +6 -6
- data/spec/formatting/html/string_spec.rb +10 -10
- data/spec/formatting/http/integer_spec.rb +3 -3
- data/spec/formatting/http/string_spec.rb +5 -5
- data/spec/formatting/sql/string_spec.rb +21 -19
- data/spec/formatting/text/array_spec.rb +15 -15
- data/spec/formatting/text/string_spec.rb +33 -33
- data/spec/fuzzing/extensions/string_spec.rb +11 -11
- data/spec/fuzzing/fuzzer_spec.rb +15 -15
- data/spec/fuzzing/fuzzing_spec.rb +5 -5
- data/spec/fuzzing/mutator_spec.rb +15 -15
- data/spec/fuzzing/repeater_spec.rb +7 -7
- data/spec/fuzzing/template_spec.rb +11 -11
- data/spec/mixin_spec.rb +10 -12
- data/spec/network/dns_spec.rb +34 -32
- data/spec/network/ftp_spec.rb +9 -9
- data/spec/network/http/http_spec.rb +237 -144
- data/spec/network/http/proxy_spec.rb +37 -37
- data/spec/network/network_spec.rb +1 -1
- data/spec/network/proxy_spec.rb +19 -19
- data/spec/network/smtp/email_spec.rb +14 -14
- data/spec/network/ssl_spec.rb +9 -9
- data/spec/network/tcp/proxy_spec.rb +9 -7
- data/spec/network/tcp/tcp_spec.rb +161 -118
- data/spec/network/telnet_spec.rb +5 -5
- data/spec/network/udp/udp_spec.rb +123 -96
- data/spec/network/unix_spec.rb +24 -25
- data/spec/path_spec.rb +43 -18
- data/spec/spec_helper.rb +0 -1
- data/spec/support/inflector_spec.rb +4 -4
- data/spec/support_spec.rb +1 -1
- data/spec/templates/erb_spec.rb +3 -3
- data/spec/templates/template_spec.rb +10 -10
- data/spec/ui/shell_spec.rb +15 -15
- data/spec/wordlist_spec.rb +19 -19
- metadata +408 -366
- data/.gemtest +0 -0
data/spec/network/dns_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Network::DNS do
|
|
8
8
|
|
9
9
|
describe "nameserver" do
|
10
10
|
it "should be nil by default" do
|
11
|
-
subject.nameserver.
|
11
|
+
expect(subject.nameserver).to be_nil
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -16,20 +16,20 @@ describe Network::DNS do
|
|
16
16
|
it "should accept Strings" do
|
17
17
|
subject.nameserver = server
|
18
18
|
|
19
|
-
subject.nameserver.
|
19
|
+
expect(subject.nameserver).to eq(server)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should accept nil" do
|
23
23
|
subject.nameserver = server
|
24
24
|
subject.nameserver = nil
|
25
25
|
|
26
|
-
subject.nameserver.
|
26
|
+
expect(subject.nameserver).to be_nil
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should convert non-nil values to Strings" do
|
30
30
|
subject.nameserver = IPAddr.new(server)
|
31
31
|
|
32
|
-
subject.nameserver.
|
32
|
+
expect(subject.nameserver).to eq(server)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -41,19 +41,21 @@ describe Network::DNS do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should return Resolv when passed no nameserver" do
|
44
|
-
subject.dns_resolver(nil).
|
44
|
+
expect(subject.dns_resolver(nil)).to eq(Resolv)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should return Resolv::DNS when passed a nameserver" do
|
48
|
-
subject.dns_resolver(server).
|
48
|
+
expect(subject.dns_resolver(server)).to be_kind_of(Resolv::DNS)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "helper methods", :network do
|
53
53
|
let(:hostname) { 'example.com' }
|
54
54
|
let(:bad_hostname) { 'foo.bar' }
|
55
|
-
let(:address) { '
|
55
|
+
let(:address) { '93.184.216.34' }
|
56
56
|
let(:bad_address) { '0.0.0.0' }
|
57
|
+
let(:reverse_address) { '192.0.43.10' }
|
58
|
+
let(:reverse_ipaddr) { IPAddr.new(reverse_address) }
|
57
59
|
let(:reverse_hostname) { '43-10.any.icann.org' }
|
58
60
|
|
59
61
|
subject do
|
@@ -64,19 +66,19 @@ describe Network::DNS do
|
|
64
66
|
|
65
67
|
describe "#dns_lookup" do
|
66
68
|
it "should lookup the address for a hostname" do
|
67
|
-
subject.dns_lookup(hostname).
|
69
|
+
expect(subject.dns_lookup(hostname)).to eq(address)
|
68
70
|
end
|
69
71
|
|
70
72
|
it "should return nil for unknown hostnames" do
|
71
|
-
subject.dns_lookup(bad_hostname).
|
73
|
+
expect(subject.dns_lookup(bad_hostname)).to be_nil
|
72
74
|
end
|
73
75
|
|
74
76
|
it "should accept non-String hostnames" do
|
75
|
-
subject.dns_lookup(hostname.to_sym).
|
77
|
+
expect(subject.dns_lookup(hostname.to_sym)).to eq(address)
|
76
78
|
end
|
77
79
|
|
78
80
|
it "should accept an additional nameserver argument" do
|
79
|
-
subject.dns_lookup(hostname,server).
|
81
|
+
expect(subject.dns_lookup(hostname,server)).to eq(address)
|
80
82
|
end
|
81
83
|
|
82
84
|
context "when given a block" do
|
@@ -87,7 +89,7 @@ describe Network::DNS do
|
|
87
89
|
resolved_address = address
|
88
90
|
end
|
89
91
|
|
90
|
-
resolved_address.
|
92
|
+
expect(resolved_address).to eq(address)
|
91
93
|
end
|
92
94
|
|
93
95
|
it "should not yield unresolved addresses" do
|
@@ -97,65 +99,65 @@ describe Network::DNS do
|
|
97
99
|
resolved_address = address
|
98
100
|
end
|
99
101
|
|
100
|
-
resolved_address.
|
102
|
+
expect(resolved_address).to be_nil
|
101
103
|
end
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
105
107
|
describe "#dns_lookup_all" do
|
106
108
|
it "should lookup all addresses for a hostname" do
|
107
|
-
subject.dns_lookup_all(hostname).
|
109
|
+
expect(subject.dns_lookup_all(hostname)).to include(address)
|
108
110
|
end
|
109
111
|
|
110
112
|
it "should return an empty Array for unknown hostnames" do
|
111
|
-
subject.dns_lookup_all(bad_hostname).
|
113
|
+
expect(subject.dns_lookup_all(bad_hostname)).to eq([])
|
112
114
|
end
|
113
115
|
|
114
116
|
it "should accept non-String hostnames" do
|
115
|
-
subject.dns_lookup_all(hostname.to_sym).
|
117
|
+
expect(subject.dns_lookup_all(hostname.to_sym)).to include(address)
|
116
118
|
end
|
117
119
|
|
118
120
|
it "should accept an additional nameserver argument" do
|
119
|
-
subject.dns_lookup_all(hostname,server).
|
121
|
+
expect(subject.dns_lookup_all(hostname,server)).to include(address)
|
120
122
|
end
|
121
123
|
|
122
124
|
context "when given a block" do
|
123
125
|
it "should yield the resolved address" do
|
124
|
-
subject.enum_for(:dns_lookup,hostname).to_a.
|
126
|
+
expect(subject.enum_for(:dns_lookup,hostname).to_a).to eq([address])
|
125
127
|
end
|
126
128
|
|
127
129
|
it "should not yield unresolved addresses" do
|
128
|
-
subject.enum_for(:dns_lookup,bad_hostname).to_a.
|
130
|
+
expect(subject.enum_for(:dns_lookup,bad_hostname).to_a).to eq([])
|
129
131
|
end
|
130
132
|
end
|
131
133
|
end
|
132
134
|
|
133
135
|
describe "#dns_reverse_lookup" do
|
134
136
|
it "should lookup the address for a hostname" do
|
135
|
-
subject.dns_reverse_lookup(
|
137
|
+
expect(subject.dns_reverse_lookup(reverse_address)).to eq(reverse_hostname)
|
136
138
|
end
|
137
139
|
|
138
140
|
it "should return nil for unknown hostnames" do
|
139
|
-
subject.dns_reverse_lookup(bad_address).
|
141
|
+
expect(subject.dns_reverse_lookup(bad_address)).to be_nil
|
140
142
|
end
|
141
143
|
|
142
144
|
it "should accept non-String addresses" do
|
143
|
-
subject.dns_reverse_lookup(
|
145
|
+
expect(subject.dns_reverse_lookup(reverse_ipaddr)).to eq(reverse_hostname)
|
144
146
|
end
|
145
147
|
|
146
148
|
it "should accept an additional nameserver argument" do
|
147
|
-
subject.dns_reverse_lookup(
|
149
|
+
expect(subject.dns_reverse_lookup(reverse_address,server)).to eq(reverse_hostname)
|
148
150
|
end
|
149
151
|
|
150
152
|
context "when given a block" do
|
151
153
|
it "should yield the resolved hostname" do
|
152
154
|
resolved_hostname = nil
|
153
155
|
|
154
|
-
subject.dns_reverse_lookup(
|
156
|
+
subject.dns_reverse_lookup(reverse_address) do |hostname|
|
155
157
|
resolved_hostname = hostname
|
156
158
|
end
|
157
159
|
|
158
|
-
resolved_hostname.
|
160
|
+
expect(resolved_hostname).to eq(reverse_hostname)
|
159
161
|
end
|
160
162
|
|
161
163
|
it "should not yield unresolved hostnames" do
|
@@ -165,35 +167,35 @@ describe Network::DNS do
|
|
165
167
|
resolved_hostname = hostname
|
166
168
|
end
|
167
169
|
|
168
|
-
resolved_hostname.
|
170
|
+
expect(resolved_hostname).to be_nil
|
169
171
|
end
|
170
172
|
end
|
171
173
|
end
|
172
174
|
|
173
175
|
describe "#dns_reverse_lookup_all" do
|
174
176
|
it "should lookup all addresses for a hostname" do
|
175
|
-
subject.dns_reverse_lookup_all(
|
177
|
+
expect(subject.dns_reverse_lookup_all(reverse_address)).to include(reverse_hostname)
|
176
178
|
end
|
177
179
|
|
178
180
|
it "should return an empty Array for unknown hostnames" do
|
179
|
-
subject.dns_reverse_lookup_all(bad_address).
|
181
|
+
expect(subject.dns_reverse_lookup_all(bad_address)).to eq([])
|
180
182
|
end
|
181
183
|
|
182
184
|
it "should accept non-String addresses" do
|
183
|
-
subject.dns_reverse_lookup_all(
|
185
|
+
expect(subject.dns_reverse_lookup_all(reverse_ipaddr)).to include(reverse_hostname)
|
184
186
|
end
|
185
187
|
|
186
188
|
it "should accept an additional nameserver argument" do
|
187
|
-
subject.dns_reverse_lookup_all(
|
189
|
+
expect(subject.dns_reverse_lookup_all(reverse_address,server)).to include(reverse_hostname)
|
188
190
|
end
|
189
191
|
|
190
192
|
context "when given a block" do
|
191
193
|
it "should yield the resolved hostnames" do
|
192
|
-
subject.enum_for(:dns_reverse_lookup_all,
|
194
|
+
expect(subject.enum_for(:dns_reverse_lookup_all,reverse_address).to_a).to eq([reverse_hostname])
|
193
195
|
end
|
194
196
|
|
195
197
|
it "should not yield unresolved hostnames" do
|
196
|
-
subject.enum_for(:dns_reverse_lookup_all,bad_address).to_a.
|
198
|
+
expect(subject.enum_for(:dns_reverse_lookup_all,bad_address).to_a).to eq([])
|
197
199
|
end
|
198
200
|
end
|
199
201
|
end
|
data/spec/network/ftp_spec.rb
CHANGED
@@ -9,20 +9,20 @@ describe Network::FTP do
|
|
9
9
|
obj
|
10
10
|
end
|
11
11
|
|
12
|
-
let(:host) { 'ftp.
|
12
|
+
let(:host) { 'ftp.osuosl.org' }
|
13
13
|
|
14
14
|
describe "#ftp_connect" do
|
15
15
|
it "should return a Net::FTP object" do
|
16
16
|
ftp = subject.ftp_connect(host)
|
17
17
|
|
18
|
-
ftp.
|
18
|
+
expect(ftp).to be_kind_of(Net::FTP)
|
19
19
|
ftp.close
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should connect to an FTP service" do
|
23
23
|
ftp = subject.ftp_connect(host)
|
24
24
|
|
25
|
-
ftp.
|
25
|
+
expect(ftp).not_to be_closed
|
26
26
|
ftp.close
|
27
27
|
end
|
28
28
|
|
@@ -30,14 +30,14 @@ describe Network::FTP do
|
|
30
30
|
it "should set passive mode by default" do
|
31
31
|
ftp = subject.ftp_connect(host)
|
32
32
|
|
33
|
-
ftp.passive.
|
33
|
+
expect(ftp.passive).to be(true)
|
34
34
|
ftp.close
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should allow disabling passive mode" do
|
38
38
|
ftp = subject.ftp_connect(host, :passive => false)
|
39
39
|
|
40
|
-
ftp.passive.
|
40
|
+
expect(ftp.passive).to be(false)
|
41
41
|
ftp.close
|
42
42
|
end
|
43
43
|
end
|
@@ -45,7 +45,7 @@ describe Network::FTP do
|
|
45
45
|
context "when given a block" do
|
46
46
|
it "should yield the new Net::FTP object" do
|
47
47
|
ftp = subject.ftp_connect(host) do |ftp|
|
48
|
-
ftp.
|
48
|
+
expect(ftp).to be_kind_of(Net::FTP)
|
49
49
|
end
|
50
50
|
|
51
51
|
ftp.close
|
@@ -61,7 +61,7 @@ describe Network::FTP do
|
|
61
61
|
yielded_ftp = ftp
|
62
62
|
end
|
63
63
|
|
64
|
-
yielded_ftp.
|
64
|
+
expect(yielded_ftp).to be_kind_of(Net::FTP)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should close the FTP session after yielding it" do
|
@@ -73,8 +73,8 @@ describe Network::FTP do
|
|
73
73
|
was_open = !ftp.closed?
|
74
74
|
end
|
75
75
|
|
76
|
-
was_open.
|
77
|
-
session.
|
76
|
+
expect(was_open).to be(true)
|
77
|
+
expect(session).to be_closed
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -4,7 +4,7 @@ require 'ronin/network/http'
|
|
4
4
|
describe Network::HTTP do
|
5
5
|
describe "proxy" do
|
6
6
|
it "should be disabled by default" do
|
7
|
-
subject.proxy.
|
7
|
+
expect(subject.proxy).not_to be_enabled
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -14,7 +14,7 @@ describe Network::HTTP do
|
|
14
14
|
it "should accept URI objects" do
|
15
15
|
options = subject.expand_url(url)
|
16
16
|
|
17
|
-
options[:host].
|
17
|
+
expect(options[:host]).to eq(url.host)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should accept Hashes" do
|
@@ -24,33 +24,61 @@ describe Network::HTTP do
|
|
24
24
|
}
|
25
25
|
options = subject.expand_url(hash)
|
26
26
|
|
27
|
-
options[:host].
|
28
|
-
options[:port].
|
27
|
+
expect(options[:host]).to eq(url.host)
|
28
|
+
expect(options[:port]).to eq(url.port)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should accept Strings" do
|
32
32
|
options = subject.expand_url(url.to_s)
|
33
33
|
|
34
|
-
options[:host].
|
35
|
-
options[:port].
|
34
|
+
expect(options[:host]).to eq(url.host)
|
35
|
+
expect(options[:port]).to eq(url.port)
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
describe ":path" do
|
39
|
+
it "should filter out empty URL paths" do
|
40
|
+
options = subject.expand_url(URI('http://example.com'))
|
40
41
|
|
41
|
-
|
42
|
+
expect(options[:path]).to be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when the path is empty" do
|
46
|
+
it "should not be set" do
|
47
|
+
options = subject.expand_url(URI('http://example.com'))
|
48
|
+
|
49
|
+
expect(options).not_to have_key(:path)
|
50
|
+
end
|
51
|
+
end
|
42
52
|
end
|
43
53
|
|
44
|
-
|
45
|
-
|
54
|
+
describe ":query" do
|
55
|
+
it "should set :query to the query string" do
|
56
|
+
options = subject.expand_url(url)
|
57
|
+
|
58
|
+
expect(options[:query]).to eq(url.query)
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when query is nil" do
|
62
|
+
it "should not be set" do
|
63
|
+
options = subject.expand_url(URI('http://example.com/path'))
|
46
64
|
|
47
|
-
|
65
|
+
expect(options).not_to have_key(:query)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when query is empty" do
|
70
|
+
it "should be set" do
|
71
|
+
options = subject.expand_url(URI('http://example.com/path?'))
|
72
|
+
|
73
|
+
expect(options[:query]).to be_empty
|
74
|
+
end
|
75
|
+
end
|
48
76
|
end
|
49
77
|
|
50
78
|
it "should set :ssl if the URI scheme is 'https'" do
|
51
79
|
options = subject.expand_url(URI('https://example.com'))
|
52
80
|
|
53
|
-
options[:ssl].
|
81
|
+
expect(options[:ssl]).to eq({})
|
54
82
|
end
|
55
83
|
end
|
56
84
|
|
@@ -59,30 +87,30 @@ describe Network::HTTP do
|
|
59
87
|
options = {:ssl => true}
|
60
88
|
expanded_options = subject.expand_options(options)
|
61
89
|
|
62
|
-
expanded_options[:ssl].
|
90
|
+
expect(expanded_options[:ssl]).to eq({})
|
63
91
|
end
|
64
92
|
|
65
93
|
it "should added a default port and path" do
|
66
94
|
options = {:host => 'example.com'}
|
67
95
|
expanded_options = subject.expand_options(options)
|
68
96
|
|
69
|
-
expanded_options[:port].
|
70
|
-
expanded_options[:path].
|
97
|
+
expect(expanded_options[:port]).to eq(80)
|
98
|
+
expect(expanded_options[:path]).to eq('/')
|
71
99
|
end
|
72
100
|
|
73
101
|
it "should add the default proxy settings" do
|
74
102
|
options = {:host => 'example.com'}
|
75
103
|
expanded_options = subject.expand_options(options)
|
76
104
|
|
77
|
-
expanded_options[:proxy].
|
105
|
+
expect(expanded_options[:proxy]).to eq(subject.proxy)
|
78
106
|
end
|
79
107
|
|
80
108
|
it "should disable the proxy settings if :proxy is nil" do
|
81
109
|
options = {:host => 'example.com', :proxy => nil}
|
82
110
|
expanded_options = subject.expand_options(options)
|
83
111
|
|
84
|
-
expanded_options[:proxy][:host].
|
85
|
-
expanded_options[:proxy][:port].
|
112
|
+
expect(expanded_options[:proxy][:host]).to be_nil
|
113
|
+
expect(expanded_options[:proxy][:port]).to be_nil
|
86
114
|
end
|
87
115
|
|
88
116
|
it "should not modify :proxy if it is a HTTP::Proxy object" do
|
@@ -90,184 +118,249 @@ describe Network::HTTP do
|
|
90
118
|
options = {:host => 'example.com', :proxy => proxy}
|
91
119
|
expanded_options = subject.expand_options(options)
|
92
120
|
|
93
|
-
expanded_options[:proxy].
|
121
|
+
expect(expanded_options[:proxy]).to eq(proxy)
|
94
122
|
end
|
95
123
|
|
96
124
|
it "should parse the :proxy option" do
|
97
125
|
options = {:host => 'example.com', :proxy => 'http://proxy.com:8181'}
|
98
126
|
expanded_options = subject.expand_options(options)
|
99
127
|
|
100
|
-
expanded_options[:proxy][:host].
|
101
|
-
expanded_options[:proxy][:port].
|
128
|
+
expect(expanded_options[:proxy][:host]).to eq('proxy.com')
|
129
|
+
expect(expanded_options[:proxy][:port]).to eq(8181)
|
102
130
|
end
|
103
131
|
|
104
132
|
it "should expand the :url option" do
|
105
133
|
options = {:url => 'http://joe:secret@example.com:8080/bla?var'}
|
106
134
|
expanded_options = subject.expand_options(options)
|
107
135
|
|
108
|
-
expanded_options[:url].
|
109
|
-
expanded_options[:host].
|
110
|
-
expanded_options[:port].
|
111
|
-
expanded_options[:user].
|
112
|
-
expanded_options[:password].
|
113
|
-
expanded_options[:path].
|
136
|
+
expect(expanded_options[:url]).to be_nil
|
137
|
+
expect(expanded_options[:host]).to eq('example.com')
|
138
|
+
expect(expanded_options[:port]).to eq(8080)
|
139
|
+
expect(expanded_options[:user]).to eq('joe')
|
140
|
+
expect(expanded_options[:password]).to eq('secret')
|
141
|
+
expect(expanded_options[:path]).to eq('/bla')
|
142
|
+
expect(expanded_options[:query]).to eq('var')
|
114
143
|
end
|
115
|
-
|
116
144
|
end
|
117
145
|
|
118
146
|
describe "headers" do
|
119
147
|
it "should convert Symbol options to HTTP Headers" do
|
120
148
|
options = {:user_agent => 'bla', :location => 'test'}
|
121
149
|
|
122
|
-
subject.headers(options).
|
150
|
+
expect(subject.headers(options)).to eq({
|
123
151
|
'User-Agent' => 'bla',
|
124
|
-
'Location'
|
125
|
-
}
|
152
|
+
'Location' => 'test'
|
153
|
+
})
|
126
154
|
end
|
127
155
|
|
128
156
|
it "should convert String options to HTTP Headers" do
|
129
157
|
options = {'user_agent' => 'bla', 'x-powered-by' => 'PHP'}
|
130
158
|
|
131
|
-
subject.headers(options).
|
132
|
-
'User-Agent'
|
159
|
+
expect(subject.headers(options)).to eq({
|
160
|
+
'User-Agent' => 'bla',
|
133
161
|
'X-Powered-By' => 'PHP'
|
134
|
-
}
|
162
|
+
})
|
135
163
|
end
|
136
164
|
|
137
165
|
it "should convert all values to Strings" do
|
138
166
|
mtime = Time.now.to_i
|
139
167
|
options = {:modified_by => mtime, :x_accept => :gzip}
|
140
168
|
|
141
|
-
subject.headers(options).
|
169
|
+
expect(subject.headers(options)).to eq({
|
142
170
|
'Modified-By' => mtime.to_s,
|
143
|
-
'X-Accept'
|
144
|
-
}
|
171
|
+
'X-Accept' => 'gzip'
|
172
|
+
})
|
145
173
|
end
|
146
174
|
end
|
147
175
|
|
148
176
|
describe "request" do
|
149
177
|
it "should handle Symbol names" do
|
150
|
-
subject.request(
|
178
|
+
expect(subject.request(
|
151
179
|
:method => :get, :path => '/'
|
152
|
-
).class.
|
180
|
+
).class).to eq(Net::HTTP::Get)
|
153
181
|
end
|
154
182
|
|
155
183
|
it "should handle String names" do
|
156
|
-
subject.request(
|
184
|
+
expect(subject.request(
|
157
185
|
:method => 'GET', :path => '/'
|
158
|
-
).class.
|
186
|
+
).class).to eq(Net::HTTP::Get)
|
159
187
|
end
|
160
188
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
189
|
+
context "with :path" do
|
190
|
+
it "should use a default path" do
|
191
|
+
expect {
|
192
|
+
subject.request(:method => :get)
|
193
|
+
}.not_to raise_error
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should set the path" do
|
197
|
+
req = subject.request(:method => :get, :path => '/foo')
|
166
198
|
|
167
|
-
|
168
|
-
|
169
|
-
subject.request(:method => :get)
|
170
|
-
}.should_not raise_error(ArgumentError)
|
199
|
+
expect(req.path).to eq('/foo')
|
200
|
+
end
|
171
201
|
end
|
172
202
|
|
173
|
-
|
174
|
-
|
203
|
+
context "with :query" do
|
204
|
+
let(:path) { '/foo' }
|
205
|
+
let(:query) { 'q=1' }
|
175
206
|
|
176
|
-
|
177
|
-
|
207
|
+
it "should append the query-string to the path" do
|
208
|
+
req = subject.request(
|
209
|
+
:method => :get,
|
210
|
+
:path => path,
|
211
|
+
:query => query
|
212
|
+
)
|
178
213
|
|
179
|
-
|
180
|
-
|
181
|
-
:method => :get,
|
182
|
-
:user => 'joe',
|
183
|
-
:password => 'secret'
|
184
|
-
)
|
214
|
+
expect(req.path).to eq("#{path}?#{query}")
|
215
|
+
end
|
185
216
|
|
186
|
-
|
187
|
-
|
217
|
+
context "when path already contains a query string" do
|
218
|
+
let(:additional_query) { 'x=2' }
|
188
219
|
|
189
|
-
|
190
|
-
|
220
|
+
it "should append the query using a '&' character" do
|
221
|
+
req = subject.request(
|
222
|
+
:method => :get,
|
223
|
+
:path => "#{path}?#{query}",
|
224
|
+
:query => additional_query
|
225
|
+
)
|
191
226
|
|
192
|
-
|
193
|
-
|
227
|
+
expect(req.path).to eq("#{path}?#{query}&#{additional_query}")
|
228
|
+
end
|
194
229
|
|
195
|
-
|
196
|
-
|
230
|
+
context "when :query is empty" do
|
231
|
+
it "should append an extra '&'" do
|
232
|
+
req = subject.request(
|
233
|
+
:method => :get,
|
234
|
+
:path => "#{path}?#{query}",
|
235
|
+
:query => ''
|
236
|
+
)
|
197
237
|
|
198
|
-
|
199
|
-
|
238
|
+
expect(req.path).to be_end_with('&')
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
200
242
|
|
201
|
-
|
202
|
-
|
243
|
+
context "when :query is empty" do
|
244
|
+
it "should append an extra '?'" do
|
245
|
+
req = subject.request(
|
246
|
+
:method => :get,
|
247
|
+
:path => path,
|
248
|
+
:query => ''
|
249
|
+
)
|
203
250
|
|
204
|
-
|
251
|
+
expect(req.path).to be_end_with('?')
|
252
|
+
end
|
253
|
+
end
|
205
254
|
end
|
206
255
|
|
207
|
-
|
208
|
-
|
256
|
+
context "with :user and :password" do
|
257
|
+
it "should accept the :user option for Basic-Auth" do
|
258
|
+
req = subject.request(:method => :get, :user => 'joe')
|
209
259
|
|
210
|
-
|
211
|
-
|
260
|
+
expect(req['authorization']).to eq("Basic am9lOg==")
|
261
|
+
end
|
212
262
|
|
213
|
-
|
214
|
-
|
263
|
+
it "should also accept the :password options for Basic-Auth" do
|
264
|
+
req = subject.request(
|
265
|
+
:method => :get,
|
266
|
+
:user => 'joe',
|
267
|
+
:password => 'secret'
|
268
|
+
)
|
215
269
|
|
216
|
-
|
270
|
+
expect(req['authorization']).to eq("Basic am9lOnNlY3JldA==")
|
271
|
+
end
|
217
272
|
end
|
218
273
|
|
219
|
-
|
220
|
-
|
274
|
+
context "with :method" do
|
275
|
+
it "should create HTTP Copy requests" do
|
276
|
+
req = subject.request(:method => :copy)
|
221
277
|
|
222
|
-
|
223
|
-
|
278
|
+
expect(req.class).to eq(Net::HTTP::Copy)
|
279
|
+
end
|
224
280
|
|
225
|
-
|
226
|
-
|
281
|
+
it "should create HTTP Delete requests" do
|
282
|
+
req = subject.request(:method => :delete)
|
227
283
|
|
228
|
-
|
229
|
-
|
284
|
+
expect(req.class).to eq(Net::HTTP::Delete)
|
285
|
+
end
|
230
286
|
|
231
|
-
|
232
|
-
|
287
|
+
it "should create HTTP Get requests" do
|
288
|
+
req = subject.request(:method => :get)
|
233
289
|
|
234
|
-
|
235
|
-
|
290
|
+
expect(req.class).to eq(Net::HTTP::Get)
|
291
|
+
end
|
236
292
|
|
237
|
-
|
238
|
-
|
293
|
+
it "should create HTTP Head requests" do
|
294
|
+
req = subject.request(:method => :head)
|
239
295
|
|
240
|
-
|
241
|
-
|
296
|
+
expect(req.class).to eq(Net::HTTP::Head)
|
297
|
+
end
|
242
298
|
|
243
|
-
|
244
|
-
|
299
|
+
it "should create HTTP Lock requests" do
|
300
|
+
req = subject.request(:method => :lock)
|
245
301
|
|
246
|
-
|
247
|
-
|
302
|
+
expect(req.class).to eq(Net::HTTP::Lock)
|
303
|
+
end
|
248
304
|
|
249
|
-
|
250
|
-
|
305
|
+
it "should create HTTP Mkcol requests" do
|
306
|
+
req = subject.request(:method => :mkcol)
|
251
307
|
|
252
|
-
|
253
|
-
|
308
|
+
expect(req.class).to eq(Net::HTTP::Mkcol)
|
309
|
+
end
|
254
310
|
|
255
|
-
|
256
|
-
|
311
|
+
it "should create HTTP Move requests" do
|
312
|
+
req = subject.request(:method => :move)
|
257
313
|
|
258
|
-
|
259
|
-
|
314
|
+
expect(req.class).to eq(Net::HTTP::Move)
|
315
|
+
end
|
316
|
+
|
317
|
+
it "should create HTTP Options requests" do
|
318
|
+
req = subject.request(:method => :options)
|
260
319
|
|
261
|
-
|
262
|
-
|
320
|
+
expect(req.class).to eq(Net::HTTP::Options)
|
321
|
+
end
|
322
|
+
|
323
|
+
it "should create HTTP Post requests" do
|
324
|
+
req = subject.request(:method => :post)
|
325
|
+
|
326
|
+
expect(req.class).to eq(Net::HTTP::Post)
|
327
|
+
end
|
328
|
+
|
329
|
+
it "should create HTTP Propfind requests" do
|
330
|
+
req = subject.request(:method => :propfind)
|
263
331
|
|
264
|
-
|
332
|
+
expect(req.class).to eq(Net::HTTP::Propfind)
|
333
|
+
end
|
334
|
+
|
335
|
+
it "should create HTTP Proppatch requests" do
|
336
|
+
req = subject.request(:method => :proppatch)
|
337
|
+
|
338
|
+
expect(req.class).to eq(Net::HTTP::Proppatch)
|
339
|
+
end
|
340
|
+
|
341
|
+
it "should create HTTP Trace requests" do
|
342
|
+
req = subject.request(:method => :trace)
|
343
|
+
|
344
|
+
expect(req.class).to eq(Net::HTTP::Trace)
|
345
|
+
end
|
346
|
+
|
347
|
+
it "should create HTTP Unlock requests" do
|
348
|
+
req = subject.request(:method => :unlock)
|
349
|
+
|
350
|
+
expect(req.class).to eq(Net::HTTP::Unlock)
|
351
|
+
end
|
352
|
+
|
353
|
+
it "should raise an UnknownRequest exception for invalid methods" do
|
354
|
+
expect {
|
355
|
+
subject.request(:method => :bla)
|
356
|
+
}.to raise_error(subject::UnknownRequest)
|
357
|
+
end
|
265
358
|
end
|
266
359
|
|
267
360
|
it "should raise an ArgumentError when :method is not specified" do
|
268
|
-
|
361
|
+
expect {
|
269
362
|
subject.request()
|
270
|
-
}.
|
363
|
+
}.to raise_error(ArgumentError)
|
271
364
|
end
|
272
365
|
end
|
273
366
|
|
@@ -287,8 +380,8 @@ describe Network::HTTP do
|
|
287
380
|
it "should create a Net::HTTP session" do
|
288
381
|
http = subject.http_connect(:host => host, :port => port)
|
289
382
|
|
290
|
-
http.
|
291
|
-
http.
|
383
|
+
expect(http).to be_kind_of(Net::HTTP)
|
384
|
+
expect(http).to be_started
|
292
385
|
|
293
386
|
http.finish
|
294
387
|
end
|
@@ -300,7 +393,7 @@ describe Network::HTTP do
|
|
300
393
|
http = session
|
301
394
|
end
|
302
395
|
|
303
|
-
http.
|
396
|
+
expect(http).to be_kind_of(Net::HTTP)
|
304
397
|
end
|
305
398
|
|
306
399
|
it "should allow yielding the expanded options" do
|
@@ -310,9 +403,9 @@ describe Network::HTTP do
|
|
310
403
|
expanded_options = options
|
311
404
|
end
|
312
405
|
|
313
|
-
expanded_options[:host].
|
314
|
-
expanded_options[:port].
|
315
|
-
expanded_options[:path].
|
406
|
+
expect(expanded_options[:host]).to eq(host)
|
407
|
+
expect(expanded_options[:port]).to eq(port)
|
408
|
+
expect(expanded_options[:path]).to eq(path)
|
316
409
|
end
|
317
410
|
end
|
318
411
|
|
@@ -324,8 +417,8 @@ describe Network::HTTP do
|
|
324
417
|
http = session
|
325
418
|
end
|
326
419
|
|
327
|
-
http.
|
328
|
-
http.
|
420
|
+
expect(http).to be_kind_of(Net::HTTP)
|
421
|
+
expect(http).not_to be_started
|
329
422
|
end
|
330
423
|
|
331
424
|
it "should allow yielding the Net::HTTP session" do
|
@@ -335,7 +428,7 @@ describe Network::HTTP do
|
|
335
428
|
http = session
|
336
429
|
end
|
337
430
|
|
338
|
-
http.
|
431
|
+
expect(http).to be_kind_of(Net::HTTP)
|
339
432
|
end
|
340
433
|
|
341
434
|
it "should allow yielding the expanded options" do
|
@@ -345,9 +438,9 @@ describe Network::HTTP do
|
|
345
438
|
expanded_options = options
|
346
439
|
end
|
347
440
|
|
348
|
-
expanded_options[:host].
|
349
|
-
expanded_options[:port].
|
350
|
-
expanded_options[:path].
|
441
|
+
expect(expanded_options[:host]).to eq(host)
|
442
|
+
expect(expanded_options[:port]).to eq(port)
|
443
|
+
expect(expanded_options[:path]).to eq(path)
|
351
444
|
end
|
352
445
|
end
|
353
446
|
|
@@ -355,7 +448,7 @@ describe Network::HTTP do
|
|
355
448
|
it "should send an arbitrary request and return the response" do
|
356
449
|
response = subject.http_request(:url => uri, :method => :options)
|
357
450
|
|
358
|
-
response.
|
451
|
+
expect(response).to be_kind_of(Net::HTTPMethodNotAllowed)
|
359
452
|
end
|
360
453
|
|
361
454
|
it "should allow yielding the request" do
|
@@ -365,7 +458,7 @@ describe Network::HTTP do
|
|
365
458
|
request = req
|
366
459
|
end
|
367
460
|
|
368
|
-
request.
|
461
|
+
expect(request).to be_kind_of(Net::HTTP::Options)
|
369
462
|
end
|
370
463
|
|
371
464
|
it "should allow yielding the expanded options" do
|
@@ -375,25 +468,25 @@ describe Network::HTTP do
|
|
375
468
|
expanded_options = options
|
376
469
|
end
|
377
470
|
|
378
|
-
expanded_options[:host].
|
379
|
-
expanded_options[:port].
|
380
|
-
expanded_options[:path].
|
471
|
+
expect(expanded_options[:host]).to eq(host)
|
472
|
+
expect(expanded_options[:port]).to eq(port)
|
473
|
+
expect(expanded_options[:path]).to eq(path)
|
381
474
|
end
|
382
475
|
end
|
383
476
|
|
384
477
|
describe "#http_status" do
|
385
478
|
it "should return an Integer" do
|
386
|
-
subject.http_status(:url => uri).
|
479
|
+
expect(subject.http_status(:url => uri)).to be_kind_of(Integer)
|
387
480
|
end
|
388
481
|
|
389
482
|
it "should return the status-code of the Response" do
|
390
|
-
subject.http_status(:url => uri).
|
483
|
+
expect(subject.http_status(:url => uri)).to eq(200)
|
391
484
|
end
|
392
485
|
end
|
393
486
|
|
394
487
|
describe "#http_ok?" do
|
395
488
|
it "should check if the Response has code 200" do
|
396
|
-
subject.http_ok?(:url => uri).
|
489
|
+
expect(subject.http_ok?(:url => uri)).to be(true)
|
397
490
|
end
|
398
491
|
end
|
399
492
|
|
@@ -402,7 +495,7 @@ describe Network::HTTP do
|
|
402
495
|
let(:headers) { subject.http_get_headers(:url => url) }
|
403
496
|
|
404
497
|
it "should return the 'Server' header" do
|
405
|
-
subject.http_server(:url => url).
|
498
|
+
expect(subject.http_server(:url => url)).to eq(headers['Server'])
|
406
499
|
end
|
407
500
|
end
|
408
501
|
|
@@ -411,7 +504,7 @@ describe Network::HTTP do
|
|
411
504
|
let(:headers) { subject.http_get_headers(:url => url) }
|
412
505
|
|
413
506
|
it "should return the 'X-Powered-By' header" do
|
414
|
-
subject.http_powered_by(:url => url).
|
507
|
+
expect(subject.http_powered_by(:url => url)).to eq(headers['X-Powered-By'])
|
415
508
|
end
|
416
509
|
end
|
417
510
|
|
@@ -419,14 +512,14 @@ describe Network::HTTP do
|
|
419
512
|
let(:headers) { subject.http_get_headers(:url => uri) }
|
420
513
|
|
421
514
|
it "should return HTTP Headers" do
|
422
|
-
headers.
|
515
|
+
expect(headers).not_to be_empty
|
423
516
|
end
|
424
517
|
|
425
518
|
it "should format the HTTP Headers accordingly" do
|
426
519
|
format = /^[A-Z][a-z0-9]*(-[A-Z][a-z0-9]*)*$/
|
427
520
|
bad_headers = headers.keys.reject { |name| name =~ format }
|
428
521
|
|
429
|
-
bad_headers.
|
522
|
+
expect(bad_headers).to eq([])
|
430
523
|
end
|
431
524
|
end
|
432
525
|
|
@@ -434,8 +527,8 @@ describe Network::HTTP do
|
|
434
527
|
it "should return the response body" do
|
435
528
|
body = subject.http_get_body(:url => uri)
|
436
529
|
|
437
|
-
body.
|
438
|
-
body.
|
530
|
+
expect(body).to be_kind_of(String)
|
531
|
+
expect(body).not_to be_empty
|
439
532
|
end
|
440
533
|
end
|
441
534
|
|
@@ -443,14 +536,14 @@ describe Network::HTTP do
|
|
443
536
|
let(:headers) { subject.http_post_headers(:url => uri) }
|
444
537
|
|
445
538
|
it "should return HTTP Headers" do
|
446
|
-
headers.
|
539
|
+
expect(headers).not_to be_empty
|
447
540
|
end
|
448
541
|
|
449
542
|
it "should format the HTTP Headers accordingly" do
|
450
543
|
format = /^[A-Z][a-z0-9]*(-[A-Z][a-z0-9]*)*$/
|
451
544
|
bad_headers = headers.keys.reject { |name| name =~ format }
|
452
545
|
|
453
|
-
bad_headers.
|
546
|
+
expect(bad_headers).to eq([])
|
454
547
|
end
|
455
548
|
end
|
456
549
|
|
@@ -458,8 +551,8 @@ describe Network::HTTP do
|
|
458
551
|
it "should return the response body" do
|
459
552
|
body = subject.http_post_body(:url => uri)
|
460
553
|
|
461
|
-
body.
|
462
|
-
body.
|
554
|
+
expect(body).to be_kind_of(String)
|
555
|
+
expect(body).not_to be_empty
|
463
556
|
end
|
464
557
|
end
|
465
558
|
end
|