passenger 4.0.30 → 4.0.31

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (409) hide show
  1. data.tar.gz.asc +7 -7
  2. data/NEWS +31 -0
  3. data/bin/passenger +5 -5
  4. data/bin/passenger-config +6 -126
  5. data/bin/passenger-install-apache2-module +108 -26
  6. data/bin/passenger-install-nginx-module +81 -27
  7. data/bin/passenger-memory-stats +7 -6
  8. data/bin/passenger-status +13 -10
  9. data/build/agents.rb +8 -12
  10. data/build/apache2.rb +12 -7
  11. data/build/basics.rb +28 -20
  12. data/build/common_library.rb +4 -4
  13. data/build/cplusplus_support.rb +4 -4
  14. data/build/cxx_tests.rb +5 -3
  15. data/build/debian.rb +1 -2
  16. data/build/integration_tests.rb +25 -9
  17. data/build/misc.rb +2 -2
  18. data/build/oxt_tests.rb +5 -6
  19. data/build/packaging.rb +72 -40
  20. data/build/ruby_tests.rb +5 -1
  21. data/build/test_basics.rb +1 -2
  22. data/debian.template/locations.ini.template +1 -0
  23. data/debian.template/rules.template +2 -1
  24. data/dev/install_scripts_bootstrap_code.rb +42 -0
  25. data/dev/run_travis.sh +1 -0
  26. data/dev/runner +27 -0
  27. data/doc/Packaging.txt.md +5 -10
  28. data/doc/Users guide Apache.idmap.txt +3 -1
  29. data/doc/Users guide Apache.txt +5 -3
  30. data/doc/Users guide Nginx.idmap.txt +9 -5
  31. data/doc/Users guide Nginx.txt +47 -17
  32. data/doc/users_guide_snippets/environment_variables.txt +2 -2
  33. data/doc/users_guide_snippets/installation.txt +6 -2
  34. data/doc/users_guide_snippets/tips.txt +4 -0
  35. data/ext/apache2/Hooks.cpp +16 -3
  36. data/ext/common/Account.h +6 -5
  37. data/ext/common/AgentsStarter.h +1 -1
  38. data/ext/common/ApplicationPool2/Common.h +72 -0
  39. data/ext/common/ApplicationPool2/Group.h +263 -148
  40. data/ext/common/ApplicationPool2/Implementation.cpp +66 -44
  41. data/ext/common/ApplicationPool2/Options.h +1 -7
  42. data/ext/common/ApplicationPool2/Pool.h +96 -72
  43. data/ext/common/ApplicationPool2/Process.h +12 -17
  44. data/ext/common/ApplicationPool2/Socket.h +4 -4
  45. data/ext/common/ApplicationPool2/SuperGroup.h +20 -17
  46. data/ext/common/Constants.h +15 -1
  47. data/ext/common/MessageServer.h +22 -0
  48. data/ext/common/Utils.cpp +4 -1
  49. data/ext/common/Utils.h +3 -1
  50. data/ext/common/Utils/StrIntUtils.h +1 -0
  51. data/ext/common/Utils/Timer.h +15 -1
  52. data/ext/common/Utils/utf8/checked.h +0 -0
  53. data/ext/common/Utils/utf8/core.h +0 -0
  54. data/ext/common/Utils/utf8/unchecked.h +0 -0
  55. data/ext/common/agents/Base.cpp +59 -35
  56. data/ext/common/agents/HelperAgent/Main.cpp +23 -12
  57. data/ext/common/agents/HelperAgent/RequestHandler.h +10 -1
  58. data/ext/common/agents/LoggingAgent/FilterSupport.h +9 -5
  59. data/ext/common/agents/TempDirToucher.c +12 -3
  60. data/ext/common/agents/Watchdog/Main.cpp +8 -2
  61. data/ext/nginx/ConfigurationCommands.c +10 -0
  62. data/ext/nginx/ConfigurationFields.h +2 -0
  63. data/ext/nginx/ContentHandler.c +32 -19
  64. data/ext/nginx/CreateLocationConfig.c +5 -0
  65. data/ext/nginx/MergeLocationConfig.c +6 -0
  66. data/ext/nginx/config +13 -6
  67. data/ext/ruby/passenger_native_support.c +61 -2
  68. data/helper-scripts/classic-rails-loader.rb +9 -10
  69. data/helper-scripts/classic-rails-preloader.rb +10 -11
  70. data/helper-scripts/node-loader.js +3 -2
  71. data/helper-scripts/rack-loader.rb +8 -9
  72. data/helper-scripts/rack-preloader.rb +9 -10
  73. data/lib/phusion_passenger.rb +36 -7
  74. data/lib/phusion_passenger/abstract_installer.rb +16 -15
  75. data/lib/phusion_passenger/active_support3_extensions/init.rb +1 -1
  76. data/lib/phusion_passenger/admin_tools/memory_stats.rb +2 -2
  77. data/lib/phusion_passenger/admin_tools/server_instance.rb +5 -5
  78. data/lib/phusion_passenger/analytics_logger.rb +3 -3
  79. data/lib/phusion_passenger/classic_rails/thread_handler_extension.rb +1 -1
  80. data/lib/phusion_passenger/config.rb +125 -0
  81. data/lib/phusion_passenger/config/about_command.rb +183 -0
  82. data/lib/phusion_passenger/config/command.rb +57 -0
  83. data/lib/phusion_passenger/config/restart_app_command.rb +146 -0
  84. data/lib/phusion_passenger/config/utils.rb +108 -0
  85. data/lib/phusion_passenger/console_text_template.rb +2 -1
  86. data/lib/phusion_passenger/constants.rb +7 -2
  87. data/lib/phusion_passenger/loader_shared_helpers.rb +12 -21
  88. data/lib/phusion_passenger/message_client.rb +15 -4
  89. data/lib/phusion_passenger/native_support.rb +116 -98
  90. data/lib/phusion_passenger/nginx/config_options.rb +5 -0
  91. data/lib/phusion_passenger/platform_info.rb +1 -1
  92. data/lib/phusion_passenger/platform_info/apache.rb +9 -5
  93. data/lib/phusion_passenger/platform_info/apache_detector.rb +5 -6
  94. data/lib/phusion_passenger/platform_info/binary_compatibility.rb +3 -3
  95. data/lib/phusion_passenger/platform_info/compiler.rb +29 -11
  96. data/lib/phusion_passenger/platform_info/curl.rb +1 -1
  97. data/lib/phusion_passenger/platform_info/cxx_portability.rb +30 -16
  98. data/lib/phusion_passenger/platform_info/depcheck.rb +6 -6
  99. data/lib/phusion_passenger/platform_info/linux.rb +2 -2
  100. data/lib/phusion_passenger/platform_info/operating_system.rb +25 -5
  101. data/lib/phusion_passenger/platform_info/ruby.rb +7 -4
  102. data/lib/phusion_passenger/platform_info/zlib.rb +1 -1
  103. data/lib/phusion_passenger/plugin.rb +0 -1
  104. data/lib/phusion_passenger/preloader_shared_helpers.rb +1 -1
  105. data/lib/phusion_passenger/public_api.rb +1 -1
  106. data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
  107. data/lib/phusion_passenger/request_handler.rb +8 -9
  108. data/lib/phusion_passenger/request_handler/thread_handler.rb +21 -9
  109. data/lib/phusion_passenger/ruby_core_enhancements.rb +1 -1
  110. data/lib/phusion_passenger/standalone/app_finder.rb +2 -2
  111. data/lib/phusion_passenger/standalone/command.rb +10 -8
  112. data/lib/phusion_passenger/standalone/help_command.rb +1 -1
  113. data/lib/phusion_passenger/standalone/main.rb +3 -3
  114. data/lib/phusion_passenger/standalone/package_runtime_command.rb +2 -2
  115. data/lib/phusion_passenger/standalone/runtime_installer.rb +55 -13
  116. data/lib/phusion_passenger/standalone/runtime_locator.rb +3 -3
  117. data/lib/phusion_passenger/standalone/start_command.rb +6 -7
  118. data/lib/phusion_passenger/standalone/status_command.rb +1 -1
  119. data/lib/phusion_passenger/standalone/stop_command.rb +1 -1
  120. data/lib/phusion_passenger/standalone/utils.rb +1 -1
  121. data/lib/phusion_passenger/standalone/version_command.rb +2 -3
  122. data/lib/phusion_passenger/utils.rb +1 -1
  123. data/lib/phusion_passenger/utils/download.rb +1 -2
  124. data/lib/phusion_passenger/utils/file_system_watcher.rb +1 -1
  125. data/lib/phusion_passenger/utils/hosts_file_parser.rb +1 -1
  126. data/lib/phusion_passenger/utils/tee_input.rb +1 -1
  127. data/lib/phusion_passenger/utils/terminal_choice_menu.rb +217 -0
  128. data/lib/phusion_passenger/utils/unseekable_socket.rb +1 -1
  129. data/resources/templates/apache2/config_snippets.txt.erb +2 -3
  130. data/resources/templates/apache2/deployment_example.txt.erb +2 -2
  131. data/resources/templates/apache2/notify_apache_module_installed.txt.erb +3 -0
  132. data/resources/templates/nginx/config_snippets.txt.erb +1 -1
  133. data/resources/templates/nginx/deployment_example.txt.erb +2 -2
  134. data/resources/templates/nginx/nginx_module_sources_not_available.txt.erb +11 -5
  135. data/rpm/Vagrantfile +1 -0
  136. data/test/cxx/ApplicationPool2/PoolTest.cpp +224 -35
  137. data/test/cxx/ApplicationPool2/ProcessTest.cpp +6 -6
  138. data/test/cxx/MessagePassingTest.cpp +1 -1
  139. data/test/cxx/RequestHandlerTest.cpp +26 -26
  140. data/test/integration_tests/apache2_tests.rb +162 -243
  141. data/test/integration_tests/native_packaging_spec.rb +10 -10
  142. data/test/integration_tests/nginx_tests.rb +87 -107
  143. data/test/integration_tests/shared/example_webapp_tests.rb +246 -0
  144. data/test/integration_tests/source_packaging_test.rb +2 -1
  145. data/test/integration_tests/standalone_tests.rb +34 -19
  146. data/test/ruby/admin_tools_spec.rb +4 -4
  147. data/test/ruby/analytics_logger_spec.rb +1 -1
  148. data/test/ruby/debug_logging_spec.rb +2 -2
  149. data/test/ruby/message_channel_spec.rb +1 -1
  150. data/test/ruby/request_handler_spec.rb +171 -64
  151. data/test/ruby/shared/loader_sharedspec.rb +5 -5
  152. data/test/ruby/shared/rails/analytics_logging_extensions_sharedspec.rb +2 -2
  153. data/test/ruby/spec_helper.rb +4 -4
  154. data/test/ruby/standalone/runtime_installer_spec.rb +1 -1
  155. data/test/ruby/standalone/runtime_locator_spec.rb +1 -1
  156. data/test/ruby/utils/file_system_watcher_spec.rb +1 -1
  157. data/test/ruby/utils/hosts_file_parser.rb +1 -1
  158. data/test/ruby/utils/unseekable_socket_spec.rb +1 -1
  159. data/test/ruby/utils_spec.rb +4 -4
  160. data/test/stub/apache2/httpd.conf.erb +5 -0
  161. data/test/stub/index.html +1 -0
  162. data/test/stub/rack/config.ru +80 -33
  163. data/test/stub/{rails_apps/1.2/empty/app/models → rack/public}/.gitignore +0 -0
  164. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/Rakefile +0 -0
  165. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/application_controller.rb +0 -0
  166. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/recipes_controller.rb +0 -0
  167. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/uploads_controller.rb +0 -0
  168. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/welcome_controller.rb +0 -0
  169. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/app/helpers/application_helper.rb +0 -0
  170. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/recipes_helper.rb +0 -0
  171. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/test_helper.rb +0 -0
  172. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/uploads_helper.rb +0 -0
  173. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/welcome_helper.rb +0 -0
  174. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/layouts/default.rhtml +0 -0
  175. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/create.rhtml +0 -0
  176. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/index.rhtml +0 -0
  177. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/new.rhtml +0 -0
  178. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/uploads/index.rhtml +0 -0
  179. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/uploads/new.html.erb +0 -0
  180. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/welcome/cached.rhtml +0 -0
  181. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/welcome/index.rhtml +0 -0
  182. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/boot.rb +0 -0
  183. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/database.yml +0 -0
  184. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/environment.rb +0 -0
  185. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/environments/development.rb +0 -0
  186. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/environments/production.rb +0 -0
  187. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/initializers/inflections.rb +0 -0
  188. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/initializers/mime_types.rb +0 -0
  189. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/routes.rb +0 -0
  190. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/log/useless.txt +0 -0
  191. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/.htaccess +0 -0
  192. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/404.html +0 -0
  193. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/422.html +0 -0
  194. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/500.html +0 -0
  195. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.cgi +0 -0
  196. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.fcgi +0 -0
  197. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.rb +0 -0
  198. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/favicon.ico +0 -0
  199. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/angrywizard.gif +0 -0
  200. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/cookbook.gif +0 -0
  201. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/header.png +0 -0
  202. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/images/rails.png +0 -0
  203. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/robots.txt +0 -0
  204. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/uploads.html +0 -0
  205. data/test/stub/{rails_apps/1.2/empty/db → rails2.3-mycook/public/uploads}/.gitignore +0 -0
  206. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/welcome/cached.html +0 -0
  207. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/about +0 -0
  208. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/console +0 -0
  209. data/test/stub/{rails_apps/2.2/empty → rails2.3-mycook}/script/dbconsole +0 -0
  210. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/destroy +0 -0
  211. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/generate +0 -0
  212. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/performance/benchmarker +0 -0
  213. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/performance/profiler +0 -0
  214. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/performance/request +0 -0
  215. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/plugin +0 -0
  216. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/inspector +0 -0
  217. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/reaper +0 -0
  218. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/spawner +0 -0
  219. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/runner +0 -0
  220. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/server +0 -0
  221. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/sites/some.site/public/uploads.html +0 -0
  222. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/sites/some.site/public/welcome/cached.html +0 -0
  223. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/cache/useless.txt +0 -0
  224. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/pids/useless.txt +0 -0
  225. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/sessions/useless.txt +0 -0
  226. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/sockets/useless.txt +0 -0
  227. data/test/stub/rails2.3/app/controllers/foo_controller.rb +1 -1
  228. data/test/stub/rails2.3/config/routes.rb +1 -2
  229. data/test/stub/wsgi/passenger_wsgi.py +47 -8
  230. data/test/stub/{rails_apps/1.2/empty/public/stylesheets → wsgi/public}/.gitignore +0 -0
  231. data/test/support/apache2_controller.rb +2 -2
  232. data/test/support/nginx_controller.rb +11 -5
  233. data/test/support/placebo-preloader.rb +2 -2
  234. data/test/support/test_helper.rb +26 -7
  235. metadata +78 -240
  236. metadata.gz.asc +7 -7
  237. data/debian.template/repack.sh +0 -42
  238. data/debian.template/watch +0 -3
  239. data/test/integration_tests/cgi_environment_spec.rb +0 -36
  240. data/test/integration_tests/hello_world_rack_spec.rb +0 -43
  241. data/test/integration_tests/hello_world_wsgi_spec.rb +0 -41
  242. data/test/integration_tests/mycook_spec.rb +0 -166
  243. data/test/stub/rack/public/rack.jpg +0 -0
  244. data/test/stub/rails_apps/1.2/empty/.gitignore +0 -3
  245. data/test/stub/rails_apps/1.2/empty/app/controllers/application.rb +0 -7
  246. data/test/stub/rails_apps/1.2/empty/config/boot.rb +0 -108
  247. data/test/stub/rails_apps/1.2/empty/config/database.yml +0 -31
  248. data/test/stub/rails_apps/1.2/empty/config/environment.rb +0 -66
  249. data/test/stub/rails_apps/1.2/empty/config/environments/development.rb +0 -21
  250. data/test/stub/rails_apps/1.2/empty/config/environments/production.rb +0 -18
  251. data/test/stub/rails_apps/1.2/empty/config/environments/staging.rb +0 -18
  252. data/test/stub/rails_apps/1.2/empty/config/environments/test.rb +0 -19
  253. data/test/stub/rails_apps/1.2/empty/config/routes.rb +0 -23
  254. data/test/stub/rails_apps/1.2/empty/doc/README_FOR_APP +0 -2
  255. data/test/stub/rails_apps/1.2/empty/public/.htaccess +0 -40
  256. data/test/stub/rails_apps/1.2/empty/public/500.html +0 -30
  257. data/test/stub/rails_apps/1.2/empty/public/dispatch.cgi +0 -10
  258. data/test/stub/rails_apps/1.2/empty/public/dispatch.fcgi +0 -24
  259. data/test/stub/rails_apps/1.2/empty/public/dispatch.rb +0 -10
  260. data/test/stub/rails_apps/1.2/empty/public/robots.txt +0 -1
  261. data/test/stub/rails_apps/1.2/empty/script/about +0 -3
  262. data/test/stub/rails_apps/1.2/empty/script/breakpointer +0 -3
  263. data/test/stub/rails_apps/1.2/empty/script/console +0 -3
  264. data/test/stub/rails_apps/1.2/empty/script/destroy +0 -3
  265. data/test/stub/rails_apps/1.2/empty/script/generate +0 -3
  266. data/test/stub/rails_apps/1.2/empty/script/plugin +0 -3
  267. data/test/stub/rails_apps/1.2/empty/script/runner +0 -3
  268. data/test/stub/rails_apps/1.2/empty/script/server +0 -3
  269. data/test/stub/rails_apps/1.2/empty/test/test_helper.rb +0 -28
  270. data/test/stub/rails_apps/2.0/empty/.gitignore +0 -3
  271. data/test/stub/rails_apps/2.0/empty/Rakefile +0 -10
  272. data/test/stub/rails_apps/2.0/empty/app/controllers/application.rb +0 -10
  273. data/test/stub/rails_apps/2.0/empty/app/helpers/application_helper.rb +0 -3
  274. data/test/stub/rails_apps/2.0/empty/app/models/.gitignore +0 -0
  275. data/test/stub/rails_apps/2.0/empty/config/boot.rb +0 -108
  276. data/test/stub/rails_apps/2.0/empty/config/database.yml +0 -31
  277. data/test/stub/rails_apps/2.0/empty/config/environment.rb +0 -59
  278. data/test/stub/rails_apps/2.0/empty/config/environments/production.rb +0 -18
  279. data/test/stub/rails_apps/2.0/empty/config/environments/staging.rb +0 -18
  280. data/test/stub/rails_apps/2.0/empty/config/environments/test.rb +0 -22
  281. data/test/stub/rails_apps/2.0/empty/config/routes.rb +0 -35
  282. data/test/stub/rails_apps/2.0/empty/db/.gitignore +0 -0
  283. data/test/stub/rails_apps/2.0/empty/doc/README_FOR_APP +0 -2
  284. data/test/stub/rails_apps/2.0/empty/public/.htaccess +0 -40
  285. data/test/stub/rails_apps/2.0/empty/public/404.html +0 -30
  286. data/test/stub/rails_apps/2.0/empty/public/dispatch.cgi +0 -10
  287. data/test/stub/rails_apps/2.0/empty/public/dispatch.fcgi +0 -24
  288. data/test/stub/rails_apps/2.0/empty/public/dispatch.rb +0 -10
  289. data/test/stub/rails_apps/2.0/empty/public/favicon.ico +0 -0
  290. data/test/stub/rails_apps/2.0/empty/public/images/rails.png +0 -0
  291. data/test/stub/rails_apps/2.0/empty/public/stylesheets/.gitignore +0 -0
  292. data/test/stub/rails_apps/2.0/empty/script/performance/benchmarker +0 -3
  293. data/test/stub/rails_apps/2.0/empty/script/performance/profiler +0 -3
  294. data/test/stub/rails_apps/2.0/empty/script/process/inspector +0 -3
  295. data/test/stub/rails_apps/2.0/empty/script/process/reaper +0 -3
  296. data/test/stub/rails_apps/2.0/empty/script/process/spawner +0 -3
  297. data/test/stub/rails_apps/2.0/empty/test/test_helper.rb +0 -38
  298. data/test/stub/rails_apps/2.2/empty/.gitignore +0 -3
  299. data/test/stub/rails_apps/2.2/empty/Rakefile +0 -10
  300. data/test/stub/rails_apps/2.2/empty/app/controllers/application.rb +0 -15
  301. data/test/stub/rails_apps/2.2/empty/app/helpers/application_helper.rb +0 -3
  302. data/test/stub/rails_apps/2.2/empty/app/models/.gitignore +0 -0
  303. data/test/stub/rails_apps/2.2/empty/config/boot.rb +0 -109
  304. data/test/stub/rails_apps/2.2/empty/config/database.yml +0 -31
  305. data/test/stub/rails_apps/2.2/empty/config/environment.rb +0 -75
  306. data/test/stub/rails_apps/2.2/empty/config/environments/development.rb +0 -17
  307. data/test/stub/rails_apps/2.2/empty/config/environments/production.rb +0 -24
  308. data/test/stub/rails_apps/2.2/empty/config/environments/staging.rb +0 -24
  309. data/test/stub/rails_apps/2.2/empty/config/environments/test.rb +0 -22
  310. data/test/stub/rails_apps/2.2/empty/config/initializers/inflections.rb +0 -10
  311. data/test/stub/rails_apps/2.2/empty/config/initializers/mime_types.rb +0 -5
  312. data/test/stub/rails_apps/2.2/empty/config/initializers/new_rails_defaults.rb +0 -17
  313. data/test/stub/rails_apps/2.2/empty/config/locales/en.yml +0 -5
  314. data/test/stub/rails_apps/2.2/empty/config/routes.rb +0 -43
  315. data/test/stub/rails_apps/2.2/empty/db/.gitignore +0 -0
  316. data/test/stub/rails_apps/2.2/empty/doc/README_FOR_APP +0 -5
  317. data/test/stub/rails_apps/2.2/empty/public/404.html +0 -30
  318. data/test/stub/rails_apps/2.2/empty/public/422.html +0 -30
  319. data/test/stub/rails_apps/2.2/empty/public/500.html +0 -33
  320. data/test/stub/rails_apps/2.2/empty/public/dispatch.cgi +0 -10
  321. data/test/stub/rails_apps/2.2/empty/public/dispatch.fcgi +0 -24
  322. data/test/stub/rails_apps/2.2/empty/public/dispatch.rb +0 -10
  323. data/test/stub/rails_apps/2.2/empty/public/favicon.ico +0 -0
  324. data/test/stub/rails_apps/2.2/empty/public/images/rails.png +0 -0
  325. data/test/stub/rails_apps/2.2/empty/public/robots.txt +0 -5
  326. data/test/stub/rails_apps/2.2/empty/public/stylesheets/.gitignore +0 -0
  327. data/test/stub/rails_apps/2.2/empty/script/about +0 -4
  328. data/test/stub/rails_apps/2.2/empty/script/console +0 -3
  329. data/test/stub/rails_apps/2.2/empty/script/destroy +0 -3
  330. data/test/stub/rails_apps/2.2/empty/script/generate +0 -3
  331. data/test/stub/rails_apps/2.2/empty/script/performance/benchmarker +0 -3
  332. data/test/stub/rails_apps/2.2/empty/script/performance/profiler +0 -3
  333. data/test/stub/rails_apps/2.2/empty/script/performance/request +0 -3
  334. data/test/stub/rails_apps/2.2/empty/script/plugin +0 -3
  335. data/test/stub/rails_apps/2.2/empty/script/process/inspector +0 -3
  336. data/test/stub/rails_apps/2.2/empty/script/process/reaper +0 -3
  337. data/test/stub/rails_apps/2.2/empty/script/process/spawner +0 -3
  338. data/test/stub/rails_apps/2.2/empty/script/runner +0 -3
  339. data/test/stub/rails_apps/2.2/empty/script/server +0 -3
  340. data/test/stub/rails_apps/2.2/empty/test/performance/browsing_test.rb +0 -9
  341. data/test/stub/rails_apps/2.2/empty/test/test_helper.rb +0 -38
  342. data/test/stub/rails_apps/2.3/empty/.gitignore +0 -3
  343. data/test/stub/rails_apps/2.3/empty/Rakefile +0 -10
  344. data/test/stub/rails_apps/2.3/empty/app/controllers/application_controller.rb +0 -10
  345. data/test/stub/rails_apps/2.3/empty/app/helpers/application_helper.rb +0 -3
  346. data/test/stub/rails_apps/2.3/empty/app/models/.gitignore +0 -0
  347. data/test/stub/rails_apps/2.3/empty/config/boot.rb +0 -110
  348. data/test/stub/rails_apps/2.3/empty/config/database.yml +0 -31
  349. data/test/stub/rails_apps/2.3/empty/config/environment.rb +0 -41
  350. data/test/stub/rails_apps/2.3/empty/config/environments/development.rb +0 -17
  351. data/test/stub/rails_apps/2.3/empty/config/environments/production.rb +0 -28
  352. data/test/stub/rails_apps/2.3/empty/config/environments/staging.rb +0 -28
  353. data/test/stub/rails_apps/2.3/empty/config/environments/test.rb +0 -28
  354. data/test/stub/rails_apps/2.3/empty/config/initializers/backtrace_silencers.rb +0 -7
  355. data/test/stub/rails_apps/2.3/empty/config/initializers/inflections.rb +0 -10
  356. data/test/stub/rails_apps/2.3/empty/config/initializers/mime_types.rb +0 -5
  357. data/test/stub/rails_apps/2.3/empty/config/initializers/new_rails_defaults.rb +0 -21
  358. data/test/stub/rails_apps/2.3/empty/config/initializers/session_store.rb +0 -15
  359. data/test/stub/rails_apps/2.3/empty/config/locales/en.yml +0 -5
  360. data/test/stub/rails_apps/2.3/empty/config/routes.rb +0 -43
  361. data/test/stub/rails_apps/2.3/empty/db/.gitignore +0 -0
  362. data/test/stub/rails_apps/2.3/empty/db/seeds.rb +0 -7
  363. data/test/stub/rails_apps/2.3/empty/doc/README_FOR_APP +0 -2
  364. data/test/stub/rails_apps/2.3/empty/public/404.html +0 -30
  365. data/test/stub/rails_apps/2.3/empty/public/422.html +0 -30
  366. data/test/stub/rails_apps/2.3/empty/public/500.html +0 -30
  367. data/test/stub/rails_apps/2.3/empty/public/favicon.ico +0 -0
  368. data/test/stub/rails_apps/2.3/empty/public/images/rails.png +0 -0
  369. data/test/stub/rails_apps/2.3/empty/public/robots.txt +0 -5
  370. data/test/stub/rails_apps/2.3/empty/public/stylesheets/.gitignore +0 -0
  371. data/test/stub/rails_apps/2.3/empty/script/about +0 -4
  372. data/test/stub/rails_apps/2.3/empty/script/console +0 -3
  373. data/test/stub/rails_apps/2.3/empty/script/dbconsole +0 -3
  374. data/test/stub/rails_apps/2.3/empty/script/destroy +0 -3
  375. data/test/stub/rails_apps/2.3/empty/script/generate +0 -3
  376. data/test/stub/rails_apps/2.3/empty/script/performance/benchmarker +0 -3
  377. data/test/stub/rails_apps/2.3/empty/script/performance/profiler +0 -3
  378. data/test/stub/rails_apps/2.3/empty/script/plugin +0 -3
  379. data/test/stub/rails_apps/2.3/empty/script/runner +0 -3
  380. data/test/stub/rails_apps/2.3/empty/script/server +0 -3
  381. data/test/stub/rails_apps/2.3/empty/test/performance/browsing_test.rb +0 -9
  382. data/test/stub/rails_apps/2.3/empty/test/test_helper.rb +0 -38
  383. data/test/stub/rails_apps/2.3/mycook/Rakefile +0 -10
  384. data/test/stub/rails_apps/2.3/mycook/app/helpers/application_helper.rb +0 -3
  385. data/test/stub/rails_apps/2.3/mycook/config/environments/development.rb +0 -18
  386. data/test/stub/rails_apps/2.3/mycook/config/initializers/inflections.rb +0 -10
  387. data/test/stub/rails_apps/2.3/mycook/config/initializers/mime_types.rb +0 -5
  388. data/test/stub/rails_apps/2.3/mycook/public/404.html +0 -30
  389. data/test/stub/rails_apps/2.3/mycook/public/422.html +0 -30
  390. data/test/stub/rails_apps/2.3/mycook/public/500.html +0 -30
  391. data/test/stub/rails_apps/2.3/mycook/public/favicon.ico +0 -0
  392. data/test/stub/rails_apps/2.3/mycook/public/images/rails.png +0 -0
  393. data/test/stub/rails_apps/2.3/mycook/public/robots.txt +0 -5
  394. data/test/stub/rails_apps/2.3/mycook/public/uploads/.gitignore +0 -0
  395. data/test/stub/rails_apps/2.3/mycook/script/about +0 -3
  396. data/test/stub/rails_apps/2.3/mycook/script/console +0 -3
  397. data/test/stub/rails_apps/2.3/mycook/script/dbconsole +0 -3
  398. data/test/stub/rails_apps/2.3/mycook/script/destroy +0 -3
  399. data/test/stub/rails_apps/2.3/mycook/script/generate +0 -3
  400. data/test/stub/rails_apps/2.3/mycook/script/performance/benchmarker +0 -3
  401. data/test/stub/rails_apps/2.3/mycook/script/performance/profiler +0 -3
  402. data/test/stub/rails_apps/2.3/mycook/script/performance/request +0 -3
  403. data/test/stub/rails_apps/2.3/mycook/script/plugin +0 -3
  404. data/test/stub/rails_apps/2.3/mycook/script/process/inspector +0 -3
  405. data/test/stub/rails_apps/2.3/mycook/script/process/reaper +0 -3
  406. data/test/stub/rails_apps/2.3/mycook/script/process/spawner +0 -3
  407. data/test/stub/rails_apps/2.3/mycook/script/runner +0 -3
  408. data/test/stub/rails_apps/2.3/mycook/script/server +0 -3
  409. data/test/stub/wsgi/public/wsgi-snake.jpg +0 -0
