hydra-access-controls 6.0.0.rc1 → 6.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hydra/datastream/rights_metadata.rb +1 -1
- data/spec/unit/ability_spec.rb +11 -11
- data/spec/unit/access_controls_enforcement_spec.rb +12 -12
- data/spec/unit/admin_policy_spec.rb +9 -9
- data/spec/unit/hydra_rights_metadata_spec.rb +8 -8
- data/spec/unit/inheritable_rights_metadata_spec.rb +8 -8
- data/spec/unit/policy_aware_ability_spec.rb +8 -8
- data/spec/unit/rights_metadata_spec.rb +5 -5
- metadata +2 -2
data/spec/unit/ability_spec.rb
CHANGED
@@ -4,17 +4,17 @@ describe Ability do
|
|
4
4
|
before do
|
5
5
|
Hydra.stub(:config).and_return({
|
6
6
|
:permissions=>{
|
7
|
-
:discover => {:group =>"
|
8
|
-
:read => {:group =>"
|
9
|
-
:edit => {:group =>"
|
7
|
+
:discover => {:group =>"discover_access_group_ssim", :individual=>"discover_access_person_ssim"},
|
8
|
+
:read => {:group =>"read_access_group_ssim", :individual=>"read_access_person_ssim"},
|
9
|
+
:edit => {:group =>"edit_access_group_ssim", :individual=>"edit_access_person_ssim"},
|
10
10
|
:owner => "depositor_t",
|
11
11
|
:embargo_release_date => "embargo_release_date_dtsi",
|
12
12
|
|
13
13
|
:inheritable => {
|
14
|
-
:discover => {:group =>"
|
15
|
-
:read => {:group =>"
|
16
|
-
:edit => {:group =>"
|
17
|
-
:owner => "
|
14
|
+
:discover => {:group =>"inheritable_discover_access_group_ssim", :individual=>"inheritable_discover_access_person_ssim"},
|
15
|
+
:read => {:group =>"inheritable_read_access_group_ssim", :individual=>"inheritable_read_access_person_ssim"},
|
16
|
+
:edit => {:group =>"inheritable_edit_access_group_ssim", :individual=>"inheritable_edit_access_person_ssim"},
|
17
|
+
:owner => "inheritable_depositor_ssim",
|
18
18
|
:embargo_release_date => "inheritable_embargo_release_date_dtsi"
|
19
19
|
}
|
20
20
|
}})
|
@@ -22,10 +22,10 @@ describe Ability do
|
|
22
22
|
|
23
23
|
describe "class methods" do
|
24
24
|
subject { Ability }
|
25
|
-
its(:read_group_field) { should == '
|
26
|
-
its(:read_person_field) { should == '
|
27
|
-
its(:edit_group_field) { should == '
|
28
|
-
its(:edit_person_field) { should == '
|
25
|
+
its(:read_group_field) { should == 'read_access_group_ssim'}
|
26
|
+
its(:read_person_field) { should == 'read_access_person_ssim'}
|
27
|
+
its(:edit_group_field) { should == 'edit_access_group_ssim'}
|
28
|
+
its(:edit_person_field) { should == 'edit_access_person_ssim'}
|
29
29
|
end
|
30
30
|
|
31
31
|
context "for a not-signed in user" do
|
@@ -28,7 +28,7 @@ describe Hydra::AccessControlsEnforcement do
|
|
28
28
|
end
|
29
29
|
it "Then I should be treated as a member of the 'public' group" do
|
30
30
|
["discover","edit","read"].each do |type|
|
31
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
31
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_ssim\:public/)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
it "Then I should not be treated as a member of the 'registered' group" do
|
@@ -48,19 +48,19 @@ describe Hydra::AccessControlsEnforcement do
|
|
48
48
|
end
|
49
49
|
it "Then I should be treated as a member of the 'public' and 'registered' groups" do
|
50
50
|
["discover","edit","read"].each do |type|
|
51
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
52
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
51
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_ssim\:public/)
|
52
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_ssim\:registered/)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
it "Then I should see assets that I have discover, read, or edit access to" do
|
56
56
|
["discover","edit","read"].each do |type|
|
57
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
57
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_person_ssim\:#{@user.user_key}/)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
it "Then I should see assets that my groups have discover, read, or edit access to" do
|
61
61
|
["faculty", "africana-faculty"].each do |group_id|
|
62
62
|
["discover","edit","read"].each do |type|
|
63
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
63
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_ssim\:#{group_id}/)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -73,7 +73,7 @@ describe Hydra::AccessControlsEnforcement do
|
|
73
73
|
RoleMapper.stub(:roles).with(user.user_key).and_return(["archivist"])
|
74
74
|
subject.stub(:current_user).and_return(user)
|
75
75
|
subject.stub(:can?).with(:read, nil).and_return(true)
|
76
|
-
stub_doc = Hydra::PermissionsSolrDocument.new({"
|
76
|
+
stub_doc = Hydra::PermissionsSolrDocument.new({"edit_access_person_ssim"=>["testuser@example.com"], "embargo_release_date_dtsi"=>(Date.parse(Time.now.to_s)+2).to_s})
|
77
77
|
|
78
78
|
subject.params = {}
|
79
79
|
subject.should_receive(:can?).with(:edit, stub_doc).and_return(true)
|
@@ -87,7 +87,7 @@ describe Hydra::AccessControlsEnforcement do
|
|
87
87
|
subject.stub(:current_user).and_return(user)
|
88
88
|
subject.stub(:can?).with(:read, nil).and_return(true)
|
89
89
|
subject.params = {}
|
90
|
-
stub_doc = Hydra::PermissionsSolrDocument.new({"
|
90
|
+
stub_doc = Hydra::PermissionsSolrDocument.new({"edit_access_person_ssim"=>["testuser@example.com"], "embargo_release_date_dtsi"=>(Date.parse(Time.now.to_s)+2).to_s})
|
91
91
|
subject.should_receive(:can?).with(:edit, stub_doc).and_return(false)
|
92
92
|
subject.should_receive(:get_permissions_solr_response_for_doc_id).and_return(stub_doc)
|
93
93
|
lambda {subject.send(:enforce_show_permissions, {})}.should raise_error Hydra::AccessDenied, "This item is under embargo. You do not have sufficient access privileges to read this document."
|
@@ -104,14 +104,14 @@ describe Hydra::AccessControlsEnforcement do
|
|
104
104
|
it "should set query fields for the user id checking against the discover, access, read fields" do
|
105
105
|
subject.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
106
106
|
["discover","edit","read"].each do |type|
|
107
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
107
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_person_ssim\:#{@stub_user.user_key}/)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
it "should set query fields for all roles the user is a member of checking against the discover, access, read fields" do
|
111
111
|
subject.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
112
112
|
["discover","edit","read"].each do |type|
|
113
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
114
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
113
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_ssim\:archivist/)
|
114
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_ssim\:researcher/)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -119,8 +119,8 @@ describe Hydra::AccessControlsEnforcement do
|
|
119
119
|
RoleMapper.stub(:roles).with(@stub_user.user_key).and_return(["abc/123","cde/567"])
|
120
120
|
subject.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
121
121
|
["discover","edit","read"].each do |type|
|
122
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
123
|
-
@solr_parameters[:fq].first.should match(/#{type}
|
122
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_ssim\:abc\\\/123/)
|
123
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_ssim\:cde\\\/567/)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Hydra::AdminPolicy do
|
4
4
|
before do
|
5
5
|
Hydra.stub(:config).and_return({:permissions=>{
|
6
|
-
:discover => {:group =>"
|
7
|
-
:read => {:group =>"
|
8
|
-
:edit => {:group =>"
|
9
|
-
:owner => "
|
6
|
+
:discover => {:group =>"discover_access_group_ssim", :individual=>"discover_access_person_ssim"},
|
7
|
+
:read => {:group =>"read_access_group_ssim", :individual=>"read_access_person_ssim"},
|
8
|
+
:edit => {:group =>"edit_access_group_ssim", :individual=>"edit_access_person_ssim"},
|
9
|
+
:owner => "depositor_ssim",
|
10
10
|
:embargo_release_date => "embargo_release_date_dtsi",
|
11
11
|
|
12
12
|
:inheritable => {
|
13
|
-
:discover => {:group =>"
|
14
|
-
:read => {:group =>"
|
15
|
-
:edit => {:group =>"
|
16
|
-
:owner => "
|
13
|
+
:discover => {:group =>"inheritable_discover_access_group_ssim", :individual=>"inheritable_discover_access_person_ssim"},
|
14
|
+
:read => {:group =>"inheritable_read_access_group_ssim", :individual=>"inheritable_read_access_person_ssim"},
|
15
|
+
:edit => {:group =>"inheritable_edit_access_group_ssim", :individual=>"inheritable_edit_access_person_ssim"},
|
16
|
+
:owner => "inheritable_depositor_ssim",
|
17
17
|
:embargo_release_date => "inheritable_embargo_release_date_dtsi"
|
18
18
|
}
|
19
19
|
}})
|
@@ -40,7 +40,7 @@ describe Hydra::AdminPolicy do
|
|
40
40
|
|
41
41
|
describe "to_solr" do
|
42
42
|
subject { Hydra::AdminPolicy.new(:title=>"Foobar").to_solr }
|
43
|
-
it "should have
|
43
|
+
it "should have title_ssim" do
|
44
44
|
subject[ActiveFedora::SolrService.solr_name('title', type: :string)].should == ["Foobar"]
|
45
45
|
end
|
46
46
|
end
|
@@ -153,10 +153,10 @@ describe Hydra::Datastream::RightsMetadata do
|
|
153
153
|
@sample.update_values(params)
|
154
154
|
solr_doc = @sample.to_solr
|
155
155
|
|
156
|
-
solr_doc["
|
157
|
-
solr_doc["
|
158
|
-
solr_doc["
|
159
|
-
solr_doc["
|
156
|
+
solr_doc["edit_access_person_ssim"].should == ["Lil Kim"]
|
157
|
+
solr_doc["edit_access_group_ssim"].sort.should == ["group1", "group2"]
|
158
|
+
solr_doc["discover_access_person_ssim"].should == ["Joe Schmoe"]
|
159
|
+
solr_doc["discover_access_group_ssim"].should == ["public"]
|
160
160
|
end
|
161
161
|
it "should solrize fixture content correctly" do
|
162
162
|
lsample = Hydra::Datastream::RightsMetadata.new(nil, nil)
|
@@ -164,10 +164,10 @@ describe Hydra::Datastream::RightsMetadata do
|
|
164
164
|
'group' => {'archivist' => 'edit', 'public' =>'read', 'bob'=>'discover'}})
|
165
165
|
|
166
166
|
solr_doc = lsample.to_solr
|
167
|
-
solr_doc["
|
168
|
-
solr_doc["
|
169
|
-
solr_doc["
|
170
|
-
solr_doc["
|
167
|
+
solr_doc["edit_access_person_ssim"].should == ["researcher1"]
|
168
|
+
solr_doc["edit_access_group_ssim"].should == ["archivist"]
|
169
|
+
solr_doc["read_access_group_ssim"].should == ["public"]
|
170
|
+
solr_doc["discover_access_group_ssim"].should == ["bob"]
|
171
171
|
end
|
172
172
|
end
|
173
173
|
describe "embargo_release_date=" do
|
@@ -4,17 +4,17 @@ require "nokogiri"
|
|
4
4
|
describe Hydra::Datastream::InheritableRightsMetadata do
|
5
5
|
before do
|
6
6
|
Hydra.stub(:config).and_return({:permissions=>{
|
7
|
-
:discover => {:group =>"
|
8
|
-
:read => {:group =>"
|
9
|
-
:edit => {:group =>"
|
10
|
-
:owner => "
|
7
|
+
:discover => {:group =>"discover_access_group_ssim", :individual=>"discover_access_person_ssim"},
|
8
|
+
:read => {:group =>"read_access_group_ssim", :individual=>"read_access_person_ssim"},
|
9
|
+
:edit => {:group =>"edit_access_group_ssim", :individual=>"edit_access_person_ssim"},
|
10
|
+
:owner => "depositor_ssim",
|
11
11
|
:embargo_release_date => "embargo_release_date_dtsi",
|
12
12
|
|
13
13
|
:inheritable => {
|
14
|
-
:discover => {:group =>"
|
15
|
-
:read => {:group =>"
|
16
|
-
:edit => {:group =>"
|
17
|
-
:owner => "
|
14
|
+
:discover => {:group =>"inheritable_discover_access_group_ssim", :individual=>"inheritable_discover_access_person_ssim"},
|
15
|
+
:read => {:group =>"inheritable_read_access_group_ssim", :individual=>"inheritable_read_access_person_ssim"},
|
16
|
+
:edit => {:group =>"inheritable_edit_access_group_ssim", :individual=>"inheritable_edit_access_person_ssim"},
|
17
|
+
:owner => "inheritable_depositor_ssim",
|
18
18
|
:embargo_release_date => "inheritable_embargo_release_date_dtsi"
|
19
19
|
}
|
20
20
|
}})
|
@@ -4,17 +4,17 @@ describe Hydra::PolicyAwareAbility do
|
|
4
4
|
before do
|
5
5
|
Hydra.stub(:config).and_return({
|
6
6
|
:permissions=>{
|
7
|
-
:discover => {:group =>"
|
8
|
-
:read => {:group =>"
|
9
|
-
:edit => {:group =>"
|
10
|
-
:owner => "
|
7
|
+
:discover => {:group =>"discover_access_group_ssim", :individual=>"discover_access_person_ssim"},
|
8
|
+
:read => {:group =>"read_access_group_ssim", :individual=>"read_access_person_ssim"},
|
9
|
+
:edit => {:group =>"edit_access_group_ssim", :individual=>"edit_access_person_ssim"},
|
10
|
+
:owner => "depositor_ssim",
|
11
11
|
:embargo_release_date => "embargo_release_date_dtsi",
|
12
12
|
|
13
13
|
:inheritable => {
|
14
|
-
:discover => {:group =>"
|
15
|
-
:read => {:group =>"
|
16
|
-
:edit => {:group =>"
|
17
|
-
:owner => "
|
14
|
+
:discover => {:group =>"inheritable_discover_access_group_ssim", :individual=>"inheritable_discover_access_person_ssim"},
|
15
|
+
:read => {:group =>"inheritable_read_access_group_ssim", :individual=>"inheritable_read_access_person_ssim"},
|
16
|
+
:edit => {:group =>"inheritable_edit_access_group_ssim", :individual=>"inheritable_edit_access_person_ssim"},
|
17
|
+
:owner => "inheritable_depositor_ssim",
|
18
18
|
:embargo_release_date => "inheritable_embargo_release_date_dtsi"
|
19
19
|
}
|
20
20
|
}})
|
@@ -61,11 +61,11 @@ describe Hydra::ModelMixins::RightsMetadata do
|
|
61
61
|
result = subject.rightsMetadata.to_solr
|
62
62
|
result.size.should == 4
|
63
63
|
## 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)
|
64
|
-
result['
|
65
|
-
result['
|
66
|
-
result['
|
67
|
-
result['
|
68
|
-
result['
|
64
|
+
result['read_access_group_ssim'].size.should == 2
|
65
|
+
result['read_access_group_ssim'].should include('group-6', 'group-7')
|
66
|
+
result['edit_access_group_ssim'].should == ['group-8']
|
67
|
+
result['discover_access_person_ssim'].should == ['person2']
|
68
|
+
result['read_access_person_ssim'].should == ['person1']
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
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.0.0.
|
4
|
+
version: 6.0.0.rc2
|
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: 2013-02-
|
14
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|