Sha256: 1dcd7f65deb69df0fc20f5b8d1406f78f5ab3e216ffcf4cf4b492d420680688d

Contents?: true

Size: 1.36 KB

Versions: 27

Compression:

Stored size: 1.36 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'phusion_passenger/abstract_server'

module PhusionPassenger

describe AbstractServer do
	before :each do
		@server = AbstractServer.new
	end
	
	after :each do
		@server.stop if @server.started?
	end
	
	it "reseeds the pseudo-random number generator after forking off a process" do
		@server.send(:define_message_handler, :random_number, :handle_random_number)
		@server.stub!(:handle_random_number).and_return do |channel|
			channel.write(rand.to_s)
		end
		
		first_num = second_num = nil
		
		@server.start
		@server.connect do |channel|
			channel.write("random_number")
			first_num = channel.read
		end
		
		@server.stop
		@server.start
		@server.connect do |channel|
			channel.write("random_number")
			second_num = channel.read
		end
		
		first_num.should_not == second_num
	end
	
	specify "its socket is password protected" do
		@server.ignore_password_errors = true
		@server.send(:define_message_handler, :number, :handle_number)
		@server.stub!(:handle_number).and_return do |channel|
			channel.write(1)
		end
		
		@server.start
		@server.instance_variable_set(:"@password", "1234")
		
		begin
			@server.connect do |channel|
				channel.write("number")
				result = channel.read
				result.should be_nil
			end
		rescue SystemCallError, IOError
			# Success.
		end
	end
end

end # module PhusionPassenger

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
passenger-3.0.21 test/ruby/abstract_server_spec.rb
passenger-3.0.19 test/ruby/abstract_server_spec.rb
passenger-3.0.18 test/ruby/abstract_server_spec.rb
passenger-3.0.17 test/ruby/abstract_server_spec.rb
passenger-3.0.15 test/ruby/abstract_server_spec.rb
passenger-3.0.14 test/ruby/abstract_server_spec.rb
passenger-3.0.13 test/ruby/abstract_server_spec.rb
passenger-3.0.12 test/ruby/abstract_server_spec.rb
yspassenger-3.0.12 test/ruby/abstract_server_spec.rb
passenger-3.0.11 test/ruby/abstract_server_spec.rb
passenger-3.0.10 test/ruby/abstract_server_spec.rb
passenger-3.0.9 test/ruby/abstract_server_spec.rb
passenger-3.0.8 test/ruby/abstract_server_spec.rb
passenger-3.0.7 test/ruby/abstract_server_spec.rb
passenger-3.0.6 test/ruby/abstract_server_spec.rb
passenger-3.0.5 test/ruby/abstract_server_spec.rb
passenger-3.0.4 test/ruby/abstract_server_spec.rb
passenger-3.0.3 test/ruby/abstract_server_spec.rb
railsware-passenger-3.0.2.1 test/ruby/abstract_server_spec.rb
passenger-3.0.2 test/ruby/abstract_server_spec.rb