@@ -32,9 +32,13 @@ ENV['PATH'] = "/usr/bin:#{ENV['PATH']}"
32
32
  LOCATIONS_INI = ENV['LOCATIONS_INI']
33
33
  abort "Please set the LOCATIONS_INI environment variable to the right locations.ini" if !LOCATIONS_INI
34
34
 
35
+ NATIVE_PACKAGING_METHOD = ENV['NATIVE_PACKAGING_METHOD']
36
+ abort "Please set NATIVE_PACKAGING_METHOD to either 'deb' or 'rpm'" if !["deb", "rpm"].include?(NATIVE_PACKAGING_METHOD)
37
+
35
38
  source_root = File.expand_path("../..", File.dirname(__FILE__))
36
39
  $LOAD_PATH.unshift("#{source_root}/lib")
37
40
  require 'phusion_passenger'
41
+ PhusionPassenger.locate_directories
38
42
  require 'tmpdir'
39
43
  require 'fileutils'
40
44
  require 'open-uri'
@@ -80,6 +84,10 @@ describe "A natively packaged Phusion Passenger" do
80
84
  end
81
85
  end
82
86
 
87
+ specify "locations.ini sets native_packaging_method to #{NATIVE_PACKAGING_METHOD}" do
88
+ File.read(LOCATIONS_INI).should =~ /^native_packaging_method=#{NATIVE_PACKAGING_METHOD}$/
89
+ end
90
+
83
91
  specify "passenger-status is in #{SBINDIR}" do
