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
@@ -8,40 +8,40 @@ describe Network::HTTP::Proxy do
|
|
8
8
|
it "should parse host-names" do
|
9
9
|
proxy = subject.parse('127.0.0.1')
|
10
10
|
|
11
|
-
proxy.host.
|
11
|
+
expect(proxy.host).to eq('127.0.0.1')
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should parse 'host:port' URLs" do
|
15
15
|
proxy = subject.parse('127.0.0.1:80')
|
16
16
|
|
17
|
-
proxy.host.
|
18
|
-
proxy.port.
|
17
|
+
expect(proxy.host).to eq('127.0.0.1')
|
18
|
+
expect(proxy.port).to eq(80)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should parse 'user@host:port' URLs" do
|
22
22
|
proxy = subject.parse('joe@127.0.0.1:80')
|
23
23
|
|
24
|
-
proxy.user.
|
25
|
-
proxy.host.
|
26
|
-
proxy.port.
|
24
|
+
expect(proxy.user).to eq('joe')
|
25
|
+
expect(proxy.host).to eq('127.0.0.1')
|
26
|
+
expect(proxy.port).to eq(80)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should prase 'user:password@host:port' URLs" do
|
30
30
|
proxy = subject.parse('joe:lol@127.0.0.1:80')
|
31
31
|
|
32
|
-
proxy.user.
|
33
|
-
proxy.password.
|
34
|
-
proxy.host.
|
35
|
-
proxy.port.
|
32
|
+
expect(proxy.user).to eq('joe')
|
33
|
+
expect(proxy.password).to eq('lol')
|
34
|
+
expect(proxy.host).to eq('127.0.0.1')
|
35
|
+
expect(proxy.port).to eq(80)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should ignore http:// prefixes when parsing proxy URLs" do
|
39
39
|
proxy = subject.parse('http://joe:lol@127.0.0.1:80')
|
40
40
|
|
41
|
-
proxy.user.
|
42
|
-
proxy.password.
|
43
|
-
proxy.host.
|
44
|
-
proxy.port.
|
41
|
+
expect(proxy.user).to eq('joe')
|
42
|
+
expect(proxy.password).to eq('lol')
|
43
|
+
expect(proxy.host).to eq('127.0.0.1')
|
44
|
+
expect(proxy.port).to eq(80)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -54,55 +54,55 @@ describe Network::HTTP::Proxy do
|
|
54
54
|
it "should accept Proxy objects" do
|
55
55
|
proxy = subject.new(:host => host, :port => port)
|
56
56
|
|
57
|
-
subject.create(proxy).
|
57
|
+
expect(subject.create(proxy)).to eq(proxy)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should accept URI::HTTP objects" do
|
61
61
|
url = URI::HTTP.build(:host => host, :port => port)
|
62
62
|
proxy = subject.create(url)
|
63
63
|
|
64
|
-
proxy.host.
|
65
|
-
proxy.port.
|
64
|
+
expect(proxy.host).to eq(host)
|
65
|
+
expect(proxy.port).to eq(port)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should accept Hash objects" do
|
69
69
|
hash = {:host => host, :port => port}
|
70
70
|
proxy = subject.create(hash)
|
71
71
|
|
72
|
-
proxy.host.
|
73
|
-
proxy.port.
|
72
|
+
expect(proxy.host).to eq(host)
|
73
|
+
expect(proxy.port).to eq(port)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should accept String objects" do
|
77
77
|
string = "#{host}:#{port}"
|
78
78
|
proxy = subject.create(string)
|
79
79
|
|
80
|
-
proxy.host.
|
81
|
-
proxy.port.
|
80
|
+
expect(proxy.host).to eq(host)
|
81
|
+
expect(proxy.port).to eq(port)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should accept nil" do
|
85
85
|
proxy = subject.create(nil)
|
86
86
|
|
87
|
-
proxy.
|
87
|
+
expect(proxy).not_to be_enabled
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should behave like a Hash" do
|
92
92
|
subject[:host] = 'example.com'
|
93
|
-
subject[:host].
|
93
|
+
expect(subject[:host]).to eq('example.com')
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should not have a host by default" do
|
97
|
-
subject.host.
|
97
|
+
expect(subject.host).to be_nil
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should not have a port by default" do
|
101
|
-
subject.port.
|
101
|
+
expect(subject.port).to be_nil
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should be disabled by default" do
|
105
|
-
subject.
|
105
|
+
expect(subject).not_to be_enabled
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should reset the host, port, user and password when disabled" do
|
@@ -113,10 +113,10 @@ describe Network::HTTP::Proxy do
|
|
113
113
|
|
114
114
|
subject.disable!
|
115
115
|
|
116
|
-
subject[:host].
|
117
|
-
subject[:port].
|
118
|
-
subject[:user].
|
119
|
-
subject[:password].
|
116
|
+
expect(subject[:host]).to be_nil
|
117
|
+
expect(subject[:port]).to be_nil
|
118
|
+
expect(subject[:user]).to be_nil
|
119
|
+
expect(subject[:password]).to be_nil
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should return a URI::HTTP representing the proxy" do
|
@@ -127,22 +127,22 @@ describe Network::HTTP::Proxy do
|
|
127
127
|
|
128
128
|
url = subject.url
|
129
129
|
|
130
|
-
url.host.
|
131
|
-
url.port.
|
132
|
-
url.user.
|
133
|
-
url.password.
|
130
|
+
expect(url.host).to eq('example.com')
|
131
|
+
expect(url.port).to eq(9001)
|
132
|
+
expect(url.user).to eq('joe')
|
133
|
+
expect(url.password).to eq('lol')
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should return nil when converting a disabled proxy to a URL" do
|
137
|
-
subject.url.
|
137
|
+
expect(subject.url).to be_nil
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should return the host-name when converted to a String" do
|
141
141
|
subject[:host] = 'example.com'
|
142
|
-
subject.to_s.
|
142
|
+
expect(subject.to_s).to eq('example.com')
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should return an empty String when there is no host-name" do
|
146
|
-
subject.to_s.
|
146
|
+
expect(subject.to_s).to be_empty
|
147
147
|
end
|
148
148
|
end
|
data/spec/network/proxy_spec.rb
CHANGED
@@ -24,8 +24,8 @@ describe Network::Proxy do
|
|
24
24
|
:server => [server_host, server_port]
|
25
25
|
)
|
26
26
|
|
27
|
-
proxy.port.
|
28
|
-
proxy.host.
|
27
|
+
expect(proxy.port).to eq(port)
|
28
|
+
expect(proxy.host).to eq('0.0.0.0')
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should allow setting both the host and port" do
|
@@ -35,8 +35,8 @@ describe Network::Proxy do
|
|
35
35
|
:server => [server_host, server_port]
|
36
36
|
)
|
37
37
|
|
38
|
-
proxy.port.
|
39
|
-
proxy.host.
|
38
|
+
expect(proxy.port).to eq(port)
|
39
|
+
expect(proxy.host).to eq(host)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should set the server_host and server_port" do
|
@@ -46,20 +46,20 @@ describe Network::Proxy do
|
|
46
46
|
:server => [server_host, server_port]
|
47
47
|
)
|
48
48
|
|
49
|
-
proxy.server_host.
|
50
|
-
proxy.server_port.
|
49
|
+
expect(proxy.server_host).to eq(server_host)
|
50
|
+
expect(proxy.server_port).to eq(server_port)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "#on_data" do
|
55
55
|
it "should call on_client_data" do
|
56
|
-
subject.
|
56
|
+
expect(subject).to receive(:on_client_data)
|
57
57
|
|
58
58
|
subject.on_data { |client,server,data| }
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should call on_server_data" do
|
62
|
-
subject.
|
62
|
+
expect(subject).to receive(:on_server_data)
|
63
63
|
|
64
64
|
subject.on_data { |client,server,data| }
|
65
65
|
end
|
@@ -68,33 +68,33 @@ describe Network::Proxy do
|
|
68
68
|
describe "actions" do
|
69
69
|
describe "#ignore!" do
|
70
70
|
it "should throw the :ignore action" do
|
71
|
-
|
71
|
+
expect {
|
72
72
|
subject.ignore!
|
73
|
-
}.
|
73
|
+
}.to throw_symbol(:action, :ignore)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "#close!" do
|
78
78
|
it "should throw the :close action" do
|
79
|
-
|
79
|
+
expect {
|
80
80
|
subject.close!
|
81
|
-
}.
|
81
|
+
}.to throw_symbol(:action, :close)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "#reset!" do
|
86
86
|
it "should throw the :reset action" do
|
87
|
-
|
87
|
+
expect {
|
88
88
|
subject.reset!
|
89
|
-
}.
|
89
|
+
}.to throw_symbol(:action, :reset)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe "#stop!" do
|
94
94
|
it "should throw the :stop action" do
|
95
|
-
|
95
|
+
expect {
|
96
96
|
subject.stop!
|
97
|
-
}.
|
97
|
+
}.to throw_symbol(:action, :stop)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -103,11 +103,11 @@ describe Network::Proxy do
|
|
103
103
|
subject { proxy.to_s }
|
104
104
|
|
105
105
|
it "should include the proxy host and port" do
|
106
|
-
subject.
|
106
|
+
expect(subject).to include("#{host}:#{port}")
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should include the server host and port" do
|
110
|
-
subject.
|
110
|
+
expect(subject).to include("#{server_host}:#{server_port}")
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -115,7 +115,7 @@ describe Network::Proxy do
|
|
115
115
|
subject { proxy.inspect }
|
116
116
|
|
117
117
|
it "should include the output of #to_s" do
|
118
|
-
subject.
|
118
|
+
expect(subject).to include(proxy.to_s)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -8,27 +8,27 @@ describe Network::SMTP::Email do
|
|
8
8
|
it "should default 'date' to Time.now" do
|
9
9
|
email = Network::SMTP::Email.new
|
10
10
|
|
11
|
-
email.date.
|
11
|
+
expect(email.date).not_to be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should accept a String body" do
|
15
15
|
body = 'hello'
|
16
16
|
email = Network::SMTP::Email.new(:body => body)
|
17
17
|
|
18
|
-
email.body.
|
18
|
+
expect(email.body).to eq([body])
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should accept an Array body" do
|
22
22
|
body = ['hello', 'world']
|
23
23
|
email = Network::SMTP::Email.new(:body => body)
|
24
24
|
|
25
|
-
email.body.
|
25
|
+
expect(email.body).to eq(body)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should default 'body' to an empty Array" do
|
29
29
|
email = Network::SMTP::Email.new
|
30
30
|
|
31
|
-
email.body.
|
31
|
+
expect(email.body).to be_empty
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -38,39 +38,39 @@ describe Network::SMTP::Email do
|
|
38
38
|
it "should add the 'from'" do
|
39
39
|
subject.from = 'joe@example.com'
|
40
40
|
|
41
|
-
subject.to_s.
|
41
|
+
expect(subject.to_s).to include("From: joe@example.com\n\r")
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when formatting 'to'" do
|
45
45
|
it "should accept an Array of addresses" do
|
46
46
|
subject.to = ['alice@example.com', 'joe@example.com']
|
47
47
|
|
48
|
-
subject.to_s.
|
48
|
+
expect(subject.to_s).to include("To: alice@example.com, joe@example.com\n\r")
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should accept a String" do
|
52
52
|
subject.to = 'joe@example.com'
|
53
53
|
|
54
|
-
subject.to_s.
|
54
|
+
expect(subject.to_s).to include("To: joe@example.com\n\r")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should add the 'subject'" do
|
59
59
|
subject.subject = 'Hello'
|
60
60
|
|
61
|
-
subject.to_s.
|
61
|
+
expect(subject.to_s).to include("Subject: Hello\n\r")
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should add the 'date'" do
|
65
65
|
subject.date = Date.parse('Sun Apr 24 17:22:55 PDT 2011')
|
66
66
|
|
67
|
-
subject.to_s.
|
67
|
+
expect(subject.to_s).to include("Date: #{subject.date}\n\r")
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should add the 'message_id'" do
|
71
71
|
subject.message_id = '1234'
|
72
72
|
|
73
|
-
subject.to_s.
|
73
|
+
expect(subject.to_s).to include("Message-Id: <#{subject.message_id}>\n\r")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should add additional headers" do
|
@@ -79,21 +79,21 @@ describe Network::SMTP::Email do
|
|
79
79
|
|
80
80
|
lines = subject.to_s.split("\n\r")
|
81
81
|
|
82
|
-
lines.
|
83
|
-
lines.
|
82
|
+
expect(lines).to include('X-Foo: Bar')
|
83
|
+
expect(lines).to include('X-Baz: Quix')
|
84
84
|
end
|
85
85
|
|
86
86
|
context "when formatting 'body'" do
|
87
87
|
it "should append each line with a CRLF" do
|
88
88
|
subject.body = ['hello', 'world']
|
89
89
|
|
90
|
-
subject.to_s.
|
90
|
+
expect(subject.to_s).to include("hello\n\rworld")
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should add a CRLF before the body" do
|
94
94
|
subject.body = ['hello', 'world']
|
95
95
|
|
96
|
-
subject.to_s.
|
96
|
+
expect(subject.to_s).to include("\n\rhello")
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
data/spec/network/ssl_spec.rb
CHANGED
@@ -6,15 +6,15 @@ describe Network::SSL do
|
|
6
6
|
subject { Network::SSL::VERIFY }
|
7
7
|
|
8
8
|
it "should map verify mode names to OpenSSL VERIFY_* constants" do
|
9
|
-
subject[:peer].
|
9
|
+
expect(subject[:peer]).to eq(OpenSSL::SSL::VERIFY_PEER)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should default to VERIFY_NONE if no verify mode name is given" do
|
13
|
-
subject[nil].
|
13
|
+
expect(subject[nil]).to eq(OpenSSL::SSL::VERIFY_NONE)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should raise an exception for unknown verify modes" do
|
17
|
-
|
17
|
+
expect { subject[:foo_bar] }.to raise_error
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -30,15 +30,15 @@ describe Network::SSL do
|
|
30
30
|
|
31
31
|
describe "#ssl_connect" do
|
32
32
|
it "should connect to an SSL protected port" do
|
33
|
-
|
33
|
+
expect {
|
34
34
|
subject.ssl_connect(host,port)
|
35
|
-
}.
|
35
|
+
}.not_to raise_error
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should return an OpenSSL::SSL::SSLSocket" do
|
39
39
|
socket = subject.ssl_connect(host,port)
|
40
40
|
|
41
|
-
socket.
|
41
|
+
expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when a block is given" do
|
@@ -49,7 +49,7 @@ describe Network::SSL do
|
|
49
49
|
socket = yielded_socket
|
50
50
|
end
|
51
51
|
|
52
|
-
socket.
|
52
|
+
expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -62,8 +62,8 @@ describe Network::SSL do
|
|
62
62
|
socket = yielded_socket
|
63
63
|
end
|
64
64
|
|
65
|
-
socket.
|
66
|
-
socket.
|
65
|
+
expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
|
66
|
+
expect(socket).to be_closed
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -29,7 +29,7 @@ describe Network::TCP::Proxy, :network => true do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should trigger when a new client connects" do
|
32
|
-
@socket.readline.
|
32
|
+
expect(@socket.readline).to eq(injection)
|
33
33
|
end
|
34
34
|
|
35
35
|
after { @socket.close }
|
@@ -47,7 +47,7 @@ describe Network::TCP::Proxy, :network => true do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should trigger after a new client connects" do
|
50
|
-
@socket.readline.
|
50
|
+
expect(@socket.readline).to eq(injection)
|
51
51
|
end
|
52
52
|
|
53
53
|
after { @socket.close }
|
@@ -56,16 +56,18 @@ describe Network::TCP::Proxy, :network => true do
|
|
56
56
|
describe "#on_client_data" do
|
57
57
|
before do
|
58
58
|
@proxy.on_client_data do |client,server,data|
|
59
|
-
data.
|
59
|
+
if (match = data.match(/HTTP\/(\d\.\d)/))
|
60
|
+
client.write("HTTP #{match[1]} detected!\r\n")
|
61
|
+
end
|
60
62
|
end
|
61
63
|
|
62
64
|
@socket = TCPSocket.new(host,port)
|
63
65
|
end
|
64
66
|
|
65
67
|
it "should trigger when the client sends data" do
|
66
|
-
@socket.write("GET / HTTP/1.
|
68
|
+
@socket.write("GET /placeholder HTTP/1.0\r\n\r\n")
|
67
69
|
|
68
|
-
@socket.readline.
|
70
|
+
expect(@socket.readline).to eq("HTTP 1.0 detected!\r\n")
|
69
71
|
end
|
70
72
|
|
71
73
|
after { @socket.close }
|
@@ -83,7 +85,7 @@ describe Network::TCP::Proxy, :network => true do
|
|
83
85
|
it "should trigger when the server sends data" do
|
84
86
|
@socket.write("GET / HTTP/1.0\r\n\r\n")
|
85
87
|
|
86
|
-
@socket.read.
|
88
|
+
expect(@socket.read).to include("Connection: keep-alive\r\n")
|
87
89
|
end
|
88
90
|
|
89
91
|
after { @socket.close }
|
@@ -103,7 +105,7 @@ describe Network::TCP::Proxy, :network => true do
|
|
103
105
|
it "should trigger when the server closes the connection" do
|
104
106
|
@socket.write("GET / HTTP/1.0\r\n\r\n")
|
105
107
|
|
106
|
-
@socket.read.end_with?(injection).
|
108
|
+
expect(@socket.read.end_with?(injection)).to be(true)
|
107
109
|
end
|
108
110
|
|
109
111
|
after { @socket.close }
|