Permalink
Browse files

Merge pull request #113 from alphagov/upgrade-gds-sso

upgrading gds-sso to version 9.1.0
  • Loading branch information...
2 parents 9852980 + 657222f commit be9a61576c2254a87821cc0c0f98e1136239b19a @bradwright bradwright committed Nov 28, 2013
Showing with 16 additions and 15 deletions.
  1. +2 −1 Gemfile
  2. +5 −5 Gemfile.lock
  3. +4 −2 app/models/user.rb
  4. +0 −2 config/initializers/gds-sso.rb
  5. +5 −5 test/unit/models/user_test.rb
View
@@ -12,7 +12,8 @@ end
gem 'mysql2', '0.3.14'
gem 'aws-ses', require: 'aws/ses'
gem "exception_notification", '3.0.1'
-gem 'gds-sso', '3.0.5'
+
+gem 'gds-sso', '9.1.0'
gem 'cancan', '1.6.9'
gem 'jquery-rails'
gem 'jquery-ui-rails', '2.0.2'
View
@@ -101,8 +101,8 @@ GEM
actionpack (>= 3.0)
formtastic-bootstrap (2.1.1)
formtastic (~> 2.2)
- gds-sso (3.0.5)
- omniauth-gds (~> 0.0.3)
+ gds-sso (9.1.0)
+ omniauth-gds (>= 3.0.0)
rack-accept (~> 0.4.4)
rails (>= 3.0.0)
warden (~> 1.2)
@@ -165,7 +165,7 @@ GEM
omniauth (1.1.4)
hashie (>= 1.2, < 3)
rack
- omniauth-gds (0.0.4)
+ omniauth-gds (3.0.0)
omniauth-oauth2 (~> 1.0)
omniauth-oauth2 (1.1.1)
oauth2 (~> 0.8.0)
@@ -259,7 +259,7 @@ GEM
raindrops (~> 0.7)
validates_timeliness (3.0.14)
timeliness (~> 0.3.6)
- warden (1.2.1)
+ warden (1.2.3)
rack (>= 1.0)
webmock (1.9.0)
addressable (>= 2.2.7)
@@ -286,7 +286,7 @@ DEPENDENCIES
cucumber-rails (= 1.3.0)
exception_notification (= 3.0.1)
formtastic-bootstrap (= 2.1.1)
- gds-sso (= 3.0.5)
+ gds-sso (= 9.1.0)
gds_zendesk (= 1.0.1)
jquery-rails
jquery-tablesorter (= 1.8.1)
View
@@ -12,16 +12,18 @@ def ability
@ability ||= Support::Permissions::Ability.new(self)
end
- def self.find_by_uid(uid)
+ def self.where(options)
+ uid = options[:uid]
auth_hash = Rails.cache.fetch(prefixed_key(uid))
- auth_hash ? User.new(auth_hash) : nil
+ auth_hash ? [ User.new(auth_hash) ] : []
end
def self.create!(auth_hash, options={})
Rails.cache.write(prefixed_key(auth_hash["uid"]), auth_hash)
User.new(auth_hash)
end
+ # only used by the mock_gds_sso strategy
def self.first
auth_hash = Rails.cache.fetch(prefixed_key('dummy-user'))
raise("Dummy user not found, run rake users:create_dummy") unless auth_hash
@@ -3,6 +3,4 @@
config.oauth_id = 'abcdefghjasndjkasndsupport'
config.oauth_secret = 'secret'
config.oauth_root_url = Plek.current.find("signon")
- config.basic_auth_user = 'api'
- config.basic_auth_password = 'defined_on_rollout_not'
end
@@ -10,23 +10,23 @@ def teardown
end
should "support persistent creation and retrieval" do
- assert_nil User.find_by_uid("12345")
+ assert User.where(uid: "12345").empty?
user = User.create!("uid" => "12345", "name" => "A", "email" => "a@b.com")
- u = User.find_by_uid("12345")
+ u = User.where(uid: "12345").first
assert_not_nil u
assert_equal "A", u.name
assert_equal "a@b.com", u.email
end
should "support remote sign-out" do
user = User.create!("uid" => "12345", "name" => "A", "email" => "a@b.com")
- assert !user.remotely_signed_out?
+ refute user.remotely_signed_out?
user.update_attribute(:remotely_signed_out, true)
assert user.remotely_signed_out?
- assert User.find_by_uid("12345").remotely_signed_out?
+ assert User.where(uid: "12345").first.remotely_signed_out?
end
should "support mass updating of attributes" do
@@ -37,6 +37,6 @@ def teardown
assert_equal "Z", user.name
assert_equal "x@y.com", user.email
- assert_equal "Z", User.find_by_uid("12345").name
+ assert_equal "Z", User.where(uid: "12345").first.name
end
end

0 comments on commit be9a615

Please sign in to comment.