84
92
  which("passenger-status").should == "#{SBINDIR}/passenger-status"
85
93
  end
@@ -191,17 +199,9 @@ describe "A natively packaged Phusion Passenger" do
191
199
  which("passenger-install-apache2-module").should == "#{BINDIR}/passenger-install-apache2-module"
192
200
  end
193
201
 
194
- it "prints the configuration snippet and exits" do
195
- output = capture_output("passenger-install-apache2-module --auto")
196
- output.should =~ /Please edit your Apache configuration file/
197
- output.should_not include("Compiling and installing Apache 2 module")
198
- output.should_not include("rake apache2")
199
- end
200
-
201
- it "produces a correct configuration snippet" do
202
+ it "checks whether the Apache module is installed" do
202
203
  output = capture_output("passenger-install-apache2-module --auto")
203
- output.should include("LoadModule passenger_module #{APACHE2_MODULE_PATH}")
204
- output.should include("PassengerRoot #{LOCATIONS_INI}")
204
+ output.should =~ /Apache module is correctly installed/
205
205
  end
206
206
  end
207
207
 
@@ -1,9 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
2
  require 'support/nginx_controller'
3
- require 'integration_tests/mycook_spec'
4
- require 'integration_tests/cgi_environment_spec'
5
- require 'integration_tests/hello_world_rack_spec'
6
- require 'integration_tests/hello_world_wsgi_spec'
3
+ require 'integration_tests/shared/example_webapp_tests'
7
4
 
