unicorn 4.1.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/t/.gitignore CHANGED
@@ -1,2 +1,5 @@
1
1
  /random_blob
2
2
  /.dep+*
3
+ /*.crt
4
+ /*.key
5
+ /ssl-stamp
data/t/GNUmakefile CHANGED
@@ -45,7 +45,11 @@ random_blob:
45
45
  dd if=/dev/urandom bs=1M count=30 of=$@.$(pid)
46
46
  mv $@.$(pid) $@
47
47
 
48
- $(T): random_blob
48
+ ssl-stamp:
49
+ ./sslgen.sh
50
+ > $@
51
+
52
+ $(T): random_blob ssl-stamp
49
53
 
50
54
  dependencies := socat curl
51
55
  deps := $(addprefix .dep+,$(dependencies))
data/t/bin/sha1sum.rb CHANGED
@@ -1,12 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- encoding: binary -*-
3
-
4
- # Reads from stdin and outputs the SHA1 hex digest of the input this is
5
- # ONLY used as a last resort, our test code will try to use sha1sum(1),
6
- # openssl(1), or gsha1sum(1) before falling back to using this. We try
7
- # all options first because we have a strong and healthy distrust of our
8
- # Ruby abilities in general, and *especially* when it comes to
9
- # understanding (and trusting the implementation of) Ruby 1.9 encoding.
3
+ # Reads from stdin and outputs the SHA1 hex digest of the input
10
4
 
11
5
  require 'digest/sha1'
12
6
  $stdout.sync = $stderr.sync = true
data/t/sslgen.sh ADDED
@@ -0,0 +1,71 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ lock=$0.lock
5
+ while ! mkdir $lock 2>/dev/null
6
+ do
7
+ echo >&2 "PID=$$ waiting for $lock"
8
+ sleep 1
9
+ done
10
+ pid=$$
11
+ trap 'if test $$ -eq $pid; then rmdir $lock; fi' EXIT
12
+
13
+ certinfo() {
14
+ echo US
15
+ echo Hell
16
+ echo A Very Special Place
17
+ echo Monkeys
18
+ echo Poo-Flingers
19
+ echo 127.0.0.1
20
+ echo kgio@bogomips.org
21
+ }
22
+
23
+ certinfo2() {
24
+ certinfo
25
+ echo
26
+ echo
27
+ }
28
+
29
+ ca_certinfo () {
30
+ echo US
31
+ echo Hell
32
+ echo An Even More Special Place
33
+ echo Deranged Monkeys
34
+ echo Poo-Hurlers
35
+ echo 127.6.6.6
36
+ echo unicorn@bogomips.org
37
+ }
38
+
39
+ openssl genrsa -out ca.key 512
40
+ ca_certinfo | openssl req -new -x509 -days 666 -key ca.key -out ca.crt
41
+
42
+ openssl genrsa -out bad-ca.key 512
43
+ ca_certinfo | openssl req -new -x509 -days 666 -key bad-ca.key -out bad-ca.crt
44
+
45
+ openssl genrsa -out server.key 512
46
+ certinfo2 | openssl req -new -key server.key -out server.csr
47
+
48
+ openssl x509 -req -days 666 \
49
+ -in server.csr -CA ca.crt -CAkey ca.key -set_serial 1 -out server.crt
50
+ n=2
51
+ mk_client_cert () {
52
+ CLIENT=$1
53
+ openssl genrsa -out $CLIENT.key 512
54
+ certinfo2 | openssl req -new -key $CLIENT.key -out $CLIENT.csr
55
+
56
+ openssl x509 -req -days 666 \
57
+ -in $CLIENT.csr -CA $CA.crt -CAkey $CA.key -set_serial $n \
58
+ -out $CLIENT.crt
59
+ rm -f $CLIENT.csr
60
+ n=$(($n + 1))
61
+ }
62
+
63
+ CA=ca
64
+ mk_client_cert client1
65
+ mk_client_cert client2
66
+
67
+ CA=bad-ca mk_client_cert bad-client
68
+
69
+ rm -f server.csr
70
+
71
+ echo OK
@@ -7,7 +7,7 @@ read_pid_unix () {
7
7
  socat - UNIX:$unix_socket | \
8
8
  tail -1)
9
9
  test -n "$x"
10
- y="$(expr "$x" : '\([0-9]\+\)')"
10
+ y="$(expr "$x" : '\([0-9][0-9]*\)')"
11
11
  test x"$x" = x"$y"
12
12
  test -n "$y"
13
13
  echo "$y"
@@ -0,0 +1,48 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+ t_plan 7 "simple HTTPS connection tests"
4
+
5
+ t_begin "setup and start" && {
6
+ rtmpfiles curl_err
7
+ unicorn_setup
8
+ cat > $unicorn_config <<EOF
9
+ ssl do
10
+ listen "$listen"
11
+ ssl_certificate "server.crt"
12
+ ssl_certificate_key "server.key"
13
+ end
14
+ pid "$pid"
15
+ stderr_path "$r_err"
16
+ stdout_path "$r_out"
17
+ EOF
18
+ unicorn -D -c $unicorn_config env.ru
19
+ unicorn_wait_start
20
+ }
21
+
22
+ t_begin "single request" && {
23
+ curl -sSfv --cacert ca.crt https://$listen/
24
+ }
25
+
26
+ t_begin "check stderr has no errors" && {
27
+ check_stderr
28
+ }
29
+
30
+ t_begin "multiple requests" && {
31
+ curl -sSfv --no-keepalive --cacert ca.crt \
32
+ https://$listen/ https://$listen/ 2>> $curl_err >> $tmp
33
+ dbgcat curl_err
34
+ }
35
+
36
+ t_begin "check stderr has no errors" && {
37
+ check_stderr
38
+ }
39
+
40
+ t_begin "killing succeeds" && {
41
+ kill $unicorn_pid
42
+ }
43
+
44
+ t_begin "check stderr has no errors" && {
45
+ check_stderr
46
+ }
47
+
48
+ t_done
data/t/test-lib.sh CHANGED
@@ -38,20 +38,29 @@ rtmpfiles () {
38
38
  for id in "$@"
39
39
  do
40
40
  name=$id
41
- _tmp=$t_pfx.$id
42
- eval "$id=$_tmp"
43
41
 
44
42
  case $name in
45
43
  *fifo)
44
+ _tmp=$t_pfx.$id
45
+ eval "$id=$_tmp"
46
46
  rm -f $_tmp
47
47
  mkfifo $_tmp
48
48
  T_RM_LIST="$T_RM_LIST $_tmp"
49
49
  ;;
50
50
  *socket)
51
+ _tmp="$(mktemp -t $id.$$.XXXXXXXX)"
52
+ if test $(printf "$_tmp" |wc -c) -gt 108
53
+ then
54
+ echo >&2 "$_tmp too long, tests may fail"
55
+ echo >&2 "Try to set TMPDIR to a shorter path"
56
+ fi
57
+ eval "$id=$_tmp"
51
58
  rm -f $_tmp
52
59
  T_RM_LIST="$T_RM_LIST $_tmp"
53
60
  ;;
54
61
  *)
62
+ _tmp=$t_pfx.$id
63
+ eval "$id=$_tmp"
55
64
  > $_tmp
56
65
  T_OK_RM_LIST="$T_OK_RM_LIST $_tmp"
57
66
  ;;
@@ -100,11 +109,5 @@ unicorn_wait_start () {
100
109
  }
101
110
 
102
111
  rsha1 () {
103
- _cmd="$(which sha1sum 2>/dev/null || :)"
104
- test -n "$_cmd" || _cmd="$(which openssl 2>/dev/null || :) sha1"
105
- test "$_cmd" != " sha1" || _cmd="$(which gsha1sum 2>/dev/null || :)"
106
-
107
- # last resort, see comments in sha1sum.rb for reasoning
108
- test -n "$_cmd" || _cmd=sha1sum.rb
109
- expr "$($_cmd)" : '\([a-f0-9]\{40\}\)'
112
+ sha1sum.rb
110
113
  }
@@ -45,7 +45,10 @@ end
45
45
 
46
46
  ROR_V = UNICORN_RAILS_TEST_VERSION.split(/\./).map { |x| x.to_i }
47
47
  RB_V = RUBY_VERSION.split(/\./).map { |x| x.to_i }
48
- if RB_V[0] >= 1 && RB_V[1] >= 9
48
+ if RB_V[0] >= 2
49
+ warn "skipping Ruby 2.0+ test with Rails <3"
50
+ do_test = false
51
+ elsif RB_V[0] >= 1 && RB_V[1] >= 9
49
52
  if RB_V[2] >= 2
50
53
  warn "Ruby 1.9.2+ is not compatible with Rails 2.x"
51
54
  do_test = false
data/test/test_helper.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
2
 
3
3
  # Copyright (c) 2005 Zed A. Shaw
4
- # You can redistribute it and/or modify it under the same terms as Ruby.
4
+ # You can redistribute it and/or modify it under the same terms as Ruby 1.8 or
5
+ # the GPLv3
5
6
  #
6
7
  # Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
7
8
  # for more information.
@@ -72,6 +73,7 @@ def hit(uris)
72
73
  res = nil
73
74
 
74
75
  if u.kind_of? String
76
+ u = 'http://127.0.0.1:8080/' if u == 'http://0.0.0.0:8080/'
75
77
  res = Net::HTTP.get(URI.parse(u))
76
78
  else
77
79
  url = URI.parse(u[0])
@@ -1,7 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
2
 
3
3
  # Copyright (c) 2005 Zed A. Shaw
4
- # You can redistribute it and/or modify it under the same terms as Ruby.
4
+ # You can redistribute it and/or modify it under the same terms as Ruby 1.8 or
5
+ # the GPLv3
5
6
  #
6
7
  # Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
7
8
  # for more information.
@@ -31,6 +31,14 @@ class HttpParserNgTest < Test::Unit::TestCase
31
31
  assert_raises(TypeError) { HttpParser.keepalive_requests = [] }
32
32
  end
33
33
 
34
+ def test_connection_TE
35
+ @parser.buf << "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: TE\r\n"
36
+ @parser.buf << "TE: trailers\r\n\r\n"
37
+ assert_nothing_raised { @parser.parse }
38
+ assert @parser.keepalive?
39
+ assert @parser.next?
40
+ end
41
+
34
42
  def test_keepalive_requests_with_next?
35
43
  req = "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n".freeze
36
44
  expect = {
@@ -1,7 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
2
 
3
3
  # Copyright (c) 2009 Eric Wong
4
- # You can redistribute it and/or modify it under the same terms as Ruby.
4
+ # You can redistribute it and/or modify it under the same terms as Ruby 1.8 or
5
+ # the GPLv3
5
6
 
6
7
  require 'test/test_helper'
7
8
 
@@ -1,7 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
2
 
3
3
  # Copyright (c) 2005 Zed A. Shaw
4
- # You can redistribute it and/or modify it under the same terms as Ruby.
4
+ # You can redistribute it and/or modify it under the same terms as Ruby 1.8 or
5
+ # the GPLv3
5
6
  #
6
7
  # Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
7
8
  # for more information.
@@ -1,7 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
2
 
3
3
  # Copyright (c) 2005 Zed A. Shaw
4
- # You can redistribute it and/or modify it under the same terms as Ruby.
4
+ # You can redistribute it and/or modify it under the same terms as Ruby 1.8 or
5
+ # the GPLv3
5
6
  #
6
7
  # Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
7
8
  # for more information.
@@ -1,7 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
2
 
3
3
  # Copyright (c) 2009 Eric Wong
4
- # You can redistribute it and/or modify it under the same terms as Ruby.
4
+ # You can redistribute it and/or modify it under the same terms as Ruby 1.8 or
5
+ # the GPLv3
5
6
  #
6
7
  # Ensure we stay sane in the face of signals being sent to us
7
8
 
@@ -0,0 +1,47 @@
1
+ # -*- encoding: binary -*-
2
+ require "test/unit"
3
+ require "unicorn"
4
+
5
+ # this tests an implementation detail, it may change so this test
6
+ # can be removed later.
7
+ class TestSniHostnames < Test::Unit::TestCase
8
+ include Unicorn::SSLServer
9
+
10
+ def setup
11
+ GC.start
12
+ end
13
+
14
+ def teardown
15
+ GC.start
16
+ end
17
+
18
+ def test_host_name_detect_one
19
+ app = Rack::Builder.new do
20
+ map "http://sni1.example.com/" do
21
+ use Rack::ContentLength
22
+ use Rack::ContentType, "text/plain"
23
+ run lambda { |env| [ 200, {}, [] ] }
24
+ end
25
+ end.to_app
26
+ hostnames = rack_sni_hostnames(app)
27
+ assert hostnames.include?("sni1.example.com")
28
+ end
29
+
30
+ def test_host_name_detect_multiple
31
+ app = Rack::Builder.new do
32
+ map "http://sni2.example.com/" do
33
+ use Rack::ContentLength
34
+ use Rack::ContentType, "text/plain"
35
+ run lambda { |env| [ 200, {}, [] ] }
36
+ end
37
+ map "http://sni3.example.com/" do
38
+ use Rack::ContentLength
39
+ use Rack::ContentType, "text/plain"
40
+ run lambda { |env| [ 200, {}, [] ] }
41
+ end
42
+ end.to_app
43
+ hostnames = rack_sni_hostnames(app)
44
+ assert hostnames.include?("sni2.example.com")
45
+ assert hostnames.include?("sni3.example.com")
46
+ end
47
+ end
data/unicorn.gemspec CHANGED
@@ -34,11 +34,11 @@ Gem::Specification.new do |s|
34
34
  # commented out. Nevertheless, upgrading to Rails 2.3.4 or later is
35
35
  # *strongly* recommended for security reasons.
36
36
  s.add_dependency(%q<rack>)
37
- s.add_dependency(%q<kgio>, '~> 2.4')
38
- s.add_dependency(%q<raindrops>, '~> 0.6')
37
+ s.add_dependency(%q<kgio>, '~> 2.6')
38
+ s.add_dependency(%q<raindrops>, '~> 0.7')
39
39
 
40
- s.add_development_dependency('isolate', '~> 3.1')
41
- s.add_development_dependency('wrongdoc', '~> 1.6')
40
+ s.add_development_dependency('isolate', '~> 3.2')
41
+ s.add_development_dependency('wrongdoc', '~> 1.6.1')
42
42
 
43
43
  # s.licenses = %w(GPLv2 Ruby) # licenses= method is not in older RubyGems
44
44
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 4
8
- - 1
9
- - 1
10
- version: 4.1.1
8
+ - 2
9
+ - 0
10
+ version: 4.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Unicorn hackers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-25 00:00:00 Z
18
+ date: 2012-01-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rack
@@ -39,11 +39,11 @@ dependencies:
39
39
  requirements:
40
40
  - - ~>
41
41
  - !ruby/object:Gem::Version
42
- hash: 11
42
+ hash: 15
43
43
  segments:
44
44
  - 2
45
- - 4
46
- version: "2.4"
45
+ - 6
46
+ version: "2.6"
47
47
  type: :runtime
48
48
  version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
@@ -54,11 +54,11 @@ dependencies:
54
54
  requirements:
55
55
  - - ~>
56
56
  - !ruby/object:Gem::Version
57
- hash: 7
57
+ hash: 5
58
58
  segments:
59
59
  - 0
60
- - 6
61
- version: "0.6"
60
+ - 7
61
+ version: "0.7"
62
62
  type: :runtime
63
63
  version_requirements: *id003
64
64
  - !ruby/object:Gem::Dependency
@@ -69,11 +69,11 @@ dependencies:
69
69
  requirements:
70
70
  - - ~>
71
71
  - !ruby/object:Gem::Version
72
- hash: 5
72
+ hash: 3
73
73
  segments:
74
74
  - 3
75
- - 1
76
- version: "3.1"
75
+ - 2
76
+ version: "3.2"
77
77
  type: :development
78
78
  version_requirements: *id004
79
79
  - !ruby/object:Gem::Dependency
@@ -84,11 +84,12 @@ dependencies:
84
84
  requirements:
85
85
  - - ~>
86
86
  - !ruby/object:Gem::Version
87
- hash: 3
87
+ hash: 13
88
88
  segments:
89
89
  - 1
90
90
  - 6
91
- version: "1.6"
91
+ - 1
92
+ version: 1.6.1
92
93
  type: :development
93
94
  version_requirements: *id005
94
95
  description: |-
@@ -201,6 +202,9 @@ files:
201
202
  - lib/unicorn/oob_gc.rb
202
203
  - lib/unicorn/preread_input.rb
203
204
  - lib/unicorn/socket_helper.rb
205
+ - lib/unicorn/ssl_client.rb
206
+ - lib/unicorn/ssl_configurator.rb
207
+ - lib/unicorn/ssl_server.rb
204
208
  - lib/unicorn/stream_input.rb
205
209
  - lib/unicorn/tee_input.rb
206
210
  - lib/unicorn/tmpio.rb
@@ -258,6 +262,7 @@ files:
258
262
  - t/rails3-app/test/performance/browsing_test.rb
259
263
  - t/rails3-app/test/test_helper.rb
260
264
  - t/rails3-app/vendor/plugins/.gitkeep
265
+ - t/sslgen.sh
261
266
  - t/t0000-http-basic.sh
262
267
  - t/t0001-reload-bad-config.sh
263
268
  - t/t0002-config-conflict.sh
@@ -293,6 +298,7 @@ files:
293
298
  - t/t0302-rails3-alt-working_directory.sh
294
299
  - t/t0303-rails3-alt-working_directory_config.ru.sh
295
300
  - t/t0304-rails3-alt-working_directory_no_embed_cli.sh
301
+ - t/t0600-https-server-basic.sh
296
302
  - t/t9000-preread-input.sh
297
303
  - t/t9001-oob_gc.sh
298
304
  - t/t9002-oob_gc-path.sh
@@ -376,6 +382,7 @@ files:
376
382
  - test/unit/test_response.rb
377
383
  - test/unit/test_server.rb
378
384
  - test/unit/test_signals.rb
385
+ - test/unit/test_sni_hostnames.rb
379
386
  - test/unit/test_socket_helper.rb
380
387
  - test/unit/test_stream_input.rb
381
388
  - test/unit/test_tee_input.rb
@@ -414,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
414
421
  requirements: []
415
422
 
416
423
  rubyforge_project: mongrel
417
- rubygems_version: 1.8.5
424
+ rubygems_version: 1.8.11
418
425
  signing_key:
419
426
  specification_version: 3
420
427
  summary: Rack HTTP server for fast clients and Unix
@@ -426,4 +433,5 @@ test_files:
426
433
  - test/unit/test_request.rb
427
434
  - test/unit/test_response.rb
428
435
  - test/unit/test_server.rb
436
+ - test/unit/test_sni_hostnames.rb
429
437
  - test/unit/test_util.rb