Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit f473af1

Browse files
authored
Merge pull request #4 from identification-io/feature/rails5_upgrade
Rails 5.x support (Dropped Rails 4.2 support)
2 parents ce179ee + 3cc12e8 commit f473af1

50 files changed

Lines changed: 407 additions & 288 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
# See http://help.github.com/ignore-files/ for more about ignoring files.
2-
#
3-
# If you find yourself ignoring temporary files generated by your text editor
4-
# or operating system, you probably want to add a global ignore instead:
5-
# git config --global core.excludesfile ~/.gitignore_global
6-
7-
# Ignore bundler config
8-
/.bundle
9-
10-
# Ignore the default SQLite database.
11-
/db/*.sqlite3
12-
13-
# Ignore all logfiles and tempfiles.
14-
/log/*.log
15-
/tmp
1+
*.gem
2+
*.rbc
3+
.bundle
4+
.config
5+
.yardoc
166
.rails_generators~
17-
18-
/coverage
19-
20-
/pkg
21-
22-
# http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
23-
/Gemfile.lock
24-
25-
# Dummy application crap
26-
/spec/dummy/log/*.log
27-
/spec/dummy/tmp
28-
/spec/dummy/db/*.sqlite3
7+
gemfiles/vendor
8+
Gemfile.lock
9+
InstalledFiles
10+
_yardoc
11+
coverage
12+
doc/
13+
lib/bundler/man
14+
pkg
15+
rdoc
16+
spec/reports
17+
test/tmp
18+
test/version_tmp
19+
tmp
20+
*.lock
21+
.idea/
22+
.ruby-version
23+
*.sqlite*
24+
*.log

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
language: ruby
22
rvm:
3-
- 2.1.0
43
- 2.2.2
54
- 2.4.0
65
- 2.4.1
6+
bundler_args: --without development
7+
gemfile:
8+
- gemfiles/rails_4.2.gemfile
9+
- gemfiles/rails_5.0.gemfile
10+
- gemfiles/rails_5.1.gemfile
11+
# matrix:
12+
# allow_failures:
13+
# - rvm: 2.4.1
14+
# # gemfile: gemfiles/rails_5.0.gemfile
15+
# # gemfile: gemfiles/rails_5.1.gemfile
716
notifications:
817
hipchat:
918
rooms:

Appraisals

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
appraise 'rails-5.0' do
2+
gem 'activerecord', '~> 5.0.0'
3+
gem 'rails-controller-testing'
4+
gem 'rspec-rails', '>= 3.5'
5+
end
6+
7+
appraise 'rails-5.1' do
8+
gem 'activerecord', '~> 5.1.0'
9+
gem 'rails-controller-testing'
10+
gem 'rspec-rails', '>= 3.5'
11+
end

Gemfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
source 'https://rubygems.org'
2+
3+
group :test do
4+
gem 'appraisal', '>= 2.1'
5+
gem 'capybara', '>= 2.1'
6+
gem 'coveralls', '>= 0.7'
7+
gem 'factory_bot', '>= 4.1'
8+
gem 'rake', '>= 10.0'
9+
gem 'rspec-its', '>= 1.0'
10+
gem 'webmock', '>= 1.9'
11+
end
12+
13+
# Specify your gem's dependencies in groupify.gemspec
214
gemspec
15+
16+
platforms :ruby do
17+
gem 'sqlite3', '>= 1.3'
18+
end

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ It currently supports [CAS 1.0 and CAS 2.0](http://apereo.github.io/cas) as well
88

99
Please check our [documentation](http://casino.rbcas.com/) for setup and configuration instructions.
1010

11+
## Test Suite
12+
13+
Run the RSpec test suite by installing the `appraisal` gem and dependencies:
14+
15+
$ gem install appraisal
16+
$ appraisal install
17+
18+
And then running tests using `appraisal`:
19+
20+
$ appraisal rake
21+
1122
## License
1223

1324
CASino is released under the [MIT License](http://www.opensource.org/licenses/MIT). See LICENSE.txt for further details.

app/controllers/casino/application_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ class CASino::ApplicationController < ::ApplicationController
55

66
layout 'application'
77

8+
rescue_from ActionController::UnknownFormat do
9+
head :not_acceptable
10+
end
11+
812
unless Rails.env.development?
913
rescue_from ActionView::MissingTemplate, with: :missing_template
1014
end

app/controllers/casino/controller_concern/ticket_validator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def validate_ticket(ticket)
77
validation_result = validate_ticket_for_service(ticket, params[:service], renew: params[:renew])
88
if validation_result.success?
99
options = { ticket: ticket }
10-
options[:proxy_granting_ticket] = acquire_proxy_granting_ticket(params[:pgtUrl], ticket) unless params[:pgtUrl].nil?
10+
options[:proxy_granting_ticket] = acquire_proxy_granting_ticket(params[:pgtUrl], ticket) if params[:pgtUrl].present?
1111
build_ticket_validation_response(true, options)
1212
else
1313
build_ticket_validation_response(false,
@@ -21,7 +21,7 @@ def build_ticket_validation_response(success, options = {})
2121
end
2222

2323
def ensure_service_ticket_parameters_present
24-
if params[:ticket].nil? || params[:service].nil?
24+
if params[:ticket].blank? || params[:service].blank?
2525
build_ticket_validation_response(false,
2626
error_code: 'INVALID_REQUEST',
2727
error_message: '"ticket" and "service" parameters are both required')

app/controllers/casino/proxy_tickets_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def build_proxy_response(success, options = {})
3131
end
3232

3333
def ensure_proxy_parameters_present
34-
if params[:pgt].nil? || params[:targetService].nil?
34+
if params[:pgt].blank? || params[:targetService].blank?
3535
build_proxy_response(false,
3636
error_code: 'INVALID_REQUEST',
3737
error_message: '"pgt" and "targetService" parameters are both required')

app/controllers/casino/sessions_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def index
1616

1717
def new
1818
tgt = current_ticket_granting_ticket
19-
return handle_signed_in(tgt) unless params[:renew] || tgt.nil?
20-
redirect_to(params[:service]) if params[:gateway] && params[:service].present?
19+
return handle_signed_in(tgt) unless params[:renew].present? || tgt.nil?
20+
redirect_to(params[:service]) if params[:gateway].present? && params[:service].present?
2121
end
2222

2323
def create
@@ -41,7 +41,7 @@ def destroy_others
4141
.ticket_granting_tickets
4242
.where('id != ?', current_ticket_granting_ticket.id)
4343
.destroy_all if signed_in?
44-
redirect_to params[:service] || sessions_path
44+
redirect_to params[:service].present? ? params[:service] : sessions_path
4545
end
4646

4747
def logout

app/helpers/casino/sessions_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def current_user
2626
def current_authenticator_context
2727
CASino.config.authenticator_context_builder.call(params, request)
2828
end
29-
29+
3030
def ensure_signed_in
3131
redirect_to login_path unless signed_in?
3232
end
@@ -87,12 +87,12 @@ def handle_signed_in(tgt, options = {})
8787
end
8888

8989
def handle_signed_in_with_service(tgt, options)
90-
if !service_allowed?(params[:service])
91-
@service = params[:service]
92-
render 'casino/sessions/service_not_allowed', status: 403
93-
else
90+
if service_allowed?(params[:service])
9491
url = acquire_service_ticket(tgt, params[:service], options).service_with_ticket_url
9592
redirect_to url, status: :see_other
93+
else
94+
@service = params[:service]
95+
render 'casino/sessions/service_not_allowed', status: 403
9696
end
9797
end
9898
end

0 commit comments

Comments
 (0)