jetpack 0.1.0 → 0.1.3

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.
Files changed (52) hide show
  1. data/.gitignore +2 -1
  2. data/LICENSE +14 -0
  3. data/README.markdown +35 -6
  4. data/Rakefile +14 -3
  5. data/bin/jetpack +39 -6
  6. data/bin_files/launch.erb +16 -0
  7. data/gems/bundler-1.1.0.gem +0 -0
  8. data/jetpack.gemspec +3 -3
  9. data/jetty_files/etc/fake.crt +31 -0
  10. data/jetty_files/etc/fake.jceks +0 -0
  11. data/jetty_files/etc/fake.key +51 -0
  12. data/jetty_files/etc/fake.pem +89 -0
  13. data/jetty_files/etc/jetty.xml.erb +53 -25
  14. data/jetty_files/jetty-init.erb +4 -0
  15. data/lib/jetpack/settings.rb +24 -10
  16. data/script/ci +1 -1
  17. data/spec/bundler_spec.rb +1 -1
  18. data/spec/filter_spec.rb +59 -0
  19. data/spec/rack_spec.rb +40 -0
  20. data/spec/sample_projects/has_gems_via_bundler/config/jetpack.yml +1 -1
  21. data/spec/sample_projects/has_gems_via_bundler_19/config/jetpack.yml +1 -1
  22. data/spec/sample_projects/has_gems_via_bundler_bad_gemfile_lock/config/jetpack.yml +1 -1
  23. data/spec/sample_projects/no_dependencies/config/jetpack.yml +1 -1
  24. data/spec/sample_projects/rack_19/Gemfile +3 -0
  25. data/spec/sample_projects/rack_19/Gemfile.lock +11 -0
  26. data/spec/sample_projects/rack_19/config.ru +8 -0
  27. data/spec/sample_projects/rack_19/config/jetpack.yml +9 -0
  28. data/spec/sample_projects/webapp/config/jetpack.yml +8 -5
  29. data/spec/sample_projects/webapp_filters/Gemfile +3 -0
  30. data/spec/sample_projects/webapp_filters/Gemfile.lock +88 -0
  31. data/spec/sample_projects/webapp_filters/app/controllers/application_controller.rb +5 -0
  32. data/spec/sample_projects/webapp_filters/config.ru +4 -0
  33. data/spec/sample_projects/webapp_filters/config/application.rb +46 -0
  34. data/spec/sample_projects/webapp_filters/config/boot.rb +6 -0
  35. data/spec/sample_projects/webapp_filters/config/environment.rb +5 -0
  36. data/spec/sample_projects/webapp_filters/config/environments/development.rb +25 -0
  37. data/spec/sample_projects/webapp_filters/config/environments/test.rb +35 -0
  38. data/spec/sample_projects/webapp_filters/config/initializers/secret_token.rb +7 -0
  39. data/spec/sample_projects/webapp_filters/config/jetpack.yml +10 -0
  40. data/spec/sample_projects/webapp_filters/config/jetpack_files/vendor/jetty/etc/custom-project-specific-jetty.xml +5 -0
  41. data/spec/sample_projects/webapp_filters/config/jetpack_files/vendor/jetty/etc/template-from-project-jetty.xml.erb +9 -0
  42. data/spec/sample_projects/webapp_filters/config/routes.rb +60 -0
  43. data/spec/sample_projects/webapp_filters/public/index.html +239 -0
  44. data/spec/sample_projects/webapp_filters/script/rails +6 -0
  45. data/spec/spec_helper.rb +0 -7
  46. data/spec/web_spec.rb +25 -9
  47. data/src/java/jetpack/filter/IgnoreUnknownHttpMethodsFilter.java +43 -0
  48. data/src/java/jetpack/filter/ValidUrlFilter.java +62 -0
  49. data/web_inf_files/web.xml.erb +46 -4
  50. metadata +110 -32
  51. data/gems/bundler-1.0.18.gem +0 -0
  52. data/gems/bundler-1.1.rc.gem +0 -0
@@ -0,0 +1,35 @@
1
+ Foo::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Foo::Application.config.secret_token = '9197ec11ccabc88f4e58933d89215efb83096cfc750bca8411096d7cbbb4f4049aa691c8887289391b0ad084d91d5507ebeef78f9d205d3c2532ad31d30c2d68'
@@ -0,0 +1,10 @@
1
+ jruby: "file://<%= File.expand_path('spec/local_mirror') %>/jruby-complete-1.6.7.jar"
2
+ jetty: "file://<%= File.expand_path('spec/local_mirror') %>/jetty-hightide-8.1.3.v20120416.zip"
3
+ jruby-rack: "file://<%= File.expand_path('spec/local_mirror') %>/jruby-rack-1.1.5.jar"
4
+ http_port: 11080
5
+ https_port: 11443
6
+ max_concurrent_connections: 15
7
+ java_options: -Xmx256M
8
+ jetty_filters: true
9
+ keystore: "etc/fake.p12"
10
+ keystore_password: "foobar"
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
3
+
4
+ <Configure id="Server" class="org.eclipse.jetty.server.Server">
5
+ </Configure>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
3
+
4
+ <Configure id="Server" class="org.eclipse.jetty.server.Server">
5
+ <Call class="java.lang.System" name="setProperty">
6
+ <Arg>HTTPS_PORT</Arg>
7
+ <Arg><%=@settings.https_port%></Arg>
8
+ </Call>
9
+ </Configure>
@@ -0,0 +1,60 @@
1
+ Foo::Application.routes.draw do
2
+ match 'hello' => 'application#hello'
3
+
4
+ # The priority is based upon order of creation:
5
+ # first created -> highest priority.
6
+
7
+ # Sample of regular route:
8
+ # match 'products/:id' => 'catalog#view'
9
+ # Keep in mind you can assign values other than :controller and :action
10
+
11
+ # Sample of named route:
12
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
13
+ # This route can be invoked with purchase_url(:id => product.id)
14
+
15
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
16
+ # resources :products
17
+
18
+ # Sample resource route with options:
19
+ # resources :products do
20
+ # member do
21
+ # get 'short'
22
+ # post 'toggle'
23
+ # end
24
+ #
25
+ # collection do
26
+ # get 'sold'
27
+ # end
28
+ # end
29
+
30
+ # Sample resource route with sub-resources:
31
+ # resources :products do
32
+ # resources :comments, :sales
33
+ # resource :seller
34
+ # end
35
+
36
+ # Sample resource route with more complex sub-resources
37
+ # resources :products do
38
+ # resources :comments
39
+ # resources :sales do
40
+ # get 'recent', :on => :collection
41
+ # end
42
+ # end
43
+
44
+ # Sample resource route within a namespace:
45
+ # namespace :admin do
46
+ # # Directs /admin/products/* to Admin::ProductsController
47
+ # # (app/controllers/admin/products_controller.rb)
48
+ # resources :products
49
+ # end
50
+
51
+ # You can have the root of your site routed with "root"
52
+ # just remember to delete public/index.html.
53
+ # root :to => "welcome#index"
54
+
55
+ # See how all your routes lay out with "rake routes"
56
+
57
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
58
+ # Note: This route will make all actions in every controller accessible via GET requests.
59
+ # match ':controller(/:action(/:id(.:format)))'
60
+ end
@@ -0,0 +1,239 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Ruby on Rails: Welcome aboard</title>
5
+ <style type="text/css" media="screen">
6
+ body {
7
+ margin: 0;
8
+ margin-bottom: 25px;
9
+ padding: 0;
10
+ background-color: #f0f0f0;
11
+ font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
12
+ font-size: 13px;
13
+ color: #333;
14
+ }
15
+
16
+ h1 {
17
+ font-size: 28px;
18
+ color: #000;
19
+ }
20
+
21
+ a {color: #03c}
22
+ a:hover {
23
+ background-color: #03c;
24
+ color: white;
25
+ text-decoration: none;
26
+ }
27
+
28
+
29
+ #page {
30
+ background-color: #f0f0f0;
31
+ width: 750px;
32
+ margin: 0;
33
+ margin-left: auto;
34
+ margin-right: auto;
35
+ }
36
+
37
+ #content {
38
+ float: left;
39
+ background-color: white;
40
+ border: 3px solid #aaa;
41
+ border-top: none;
42
+ padding: 25px;
43
+ width: 500px;
44
+ }
45
+
46
+ #sidebar {
47
+ float: right;
48
+ width: 175px;
49
+ }
50
+
51
+ #footer {
52
+ clear: both;
53
+ }
54
+
55
+
56
+ #header, #about, #getting-started {
57
+ padding-left: 75px;
58
+ padding-right: 30px;
59
+ }
60
+
61
+
62
+ #header {
63
+ background-image: url("images/rails.png");
64
+ background-repeat: no-repeat;
65
+ background-position: top left;
66
+ height: 64px;
67
+ }
68
+ #header h1, #header h2 {margin: 0}
69
+ #header h2 {
70
+ color: #888;
71
+ font-weight: normal;
72
+ font-size: 16px;
73
+ }
74
+
75
+
76
+ #about h3 {
77
+ margin: 0;
78
+ margin-bottom: 10px;
79
+ font-size: 14px;
80
+ }
81
+
82
+ #about-content {
83
+ background-color: #ffd;
84
+ border: 1px solid #fc0;
85
+ margin-left: -55px;
86
+ margin-right: -10px;
87
+ }
88
+ #about-content table {
89
+ margin-top: 10px;
90
+ margin-bottom: 10px;
91
+ font-size: 11px;
92
+ border-collapse: collapse;
93
+ }
94
+ #about-content td {
95
+ padding: 10px;
96
+ padding-top: 3px;
97
+ padding-bottom: 3px;
98
+ }
99
+ #about-content td.name {color: #555}
100
+ #about-content td.value {color: #000}
101
+
102
+ #about-content ul {
103
+ padding: 0;
104
+ list-style-type: none;
105
+ }
106
+
107
+ #about-content.failure {
108
+ background-color: #fcc;
109
+ border: 1px solid #f00;
110
+ }
111
+ #about-content.failure p {
112
+ margin: 0;
113
+ padding: 10px;
114
+ }
115
+
116
+
117
+ #getting-started {
118
+ border-top: 1px solid #ccc;
119
+ margin-top: 25px;
120
+ padding-top: 15px;
121
+ }
122
+ #getting-started h1 {
123
+ margin: 0;
124
+ font-size: 20px;
125
+ }
126
+ #getting-started h2 {
127
+ margin: 0;
128
+ font-size: 14px;
129
+ font-weight: normal;
130
+ color: #333;
131
+ margin-bottom: 25px;
132
+ }
133
+ #getting-started ol {
134
+ margin-left: 0;
135
+ padding-left: 0;
136
+ }
137
+ #getting-started li {
138
+ font-size: 18px;
139
+ color: #888;
140
+ margin-bottom: 25px;
141
+ }
142
+ #getting-started li h2 {
143
+ margin: 0;
144
+ font-weight: normal;
145
+ font-size: 18px;
146
+ color: #333;
147
+ }
148
+ #getting-started li p {
149
+ color: #555;
150
+ font-size: 13px;
151
+ }
152
+
153
+
154
+ #sidebar ul {
155
+ margin-left: 0;
156
+ padding-left: 0;
157
+ }
158
+ #sidebar ul h3 {
159
+ margin-top: 25px;
160
+ font-size: 16px;
161
+ padding-bottom: 10px;
162
+ border-bottom: 1px solid #ccc;
163
+ }
164
+ #sidebar li {
165
+ list-style-type: none;
166
+ }
167
+ #sidebar ul.links li {
168
+ margin-bottom: 5px;
169
+ }
170
+
171
+ </style>
172
+ <script type="text/javascript">
173
+ function about() {
174
+ info = document.getElementById('about-content');
175
+ if (window.XMLHttpRequest)
176
+ { xhr = new XMLHttpRequest(); }
177
+ else
178
+ { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
179
+ xhr.open("GET","rails/info/properties",false);
180
+ xhr.send("");
181
+ info.innerHTML = xhr.responseText;
182
+ info.style.display = 'block'
183
+ }
184
+ </script>
185
+ </head>
186
+ <body>
187
+ <div id="page">
188
+ <div id="sidebar">
189
+ <ul id="sidebar-items">
190
+ <li>
191
+ <h3>Browse the documentation</h3>
192
+ <ul class="links">
193
+ <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
194
+ <li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
195
+ <li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
196
+ <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
197
+ </ul>
198
+ </li>
199
+ </ul>
200
+ </div>
201
+
202
+ <div id="content">
203
+ <div id="header">
204
+ <h1>Welcome aboard</h1>
205
+ <h2>You&rsquo;re riding Ruby on Rails!</h2>
206
+ </div>
207
+
208
+ <div id="about">
209
+ <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
210
+ <div id="about-content" style="display: none"></div>
211
+ </div>
212
+
213
+ <div id="getting-started">
214
+ <h1>Getting started</h1>
215
+ <h2>Here&rsquo;s how to get rolling:</h2>
216
+
217
+ <ol>
218
+ <li>
219
+ <h2>Use <code>rails generate</code> to create your models and controllers</h2>
220
+ <p>To see all available options, run it without parameters.</p>
221
+ </li>
222
+
223
+ <li>
224
+ <h2>Set up a default route and remove or rename this file</h2>
225
+ <p>Routes are set up in config/routes.rb.</p>
226
+ </li>
227
+
228
+ <li>
229
+ <h2>Create your database</h2>
230
+ <p>Run <code>rake db:migrate</code> to create your database. If you're not using SQLite (the default), edit <code>config/database.yml</code> with your username and password.</p>
231
+ </li>
232
+ </ol>
233
+ </div>
234
+ </div>
235
+
236
+ <div id="footer">&nbsp;</div>
237
+ </div>
238
+ </body>
239
+ </html>
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env jruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -20,13 +20,6 @@ def x!(cmd)
20
20
  return result
21
21
  end
22
22
 
23
- deps = %w(jetty-hightide-7.4.5.v20110725.zip jruby-complete-1.6.4.jar jruby-rack-1.0.10.jar)
24
- mkdir_p "spec/local_mirror" unless File.directory?("spec/local_mirror")
25
- deps.each do |file|
26
- target = File.join("spec", "local_mirror", file)
27
- x! "curl --silent --show-error -o #{target} http://mirrors.squareup.com/distfiles/#{file}" unless File.exists?(target)
28
- end
29
-
30
23
  def reset
31
24
  Dir["spec/sample_projects/*/vendor/bundle"].each{|d|FileUtils.rm_rf(d)}
32
25
  Dir["spec/sample_projects/*/vendor/bundler_gem"].each{|d|FileUtils.rm_rf(d)}
@@ -26,29 +26,45 @@ describe "jetpack - web start" do
26
26
  File.exists?("spec/sample_projects/webapp/vendor/jetty/etc/template-from-project-jetty.xml").should == true
27
27
  File.exists?("spec/sample_projects/webapp/vendor/jetty/etc/template-from-project-jetty.xml.erb").should == false
28
28
  File.read("spec/sample_projects/webapp/vendor/jetty/etc/template-from-project-jetty.xml").should
29
- include("<Arg>10443</Arg>")
29
+ include("<Arg>9443</Arg>")
30
30
  File.exists?("spec/sample_projects/webapp/vendor/jetty/jetty-init").should == true
31
31
  end
32
32
 
33
- it "respects the maximun number of concurrent connections" do
33
+ it "places a launch script, and includes java_options" do
34
+ File.exists?("spec/sample_projects/webapp/bin/launch").should == true
35
+ File.read("spec/sample_projects/webapp/bin/launch").should include("java -jar -Xmx256M")
36
+ File.read("spec/sample_projects/webapp/bin/launch").should include("start.jar")
37
+ end
38
+
39
+ it "respects the maximun number of concurrent connections, http and https port" do
34
40
  jetty_xml = "spec/sample_projects/webapp/vendor/jetty/etc/jetty.xml"
35
41
  settings = YAML.load_file("spec/sample_projects/webapp/config/jetpack.yml")
36
42
  max_threads_setting = /<Set name="maxThreads">#{settings["max_concurrent_connections"]}<\/Set>/
37
43
 
38
44
  File.exists?(jetty_xml).should == true
39
- File.readlines(jetty_xml).grep(max_threads_setting).should_not be_empty
45
+
46
+ jetty_xml_content = File.readlines(jetty_xml)
47
+ jetty_xml_content.grep(max_threads_setting).should_not be_empty
48
+
49
+ jetty_xml_content.grep(/<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">/).should_not be_empty
50
+ jetty_xml_content.grep(/<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">/).should_not be_empty
40
51
  end
41
52
 
42
53
  it "runs" do
43
54
  pid_to_kill = run_app
55
+ begin
56
+ #HTTP XX443 - intended to be proxied to from something listening on 443
57
+ x!("curl https://localhost:9443/hello --insecure")[:stdout].split("<br/>").first.strip.should == "Hello World"
44
58
 
45
- #HTTP 4443 - intended to be proxied to from something listening on 443
46
- x!("curl https://localhost:10443/hello --insecure")[:stdout].split("<br/>").first.strip.should == "Hello World"
59
+ #HTTP XXX80 - intended for internal health checking
60
+ x!("curl http://localhost:9080/hello")[:stdout].split("<br/>").first.strip.should == "Hello World"
47
61
 
48
- #HTTP 9080 - intended for internal health checking
49
- x!("curl http://localhost:10080/hello --insecure")[:stdout].split("<br/>").first.strip.should == "Hello World"
62
+ x!("curl http://#{Socket.gethostname}:9080/hello")[:stdout].split("<br/>").first.strip.should == "Hello World"
50
63
 
51
- system("kill -9 #{pid_to_kill}")
64
+ x!("curl http://127.0.0.1:9080/hello")[:stdout].split("<br/>").first.strip.should == "Hello World"
65
+ ensure
66
+ system("kill -9 #{pid_to_kill}")
67
+ end
52
68
  end
53
69
 
54
70
  def run_app
@@ -56,7 +72,7 @@ describe "jetpack - web start" do
56
72
  start_time = Time.now
57
73
  loop do
58
74
  begin
59
- TCPSocket.open("localhost", 10443)
75
+ TCPSocket.open("localhost", 9443)
60
76
  return jetty_pid
61
77
  rescue Errno::ECONNREFUSED
62
78
  raise "it's taking too long to start the server, something might be wrong" if Time.now - start_time > 60