hydra-access-controls 9.1.0 → 9.1.1

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: 53a9ac37f60be38af2c511a423f849ecd9991c0f
4
- data.tar.gz: 8ac4de9c1ac17eabc873ed5e0775d252d4e0b77b
3
+ metadata.gz: 7782c91f12b8adf883784a67f458f3cca644440f
4
+ data.tar.gz: 2366fd1859fbff67528d71d019cdeb56d9c2adcb
5
5
  SHA512:
6
- metadata.gz: 61551d7bed4090045e64c9c07b1f38c28edd724e5df26c0e38987a031f72f6bcc12d717f9a538af4c29fded68091da6ec345f5c5503ea234a8e9c1b182d6046a
7
- data.tar.gz: adb99e576d8f641be0ef66b7efedde72840f1fe3a859c59f457fe18eb9ce3933bb9ca14a5c9fd00dbca50bc744420c485e6a6cb28d0ce5eb6a5b74014e3c923f
6
+ metadata.gz: 3acd120d58cc9e4cdf13d8c123f455e7f5811672795887b24c7fa8b5ce3a9dfec33f70c7c2f43608bce6d1410573892455c6f4492efa5eed93e7c2dad4cb9882
7
+ data.tar.gz: 409e79be0563d2c72e45e6cc97174979b30af36b69bc6bd4d1f68b8a5a3fe4b6eb71afd95e517a2ffb04d3235a37d037ab5184e04cd31beb690b386b88d64be4
data/README.textile CHANGED
@@ -77,7 +77,7 @@ In config/initializers/hydra_config.rb
77
77
 
78
78
  h3. Policy-based Enforcement (or Collecton-level enforcement)
79
79
 
80
- If you have Policy-based enforcement enabled, then objects will inherit extra GRANT permissions from AdminPolicy objects (APOs) they are linked to with an isGovernedBy RDF relationship (stored in solr as _is_governed_by_ssim_ field). This allows you to grant discover/read/edit access for a whole set of objects by changing the policy they are governed by.
80
+ If you have Policy-based enforcement enabled, then objects will inherit extra GRANT permissions from AdminPolicy objects (APOs) they are linked to with an isGovernedBy RDF relationship (stored in solr as _isGovernedBy_ssim_ field). This allows you to grant discover/read/edit access for a whole set of objects by changing the policy they are governed by.
81
81
 
82
82
  AdminPolicy objects store their inheritable rightsMetadata in a datastream called defaultRights. This datastream uses the regular Hydra rightsMetadata schema. Each AdminPolicy object also has its own rightsMetadata datasream, like all other Hydra assets, which specifies who is able to _edit_ the Policy or _use_ it (associate it with objects).
83
83
 
@@ -1,34 +1,30 @@
1
1
  # Repeats access controls evaluation methods, but checks against a governing "Policy" object (or "Collection" object) that provides inherited access controls.
2
2
  module Hydra::PolicyAwareAbility
3
3
  extend ActiveSupport::Concern
4
- extend Deprecation
5
4
  include Hydra::Ability
6
5
 
7
6
  IS_GOVERNED_BY_SOLR_FIELD = "isGovernedBy_ssim".freeze
8
7
 
9
8
  # Extends Hydra::Ability.test_edit to try policy controls if object-level controls deny access
10
- def test_edit(pid)
11
- super || test_edit_from_policy(pid)
9
+ def test_edit(id)
10
+ super || test_edit_from_policy(id)
12
11
  end
13
12
 
14
13
  # Extends Hydra::Ability.test_read to try policy controls if object-level controls deny access
15
- def test_read(pid)
16
- super || test_read_from_policy(pid)
14
+ def test_read(id)
15
+ super || test_read_from_policy(id)
17
16
  end
18
17
 
19
- # Returns the pid of policy object (is_governed_by) for the specified object
20
- # Assumes that the policy object is associated by an is_governed_by relationship
21
- # (which is stored as "is_governed_by_ssim" in object's solr document)
18
+ # Returns the id of policy object (isGovernedBy_ssim) for the specified object
19
+ # Assumes that the policy object is associated by an isGovernedBy relationship
20
+ # (which is stored as "isGovernedBy_ssim" in object's solr document)
22
21
  # Returns nil if no policy associated with the object
