hydra-access-controls 8.1.0 → 8.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a9a107ab5eb383394ebfc47c69dce414947a066
4
- data.tar.gz: 700a1c079faad7648d7255c296f219355aae9463
3
+ metadata.gz: 7d0c332d417111f77876c46bd3331349ce28da60
4
+ data.tar.gz: 1282b9c10fe0ac75ba5e2793da8a08a1e0deb462
5
5
  SHA512:
6
- metadata.gz: 9a456db93036e5e7e24559357a468e1609f5ce6d89faf40c5db9bfe2af7c09c0bc359d733cf518079d05b24f76432a7feda172bd64a315d21ee0f831ac81d701
7
- data.tar.gz: 3ad0be9f95328df88caa11274857b3842fa130c0a70c13e65c50ad948eefe0d79904c2be440b741ccc8c3b2c69b5ecce9767b12a9ccbbd93438fbe252c3f54a7
6
+ metadata.gz: 36f0b7eeab09aeee018e6610fd510a392110e7c6d6251d7b78b70c9c9b33b36014675b373f36487e53139ed79f397fa0e4404aee052c2f1c9630b4120c1cd2da
7
+ data.tar.gz: c61a05b0b34fdf009ab676eda0a67f209f42c53d792952e39e454ac09be6cc4c9c2c66f665d47717a0b89a50e4155462ac6b8cb07c2bde46a577b351a374d33f
@@ -16,10 +16,10 @@ Gem::Specification.new do |gem|
16
16
  gem.version = version
17
17
  gem.license = "APACHE2"
18
18
 
19
- gem.required_ruby_version = '>= 1.9.3'
19
+ gem.required_ruby_version = '>= 2.0.0'
20
20
 
21
21
  gem.add_dependency 'activesupport', '~> 4.0'
22
- gem.add_dependency "active-fedora", '~> 8.0.0'
22
+ gem.add_dependency "active-fedora", '~> 8.0'
23
23
  gem.add_dependency "om", '~> 3.0', '>= 3.0.7'
24
24
  gem.add_dependency 'cancancan', '~> 1.8'
25
25
  gem.add_dependency 'deprecation', '~> 0.1'
@@ -4,8 +4,7 @@ module Hydra::PolicyAwareAccessControlsEnforcement
4
4
  # Extends Hydra::AccessControlsEnforcement.apply_gated_discovery to reflect policy-provided access
5
5
  # appends the result of policy_clauses into the :fq
6
6
  # @param solr_parameters the current solr parameters
7
- # @param user_parameters the current user-subitted parameters
8
- def apply_gated_discovery(solr_parameters, user_parameters)
7
+ def apply_gated_discovery(solr_parameters)
9
8
  solr_parameters[:fq] ||= []
10
9
  solr_parameters[:fq] << gated_discovery_filters.join(" OR ")
11
10
  logger.debug("POLICY-aware Solr parameters: #{ solr_parameters.inspect }")
@@ -43,13 +42,11 @@ module Hydra::PolicyAwareAccessControlsEnforcement
43
42
 
44
43
  def apply_policy_user_permissions(permission_types = discovery_permissions)
45
44
  # for individual user access
46
- user_access_filters = []
47
- if current_user
48
- permission_types.each do |type|
49
- user_access_filters << escape_filter(ActiveFedora::SolrService.solr_name("inheritable_#{type}_access_person", Hydra::Datastream::RightsMetadata.indexer ), current_user.user_key)
50
- end
45
+ user = current_ability.current_user
46
+ return [] unless user && user.user_key.present?
47
+ permission_types.map do |type|
48
+ escape_filter(ActiveFedora::SolrService.solr_name("inheritable_#{type}_access_person", Hydra::Datastream::RightsMetadata.indexer ), user.user_key)
51
49
  end
52
- user_access_filters
53
50
  end
54
51
 
55
52
  # Returns the Model used for AdminPolicy objects.
@@ -20,11 +20,18 @@ end
20
20
  require 'support/rails'
21
21
 
22
22
  # Since we're not doing a Rails Engine test, we have to load these classes manually:
23
- require_relative '../app/models/role_mapper'
24
- require_relative '../app/models/ability'
25
- require_relative '../app/services/hydra/lease_service'
26
- require_relative '../app/services/hydra/embargo_service'
27
- require_relative '../app/validators/hydra/future_date_validator'
23
+ require 'active_support'
24
+ require 'active_support/dependencies'
25
+ relative_load_paths = ["#{Blacklight.root}/app/controllers/concerns",
26
+ "#{Blacklight.root}/app/models",
27
+ "app/models",
28
+ "app/models/concerns",
29
+ "app/indexers",
30
+ "app/services",
31
+ "app/validators",
32
+ "app/vocabularies"]
33
+ ActiveSupport::Dependencies.autoload_paths += relative_load_paths
34
+
28
35
  require 'support/mods_asset'
29
36
  require 'support/solr_document'
30
37
  require "support/user"
@@ -90,7 +90,6 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
90
90
 
91
91
  before do
92
92
  @solr_parameters = {}
93
- @user_parameters = {}
94
93
  @user = FactoryGirl.build(:sara_student)
95
94
  end
96
95
 
@@ -129,13 +128,13 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
129
128
  # stubbing out policies_with_access because solr doesn't always return them in the same order.
130
129
  policy_pids = (1..8).map {|n| "test:policy#{n}"}
131
130
  subject.should_receive(:policies_with_access).and_return(policy_pids)
132
- subject.apply_gated_discovery(@solr_parameters, @user_parameters)
131
+ subject.apply_gated_discovery(@solr_parameters)
133
132
  governed_field = ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)
134
133
  @solr_parameters[:fq].first.should include(" OR (_query_:\"{!raw f=#{governed_field}}info:fedora/test:policy1\" OR _query_:\"{!raw f=#{governed_field}}info:fedora/test:policy2\" OR _query_:\"{!raw f=#{governed_field}}info:fedora/test:policy3\" OR _query_:\"{!raw f=#{governed_field}}info:fedora/test:policy4\" OR _query_:\"{!raw f=#{governed_field}}info:fedora/test:policy5\" OR _query_:\"{!raw f=#{governed_field}}info:fedora/test:policy6\" OR _query_:\"{!raw f=#{governed_field}}info:fedora/test:policy7\" OR _query_:\"{!raw f=#{governed_field}}info:fedora/test:policy8\")")
135
134
  end
136
135
  it "should not change anything if there are no clauses to add" do
137
136
  subject.stub(:policy_clauses).and_return(nil)
138
- subject.apply_gated_discovery(@solr_parameters, @user_parameters)
137
+ subject.apply_gated_discovery(@solr_parameters)
139
138
  @solr_parameters[:fq].first.should_not include(" OR (#{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy1 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy2 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy3 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy4 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy5 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy6 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy7 OR #{ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy8)")
140
139
  end
141
140
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-access-controls
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0
4
+ version: 8.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-03-27 00:00:00.000000000 Z
13
+ date: 2017-02-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: 8.0.0
35
+ version: '8.0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: 8.0.0
42
+ version: '8.0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: om
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -228,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  requirements:
229
229
  - - ">="
230
230
  - !ruby/object:Gem::Version
231
- version: 1.9.3
231
+ version: 2.0.0
232
232
  required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - ">="
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  version: '0'
237
237
  requirements: []
238
238
  rubyforge_project:
239
- rubygems_version: 2.2.2
239
+ rubygems_version: 2.6.8
240
240
  signing_key:
241
241
  specification_version: 4
242
242
  summary: Access controls for project hydra
@@ -269,4 +269,3 @@ test_files:
269
269
  - spec/unit/visibility_spec.rb
270
270
  - spec/unit/with_access_right_spec.rb
271
271
  - spec/validators/future_date_validator_spec.rb
272
- has_rdoc: