hydra-access-controls 6.2.1 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9ab5ff5dd113d153750288e038a75ab36d53ed9
|
4
|
+
data.tar.gz: db5e2a8772177b3e2df411f1dc711a807a0209b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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 =
|
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
|
-
|
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)
|