hydra-access-controls 5.0.0.pre9 → 5.0.0.pre10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +0 -2
- data/lib/hydra-access-controls.rb +3 -0
- data/lib/hydra/datastream/inheritable_rights_metadata.rb +1 -2
- data/lib/hydra/datastream/rights_metadata.rb +15 -2
- data/spec/unit/ability_spec.rb +0 -2
- data/spec/unit/admin_policy_spec.rb +1 -6
- data/spec/unit/inheritable_rights_metadata_spec.rb +0 -4
- data/spec/unit/policy_aware_ability_spec.rb +0 -2
- data/spec/unit/rights_metadata_spec.rb +16 -0
- metadata +2 -2
data/README.textile
CHANGED
@@ -66,7 +66,6 @@ Hydra uses its own set of default solr field names to track rights-related metad
|
|
66
66
|
Hydra.configure(:shared) do |config|
|
67
67
|
# ... other stuff ...
|
68
68
|
config[:permissions] = {
|
69
|
-
:catchall => "access_t",
|
70
69
|
:discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
|
71
70
|
:read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
|
72
71
|
:edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
|
@@ -74,7 +73,6 @@ Hydra uses its own set of default solr field names to track rights-related metad
|
|
74
73
|
:embargo_release_date => "embargo_release_date_dt"
|
75
74
|
}
|
76
75
|
config[:permissions][:inheritable] = {
|
77
|
-
:catchall => "inheritable_access_t",
|
78
76
|
:discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
|
79
77
|
:read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
|
80
78
|
:edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'active_support'
|
2
|
+
# TODO would it be possible to put the require fedora in an after_initialize block like this?
|
3
|
+
#ActiveSupport.on_load(:after_initialize) do
|
4
|
+
# This would allow solrizer to load it's config files after the rails logger is up.
|
2
5
|
require 'active-fedora'
|
3
6
|
require 'cancan'
|
4
7
|
|
@@ -7,7 +7,6 @@ module Hydra
|
|
7
7
|
@terminology = Hydra::Datastream::RightsMetadata.terminology
|
8
8
|
|
9
9
|
def to_solr(solr_doc=Hash.new)
|
10
|
-
solr_doc["inheritable_access_t"] = access.machine.group.val + access.machine.person.val
|
11
10
|
solr_doc["inheritable_discover_access_group_t"] = discover_access.machine.group
|
12
11
|
solr_doc["inheritable_discover_access_person_t"] = discover_access.machine.person
|
13
12
|
solr_doc["inheritable_read_access_group_t"] = read_access.machine.group
|
@@ -19,4 +18,4 @@ module Hydra
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
22
|
-
end
|
21
|
+
end
|
@@ -21,7 +21,7 @@ module Hydra
|
|
21
21
|
t.description(:path=>'human', :attributes=>{:type=>'description'})
|
22
22
|
t.url(:path=>'machine', :attributes=>{:type=>'uri'})
|
23
23
|
}
|
24
|
-
t.access
|
24
|
+
t.access do
|
25
25
|
t.human_readable(:path=>"human")
|
26
26
|
t.machine {
|
27
27
|
t.group
|
@@ -30,7 +30,7 @@ module Hydra
|
|
30
30
|
t.person(:proxy=>[:machine, :person])
|
31
31
|
t.group(:proxy=>[:machine, :group])
|
32
32
|
# accessor :access_person, :term=>[:access, :machine, :person]
|
33
|
-
|
33
|
+
end
|
34
34
|
t.discover_access(:ref=>[:access], :attributes=>{:type=>"discover"})
|
35
35
|
t.read_access(:ref=>[:access], :attributes=>{:type=>"read"})
|
36
36
|
t.edit_access(:ref=>[:access], :attributes=>{:type=>"edit"})
|
@@ -175,6 +175,19 @@ module Hydra
|
|
175
175
|
|
176
176
|
def to_solr(solr_doc=Hash.new)
|
177
177
|
super(solr_doc)
|
178
|
+
vals = edit_access.machine.group
|
179
|
+
solr_doc['edit_access_group_t'] = vals unless vals.empty?
|
180
|
+
vals = discover_access.machine.group
|
181
|
+
solr_doc['discover_access_group_t'] = vals unless vals.empty?
|
182
|
+
vals = read_access.machine.group
|
183
|
+
solr_doc['read_access_group_t'] = vals unless vals.empty?
|
184
|
+
vals = edit_access.machine.person
|
185
|
+
solr_doc['edit_access_person_t'] = vals unless vals.empty?
|
186
|
+
vals = discover_access.machine.person
|
187
|
+
solr_doc['discover_access_person_t'] = vals unless vals.empty?
|
188
|
+
vals = read_access.machine.person
|
189
|
+
solr_doc['read_access_person_t'] = vals unless vals.empty?
|
190
|
+
|
178
191
|
::Solrizer::Extractor.insert_solr_field_value(solr_doc, "embargo_release_date_dt", embargo_release_date(:format=>:solr_date)) if embargo_release_date
|
179
192
|
solr_doc
|
180
193
|
end
|
data/spec/unit/ability_spec.rb
CHANGED
@@ -5,7 +5,6 @@ describe Ability do
|
|
5
5
|
before do
|
6
6
|
Hydra.stub(:config).and_return({
|
7
7
|
:permissions=>{
|
8
|
-
:catchall => "access_t",
|
9
8
|
:discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
|
10
9
|
:read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
|
11
10
|
:edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
|
@@ -13,7 +12,6 @@ describe Ability do
|
|
13
12
|
:embargo_release_date => "embargo_release_date_dt",
|
14
13
|
|
15
14
|
:inheritable => {
|
16
|
-
:catchall => "inheritable_access_t",
|
17
15
|
:discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
|
18
16
|
:read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
|
19
17
|
:edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
|
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe Hydra::AdminPolicy do
|
4
4
|
before do
|
5
5
|
Hydra.stub(:config).and_return({:permissions=>{
|
6
|
-
:catchall => "access_t",
|
7
6
|
:discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
|
8
7
|
:read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
|
9
8
|
:edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
|
@@ -11,7 +10,6 @@ describe Hydra::AdminPolicy do
|
|
11
10
|
:embargo_release_date => "embargo_release_date_dt",
|
12
11
|
|
13
12
|
:inheritable => {
|
14
|
-
:catchall => "inheritable_access_t",
|
15
13
|
:discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
|
16
14
|
:read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
|
17
15
|
:edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
|
@@ -62,7 +60,7 @@ describe Hydra::AdminPolicy do
|
|
62
60
|
describe "to_solr" do
|
63
61
|
subject {@policy.to_solr}
|
64
62
|
it "should not affect normal solr permissions fields" do
|
65
|
-
|
63
|
+
puts subject
|
66
64
|
subject.should_not have_key( Hydra.config[:permissions][:discover][:group] )
|
67
65
|
subject.should_not have_key( Hydra.config[:permissions][:discover][:individual] )
|
68
66
|
subject.should_not have_key( Hydra.config[:permissions][:read][:group] )
|
@@ -72,9 +70,6 @@ describe Hydra::AdminPolicy do
|
|
72
70
|
subject.should_not have_key( Hydra.config[:permissions][:embargo_release_date] )
|
73
71
|
end
|
74
72
|
it "should provide prefixed/inherited solr permissions fields" do
|
75
|
-
catchall = Hydra.config[:permissions][:inheritable][:catchall]
|
76
|
-
subject[catchall].should have(7).items
|
77
|
-
subject[catchall].should include("posers", "slightlycoolkids", "africana-faculty", "cool-kids", "constantine", "nero", "julius_caesar")
|
78
73
|
subject[Hydra.config[:permissions][:inheritable][:discover][:group] ].should == ["posers"]
|
79
74
|
subject[Hydra.config[:permissions][:inheritable][:discover][:individual] ].should == ["constantine"]
|
80
75
|
subject[Hydra.config[:permissions][:inheritable][:read][:group] ].should == ["slightlycoolkids"]
|
@@ -4,7 +4,6 @@ require "nokogiri"
|
|
4
4
|
describe Hydra::Datastream::InheritableRightsMetadata do
|
5
5
|
before do
|
6
6
|
Hydra.stub(:config).and_return({:permissions=>{
|
7
|
-
:catchall => "access_t",
|
8
7
|
:discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
|
9
8
|
:read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
|
10
9
|
:edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
|
@@ -12,7 +11,6 @@ describe Hydra::Datastream::InheritableRightsMetadata do
|
|
12
11
|
:embargo_release_date => "embargo_release_date_dt",
|
13
12
|
|
14
13
|
:inheritable => {
|
15
|
-
:catchall => "inheritable_access_t",
|
16
14
|
:discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
|
17
15
|
:read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
|
18
16
|
:edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
|
@@ -42,7 +40,6 @@ describe Hydra::Datastream::InheritableRightsMetadata do
|
|
42
40
|
describe "to_solr" do
|
43
41
|
subject {@sample.to_solr}
|
44
42
|
it "should NOT provide normal solr permissions fields" do
|
45
|
-
subject.should_not have_key( Hydra.config[:permissions][:catchall] )
|
46
43
|
subject.should_not have_key( Hydra.config[:permissions][:discover][:group] )
|
47
44
|
subject.should_not have_key( Hydra.config[:permissions][:discover][:individual] )
|
48
45
|
subject.should_not have_key( Hydra.config[:permissions][:read][:group] )
|
@@ -52,7 +49,6 @@ describe Hydra::Datastream::InheritableRightsMetadata do
|
|
52
49
|
subject.should_not have_key( Hydra.config[:permissions][:embargo_release_date] )
|
53
50
|
end
|
54
51
|
it "should provide prefixed/inherited solr permissions fields" do
|
55
|
-
subject[Hydra.config[:permissions][:inheritable][:catchall] ].should == ["posers", "slightly-cool-kids", "africana-faculty", "cool-kids", "constantine", "nero", "julius_caesar"]
|
56
52
|
subject[Hydra.config[:permissions][:inheritable][:discover][:group] ].should == ["posers"]
|
57
53
|
subject[Hydra.config[:permissions][:inheritable][:discover][:individual] ].should == ["constantine"]
|
58
54
|
subject[Hydra.config[:permissions][:inheritable][:read][:group] ].should == ["slightly-cool-kids"]
|
@@ -4,7 +4,6 @@ describe Hydra::PolicyAwareAbility do
|
|
4
4
|
before do
|
5
5
|
Hydra.stub(:config).and_return({
|
6
6
|
:permissions=>{
|
7
|
-
:catchall => "access_t",
|
8
7
|
:discover => {:group =>"discover_access_group_t", :individual=>"discover_access_person_t"},
|
9
8
|
:read => {:group =>"read_access_group_t", :individual=>"read_access_person_t"},
|
10
9
|
:edit => {:group =>"edit_access_group_t", :individual=>"edit_access_person_t"},
|
@@ -12,7 +11,6 @@ describe Hydra::PolicyAwareAbility do
|
|
12
11
|
:embargo_release_date => "embargo_release_date_dt",
|
13
12
|
|
14
13
|
:inheritable => {
|
15
|
-
:catchall => "inheritable_access_t",
|
16
14
|
:discover => {:group =>"inheritable_discover_access_group_t", :individual=>"inheritable_discover_access_person_t"},
|
17
15
|
:read => {:group =>"inheritable_read_access_group_t", :individual=>"inheritable_read_access_person_t"},
|
18
16
|
:edit => {:group =>"inheritable_edit_access_group_t", :individual=>"inheritable_edit_access_person_t"},
|
@@ -47,6 +47,22 @@ describe Hydra::ModelMixins::RightsMetadata do
|
|
47
47
|
|
48
48
|
end
|
49
49
|
|
50
|
+
context "to_solr" do
|
51
|
+
before do
|
52
|
+
subject.rightsMetadata.update_permissions("person"=>{"person1"=>"read","person2"=>"discover"}, "group"=>{'group-6' => 'read', "group-7"=>'read', 'group-8'=>'edit'})
|
53
|
+
end
|
54
|
+
it "should produce a solr document" do
|
55
|
+
result = subject.rightsMetadata.to_solr
|
56
|
+
result.size.should == 4
|
57
|
+
## Wrote the test in this way, because the implementation uses a hash, and the hash order is not deterministic (especially in ruby 1.8.7)
|
58
|
+
result['read_access_group_t'].size.should == 2
|
59
|
+
result['read_access_group_t'].should include('group-6', 'group-7')
|
60
|
+
result['edit_access_group_t'].should == ['group-8']
|
61
|
+
result['discover_access_person_t'].should == ['person2']
|
62
|
+
result['read_access_person_t'].should == ['person1']
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
50
66
|
context "with rightsMetadata" do
|
51
67
|
before do
|
52
68
|
subject.rightsMetadata.update_permissions("person"=>{"person1"=>"read","person2"=>"discover"}, "group"=>{'group-6' => 'read', "group-7"=>'read', 'group-8'=>'edit'})
|
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: 5.0.0.
|
4
|
+
version: 5.0.0.pre10
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-10-
|
14
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|