spec/celluloid/io/ssl_server_spec.rb in celluloid-io-0.16.5.pre0 vs spec/celluloid/io/ssl_server_spec.rb in celluloid-io-0.17.0
- old
+ new
@@ -7,11 +7,12 @@
OpenSSL::SSL::SSLContext.new.tap do |context|
context.cert = client_cert
context.key = client_key
end
end
-
+
+ let(:example_port) { assign_port }
let(:server_cert) { OpenSSL::X509::Certificate.new fixture_dir.join("server.crt").read }
let(:server_key) { OpenSSL::PKey::RSA.new fixture_dir.join("server.key").read }
let(:server_context) do
OpenSSL::SSL::SSLContext.new.tap do |context|
context.cert = server_cert
@@ -22,19 +23,19 @@
describe "#accept" do
let(:payload) { 'ohai' }
context "inside Celluloid::IO" do
it "should be evented" do
- with_ssl_server do |subject|
+ with_ssl_server(example_port) do |subject|
expect(within_io_actor { Celluloid::IO.evented? }).to be_truthy
end
end
it "accepts a connection and returns a Celluloid::IO::SSLSocket" do
- with_ssl_server do |subject|
+ with_ssl_server(example_port) do |subject|
thread = Thread.new do
- raw = TCPSocket.new(example_addr, example_ssl_port)
+ raw = TCPSocket.new(example_addr, example_port)
OpenSSL::SSL::SSLSocket.new(raw, client_context).connect
end
peer = within_io_actor { subject.accept }
expect(peer).to be_a Celluloid::IO::SSLSocket
@@ -45,19 +46,19 @@
end
end
context "outside Celluloid::IO" do
it "should be blocking" do
- with_ssl_server do |subject|
+ with_ssl_server(example_port) do |subject|
expect(Celluloid::IO).not_to be_evented
end
end
it "accepts a connection and returns a Celluloid::IO::SSLSocket" do
- with_ssl_server do |subject|
+ with_ssl_server(example_port) do |subject|
thread = Thread.new do
- raw = TCPSocket.new(example_addr, example_ssl_port)
+ raw = TCPSocket.new(example_addr, example_port)
OpenSSL::SSL::SSLSocket.new(raw, client_context).connect
end
peer = subject.accept
expect(peer).to be_a Celluloid::IO::SSLSocket
@@ -69,18 +70,18 @@
end
end
describe "#initialize" do
it "should auto-wrap a raw ::TCPServer" do
- raw_server = ::TCPServer.new(example_addr, example_ssl_port)
- with_ssl_server(raw_server) do |ssl_server|
+ raw_server = ::TCPServer.new(example_addr, example_port)
+ with_ssl_server(example_port, raw_server) do |ssl_server|
expect(ssl_server.tcp_server.class).to eq(Celluloid::IO::TCPServer)
end
end
end
- def with_ssl_server(raw_server = nil)
- raw_server ||= Celluloid::IO::TCPServer.new(example_addr, example_ssl_port)
+ def with_ssl_server(port, raw_server = nil)
+ raw_server ||= Celluloid::IO::TCPServer.new(example_addr, port)
server = Celluloid::IO::SSLServer.new(raw_server, server_context)
begin
yield server
ensure
server.close