23
- def policy_pid_for(object_pid)
24
- policy_pid = policy_pid_cache[object_pid]
25
- return policy_pid if policy_pid
26
- solr_result = ActiveFedora::Base.find_with_conditions({id: object_pid}, fl: governed_by_solr_field)
27
- begin
28
- policy_pid_cache[object_pid] = policy_pid = value_from_solr_field(solr_result, governed_by_solr_field).first.gsub("info:fedora/", "")
29
- rescue NoMethodError
30
- end
31
- return policy_pid
22
+ def policy_id_for(object_id)
23
+ policy_id = policy_id_cache[object_id]
24
+ return policy_id if policy_id
25
+ solr_result = ActiveFedora::Base.find_with_conditions({ id: object_id }, fl: governed_by_solr_field).first
26
+ return unless solr_result
27
+ policy_id_cache[object_id] = policy_id = Array(solr_result[governed_by_solr_field]).first
32
28
  end
33
29
 
34
30
  def governed_by_solr_field
@@ -37,102 +33,78 @@ module Hydra::PolicyAwareAbility
37
33
  IS_GOVERNED_BY_SOLR_FIELD
38
34
  end
39
35
 
40
- # Returns the permissions solr document for policy_pid
36
+ # Returns the permissions solr document for policy_id
41
37
  # The document is stored in an instance variable, so calling this multiple times will only query solr once.
42
38
  # To force reload, set @policy_permissions_solr_cache to {}
43
- def policy_permissions_doc(policy_pid)
39
+ def policy_permissions_doc(policy_id)
44
40
  @policy_permissions_solr_cache ||= {}
45
- @policy_permissions_solr_cache[policy_pid] ||= get_permissions_solr_response_for_doc_id(policy_pid)
41
+ @policy_permissions_solr_cache[policy_id] ||= get_permissions_solr_response_for_doc_id(policy_id)
46
42
  end
47
43
 
48
44
  # Tests whether the object's governing policy object grants edit access for the current user
49
- def test_edit_from_policy(object_pid)
50
- policy_pid = policy_pid_for(object_pid)
51
- return false if policy_pid.nil?
52
- Rails.logger.debug("[CANCAN] -policy- Does the POLICY #{policy_pid} provide EDIT permissions for #{current_user.user_key}?")
53
- group_intersection = user_groups & edit_groups_from_policy( policy_pid )
54
- result = !group_intersection.empty? || edit_users_from_policy( policy_pid ).include?(current_user.user_key)
45
+ def test_edit_from_policy(object_id)
46
+ policy_id = policy_id_for(object_id)
47
+ return false if policy_id.nil?
48
+ Rails.logger.debug("[CANCAN] -policy- Does the POLICY #{policy_id} provide EDIT permissions for #{current_user.user_key}?")
49
+ group_intersection = user_groups & edit_groups_from_policy( policy_id )
50
+ result = !group_intersection.empty? || edit_users_from_policy( policy_id ).include?(current_user.user_key)
55
51
  Rails.logger.debug("[CANCAN] -policy- decision: #{result}")
56
52
  result
57
53
  end
58
54
 
59
55
  # Tests whether the object's governing policy object grants read access for the current user
60
- def test_read_from_policy(object_pid)
61
- policy_pid = policy_pid_for(object_pid)
62
- return false if policy_pid.nil?
63
- Rails.logger.debug("[CANCAN] -policy- Does the POLICY #{policy_pid} provide READ permissions for #{current_user.user_key}?")
64
- group_intersection = user_groups & read_groups_from_policy( policy_pid )
65
- result = !group_intersection.empty? || read_users_from_policy( policy_pid ).include?(current_user.user_key)
56
+ def test_read_from_policy(object_id)
57
+ policy_id = policy_id_for(object_id)
58
+ return false if policy_id.nil?
59
+ Rails.logger.debug("[CANCAN] -policy- Does the POLICY #{policy_id} provide READ permissions for #{current_user.user_key}?")
60
+ group_intersection = user_groups & read_groups_from_policy( policy_id )
61
+ result = !group_intersection.empty? || read_users_from_policy( policy_id ).include?(current_user.user_key)
66
62
  Rails.logger.debug("[CANCAN] -policy- decision: #{result}")
67
63
  result
68
64
  end
69
65
 
70
- # Returns the list of groups granted edit access by the policy object identified by policy_pid
71
- def edit_groups_from_policy(policy_pid)
72
- policy_permissions = policy_permissions_doc(policy_pid)
66
+ # Returns the list of groups granted edit access by the policy object identified by policy_id
67
+ def edit_groups_from_policy(policy_id)
68
+ policy_permissions = policy_permissions_doc(policy_id)
73
69
  edit_group_field = Hydra.config.permissions.inheritable[:edit][:group]
74
70
  eg = ((policy_permissions == nil || policy_permissions.fetch(edit_group_field,nil) == nil) ? [] : policy_permissions.fetch(edit_group_field,nil))
75
71
  Rails.logger.debug("[CANCAN] -policy- edit_groups: #{eg.inspect}")
76
72
  return eg
77
73
  end
78
74
 
79
- # Returns the list of groups granted read access by the policy object identified by policy_pid
75
+ # Returns the list of groups granted read access by the policy object identified by policy_id
80
76
  # Note: edit implies read, so read_groups is the union of edit and read groups
81
- def read_groups_from_policy(policy_pid)
82
- policy_permissions = policy_permissions_doc(policy_pid)
77
+ def read_groups_from_policy(policy_id)
78
+ policy_permissions = policy_permissions_doc(policy_id)
83
79
  read_group_field = Hydra.config.permissions.inheritable[:read][:group]
84
- rg = edit_groups_from_policy(policy_pid) | ((policy_permissions == nil || policy_permissions.fetch(read_group_field,nil) == nil) ? [] : policy_permissions.fetch(read_group_field,nil))
80
+ rg = edit_groups_from_policy(policy_id) | ((policy_permissions == nil || policy_permissions.fetch(read_group_field,nil) == nil) ? [] : policy_permissions.fetch(read_group_field,nil))
85
81
  Rails.logger.debug("[CANCAN] -policy- read_groups: #{rg.inspect}")
86
82
  return rg
87
83
  end
88
84
 
89
- def edit_persons_from_policy(policy_pid)
90
- Deprecation.warn(Hydra::PolicyAwareAbility, "The edit_persons_from_policy method is deprecated and will be removed from Hydra::PolicyAwareAbility in hydra-head 8.0. Use edit_users_from_policy instead.", caller)
91
- edit_users_from_policy(policy_pid)
92
- end
93
-
94
- # Returns the list of users granted edit access by the policy object identified by policy_pid
95
- def edit_users_from_policy(policy_pid)
96
- policy_permissions = policy_permissions_doc(policy_pid)
85
+ # Returns the list of users granted edit access by the policy object identified by policy_id
86
+ def edit_users_from_policy(policy_id)
87
+ policy_permissions = policy_permissions_doc(policy_id)
97
88
  edit_user_field = Hydra.config.permissions.inheritable[:edit][:individual]
98
89
  eu = ((policy_permissions == nil || policy_permissions.fetch(edit_user_field,nil) == nil) ? [] : policy_permissions.fetch(edit_user_field,nil))
99
90
  Rails.logger.debug("[CANCAN] -policy- edit_users: #{eu.inspect}")
100
91
  return eu
101
92
  end
102
93
 
103
- def read_persons_from_policy(policy_pid)
104
- Deprecation.warn(Hydra::PolicyAwareAbility, "The read_persons_from_policy method is deprecated and will be removed from Hydra::PolicyAwareAbility in hydra-head 8.0. Use read_users_from_policy instead.", caller)
105
- read_users_from_policy(policy_pid)
106
- end
107
-
108
- # Returns the list of users granted read access by the policy object identified by policy_pid
94
+ # Returns the list of users granted read access by the policy object identified by policy_id
109
95
  # Note: edit implies read, so read_users is the union of edit and read users
110
- def read_users_from_policy(policy_pid)
111
- policy_permissions = policy_permissions_doc(policy_pid)
96
+ def read_users_from_policy(policy_id)
97
+ policy_permissions = policy_permissions_doc(policy_id)
112
98
  read_user_field = Hydra.config.permissions.inheritable[:read][:individual]
113
- ru = edit_users_from_policy(policy_pid) | ((policy_permissions == nil || policy_permissions.fetch(read_user_field, nil) == nil) ? [] : policy_permissions.fetch(read_user_field, nil))
99
+ ru = edit_users_from_policy(policy_id) | ((policy_permissions == nil || policy_permissions.fetch(read_user_field, nil) == nil) ? [] : policy_permissions.fetch(read_user_field, nil))
114
100
  Rails.logger.debug("[CANCAN] -policy- read_users: #{ru.inspect}")
115
101
  return ru
116
102
  end
117
103
 
118
104
  private
119
105
 
120
- # Grabs the value of field_name from solr_result
121
- # @example
122
- # solr_result = Multiresimage.find_with_conditions({:id=>object_pid}, :fl=>'is_governed_by_ssim')
123
- # value_from_solr_field(solr_result, 'is_governed_by_ssim')
124
- # => ["info:fedora/changeme:2278"]
125
- def value_from_solr_field(solr_result, field_name)
126
- field_from_result = solr_result.select {|x| x.has_key?(field_name)}.first
127
- if field_from_result.nil?
128
- nil
129
- else
130
- field_from_result[field_name]
131
- end
132
- end
133
-
134
- def policy_pid_cache
135
- @policy_pid_cache ||= {}
106
+ def policy_id_cache
107
+ @policy_id_cache ||= {}
136
108
  end
137
109
 
138
110
  end
@@ -1,22 +1,21 @@
1
1
  # Repeats access controls evaluation methods, but checks against a governing "Policy" object (or "Collection" object) that provides inherited access controls.
2
2
  module Hydra::PolicyAwareAccessControlsEnforcement
3
- extend Deprecation
4
3
 
5
4
  # Extends Hydra::AccessControlsEnforcement.apply_gated_discovery to reflect policy-provided access
6
5
  # appends the result of policy_clauses into the :fq
7
6
  # @param solr_parameters the current solr parameters
8
7
  # @param user_parameters the current user-subitted parameters
9
- def apply_gated_discovery(solr_parameters, user_parameters)
8
+ def apply_gated_discovery(solr_parameters)
10
9
  solr_parameters[:fq] ||= []
11
- solr_parameters[:fq] << gated_discovery_filters.join(" OR ")
10
+ solr_parameters[:fq] << gated_discovery_filters.join(' OR '.freeze)
12
11
  logger.debug("POLICY-aware Solr parameters: #{ solr_parameters.inspect }")
13
12
  end
14
13
 
15
14
  # returns solr query for finding all objects whose policies grant discover access to current_user
16
15
  def policy_clauses
17
- policy_pids = policies_with_access
18
- return nil if policy_pids.empty?
19
- '(' + policy_pids.map {|pid| ActiveFedora::SolrQueryBuilder.construct_query_for_rel(is_governed_by: "info:fedora/#{pid}")}.join(' OR ') + ')'
16
+ policy_ids = policies_with_access
17
+ return nil if policy_ids.empty?
18
+ '(' + policy_ids.map {|id| ActiveFedora::SolrQueryBuilder.construct_query_for_rel(isGovernedBy: id)}.join(' OR '.freeze) + ')'
20
19
  end
21
20
 
22
21
  # find all the policies that grant discover/read/edit permissions to this user or any of its groups
@@ -31,11 +30,6 @@ module Hydra::PolicyAwareAccessControlsEnforcement
31
30
  result.map {|h| h['id']}
32
31
  end
33
32
 
34
- def apply_policy_role_permissions(permission_types = discovery_permissions)
35
- Deprecation.warn(Hydra::PolicyAwareAccessControlsEnforcement, "The method apply_policy_role_permissions is deprecated and will be removed from Hydra::PolicyAwareAccessControlsEnforcement in hydra-head 8.0. Use apply_policy_group_permissions instead.", caller)
36
- apply_policy_group_permissions(permission_types)
37
- end
38
-
39
33
  def apply_policy_group_permissions(permission_types = discovery_permissions)
40
34
  # for groups
41
35
  user_access_filters = []
@@ -47,20 +41,13 @@ module Hydra::PolicyAwareAccessControlsEnforcement
47
41
  user_access_filters
48
42
  end
49
43
 
50
- def apply_policy_individual_permissions(permission_types = discovery_permissions)
51
- Deprecation.warn(Hydra::PolicyAwareAccessControlsEnforcement, "The method apply_policy_individual_permissions is deprecated and will be removed from Hydra::PolicyAwareAccessControlsEnforcement in hydra-head 8.0. Use apply_policy_user_permissions instead.", caller)
52
- apply_policy_user_permissions(permission_types)
53
- end
54
-
55
44
  def apply_policy_user_permissions(permission_types = discovery_permissions)
56
45
  # for individual user access