8
5
  describe "Phusion Passenger for Nginx" do
9
6
  before :all do
@@ -11,11 +8,11 @@ describe "Phusion Passenger for Nginx" do
11
8
  STDERR.puts "*** ERROR: You must set the 'nginx' config option in test/config.json."
12
9
  exit!(1)
13
10
  end
14
-
11
+
15
12
  check_hosts_configuration
16
13
  FileUtils.mkdir_p("tmp.nginx")
17
14
  end
18
-
15
+
19
16
  after :all do
20
17
  begin
21
18
  @nginx.stop if @nginx
@@ -23,7 +20,7 @@ describe "Phusion Passenger for Nginx" do
23
20
  FileUtils.rm_rf("tmp.nginx")
24
21
  end
25
22
  end
26
-
23
+
27
24
  before :each do
28
25
  File.open("test.log", "a") do |f|
29
26
  # Make sure that all Nginx log output is prepended by the test description
@@ -42,189 +39,172 @@ describe "Phusion Passenger for Nginx" do
42
39
  end
43
40
  end
44
41
 
45
- describe "MyCook(tm) beta running a root URI" do
42
+ describe "a Ruby app running on the root URI" do
46
43
  before :all do
47
44
  create_nginx_controller
48
45
  @server = "http://1.passenger.test:#{@nginx.port}"
