Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for ruby-2, rails-4 and rspec-3 #238

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.2.0
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
source "http://rubygems.org"
gemspec


# Gems for authenticators
group :ldap do
gem "net-ldap", "~> 0.1.1"
end

group :active_resource do
gem "activeresource", ">= 2.3.12", "< 4.0"
gem 'activeresource', '~> 4.0.0'
end
7 changes: 4 additions & 3 deletions lib/casserver/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,10 @@ def self.init_database!
st.destroy
end

pgts = CASServer::Model::ProxyGrantingTicket.find(:all,
:conditions => [CASServer::Model::ServiceTicket.quoted_table_name+".username = ?", tgt.username],
:include => :service_ticket)
pgts = CASServer::Model::ProxyGrantingTicket.where(
CASServer::Model::ServiceTicket.quoted_table_name + '.username = ?', tgt.username
).joins(:service_ticket)

pgts.each do |pgt|
$LOG.debug("Deleting Proxy-Granting Ticket '#{pgt}' for user '#{pgt.service_ticket.username}'")
pgt.destroy
Expand Down
9 changes: 5 additions & 4 deletions rubycas-server.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ $gemspec = Gem::Specification.new do |s|
s.has_rdoc = true
s.post_install_message = "For more information on RubyCAS-Server, see http://rubycas.github.com"

s.add_dependency("activerecord", ">= 2.3.12", "< 4.0")
s.add_dependency("activesupport", ">= 2.3.12", "< 4.0")
s.add_dependency("sinatra", "~> 1.0")
s.add_dependency("sinatra-r18n", '~> 1.1.0')
s.add_dependency('activerecord', '~> 4.2')
s.add_dependency('activesupport', '~> 4.2')
s.add_dependency('sinatra', '~> 1.4.5')
s.add_dependency('sinatra-r18n', '~> 2.0.3')
s.add_dependency("crypt-isaac", "~> 0.9.1")

s.add_development_dependency("rack-test")
s.add_development_dependency("capybara", '1.1.2')
s.add_development_dependency("rspec")
s.add_development_dependency("rspec-core")
s.add_development_dependency('rspec-its')
s.add_development_dependency("rake", "0.8.7")
s.add_development_dependency("sqlite3", "~> 1.3.1")
s.add_development_dependency("appraisal", "~> 0.4.1")
Expand Down
14 changes: 7 additions & 7 deletions spec/casserver/authenticators/active_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

def mock_authenticate identity = nil
identity = CASServer::Authenticators::Helpers::Identity.new if identity.nil?
CASServer::Authenticators::Helpers::Identity.stub!(:authenticate).and_return(identity)
CASServer::Authenticators::Helpers::Identity.stub(:authenticate).and_return(identity)
end

def sample_identity attrs = {}
Expand All @@ -82,33 +82,33 @@ def sample_identity attrs = {}
auth.configure({}.with_indifferent_access)
identity = sample_identity({:email => '[email protected]'})
mock_authenticate identity
auth.validate(credentials).should be_true
auth.validate(credentials).should be(true)
auth.extra_attributes.should == identity.attributes
end

it "should return false when http raises" do
CASServer::Authenticators::Helpers::Identity.stub!(:authenticate).and_raise(ActiveResource::ForbiddenAccess.new({}))
auth.validate(credentials).should be_false
CASServer::Authenticators::Helpers::Identity.stub(:authenticate).and_raise(ActiveResource::ForbiddenAccess.new({}))
auth.validate(credentials).should be(false)
end

it "should apply extra_attribute filter" do
auth.configure({ :extra_attributes => 'age'}.with_indifferent_access)
mock_authenticate sample_identity({ :email => '[email protected]', :age => 28 })
auth.validate(credentials).should be_true
auth.validate(credentials).should be(true)
auth.extra_attributes.should == { "age" => "28" }
end

it "should only extract not filtered attributes" do
auth.configure({ :filter_attributes => 'age'}.with_indifferent_access)
mock_authenticate sample_identity({ :email => '[email protected]', :age => 28 })
auth.validate(credentials).should be_true
auth.validate(credentials).should be(true)
auth.extra_attributes.should == { "email" => '[email protected]' }
end

it "should filter password if filter attributes is not given" do
auth.configure({}.with_indifferent_access)
mock_authenticate sample_identity({ :email => '[email protected]', :password => 'secret' })
auth.validate(credentials).should be_true
auth.validate(credentials).should be(true)
auth.extra_attributes.should == { "email" => '[email protected]' }
end
end
Expand Down
24 changes: 12 additions & 12 deletions spec/casserver/authenticators/ldap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
# Trigger autoload to load net ldap
CASServer::Authenticators::LDAP

@ldap_entry = mock(Net::LDAP::Entry.new)
@ldap_entry.stub!(:[]).and_return("Test")

@ldap = mock(Net::LDAP)
@ldap.stub!(:host=)
@ldap.stub!(:port=)
@ldap.stub!(:encryption)
@ldap.stub!(:bind_as).and_return(true)
@ldap.stub!(:authenticate).and_return(true)
@ldap.stub!(:search).and_return([@ldap_entry])

Net::LDAP.stub!(:new).and_return(@ldap)
@ldap_entry = double(Net::LDAP::Entry.new)
@ldap_entry.stub(:[]).and_return("Test")

@ldap = double(Net::LDAP)
@ldap.stub(:host=)
@ldap.stub(:port=)
@ldap.stub(:encryption)
@ldap.stub(:bind_as).and_return(true)
@ldap.stub(:authenticate).and_return(true)
@ldap.stub(:search).and_return([@ldap_entry])

Net::LDAP.stub(:new).and_return(@ldap)
end

describe '#validate' do
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rubygems'
require 'rack/test'
require 'rspec'
require 'rspec/its'
#require 'spec/autorun'
#require 'spec/interop/test'
require 'logger'
Expand Down