authpds 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- class Institution < Struct.new(:display_name, :name, :default,
1
+ class Institution < Struct.new(:display_name, :name, :default,
2
2
  :application_layout, :ip_addresses, :parent_institution, :view_attributes, :login_attributes)
3
3
  require 'ipaddr'
4
4
 
@@ -9,8 +9,8 @@ class Institution < Struct.new(:display_name, :name, :default,
9
9
  members.each {|m| self.send( ("#{m}=").to_sym , (h.delete("#{m}".to_sym) || h.delete("#{m}"))) }
10
10
  # If the institution is named default, take that as an
11
11
  # indication that it's the default institution
12
- default = true if name.eql?("default") or name.eql?("DEFAULT")
13
- default = false unless default
12
+ self.default= true if name == "default" or name == "DEFAULT"
13
+ self.default= false unless default
14
14
  # Log the fact that there are left overs in the hash
15
15
  # Rails.logger.warn("The following institution settings were ignored: #{h.inspect}.") unless h.empty?
16
16
  end
@@ -51,6 +51,7 @@ class InstitutionList
51
51
  # Turn the institution hashes to Institutions
52
52
  institution_list.each_pair do |institution_name, institution_hash|
53
53
  institution_hash["name"] = institution_name
54
+ institution_hash["default"] = false if institution_hash["default"].nil?
54
55
  # Merge with parent institution
55
56
  institution_hash =
56
57
  institution_list[institution_hash["parent_institution"]].
@@ -1,3 +1,3 @@
1
1
  module Authpds
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -37,11 +37,11 @@ ActiveRecord::Schema.define(:version => 1) do
37
37
  end
38
38
 
39
39
  # Load support files
40
- require File.dirname(__FILE__) + '/../lib/authpds' unless defined?(Authpds)
40
+ require File.dirname(__FILE__) + '/../lib/authpds'
41
41
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
42
42
 
43
43
  class ActiveSupport::TestCase
44
- VALID_PDS_HANDLE_FOR_NYU = '73201295126115517644686139782'
44
+ VALID_PDS_HANDLE_FOR_NYU = '732012103839115682024010207789'
45
45
  VALID_PDS_HANDLE_FOR_NEWSCHOOL = '272201212284614806184193096120278'
46
46
  VALID_PDS_HANDLE_FOR_COOPER = '272201212284614806184193096120278'
47
47
  INVALID_PDS_HANDLE = "Invalid"
@@ -0,0 +1,53 @@
1
+ require 'test_helper'
2
+
3
+ class InstitutionListTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ InstitutionList.class_variable_set(:@@institutions_yaml_path, nil)
7
+ InstitutionList.instance.instance_variable_set(:@institutions, nil)
8
+ @yaml_path = "#{File.dirname(__FILE__)}/../support/config/institutions.yml"
9
+ end
10
+
11
+ test "yaml_path" do
12
+ assert_raise ArgumentError do
13
+ InstitutionList.yaml_path= nil
14
+ end
15
+ assert_raise NameError do
16
+ InstitutionList.yaml_path= "garbage_path"
17
+ end
18
+ assert_nothing_raised do
19
+ InstitutionList.yaml_path= @yaml_path
20
+ InstitutionList.instance.institutions
21
+ end
22
+ end
23
+
24
+ test "defined" do
25
+ assert(!InstitutionList.institutions_defined?)
26
+ InstitutionList.yaml_path= @yaml_path
27
+ assert(InstitutionList.institutions_defined?)
28
+ end
29
+
30
+ test "defaults" do
31
+ assert_raise ArgumentError do
32
+ InstitutionList.instance.defaults
33
+ end
34
+ assert_nothing_raised do
35
+ InstitutionList.yaml_path= @yaml_path
36
+ InstitutionList.instance.defaults
37
+ end
38
+ assert_not_nil(InstitutionList.instance.defaults)
39
+ assert_equal([InstitutionList.instance.get("NYUAD")], InstitutionList.instance.defaults)
40
+ end
41
+
42
+ test "institutions_with_ip" do
43
+ assert_raise ArgumentError do
44
+ InstitutionList.instance.institutions_with_ip "128.122.149.122"
45
+ end
46
+ assert_nothing_raised do
47
+ InstitutionList.yaml_path= @yaml_path
48
+ InstitutionList.instance.institutions_with_ip "128.122.149.122"
49
+ end
50
+ assert_not_nil(InstitutionList.instance.institutions_with_ip "128.122.149.122")
51
+ assert_equal([InstitutionList.instance.get("NYU")], InstitutionList.instance.institutions_with_ip("128.122.149.122"))
52
+ end
53
+ end
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ class InstitutionTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ test "default" do
9
+ default_name_institution = Institution.new({"name" => "default"})
10
+ assert(default_name_institution.default, "Default name didn't work.")
11
+ regular_institution = Institution.new({"name" => "not_default"})
12
+ assert(!regular_institution.default, "Default attribute didn't work.")
13
+ default_attribute_institution = Institution.new({"name" => "not_default", "default" => "true"})
14
+ assert(default_attribute_institution.default)
15
+ end
16
+
17
+ end
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class PdsTest < ActiveSupport::TestCase
4
4
 
5
5
  def setup
6
- @pds_url = "https://login.library.nyu.edu"
6
+ @pds_url = "https://logindev.library.nyu.edu"
7
7
  @calling_system = "authpds"
8
8
  @valid_pds_handle_for_nyu = VALID_PDS_HANDLE_FOR_NYU
9
9
  @valid_pds_handle_for_newschool = VALID_PDS_HANDLE_FOR_NEWSCHOOL
@@ -37,7 +37,7 @@ class PdsTest < ActiveSupport::TestCase
37
37
  assert_equal("Error User does not exist", get_attribute.error)
38
38
  end
39
39
 
40
- test "bor_info_valid" do
40
+ test "bor_info_valid_nyu" do
41
41
  nyu = Authpds::Exlibris::Pds::BorInfo.new(@pds_url, @calling_system, @valid_pds_handle_for_nyu, @bor_info_attributes)
42
42
  assert_equal("N12162279", nyu.id)
43
43
  assert_equal("std5", nyu.uid)
@@ -52,6 +52,9 @@ class PdsTest < ActiveSupport::TestCase
52
52
  assert_equal("GA", nyu.college_code)
53
53
  assert_equal("CSCI", nyu.dept_code)
54
54
  assert_equal("Information Systems", nyu.major)
55
+ end
56
+
57
+ test "bor_info_valid_newschool" do
55
58
  newschool = Authpds::Exlibris::Pds::BorInfo.new(@pds_url, @calling_system, @valid_pds_handle_for_newschool, @bor_info_attributes)
56
59
  assert_equal("N00206454", newschool.id)
57
60
  assert_equal("314519567249252", newschool.uid)
@@ -41,13 +41,12 @@ class UserSessionTest < ActiveSupport::TestCase
41
41
 
42
42
  test "primary_institution" do
43
43
  user = User.new
44
- assert_raise ArgumentError do
45
- user.primary_institution= "NYU"
46
- end
47
- InstitutionList.yaml_path= "#{File.dirname(__FILE__)}/../support/config/institutions.yml"
48
44
  assert_nothing_raised ArgumentError do
49
45
  user.primary_institution= "NYU"
50
46
  end
47
+ assert_equal(nil, user.primary_institution)
48
+ InstitutionList.yaml_path= "#{File.dirname(__FILE__)}/../support/config/institutions.yml"
49
+ assert_equal(InstitutionList.instance.get("NYU"), user.primary_institution)
51
50
  end
52
51
 
53
52
  test "institutions" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authpds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2151877240 !ruby/object:Gem::Requirement
16
+ requirement: &2151877280 !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: *2151877240
24
+ version_requirements: *2151877280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: authlogic
27
- requirement: &2151876040 !ruby/object:Gem::Requirement
27
+ requirement: &2151876220 !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: *2151876040
35
+ version_requirements: *2151876220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &2151869520 !ruby/object:Gem::Requirement
38
+ requirement: &2151869780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2151869520
46
+ version_requirements: *2151869780
47
47
  description: Libraries that use Ex Libris products, can integrate Rails application
48
48
  with PDS to provide single sign-on across systems.
49
49
  email:
@@ -73,6 +73,8 @@ files:
73
73
  - test/test_helper.rb
74
74
  - test/unit/authpds_controller_test.rb
75
75
  - test/unit/authpds_user_sessions_controller_test.rb
76
+ - test/unit/institution_list_test.rb
77
+ - test/unit/institution_test.rb
76
78
  - test/unit/pds_test.rb
77
79
  - test/unit/user_session_test.rb
78
80
  - test/unit/user_test.rb
@@ -110,6 +112,8 @@ test_files:
110
112
  - test/test_helper.rb
111
113
  - test/unit/authpds_controller_test.rb
112
114
  - test/unit/authpds_user_sessions_controller_test.rb
115
+ - test/unit/institution_list_test.rb
116
+ - test/unit/institution_test.rb
113
117
  - test/unit/pds_test.rb
114
118
  - test/unit/user_session_test.rb
115
119
  - test/unit/user_test.rb