49
- @base_uri = ""
50
- @stub = ClassicRailsStub.new('rails_apps/2.3/mycook')
46
+ @stub = RackStub.new('rack')
51
47
  @nginx.add_server do |server|
52
48
  server[:server_name] = "1.passenger.test"
53
49
  server[:root] = "#{@stub.full_app_root}/public"
54
50
  end
55
51
  @nginx.start
56
52
  end
57
-
53
+
58
54
  after :all do
59
55
  @stub.destroy
60
56
  @nginx.stop if @nginx
61
57
  end
62
-
58
+
63
59
  before :each do
64
60
  @stub.reset
65
61
  end
66
-
67
- it_should_behave_like "MyCook(tm) beta"
68
- include_examples "CGI environment variables compliance"
62
+
63
+ it_should_behave_like "an example web app"
69
64
  end
70
-
71
- describe "MyCook(tm) beta running in a sub-URI" do
65
+
66
+ describe "a Ruby app running in a sub-URI" do
72
67
  before :all do
73
- @base_uri = "/mycook"
74
- @stub = ClassicRailsStub.new('rails_apps/2.3/mycook')
75
- FileUtils.rm_rf('tmp.webdir')
76
- FileUtils.mkdir_p('tmp.webdir')
77
- FileUtils.cp_r('stub/zsfa/.', 'tmp.webdir')
78
- FileUtils.ln_sf(@stub.full_app_root + "/public", 'tmp.webdir/mycook')
79
-
80
68
  create_nginx_controller
69
+ @server = "http://1.passenger.test:#{@nginx.port}/subapp"
70
+ @stub = RackStub.new('rack')
81
71
  @nginx.add_server do |server|
82
72
  server[:server_name] = "1.passenger.test"
83
- server[:root] = File.expand_path("tmp.webdir")
84
- server[:passenger_base_uri] = "/mycook"
73
+ server[:root] = "#{PhusionPassenger.source_root}/test/stub"
74
+ server << %Q{
75
+ location ~ ^/subapp(/.*|$) {
76
+ alias #{@stub.full_app_root}/public$1;
77
+ passenger_base_uri /subapp;
78
+ passenger_document_root #{@stub.full_app_root}/public;
79
+ passenger_app_root #{@stub.full_app_root};
80
+ passenger_enabled on;
81
+ }
82
+ }
85
83
  end
86
84
  @nginx.start
87
85
  end
88
-
86
+
89
87
  after :all do
90
- FileUtils.rm_rf('tmp.webdir')
91
88
  @stub.destroy
92
89
  @nginx.stop if @nginx
93
90
  end
94
-
91
+
95
92
  before :each do
96
- @server = "http://1.passenger.test:#{@nginx.port}/mycook"
97
93
  @stub.reset
98
94
  end
99
95
 
100
- it_should_behave_like "MyCook(tm) beta"
101
- include_examples "CGI environment variables compliance"
102
-
96
+ it_should_behave_like "an example web app"
97
+
103
98
  it "does not interfere with the root website" do
104
99
  @server = "http://1.passenger.test:#{@nginx.port}"
105
- get('/').should =~ /Zed, you rock\!/
100
+ get('/').should == "This is the stub directory."
106
101
  end
107
102
  end
108
-
109
- describe "Rack application running in root URI" do
103
+
104
+ describe "a Python app running on the root URI" do
110
105
  before :all do
111
106
  create_nginx_controller
112
- @server = "http://passenger.test:#{@nginx.port}"
113
- @stub = RackStub.new('rack')
107
+ @server = "http://1.passenger.test:#{@nginx.port}"
108
+ @stub = PythonStub.new('wsgi')
114
109
  @nginx.add_server do |server|
115
- server[:server_name] = "passenger.test"
110
+ server[:server_name] = "1.passenger.test"
116
111
  server[:root] = "#{@stub.full_app_root}/public"
117
- server[:passenger_max_requests] = 3
118
112
  end
119
113
  @nginx.start
120
114
  end
121
-
115
+
122
116
  after :all do
123
117
  @stub.destroy
124
118
  @nginx.stop if @nginx
125
119
  end
126
-
120
+
127
121
  before :each do
128
122
  @stub.reset
129
123
  end
130
-
131
- it_should_behave_like "HelloWorld Rack application"
124
+
125
+ it_should_behave_like "an example web app"
132
126
  end
133
-
134
- describe "Rack application running in sub-URI" do
127
+
128
+ describe "a Python app running in a sub-URI" do
135
129
  before :all do
136
- FileUtils.rm_rf('tmp.webdir')
137
- FileUtils.mkdir_p('tmp.webdir')
138
- @stub = RackStub.new('rack')
139
130
  create_nginx_controller
131
+ @server = "http://1.passenger.test:#{@nginx.port}/subapp"
132
+ @stub = PythonStub.new('wsgi')
140
133
  @nginx.add_server do |server|
141
- FileUtils.ln_s(@stub.full_app_root + "/public", 'tmp.webdir/rack')
142
- server[:server_name] = "passenger.test"
143
- server[:root] = File.expand_path('tmp.webdir')
144
- server[:passenger_base_uri] = "/rack"
134
+ server[:server_name] = "1.passenger.test"
135
+ server[:root] = "#{PhusionPassenger.source_root}/test/stub"
136
+ server << %Q{
137
+ location ~ ^/subapp(/.*|$) {
138
+ alias #{@stub.full_app_root}/public$1;
139
+ passenger_base_uri /subapp;
140
+ passenger_app_root #{@stub.full_app_root};
141
+ passenger_document_root #{@stub.full_app_root}/public;
142
+ passenger_enabled on;
143
+ }
144
+ }
145
145
  end
146
146
  @nginx.start
147
- @server = "http://passenger.test:#{@nginx.port}/rack"
148
147
  end
149
-
148
+
150
149
  after :all do
151
150
  @stub.destroy
152
- FileUtils.rm_rf('tmp.webdir')
153
151
  @nginx.stop if @nginx
154
152
  end
155
-
153
+
156
154
  before :each do
157
155
  @stub.reset
158
156
  end
159
-
160
- it_should_behave_like "HelloWorld Rack application"
161
- end
162
-
163
- describe "Rack application running within Rails directory structure" do
164
- before :all do
165
- create_nginx_controller
166
- @server = "http://passenger.test:#{@nginx.port}"
167
- @stub = ClassicRailsStub.new('rails_apps/2.3/mycook')
168
- FileUtils.cp_r("stub/rack/.", @stub.app_root)
169
- @nginx.add_server do |server|
170
- server[:server_name] = "passenger.test"
171
- server[:root] = "#{@stub.full_app_root}/public"
172
- end
173
- @nginx.start
174
- end
175
-
176
- after :all do
177
- @stub.destroy
178
- @nginx.stop if @nginx
179
- end
180
-
181
- before :each do
182
- @stub.reset
183
- FileUtils.cp_r("stub/rack/.", @stub.app_root)
157
+
158
+ it_should_behave_like "an example web app"
159
+
160
+ it "does not interfere with the root website" do
161
+ @server = "http://1.passenger.test:#{@nginx.port}"
162
+ get('/').should == "This is the stub directory."
184
163
  end
185
-
186
- it_should_behave_like "HelloWorld Rack application"
187
164
  end
188
-
165
+
189
166
  describe "various features" do
190
167
  before :all do
191
168
  create_nginx_controller
192
- @server = "http://passenger.test:#{@nginx.port}"
169
+ @server = "http://1.passenger.test:#{@nginx.port}"
193
170
  @stub = RackStub.new('rack')
171
+ @nginx.set(:passenger_load_shell_envvars => 'off')
194
172
  @nginx.add_server do |server|
195
- server[:server_name] = "passenger.test"
173
+ server[:server_name] = "1.passenger.test"
196
174
  server[:root] = "#{@stub.full_app_root}/public"
197
175
  server << %q{
198
176
  location /crash_without_friendly_error_page {
177
+ passenger_enabled on;
199
178
  passenger_friendly_error_pages off;
200
179
  }
201
180
  }
202
181
  end
203
182
  @nginx.add_server do |server|
204
- server[:server_name] = "1.passenger.test"
183
+ server[:server_name] = "2.passenger.test"
205
184
  server[:root] = "#{@stub.full_app_root}/public"
206
185
  server[:passenger_app_group_name] = "secondary"
207
186
  server[:passenger_show_version_in_header] = "off"
208
187
  end
209
188
  @nginx.add_server do |server|
210
- server[:server_name] = "2.passenger.test"
189
+ server[:server_name] = "3.passenger.test"
190
+ server[:passenger_app_group_name] = "tertiary"
211
191
  server[:root] = "#{@stub.full_app_root}/public"
212
192
  server[:passenger_max_requests] = 3
213
193
  end
214
194
  @nginx.start
215
195
  end
216
-
196
+
217
197
  after :all do
218
198
  @stub.destroy
219
199
  @nginx.stop if @nginx
220
200
  end
221
-
201
+
222
202
  before :each do
223
203
  @stub.reset
224
204
  @error_page_signature = /<meta name="generator" content="Phusion Passenger">/
225
205
  File.touch("#{@stub.app_root}/tmp/restart.txt", 1 + rand(100000))
226
206
  end
227
-
207
+
228
208
  it "sets ENV['SERVER_SOFTWARE']" do
229
209
  File.write("#{@stub.app_root}/config.ru", %q{
230
210
  server_software = ENV['SERVER_SOFTWARE']
@@ -235,7 +215,7 @@ describe "Phusion Passenger for Nginx" do
235
215
  })
236
216
  get('/').should =~ /nginx/i
237
217
  end
238
-
218
+
239
219
  it "displays a friendly error page if the application fails to spawn" do
240
220
  File.write("#{@stub.app_root}/config.ru", %q{
241
221
  raise "my error"
@@ -244,7 +224,7 @@ describe "Phusion Passenger for Nginx" do
244
224
  data.should =~ /#{@error_page_signature}/
245
225
  data.should =~ /my error/
246
226
  end
247
-
227
+
248
228
  it "doesn't display a friendly error page if the application fails to spawn but passenger_friendly_error_pages is off" do
249
229
  File.write("#{@stub.app_root}/config.ru", %q{
250
230
  raise "my error"
@@ -253,29 +233,29 @@ describe "Phusion Passenger for Nginx" do
253
233
  data.should_not =~ /#{@error_page_signature}/
254
234
  data.should_not =~ /my error/
255
235
  end
256
-
236
+
257
237
  it "appends an X-Powered-By header containing the Phusion Passenger version number" do
258
238
  response = get_response('/')
259
239
  response["X-Powered-By"].should include("Phusion Passenger")
260
240
  response["X-Powered-By"].should include(PhusionPassenger::VERSION_STRING)
261
241
  end
262
-
242
+
263
243
  it "omits the version number in X-Powered-By when passenger_show_version_in_header is off" do
264
- @server = "http://1.passenger.test:#{@nginx.port}/"
244
+ @server = "http://2.passenger.test:#{@nginx.port}/"
265
245
  response = get_response('/')
266
246
  response["X-Powered-By"].should include("Phusion Passenger")
267
247
  response["X-Powered-By"].should_not include(PhusionPassenger::VERSION_STRING)
268
248
  end
269
-
249
+
270
250
  it "respawns the app after handling max_requests requests" do
271
- @server = "http://2.passenger.test:#{@nginx.port}/"
251
+ @server = "http://3.passenger.test:#{@nginx.port}/"
272
252
  pid = get("/pid")
273
253
  get("/pid").should == pid
274
254
  get("/pid").should == pid
275
255
  get("/pid").should_not == pid
276
256
  end
277
257
  end
278
-
258
+
279
259
  describe "oob work" do
280
260
  before :all do
281
261
  create_nginx_controller
@@ -292,10 +272,10 @@ describe "Phusion Passenger for Nginx" do
292
272
  @stub.destroy
293
273
  @nginx.stop if @nginx
294
274
  end
295
-
275
+
296
276
  before :each do
297
277
  @stub.reset
298
-
278
+
299
279
  File.write("#{@stub.app_root}/config.ru", <<-RUBY)
300
280
  PhusionPassenger.on_event(:oob_work) do
301
281
  f = File.open("#{@stub.full_app_root}/oob_work.\#{$$}", 'w')
@@ -311,16 +291,16 @@ describe "Phusion Passenger for Nginx" do
311
291
  end
312
292
  run app
313
293
  RUBY
314
-
294
+
315
295
  @nginx.start
316
296
  end
317
-
297
+
318
298
  it "invokes oobw when requested by the app process" do
319
299
  pid = get("/oobw")
320
300
  sleep 0.5 # wait for oobw callback to be invoked
321
301
  File.exists?("#{@stub.app_root}/oob_work.#{pid}").should == true
322
302
  end
323
-
303
+
324
304
  it "does not block client while invoking oob work" do
325
305
  get("/") # ensure there are spawned app processes
326
306
  t0 = Time.now
@@ -329,9 +309,9 @@ describe "Phusion Passenger for Nginx" do
329
309
  secs.should <= 0.1
330
310
  end
331
311
  end
332
-
312
+
333
313
  ##### Helper methods #####
334
-
314
+
335
315
  def start_web_server_if_necessary
336
316
  if !@nginx.running?
337
317
  @nginx.start
@@ -0,0 +1,246 @@
1
+ require 'socket'
2
+ require 'fileutils'
3
+
4
+ shared_examples_for "an example web app" do
5
+ it "responds to GET requests for static asset" do
6
+ FileUtils.cp('stub/garbage1.dat', @stub.full_app_root + "/public/garbage1.dat")
7
+ get('/garbage1.dat').should == @stub.public_file('garbage1.dat')
8
+ end
9
+
10
+ it "supports page caching on file URIs" do
11
+ File.write(@stub.full_app_root + "/public/cached.html", "This is the cached version of /cached")
12
+ get('/cached').should == "This is the cached version of /cached"
13
+ end
14
+
15
+ it "supports page caching on directory URIs" do
16
+ File.write(@stub.full_app_root + "/public/cached.html", "This is the cached version of /cached")
17
+ Dir.mkdir(@stub.full_app_root + "/public/cached")
18
+ get('/cached').should == "This is the cached version of /cached"
19
+ end
20
+
21
+ it "supports page caching on root/base URIs" do
22
+ File.write(@stub.full_app_root + "/public/index.html", "This is index.html")
23
+ get('/').should == "This is index.html"
24
+ end
25
+
26
+ it "doesn't use page caching if the HTTP request is not GET" do
27
+ File.write(@stub.full_app_root + "/public/cached.html", "This is the cached version of /cached")
28
+ post('/cached').should == "This is the uncached version of /cached"
29
+ end
30
+
31
+ it "responds to GET requests on dynamic pages" do
32
+ get('/').should == "front page"
33
+ end
34
+
35
+ it "properly receives GET parameters" do
36
+ result = get('/parameters?first=one&second=two')
37
+ result.should == "Method: GET\n" +
38
+ "First: one\n" +
39
+ "Second: two\n"
40
+ end
41
+
42
+ it "responds to POST requests on dynamic pages" do
43
+ result = post('/parameters',
44
+ "first" => "one",
45
+ "second" => "two"
46
+ )
47
+ result.should == "Method: POST\n" +
48
+ "First: one\n" +
49
+ "Second: two\n"
50
+ end
51
+
52
+ it "properly handles file uploads" do
53
+ static_file = File.open('stub/garbage1.dat', 'rb')
54
+ params = {
55
+ 'name1' => 'Kotonoha',
56
+ 'name2' => 'Sekai',
57
+ 'data' => static_file
58
+ }
59
+ begin
60
+ # For some reason the WSGI stub app does not accept the multipart data generated by
61
+ # post(), so we use curl instead.
62
+ command = "curl --silent -F name1=Kotonoha -F name2=Sekai -F data=@stub/garbage1.dat #{@server}/upload_with_params"
63
+ response = IO.popen(command, "rb") do |io|
64
+ io.read
65
+ end
66
+ response.should ==
67
+ binary_string("name 1 = Kotonoha\n") <<
68
+ binary_string("name 2 = Sekai\n") <<
69
+ binary_string("data = ") << static_file.read
70
+ ensure
71
+ static_file.close
72
+ end
73
+ end
74
+
75
+ it "properly handles POST requests with 'chunked' transfer encoding" do
76
+ uri = URI.parse(@server)
77
+ socket = TCPSocket.new(uri.host, uri.port)
78
+ begin
79
+ socket.write("POST #{base_uri}/raw_upload_to_file HTTP/1.1\r\n")
80
+ socket.write("Host: #{uri.host}:#{uri.port}\r\n")
81
+ socket.write("Transfer-Encoding: chunked\r\n")
82
+ socket.write("Content-Type: text/plain\r\n")
83
+ socket.write("Connection: close\r\n")
84
+ socket.write("X-Output: output.txt\r\n")
85
+ socket.write("\r\n")
86
+
87
+ chunk = "foo=bar!"
88
+ socket.write("%X\r\n%s\r\n" % [chunk.size, chunk])
89
+ socket.write("0\r\n\r\n")
90
+ socket.flush
91
+
92
+ socket.read.should =~ /\r\nok\Z/
93
+ ensure
94
+ socket.close
95
+ end
96
+
97
+ File.read(@stub.full_app_root + "/output.txt").should == "foo=bar!"
98
+ end
99
+
100
+ it "supports responses with the 'chunked' transfer encoding" do
101
+ get('/chunked').should ==
102
+ "chunk1\n" +
103
+ "chunk2\n" +
104
+ "chunk3\n"
105
+ end
106
+
107
+ it "supports custom headers in responses" do
108
+ response = get_response('/extra_header')
109
+ response["X-Foo"].should == "Bar"
110
+ end
111
+
112
+ it "sets the 'Status' header in responses" do
113
+ response = get_response('/nonexistant')
114
+ response["Status"].should == "404 Not Found"
115
+ end
116
+
117
+ specify "REQUEST_URI contains the request URI including query string" do
118
+ cgi_envs = get('/env?foo=escaped%20string')
119
+ cgi_envs.should include("REQUEST_URI = #{base_uri}/env?foo=escaped%20string\n")
120
+ end
121
+
122
+ specify "REQUEST_URI contains the original escaped URI" do
123
+ cgi_envs = get('/env/%C3%BC?foo=escaped%20string')
124
+ cgi_envs.downcase.should include("request_uri = #{base_uri}/env/%c3%bc?foo=escaped%20string\n")
125
+ end
126
+
127
+ specify "PATH_INFO contains the request URI without the base URI and without the query string" do
128
+ cgi_envs = get('/env?foo=escaped%20string')
129
+ cgi_envs.should include("PATH_INFO = /env\n")
130
+ end
131
+
132
+ specify "PATH_INFO contains the original escaped URI" do
133
+ cgi_envs = get('/env/%C3%BC')
134
+ cgi_envs.downcase.should include("path_info = /env/%c3%bc\n")
135
+ end
136
+
137
+ specify "QUERY_STRING contains the query string" do
138
+ cgi_envs = get('/env?foo=escaped%20string')
139
+ cgi_envs.should include("QUERY_STRING = foo=escaped%20string\n")
140
+ end
141
+
142
+ specify "QUERY_STRING must be present even when there's no query string" do
143
+ cgi_envs = get('/env')
144
+ cgi_envs.should include("QUERY_STRING = \n")
145
+ end
146
+
147
+ specify "SCRIPT_NAME contains the base URI, or the empty string if the app is deployed on the root URI" do
148
+ cgi_envs = get('/env')
149
+ cgi_envs.should include("SCRIPT_NAME = #{base_uri}\n")
150
+ end
151
+
152
+ it "appends an X-Powered-By header containing the Phusion Passenger version number" do
153
+ response = get_response('/')
154
+ response["X-Powered-By"].should include("Phusion Passenger")
155
+ response["X-Powered-By"].should include(PhusionPassenger::VERSION_STRING)
156
+ end
157
+
158
+ it "buffers uploads" do
159
+ get('/') # Force spawning so that the timeout below is enough.
160
+
161
+ uri = URI.parse(@server)
162
+ socket = TCPSocket.new(uri.host, uri.port)
163
+ begin
164
+ upload_data = File.read("stub/upload_data.txt")
165
+ size_of_first_half = upload_data.size / 2
166
+
167
+ socket.write("POST #{base_uri}/ HTTP/1.1\r\n")
168
+ socket.write("Host: #{uri.host}:#{uri.port}\r\n")
169
+ socket.write("Content-Type: multipart/form-data\r\n")
170
+ socket.write("Content-Length: #{upload_data.size}\r\n")
171
+ socket.write("Connection: close\r\n")
172
+ socket.write("\r\n")
173
+
174
+ socket.write(upload_data[0 .. size_of_first_half - 1])
175
+ socket.flush
176
+
177
+ Timeout.timeout(10) do
178
+ get('/').should == "front page"
179
+ end
180
+
181
+ socket.write(upload_data[0 .. size_of_first_half])
182
+ socket.flush
183
+ socket.read.should =~ /front page/
184
+ ensure
185
+ socket.close rescue nil
186
+ end
187
+ end
188
+
189
+ it "buffers any number of concurrent uploads" do
190
+ get('/') # Force spawning so that the timeout below is enough.
191
+ sockets = []
192
+
193
+ uri = URI.parse(@server)
194
+ upload_data = File.read("stub/upload_data.txt")
195
+ size_of_first_half = upload_data.size / 2
196
+
197
+ begin
198
+ 5.times do |i|
199
+ socket = TCPSocket.new(uri.host, uri.port)
200
+ sockets << socket
201
+ socket.write("POST #{base_uri}/ HTTP/1.1\r\n")
202
+ socket.write("Host: #{uri.host}:#{uri.port}\r\n")
203
+ socket.write("Content-Type: multipart/form-data\r\n")
204
+ socket.write("Content-Length: #{upload_data.size}\r\n")
205
+ socket.write("Connection: close\r\n")
206
+ socket.write("\r\n")
207
+ socket.write(upload_data[0 .. size_of_first_half - 1])
208
+ socket.flush
209
+ end
210
+ Timeout.timeout(10) do
211
+ get('/').should == "front page"
212
+ end
213
+ sockets.each do |socket|
214
+ socket.write(upload_data[size_of_first_half .. -1])
215
+ socket.flush
216
+ socket.read.should =~ /front page/
217
+ end
218
+ ensure
219
+ sockets.each do |socket|
220
+ socket.close rescue nil
221
+ end
222
+ end
223
+ end
224
+
225
+ it "supports restarting via restart.txt" do
226
+ get('/').should == "front page"
227
+ File.write(@stub.full_app_root + "/front_page.txt", "new front page")
228
+ File.touch(@stub.full_app_root + "/tmp/restart.txt", 2)
229
+ get('/').should == "new front page"
230
+ end
231
+
232
+ it "runs as an unprivileged user" do
233
+ get('/touch_file?file=file.txt').should == "ok"
234
+ stat = File.stat(@stub.full_app_root + "/file.txt")
235
+ stat.uid.should_not == 0
236
+ stat.gid.should_not == 0
237
+ end
238
+
239
+ ############
240
+
241
+ private
242
+ def base_uri
243
+ uri = URI.parse(@server)
244
+ return uri.path.sub(%r(/$), '')
245
+ end
246
+ end