hydra-access-controls 6.2.1 → 6.2.2

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: 5d7ec1b3adb389dc48bd7289d972644827be5eb2
4
- data.tar.gz: 9f8137ca800cfa87d14ab4eeebe68d1a55b9280d
3
+ metadata.gz: a9ab5ff5dd113d153750288e038a75ab36d53ed9
4
+ data.tar.gz: db5e2a8772177b3e2df411f1dc711a807a0209b8
5
5
  SHA512:
6
- metadata.gz: cbdbde25b685579b8f9685d65c9f6ef9d84669ff1db988c1ca5eac3a6d66f6a271e9fbf686856de5292c122d0a5538617133591f78c1de4ef4d85ae1918831a6
7
- data.tar.gz: 37e07d96b2fe872966d00eb2fda3e87c7d7b30be1e664ac23e07a0760cae70bf05303da96eec601b96706141e86494b392502427a497a7e90d5bbb0477d5f631
6
+ metadata.gz: 23003e32b9a7a0db212091222726077bd2f1c336ab1f5d037296a945fe58b653f60fe2e71c6f2f840c0886e161679d58e436abc6597fbf2d932e42985129a567
7
+ data.tar.gz: d0ae6b4160474dd0500c383e7c66ec3b424926f351f7cb4c2a27b548b9cbe1a990db1481966e7911a3ccff5fcb94ca2e3378089c515a91cbeb14da4519003d27
@@ -98,7 +98,7 @@ module Hydra
98
98
  type = selector.keys.first.to_sym
99
99
  actor = selector.values.first
100
100
  if new_access_level.nil?
101
- xpath = self.class.terminology.xpath_for(:access, type, actor)
101
+ xpath = xpath(type, actor)
102
102
  nodeset = self.find_by_terms(xpath)
103
103
  if nodeset.empty?
104
104
  return "none"
@@ -224,10 +224,22 @@ module Hydra
224
224
  return unless ng_xml
225
225
  type = selector.keys.first.to_sym
226
226
  actor = selector.values.first
227
- xpath = self.class.terminology.xpath_for(:access, type, actor)
227
+ xpath = xpath(type, actor)
228
228
  nodes_to_purge = self.find_by_terms(xpath)
229
229
  nodes_to_purge.each {|node| node.remove}
230
230
  end
231
+
232
+ # @param [Symbol] type (:group, :person)
233
+ # @param [String,TrueClass] actor the user we want to find. If actor is true, then don't query.
234
+ def xpath(type, actor)
235
+ raise ArgumentError, "Type must either be ':group' or ':person'. You provided: '#{type.inspect}'" unless [:group, :person].include?(type)
236
+ path = "//oxns:access/oxns:machine/oxns:#{type}"
237
+ if actor.is_a? String
238
+ clean_actor = actor.gsub("'", '')
239
+ path += "[text() = '#{clean_actor}']"
240
+ end
241
+ path
242
+ end
231
243
 
232
244
  end
233
245
  end
@@ -120,7 +120,8 @@ describe Hydra::PolicyAwareAccessControlsEnforcement do
120
120
  policy_pids = (1..8).map {|n| "test:policy#{n}"}
121
121
  subject.should_receive(:policies_with_access).and_return(policy_pids)
122
122
  subject.apply_gated_discovery(@solr_parameters, @user_parameters)
123
- @solr_parameters[:fq].first.should 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)")
123
+ governed_field = ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)
124
+ @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\")")
124
125
  end
125
126
  it "should not change anything if there are no clauses to add" do
126
127
  subject.stub(:policy_clauses).and_return(nil)
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: 6.2.1
4
+ version: 6.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer