caterpillar 1.4.4 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/ChangeLog +27 -0
- data/MIT-LICENSE +0 -4
- data/README.rdoc +3 -3
- data/Rakefile +6 -22
- data/caterpillar.gemspec +28 -0
- data/generators/caterpillar/caterpillar_generator.rb +12 -4
- data/generators/caterpillar/templates/config/portlets.rb +10 -2
- data/generators/caterpillar/templates/stylesheets/portlet_test_bench/main.css +2 -2
- data/init.rb +20 -8
- data/lib/caterpillar.rb +33 -27
- data/lib/caterpillar/config.rb +3 -1
- data/lib/caterpillar/helpers/liferay.rb +129 -132
- data/lib/caterpillar/helpers/portlet.rb +41 -0
- data/lib/caterpillar/liferay.rb +2 -3
- data/lib/caterpillar/navigation.rb +2 -4
- data/lib/caterpillar/parser.rb +1 -5
- data/lib/caterpillar/portlet.rb +20 -19
- data/lib/caterpillar/portlet_support.rb +9 -22
- data/lib/caterpillar/security.rb +20 -42
- data/lib/caterpillar/task.rb +17 -36
- data/lib/caterpillar/usage.rb +14 -10
- data/lib/caterpillar/util.rb +1 -1
- data/lib/java/rails-portlet-0.12.0.jar +0 -0
- data/lib/rails_gem_chooser.rb +14 -7
- data/lib/web/portlet.rb +1 -1
- data/portlet_test_bench/controllers/caterpillar/application.rb +0 -5
- data/portlet_test_bench/controllers/caterpillar/junit_controller.rb +30 -9
- data/portlet_test_bench/controllers/caterpillar/liferay_controller.rb +13 -3
- data/portlet_test_bench/controllers/caterpillar/session_controller.rb +3 -0
- data/portlet_test_bench/controllers/caterpillar/xhr_controller.rb +12 -1
- data/portlet_test_bench/views/caterpillar/application/_back_to_menu.html.erb +1 -1
- data/portlet_test_bench/views/caterpillar/application/index.html.erb +8 -1
- data/portlet_test_bench/views/caterpillar/application/portlet_test_bench.html.erb +26 -8
- data/portlet_test_bench/views/caterpillar/css/background.html.erb +4 -1
- data/portlet_test_bench/views/caterpillar/css/simple.html.erb +13 -9
- data/portlet_test_bench/views/caterpillar/liferay/session_variables.html.erb +3 -12
- data/portlet_test_bench/views/caterpillar/session/cookies.html.erb +5 -0
- data/portlet_test_bench/views/caterpillar/session/namespace.html.erb +14 -0
- data/portlet_test_bench/views/caterpillar/xhr/resource.html.erb +15 -0
- data/portlet_test_bench/views/caterpillar/xhr/time.html.erb +7 -6
- data/spec/app1/config/routes.rb +3 -0
- data/spec/app2/config/routes.rb +7 -0
- data/spec/app3/config/routes.rb +5 -0
- data/spec/caterpillar/helper_spec.rb +69 -0
- data/spec/caterpillar/task_spec.rb +192 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +44 -0
- data/test/README +4 -0
- data/test/dtd/liferay-display_5_1_0.dtd +44 -44
- data/test/dtd/liferay-display_5_2_0.dtd +44 -44
- data/test/dtd/liferay-display_6_0_0.dtd +44 -44
- data/test/dtd/liferay-portlet-app_5_1_0.dtd +582 -582
- data/test/dtd/liferay-portlet-app_5_2_0.dtd +642 -642
- data/test/dtd/liferay-portlet-app_6_0_0.dtd +730 -730
- data/test/dtd/portlet-app_2_0.xsd +830 -830
- data/test/liferay_helpers_test.rb +94 -7
- data/test/portlet_support_test.rb +0 -18
- data/test/portlets_test.rb +6 -11
- data/test/xml_test.rb +4 -14
- metadata +53 -31
- data/lib/java/rails-portlet-0.10.1.jar +0 -0
data/lib/caterpillar/util.rb
CHANGED
Binary file
|
data/lib/rails_gem_chooser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#--
|
3
|
-
# (c) Copyright 2009
|
3
|
+
# (c) Copyright 2009 - 2011 Mikael Lammentausta
|
4
4
|
#
|
5
5
|
# See the file MIT-LICENSE included with the distribution for
|
6
6
|
# software license details.
|
@@ -31,7 +31,7 @@ class RailsGemChooser
|
|
31
31
|
STDERR.puts 'Could not detect Rails version'
|
32
32
|
return nil
|
33
33
|
end
|
34
|
-
|
34
|
+
end
|
35
35
|
# don't attempt to load Rails if building a Rubygem..!
|
36
36
|
if $0[/gem$/] or !File.exist?(config_file)
|
37
37
|
return nil
|
@@ -40,7 +40,7 @@ class RailsGemChooser
|
|
40
40
|
f=File.open(config_file)
|
41
41
|
config = f.read
|
42
42
|
f.close
|
43
|
-
rails_gem_version = config[/^RAILS_GEM_VERSION.*(\d\.\d\.\d)/,1]
|
43
|
+
rails_gem_version = config[/^RAILS_GEM_VERSION.*(\d\.\d\.\d+)/,1]
|
44
44
|
#STDOUT.puts 'Detected Rails version %s from the config file %s' % [rails_gem_version,config_file]
|
45
45
|
return rails_gem_version
|
46
46
|
end
|
@@ -48,6 +48,7 @@ class RailsGemChooser
|
|
48
48
|
|
49
49
|
# Load a specific GEM
|
50
50
|
def __load_gem(require_name, gem_name, version)
|
51
|
+
#STDOUT.puts 'Loading gem: %s v %s' % [require_name, version]
|
51
52
|
version ? gem(gem_name, '= '+version) : gem(gem_name)
|
52
53
|
begin
|
53
54
|
require require_name
|
@@ -58,7 +59,9 @@ class RailsGemChooser
|
|
58
59
|
|
59
60
|
# Either define +rails_gem_version+ or +config_file+
|
60
61
|
def __load(rails_gem_version=nil,config_file=nil)
|
61
|
-
|
62
|
+
if (config_file and rails_gem_version) and (version != rails_gem_version)
|
63
|
+
raise 'oops: Rails version mismatch'
|
64
|
+
end
|
62
65
|
|
63
66
|
rails_gem_version ||= version(config_file) # also detects ENV['RAILS_GEM_VERSION']
|
64
67
|
|
@@ -68,7 +71,7 @@ class RailsGemChooser
|
|
68
71
|
# except that with the underline divider the gem is not found ..
|
69
72
|
#rails_gems = %w{ activesupport actionpack activerecord }
|
70
73
|
|
71
|
-
rails_gems = {
|
74
|
+
rails_gems = {
|
72
75
|
# require name gem name
|
73
76
|
"active_support" => "activesupport",
|
74
77
|
"action_pack" => "actionpack",
|
@@ -78,9 +81,13 @@ class RailsGemChooser
|
|
78
81
|
rails_gems.keys.each do |rg_key|
|
79
82
|
__load_gem(rg_key, rails_gems[rg_key], rails_gem_version)
|
80
83
|
end
|
81
|
-
require 'action_controller'
|
84
|
+
require 'action_controller' # action_controller lives in action_pack
|
82
85
|
|
83
|
-
#STDOUT.puts
|
86
|
+
#STDOUT.puts "Loaded gems:"
|
87
|
+
#STDOUT.puts "ActiveRecord: %s" % ActiveRecord::VERSION::STRING
|
88
|
+
#STDOUT.puts "ActionPack: %s" % ActionPack::VERSION::STRING
|
89
|
+
#require 'active_support/version'
|
90
|
+
#STDOUT.puts "ActiveSupport: %s" % ActiveSupport::VERSION::STRING
|
84
91
|
end
|
85
92
|
|
86
93
|
end
|
data/lib/web/portlet.rb
CHANGED
@@ -10,11 +10,6 @@ class Caterpillar::ApplicationController < ActionController::Base
|
|
10
10
|
# Rails-portlet has session cookie support.
|
11
11
|
#session :disabled => true
|
12
12
|
|
13
|
-
# Import security filters
|
14
|
-
include Caterpillar::Security
|
15
|
-
secure_portlet_sessions
|
16
|
-
|
17
|
-
|
18
13
|
### Used for navigating the test bench
|
19
14
|
|
20
15
|
# If controller is not ApplicationController, test is selected.
|
@@ -4,6 +4,7 @@ class Caterpillar::JunitController < Caterpillar::ApplicationController
|
|
4
4
|
layout false
|
5
5
|
|
6
6
|
def index
|
7
|
+
logger.debug request.inspect
|
7
8
|
render :text => "", :layout => 'bare'
|
8
9
|
end
|
9
10
|
|
@@ -189,21 +190,18 @@ class Caterpillar::JunitController < Caterpillar::ApplicationController
|
|
189
190
|
render :text => txt, :status => 200
|
190
191
|
end
|
191
192
|
|
192
|
-
#
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
render :inline => txt, :status => 200
|
198
|
-
end
|
199
|
-
before_filter :get_liferay_uid, :only => [:liferay_uid, :cookies_liferay_auth]
|
193
|
+
# include filters authorize_agent, authorize_request
|
194
|
+
include Caterpillar::Security::InstanceMethods
|
195
|
+
|
196
|
+
# include filters get_liferay_uid, get_liferay_gid
|
197
|
+
include Caterpillar::Helpers::Liferay
|
200
198
|
|
201
199
|
#
|
202
200
|
# authenticate these actions
|
203
201
|
#
|
204
202
|
before_filter :authorize_request, :only => [
|
205
203
|
:authorized,
|
206
|
-
:
|
204
|
+
:liferay_uid_auth,
|
207
205
|
:foobarcookies_auth,
|
208
206
|
:foobarcookiestxt_auth,
|
209
207
|
:cookies_liferay_auth
|
@@ -211,6 +209,15 @@ class Caterpillar::JunitController < Caterpillar::ApplicationController
|
|
211
209
|
alias :foobarcookies_auth :foobarcookies
|
212
210
|
alias :foobarcookiestxt_auth :foobarcookiestxt
|
213
211
|
|
212
|
+
#
|
213
|
+
# collect Liferay UID cookie
|
214
|
+
#
|
215
|
+
before_filter :get_liferay_uid, :only => [
|
216
|
+
:liferay_uid,
|
217
|
+
:liferay_uid_auth,
|
218
|
+
:cookies_liferay_auth
|
219
|
+
]
|
220
|
+
|
214
221
|
# test session authorization
|
215
222
|
def authorized
|
216
223
|
render :nothing => true, :status => 200
|
@@ -222,6 +229,20 @@ class Caterpillar::JunitController < Caterpillar::ApplicationController
|
|
222
229
|
render :inline => @uid, :status => 200
|
223
230
|
end
|
224
231
|
|
232
|
+
# test Liferay UID cookie and authentication
|
233
|
+
def liferay_uid_auth
|
234
|
+
@uid = 'nil' if @uid.nil?
|
235
|
+
render :inline => @uid, :status => 200
|
236
|
+
end
|
237
|
+
|
238
|
+
# test foobarcookies with Liferay UID cookie and authentication.
|
239
|
+
# 5 cookies altogether.
|
240
|
+
def cookies_liferay_auth
|
241
|
+
txt = "Liferay_UID: #{@uid}\n"
|
242
|
+
txt += "#{cookies[:foo]}#{cookies[:bar]}#{cookies[:baz]}"
|
243
|
+
render :inline => txt, :status => 200
|
244
|
+
end
|
245
|
+
|
225
246
|
def target1
|
226
247
|
render :action => 'target1', :layout => 'bare'
|
227
248
|
end
|
@@ -1,11 +1,21 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
class Caterpillar::LiferayController < Caterpillar::ApplicationController
|
2
3
|
|
4
|
+
# Import security filters
|
5
|
+
include Caterpillar::Security
|
6
|
+
secure_portlet_sessions(:only => :authorized_sessions)
|
7
|
+
|
8
|
+
# UID & GID filters
|
9
|
+
include Caterpillar::Helpers::Liferay
|
10
|
+
before_filter :get_liferay_uid, :only => :session_variables
|
11
|
+
before_filter :get_liferay_gid, :only => :session_variables
|
3
12
|
|
4
|
-
class Caterpillar::LiferayController < Caterpillar::ApplicationController
|
5
13
|
|
6
14
|
def session_variables
|
7
|
-
|
8
|
-
|
15
|
+
end
|
16
|
+
|
17
|
+
def authorized_sessions
|
18
|
+
render :inline => 'Request was authorized via shared secret'
|
9
19
|
end
|
10
20
|
|
11
21
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
class Caterpillar::XhrController < Caterpillar::ApplicationController
|
3
|
-
|
3
|
+
include Caterpillar::Helpers::Liferay
|
4
|
+
|
4
5
|
def prototype
|
5
6
|
# the page with the XHR triggers
|
6
7
|
@javascripts = %w{prototype}
|
@@ -17,4 +18,14 @@ class Caterpillar::XhrController < Caterpillar::ApplicationController
|
|
17
18
|
send_data Time.now.to_s, :type => 'text/html'
|
18
19
|
end
|
19
20
|
|
21
|
+
# Liferay resource URL
|
22
|
+
def resource
|
23
|
+
logger.debug params
|
24
|
+
@resource_url = cookies[:Liferay_resourceUrl]
|
25
|
+
logger.debug @resource_url
|
26
|
+
@r_u_params = params.dup
|
27
|
+
#p url_for(:controller => Caterpillar::XhrController )
|
28
|
+
|
29
|
+
end
|
30
|
+
|
20
31
|
end
|
@@ -1,5 +1,12 @@
|
|
1
|
+
<style type="text/css">
|
2
|
+
body {
|
3
|
+
background: white;
|
4
|
+
}
|
5
|
+
</style>
|
6
|
+
<%= image_tag 'caterpillar/caterpillar.gif' %>
|
7
|
+
<span style="font-size: 3em;">
|
1
8
|
Caterpillar <%= Caterpillar::VERSION %>
|
2
|
-
|
9
|
+
</span>
|
3
10
|
<hr />
|
4
11
|
|
5
12
|
Includes <%= link_to 'portlet test bench', portlet_test_bench_url %>.
|
@@ -36,7 +36,7 @@ background: white;
|
|
36
36
|
<div class="testBenchHeader">Rails-portlet test bench</div>
|
37
37
|
|
38
38
|
<p style="font-size: 14px;">
|
39
|
-
These are isolated test cases of the Rails-portlet, for manual testing in the browser. The <%= link_to_exit_portlet 'source code', 'http://
|
39
|
+
These are isolated test cases of the Rails-portlet, for manual testing in the browser. The <%= link_to_exit_portlet 'source code', 'http://github.com/lamikae/caterpillar/tree/master/portlet_test_bench/' -%> can be used as a reference for using the same features in other Rails apps.
|
40
40
|
</p>
|
41
41
|
|
42
42
|
<div class="testBenchSuite">HTTP</div>
|
@@ -107,6 +107,20 @@ These are isolated test cases of the Rails-portlet, for manual testing in the br
|
|
107
107
|
|
108
108
|
</div>
|
109
109
|
|
110
|
+
<div class="testBenchSuite">Liferay</div>
|
111
|
+
<div class="testContainer">
|
112
|
+
|
113
|
+
<%= link_to 'Liferay UID and GID',
|
114
|
+
url_for(
|
115
|
+
:controller => 'Caterpillar::Liferay',
|
116
|
+
:action => :session_variables
|
117
|
+
)
|
118
|
+
-%><br />
|
119
|
+
|
120
|
+
<%= link_to 'Liferay resource URL',
|
121
|
+
:controller => 'Caterpillar::Xhr', :action => :resource -%><br />
|
122
|
+
|
123
|
+
</div>
|
110
124
|
|
111
125
|
<div class="testBenchSuite">Misc</div>
|
112
126
|
<div class="testContainer">
|
@@ -120,16 +134,20 @@ These are isolated test cases of the Rails-portlet, for manual testing in the br
|
|
120
134
|
<%= link_to 'Link outside the portlet',
|
121
135
|
:controller => 'Caterpillar::Resource', :action => :exit_portlet -%><br />
|
122
136
|
|
123
|
-
<%= link_to 'Liferay session variables',
|
124
|
-
url_for(
|
125
|
-
:controller => 'Caterpillar::Liferay',
|
126
|
-
:action => :session_variables
|
127
|
-
)+'/uid/%UID%/gid/%GID%'
|
128
|
-
-%><br />
|
129
|
-
|
130
137
|
<%= link_to 'Flash message',
|
131
138
|
:controller => 'Caterpillar::Session', :action => :flash_msg -%><br />
|
132
139
|
|
140
|
+
<%= link_to 'Cookies set by rails-portlet',
|
141
|
+
:controller => 'Caterpillar::Session', :action => :cookies -%><br />
|
142
|
+
|
143
|
+
<%= link_to 'Portlet namespace',
|
144
|
+
:controller => 'Caterpillar::Session', :action => :namespace -%><br />
|
145
|
+
|
146
|
+
|
147
|
+
<%= link_to 'Portlet request authorization via shared secret',
|
148
|
+
:controller => 'Caterpillar::Liferay', :action => :authorized_sessions -%><br />
|
149
|
+
|
150
|
+
|
133
151
|
</div>
|
134
152
|
|
135
153
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html>
|
1
3
|
<head>
|
2
4
|
<title>Simple CSS test</title>
|
3
5
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8"></meta>
|
@@ -27,4 +29,5 @@
|
|
27
29
|
<div id="background_image"></div>
|
28
30
|
</center>
|
29
31
|
|
30
|
-
</body>
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html>
|
1
3
|
<head>
|
2
4
|
<title>Simple CSS test</title>
|
3
5
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8"></meta>
|
@@ -8,7 +10,8 @@
|
|
8
10
|
/* simple.html.erb */
|
9
11
|
#head_ref {
|
10
12
|
margin: 25px; padding: 10px; border: 1px solid #000000;
|
11
|
-
background:
|
13
|
+
background: blue;
|
14
|
+
color: white;
|
12
15
|
}
|
13
16
|
</style>
|
14
17
|
</head>
|
@@ -18,36 +21,37 @@
|
|
18
21
|
<style type="text/css" id="style_in_body">
|
19
22
|
#body_ref {
|
20
23
|
margin: 25px; padding: 10px; border: 1px solid #000000;
|
21
|
-
background:
|
24
|
+
background: green;
|
22
25
|
}
|
23
26
|
</style>
|
24
27
|
|
25
28
|
Body<br />
|
26
|
-
<b>background-color:
|
29
|
+
<b>background-color: gray; font: 11px Arial,Helvetica;</b>
|
27
30
|
<p class="info">
|
28
31
|
All the following divs should appear the same, with different background colors.<br />
|
29
32
|
<b>margin: 25px; padding: 10px; border: 1px solid #000000;</b>
|
30
33
|
</p>
|
31
|
-
<div style="margin: 25px; padding: 10px; border: 1px solid #000000; background:
|
34
|
+
<div style="margin: 25px; padding: 10px; border: 1px solid #000000; background: orange;">
|
32
35
|
This is a div with self-contained style parameters. <br />
|
33
|
-
<b>background:
|
36
|
+
<b>background: orange</b>
|
34
37
|
</div>
|
35
38
|
|
36
39
|
<div id="simple_content">
|
37
40
|
This is a div with style definitions in <i>main.css</i>.<br />
|
38
|
-
<b>background:
|
41
|
+
<b>background: purple</b>
|
39
42
|
</div>
|
40
43
|
|
41
44
|
<div id="head_ref">
|
42
45
|
This is a div with style definitions in <i><head></i>.<br />
|
43
|
-
<b>background:
|
46
|
+
<b>background: blue</b>
|
44
47
|
</div>
|
45
48
|
|
46
49
|
<div id="body_ref">
|
47
50
|
This is a div with style definitions in <i><body></i>.<br />
|
48
|
-
<b>background:
|
51
|
+
<b>background: green</b>
|
49
52
|
</div>
|
50
53
|
|
51
54
|
<br />
|
52
55
|
|
53
|
-
</body>
|
56
|
+
</body>
|
57
|
+
</html>
|
@@ -4,16 +4,13 @@ These tests check that Liferay session variables are available in Rails.
|
|
4
4
|
</p>
|
5
5
|
|
6
6
|
<p>
|
7
|
-
These variables are accessible in Java JSR286 portlets from the Liferay API.
|
8
|
-
When the Rails-portlet receives a request where the URL contains keywords %UID% or %GID%, these are replaced by the values received from the Liferay API. Rails receives a request with the actual UID number and GID numbers, respectively. The page (Layout in the database) where the portlet is has defined this Group.
|
7
|
+
These variables are accessible in Java JSR286 portlets from the Liferay API. Rails-portlet includes these values into a cookie that is available in Rails.
|
9
8
|
</p>
|
10
9
|
|
11
10
|
<p>
|
12
|
-
<%#= link_to 'UID', url_for(:action => :session_variables)+'/uid/%UID%' -%><br/>
|
13
|
-
<%#= link_to 'UID debug', url_for(:action => :session_variables)+'/uid/10000' -%><br/>
|
14
11
|
<% if @uid -%>
|
15
12
|
<span style="font-size: 18px;">
|
16
|
-
|
13
|
+
Liferay UID: <%= @uid %>
|
17
14
|
</span>
|
18
15
|
<% else -%>
|
19
16
|
No UID found!
|
@@ -21,18 +18,12 @@ When the Rails-portlet receives a request where the URL contains keywords %UID%
|
|
21
18
|
</p>
|
22
19
|
|
23
20
|
<p>
|
24
|
-
<%#= link_to 'GID', url_for(:action => :session_variables)+'/gid/%GID%' -%><br/>
|
25
|
-
<%#= link_to 'GID debug', url_for(:action => :session_variables)+'/gid/20000' -%><br/>
|
26
21
|
<% if @gid -%>
|
27
22
|
<span style="font-size: 18px;">
|
28
|
-
|
23
|
+
Liferay GID: <%= @gid %>
|
29
24
|
</span>
|
30
25
|
<% else -%>
|
31
26
|
No GID found!
|
32
27
|
<% end -%>
|
33
28
|
</p>
|
34
29
|
|
35
|
-
<p style="font-size: 18px;">
|
36
|
-
<%#= link_to 'Reset', :action => :session_variables -%>
|
37
|
-
</p>
|
38
|
-
|