authpds-nyu 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/authpds-nyu.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'active_support/dependencies'
2
2
  require 'authpds'
3
+ require 'exlibris-aleph'
3
4
  AUTHPDS_NYU_PATH = File.dirname(__FILE__) + "/authpds-nyu/"
4
5
  [
5
6
  'session',
@@ -61,6 +61,11 @@ module AuthpdsNyu
61
61
  login_inaccessible_url "http://library.nyu.edu/errors/login-library-nyu-edu/"
62
62
  end
63
63
  end
64
+
65
+ # Override logout url for NYU.
66
+ def logout_url
67
+ return "#{self.class.pds_url}/logout?url=#{CGI::escape(controller.user_session_redirect_url(self.class.redirect_logout_url))}"
68
+ end
64
69
 
65
70
  def aleph_bor_auth_permissions(bor_id=nil, verification=nil, adm=nil, sublibrary=nil)
66
71
  bor_auth = aleph_bor_auth(bor_id, verification, adm, sublibrary)
@@ -75,8 +80,8 @@ module AuthpdsNyu
75
80
  sublibrary = self.class.aleph_default_sublibrary if sublibrary.nil?
76
81
  # Call X-Service
77
82
  bor_auth =
78
- AuthPdsNyu::Exlibris::Aleph::BorAuth.
79
- new(aleph_url, adm, sublibrary, "N", bor_id, bor_verification)
83
+ Exlibris::Aleph::BorAuth.
84
+ new(aleph_url, adm, sublibrary, "N", bor_id, verification)
80
85
  controller.logger.error(
81
86
  "Error in #{self.class}. "+
82
87
  "No permissions returned from Aleph bor-auth for user with bor_id #{bor_id}."+
@@ -1,3 +1,3 @@
1
1
  module AuthpdsNyu
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  class UserSession < Authlogic::Session::Base
2
2
  pds_url "https://logindev.library.nyu.edu"
3
- redirect_logout_url "https://logindev.library.nyu.edu/logout"
4
- aleph_url "http://alephstage.library.nyu.edu"
3
+ redirect_logout_url "http://bobcatdev.library.nyu.edu"
4
+ aleph_url "http://aleph.library.nyu.edu"
5
5
  calling_system "authpds-nyu"
6
6
  end
data/test/test_helper.rb CHANGED
@@ -42,9 +42,9 @@ require File.dirname(__FILE__) + '/../lib/authpds-nyu'
42
42
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
43
43
 
44
44
  class ActiveSupport::TestCase
45
- VALID_OPENSSO_FOR_NYU = 'AQIC5wM2LY4SfcwFgz4BiWlHd1XVs6_wwHYAti2Wn-C9o18.*AAJTSQACMDIAAlNLAAk4OTU0ODMzNDIAAlMxAAIwMQ..*'
45
+ VALID_OPENSSO_FOR_NYU = 'AQIC5wM2LY4Sfcz_O7UA1U1KruO_dMKGYQQKYhZNqDgeEPI.*AAJTSQACMDIAAlNLAAstMTMwMzI0MzkzMwACUzEAAjAx*'
46
46
  INVALID_OPENSSO = "Invalid"
47
- VALID_PDS_HANDLE_FOR_NEW_NYU = '83201295456116368349190324314'
47
+ VALID_PDS_HANDLE_FOR_NEW_NYU = '293201211510129623735547952389'
48
48
  VALID_PDS_HANDLE_FOR_EXISTING_NYU = '83201295456116368349190324314'
49
49
  VALID_PDS_HANDLE_FOR_NEWSCHOOL = '272201212284614806184193096120278'
50
50
  VALID_PDS_HANDLE_FOR_COOPER = '272201212284614806184193096120278'
@@ -67,14 +67,15 @@ class Authlogic::TestCase::MockController
67
67
  include Authpds::Controllers::AuthpdsController
68
68
 
69
69
  def url_for(options={})
70
- return "http://railsapp.library.nyu.edu/validate?return_url=#{options[:return_url]}"
70
+ return "#{root_url}/validate?return_url=#{options[:return_url]}"
71
71
  end
72
72
 
73
73
  def root_url
74
+ return "http://railsapp.library.nyu.edu"
74
75
  end
75
76
 
76
77
  def validate_url(options={})
77
- return "http://railsapp.library.nyu.edu/validate?return_url=#{options[:return_url]}"
78
+ return "#{root_url}/validate?return_url=#{options[:return_url]}"
78
79
  end
79
80
 
80
81
  def performed?
@@ -23,6 +23,29 @@ class UserSessionTest < ActiveSupport::TestCase
23
23
  user_session = UserSession.find
24
24
  end
25
25
 
26
+ test "logout_url" do
27
+ user_session = UserSession.new
28
+ assert_equal(
29
+ "https://logindev.library.nyu.edu/logout?url=http%3A%2F%2Fbobcatdev.library.nyu.edu",
30
+ user_session.logout_url)
31
+ end
32
+
33
+ test "aleph_bor_auth" do
34
+ user_session = UserSession.new
35
+ bor_auth = user_session.aleph_bor_auth("N12162279", "d4465aacaa645f2164908cd4184c09f0", "NYU50", "BOBST")
36
+ assert_equal("51", bor_auth.permissions[:bor_status])
37
+ assert_equal("CB", bor_auth.permissions[:bor_type])
38
+ assert_equal("Y", bor_auth.permissions[:hold_on_shelf])
39
+ end
40
+
41
+ test "aleph_bor_auth_permissions" do
42
+ user_session = UserSession.new
43
+ permissions = user_session.aleph_bor_auth_permissions("N12162279", "d4465aacaa645f2164908cd4184c09f0", "NYU50", "BOBST")
44
+ assert_equal("51", permissions[:bor_status])
45
+ assert_equal("CB", permissions[:bor_type])
46
+ assert_equal("Y", permissions[:hold_on_shelf])
47
+ end
48
+
26
49
  # test "find_new_user" do
27
50
  # controller.cookies[:PDS_HANDLE] = { :value => VALID_PDS_HANDLE_FOR_NEW_NYU }
28
51
  # user_session = UserSession.find
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authpds-nyu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-23 00:00:00.000000000 Z
12
+ date: 2012-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2151931660 !ruby/object:Gem::Requirement
16
+ requirement: &2151935160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151931660
24
+ version_requirements: *2151935160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: authpds
27
- requirement: &2151930040 !ruby/object:Gem::Requirement
27
+ requirement: &2151933360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2151930040
35
+ version_requirements: *2151933360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: exlibris-aleph
38
- requirement: &2151928280 !ruby/object:Gem::Requirement
38
+ requirement: &2151931920 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2151928280
46
+ version_requirements: *2151931920
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &2151926300 !ruby/object:Gem::Requirement
49
+ requirement: &2151930360 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2151926300
57
+ version_requirements: *2151930360
58
58
  description: NYU libraries SSO client.
59
59
  email:
60
60
  - scotdalton@gmail.com
@@ -75,7 +75,6 @@ files:
75
75
  - test/support/user.rb
76
76
  - test/support/user_session.rb
77
77
  - test/test_helper.rb
78
- - test/unit/aleph_bor_auth_test.rb
79
78
  - test/unit/opensso_test.rb
80
79
  - test/unit/user_session_test.rb
81
80
  homepage: http://github.com/scotdalton/authpds-nyu
@@ -108,6 +107,5 @@ test_files:
108
107
  - test/support/user.rb
109
108
  - test/support/user_session.rb
110
109
  - test/test_helper.rb
111
- - test/unit/aleph_bor_auth_test.rb
112
110
  - test/unit/opensso_test.rb
113
111
  - test/unit/user_session_test.rb
@@ -1,28 +0,0 @@
1
- require 'test_helper'
2
- class AlephBorAuthTest < ActiveSupport::TestCase
3
-
4
- def setup
5
- activate_authlogic
6
- controller.session[:session_id] = "FakeSessionID"
7
- # controller.cookies[:PDS_HANDLE] = { :value => VALID_PDS_HANDLE_FOR_NEW_NYU }
8
- controller.cookies[:iPlanetDirectoryPro] = { :value => VALID_OPENSSO_FOR_NYU }
9
- end
10
-
11
- test "new" do
12
- bor_auth =
13
- AuthpdsNyu::Exlibris::Aleph::BorAuth.new(
14
- "http://alephstage.library.nyu.edu", "NYU50", "BOBST", "N",
15
- "N12162279", "d4465aacaa645f2164908cd4184c09f0")
16
- assert_nil(bor_auth.error, "Error is not nil.")
17
- end
18
-
19
- test "permissions" do
20
- bor_auth =
21
- AuthpdsNyu::Exlibris::Aleph::BorAuth.new(
22
- "http://alephstage.library.nyu.edu", "NYU50", "BOBST", "N",
23
- "N12162279", "d4465aacaa645f2164908cd4184c09f0")
24
- assert_equal("51", bor_auth.permissions[:bor_status])
25
- assert_equal("CB", bor_auth.permissions[:bor_type])
26
- assert_equal("Y", bor_auth.permissions[:hold_on_shelf])
27
- end
28
- end