57
- user_access_filters = []
58
- if current_user
59
- permission_types.each do |type|
60
- user_access_filters << escape_filter(Hydra.config.permissions.inheritable[type.to_sym].individual, current_user.user_key)
61
- end
46
+ user = current_ability.current_user
47
+ return [] unless user && user.user_key.present?
48
+ permission_types.map do |type|
49
+ escape_filter(Hydra.config.permissions.inheritable[type.to_sym].individual, user.user_key)
62
50
  end
63
- user_access_filters
64
51
  end
65
52
 
66
53
  # Returns the Model used for AdminPolicy objects.
@@ -36,7 +36,7 @@ describe Hydra::PolicyAwareAbility do
36
36
 
37
37
  subject { PolicyAwareClass.new( User.new ) }
38
38
 
39
- describe "policy_pid_for" do
39
+ describe "policy_id_for" do
40
40
  before do
41
41
  @policy2 = Hydra::AdminPolicy.create
42
42
  @policy2.default_permissions.create [
@@ -54,9 +54,9 @@ describe Hydra::PolicyAwareAbility do
54
54
  end
55
55
 
56
56
  it "should retrieve the pid doc for the current object's governing policy" do
57
- expect(subject.policy_pid_for(@asset.id)).to eq @policy.id
58
- expect(subject.policy_pid_for(@asset2.id)).to eq @policy2.id
59
- expect(subject.policy_pid_for(@asset3.id)).to be_nil
57
+ expect(subject.policy_id_for(@asset.id)).to eq @policy.id
58
+ expect(subject.policy_id_for(@asset2.id)).to eq @policy2.id
59
+ expect(subject.policy_id_for(@asset3.id)).to be_nil
60
60
  end
61
61
  end
62
62
 
@@ -2,13 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  describe Hydra::PolicyAwareAccessControlsEnforcement do
4
4
  before do
5
- class PolicyMockController
5
+ class PolicyMockSearchBuilder
6
6
  include Hydra::AccessControlsEnforcement
7
7
  include Hydra::PolicyAwareAccessControlsEnforcement
8
8
  attr_accessor :params
9
9
 
10
+ def initialize(current_ability)
11
+ @current_ability = current_ability
12
+ end
13
+
10
14
  def current_ability
11
- @current_ability ||= Ability.new(current_user)
15
+ @current_ability
12
16
  end
13
17
 
14
18
  def session
@@ -16,7 +20,6 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
16
20
 
17
21
  delegate :logger, to: :Rails
18
22
  end
19
-
20
23
  @sample_policies = []
21
24
  # user discover
22
25
  policy1 = Hydra::AdminPolicy.create("test-policy1")
@@ -84,19 +87,18 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
84
87
  @policies_with_access = @sample_policies.select { |p| p.id != policy_no_access.id }
85
88
  end
86
89
 
87
- subject { PolicyMockController.new }
90
+ let(:current_ability) { Ability.new(user) }
91
+ subject { PolicyMockSearchBuilder.new(current_ability) }
92
+ let(:user) { FactoryGirl.build(:sara_student) }
88
93
 
89
94
  before do
90
95
  @solr_parameters = {}
91
- @user_parameters = {}
92
- @user = FactoryGirl.build(:sara_student)
93
96
  end
94
97
 
95
98
  describe "policies_with_access" do
96
99
  context "Authenticated user" do
97
100
  before do
98
- allow(RoleMapper).to receive(:roles).with(@user).and_return(@user.roles)
99
- allow(subject).to receive(:current_user).and_return(@user)
101
+ allow(RoleMapper).to receive(:roles).with(user).and_return(user.roles)
100
102
  end
101
103
  it "should return the policies that provide discover permissions" do
102
104
  @policies_with_access.map {|p| p.id }.each do |p|
@@ -111,7 +113,7 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
111
113
  end
112
114
  end
113
115
  context "Anonymous user" do
114
- before { allow(subject).to receive(:current_user).and_return(nil) }
116
+ let(:user) { nil }
115
117
  it "should return the policies that provide discover permissions" do
116
118
  expect(subject.policies_with_access).to match_array ["test-policy7", "test-policy8"]
117
119
  end
@@ -120,33 +122,28 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
120
122
 
121
123
  describe "apply_gated_discovery" do
122
124
  before do
123
- allow(RoleMapper).to receive(:roles).with(@user).and_return(@user.roles)
124
- allow(subject).to receive(:current_user).and_return(@user)
125
+ allow(RoleMapper).to receive(:roles).with(user).and_return(user.roles)
125
126
  end
127
+ let(:governed_field) { ActiveFedora::SolrQueryBuilder.solr_name('isGovernedBy', :symbol) }
126
128
 
127
129
  it "should include policy-aware query" do
128
130
  # stubbing out policies_with_access because solr doesn't always return them in the same order.
129
- policy_ids = (1..8).map {|n| "test:policy#{n}"}
131
+ policy_ids = (1..8).map {|n| "policies/#{n}"}
130
132
  expect(subject).to receive(:policies_with_access).and_return(policy_ids)
131
- subject.apply_gated_discovery(@solr_parameters, @user_parameters)
132
- governed_field = ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)
133
- expect(@solr_parameters[:fq].first).to 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\")")
133
+ subject.apply_gated_discovery(@solr_parameters)
134
+ expect(@solr_parameters[:fq].first).to include(" OR (_query_:\"{!raw f=#{governed_field}}policies/1\" OR _query_:\"{!raw f=#{governed_field}}policies/2\" OR _query_:\"{!raw f=#{governed_field}}policies/3\" OR _query_:\"{!raw f=#{governed_field}}policies/4\" OR _query_:\"{!raw f=#{governed_field}}policies/5\" OR _query_:\"{!raw f=#{governed_field}}policies/6\" OR _query_:\"{!raw f=#{governed_field}}policies/7\" OR _query_:\"{!raw f=#{governed_field}}policies/8\")")
134
135
  end
135
136
 
136
137
  it "should not change anything if there are no clauses to add" do
137
138
  allow(subject).to receive(:policy_clauses).and_return(nil)
138
- subject.apply_gated_discovery(@solr_parameters, @user_parameters)
139
- expect(@solr_parameters[:fq].first).to_not include(" OR (#{ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy1 OR #{ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy2 OR #{ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy3 OR #{ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy4 OR #{ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy5 OR #{ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy6 OR #{ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy7 OR #{ActiveFedora::SolrQueryBuilder.solr_name('is_governed_by', :symbol)}:info\\:fedora\\/test\\:policy8)")
139
+ subject.apply_gated_discovery(@solr_parameters)
140
+ expect(@solr_parameters[:fq].first).not_to include(" OR (_query_:\"{!raw f=#{governed_field}}policies/1\" OR _query_:\"{!raw f=#{governed_field}}policies/2\" OR _query_:\"{!raw f=#{governed_field}}policies/3\" OR _query_:\"{!raw f=#{governed_field}}policies/4\" OR _query_:\"{!raw f=#{governed_field}}policies/5\" OR _query_:\"{!raw f=#{governed_field}}policies/6\" OR _query_:\"{!raw f=#{governed_field}}policies/7\" OR _query_:\"{!raw f=#{governed_field}}policies/8\")")
140
141
  end
141
142
  end
142
143
 
143
144
  describe "apply_policy_role_permissions" do
144
- before do
145
- allow(subject).to receive(:current_user).and_return(@user)
146
- end
147
-
148
145
  it "should escape slashes in the group names" do
149
- allow(RoleMapper).to receive(:roles).with(@user).and_return(["abc/123","cde/567"])
146
+ allow(RoleMapper).to receive(:roles).with(user).and_return(["abc/123","cde/567"])
150
147
  user_access_filters = subject.apply_policy_group_permissions
151
148
  ["edit","discover","read"].each do |type|
152
149
  expect(user_access_filters).to include("inheritable_#{type}_access_group_ssim\:abc\\\/123")
@@ -155,7 +152,7 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
155
152
  end
156
153
 
157
154
  it "should escape spaces in the group names" do
158
- allow(RoleMapper).to receive(:roles).with(@user).and_return(["abc 123","cd/e 567"])
155
+ allow(RoleMapper).to receive(:roles).with(user).and_return(["abc 123","cd/e 567"])
159
156
  user_access_filters = subject.apply_policy_group_permissions
160
157
  ["edit","discover","read"].each do |type|
161
158
  expect(user_access_filters).to include("inheritable_#{type}_access_group_ssim\:abc\\ 123")
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: 9.1.0
4
+ version: 9.1.1
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-06 00:00:00.000000000 Z
13
+ date: 2015-03-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport