hydra-access-controls 9.2.0 → 9.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e86f8618f5fea8b5b0ebb586211a5a24e69af62
|
4
|
+
data.tar.gz: ade8ed9c17682b50360720acc0e676dbb06a2da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c71a8bea0eba274948914728e8b482e2be8ea17017d1e7a185ccc9507c2cd4a38ed2b2800aba272a4b04219b913bac0093c32ca369e539270195b987011e91
|
7
|
+
data.tar.gz: 22f264780da8a0add489f00ea65ef86fa20ee5201d0b0c9dc0a8e9aba0213fbed13b716b51b574e3fcca664ed7b02bf07c90f0874a97f4a6afd736958284a909
|
@@ -5,7 +5,8 @@ module Hydra
|
|
5
5
|
include Hydra::AccessControls::WithAccessRight
|
6
6
|
|
7
7
|
included do
|
8
|
-
validates :
|
8
|
+
validates :lease_expiration_date, :'hydra/future_date' => true, if: :lease
|
9
|
+
validates :embargo_release_date, :'hydra/future_date' => true, if: :embargo
|
9
10
|
|
10
11
|
belongs_to :embargo, predicate: Hydra::ACL.hasEmbargo, class_name: 'Hydra::AccessControls::Embargo'
|
11
12
|
belongs_to :lease, predicate: Hydra::ACL.hasLease, class_name: 'Hydra::AccessControls::Lease'
|
@@ -44,12 +45,8 @@ module Hydra
|
|
44
45
|
# The lease_visibility! and embargo_visibility! methods rely on this to deactivate the lease when applicable.
|
45
46
|
def visibility=(value)
|
46
47
|
# If changing from embargo or lease, deactivate the lease/embargo and wipe out the associated metadata before proceeding
|
47
|
-
if
|
48
|
-
|
49
|
-
end
|
50
|
-
if !lease_expiration_date.nil?
|
51
|
-
deactivate_lease! unless value == visibility_during_lease
|
52
|
-
end
|
48
|
+
deactivate_embargo! if deactivate_embargo?(value)
|
49
|
+
deactivate_lease! if deactivate_lease?(value)
|
53
50
|
super
|
54
51
|
end
|
55
52
|
|
@@ -149,6 +146,19 @@ module Hydra
|
|
149
146
|
end
|
150
147
|
end
|
151
148
|
end
|
149
|
+
|
150
|
+
private
|
151
|
+
|
152
|
+
# @return [true, false] true if there is an embargo set up and the visibility will change
|
153
|
+
def deactivate_embargo?(value)
|
154
|
+
embargo && embargo.embargo_release_date && value != embargo.visibility_during_embargo
|
155
|
+
end
|
156
|
+
|
157
|
+
# @return [true, false] true if there is a lease set up and the visibility will change
|
158
|
+
def deactivate_lease?(value)
|
159
|
+
lease && lease.lease_expiration_date && value != lease.visibility_during_lease
|
160
|
+
end
|
161
|
+
|
152
162
|
end
|
153
163
|
end
|
154
164
|
end
|
@@ -39,7 +39,7 @@ module Hydra
|
|
39
39
|
|
40
40
|
def public_visibility!
|
41
41
|
visibility_will_change! unless visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
42
|
-
set_read_groups([Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC], [])
|
42
|
+
set_read_groups([Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC], [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED])
|
43
43
|
end
|
44
44
|
|
45
45
|
def registered_visibility!
|
@@ -18,25 +18,58 @@ describe Hydra::AccessControls::Embargoable do
|
|
18
18
|
let(:past_date) { Date.today-2 }
|
19
19
|
subject { TestModel.new }
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
describe 'validations' do
|
22
|
+
context "with dates" do
|
23
|
+
subject { ModsAsset.new(lease_expiration_date: past_date, embargo_release_date: past_date) }
|
24
|
+
it "validates embargo_release_date and lease_expiration_date" do
|
25
|
+
expect(subject).to_not be_valid
|
26
|
+
expect(subject.errors[:lease_expiration_date]).to eq ['Must be a future date']
|
27
|
+
expect(subject.errors[:embargo_release_date]).to eq ['Must be a future date']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "without an embargo" do
|
32
|
+
subject { ModsAsset.new }
|
33
|
+
|
34
|
+
before { subject.valid? }
|
35
|
+
|
36
|
+
it "doesn't create a new embargo" do
|
37
|
+
expect(subject.embargo).to be_nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it "doesn't create a new lease" do
|
41
|
+
expect(subject.lease).to be_nil
|
42
|
+
end
|
27
43
|
end
|
28
44
|
end
|
29
45
|
|
30
46
|
context 'visibility=' do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
47
|
+
context "when the object is not under embargo or lease" do
|
48
|
+
before do
|
49
|
+
subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
50
|
+
end
|
51
|
+
it "doesn't create embargo or lease" do
|
52
|
+
expect(subject.embargo).to be_nil
|
53
|
+
expect(subject.lease).to be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when changing from embargo" do
|
58
|
+
before do
|
59
|
+
subject.embargo_release_date = future_date.to_s
|
60
|
+
end
|
61
|
+
it "wipes out associated embargo metadata" do
|
62
|
+
expect(subject).to receive(:deactivate_embargo!)
|
63
|
+
subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
64
|
+
end
|
35
65
|
end
|
36
66
|
|
37
67
|
context "when changing from lease" do
|
38
|
-
|
68
|
+
before do
|
39
69
|
subject.apply_lease(future_date.to_s, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "wipes out associated lease metadata and marks visibility as changed" do
|
40
73
|
expect(subject).to receive(:deactivate_lease!)
|
41
74
|
subject.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
42
75
|
expect(subject).to be_visibility_changed
|
@@ -11,6 +11,67 @@ describe Hydra::AccessControls::Visibility do
|
|
11
11
|
include VisibilityOverride
|
12
12
|
end
|
13
13
|
|
14
|
+
describe "setting visibility" do
|
15
|
+
before do
|
16
|
+
class Foo < ActiveFedora::Base
|
17
|
+
include Hydra::AccessControls::Permissions
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
after { Object.send(:remove_const, :Foo) }
|
22
|
+
|
23
|
+
subject { Foo.new }
|
24
|
+
|
25
|
+
[ Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE,
|
26
|
+
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED,
|
27
|
+
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC ]
|
28
|
+
.each do |vis|
|
29
|
+
|
30
|
+
describe "to #{vis}" do
|
31
|
+
|
32
|
+
before { subject.visibility=vis }
|
33
|
+
|
34
|
+
it "should be set to #{vis}" do
|
35
|
+
expect(subject.visibility).to eql vis
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "and then to private" do
|
39
|
+
before { subject.visibility=Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
|
40
|
+
it "should be set to private" do
|
41
|
+
expect(subject.visibility).to eql Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
42
|
+
end
|
43
|
+
it "should have no permissions" do
|
44
|
+
expect(subject.permissions.map(&:to_hash)).to be_empty
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "and then to authenticated" do
|
49
|
+
before { subject.visibility=Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED }
|
50
|
+
it "should be set to authenticated" do
|
51
|
+
expect(subject.visibility).to eql Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
52
|
+
end
|
53
|
+
it "should have authenticated permissions only" do
|
54
|
+
expect(subject.permissions.map(&:to_hash)).to match_array [
|
55
|
+
{type: "group", access: "read", name: Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED } ]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "and then to public" do
|
60
|
+
before { subject.visibility=Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC }
|
61
|
+
it "should be set to public" do
|
62
|
+
expect(subject.visibility).to eql Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
63
|
+
end
|
64
|
+
it "should have public permissions only" do
|
65
|
+
expect(subject.permissions.map(&:to_hash)).to match_array [
|
66
|
+
{type: "group", access: "read", name: Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC } ]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
14
75
|
it 'allows for overrides of visibility' do
|
15
76
|
expect{
|
16
77
|
MockParent.new(visibility: Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE)
|
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.2.
|
4
|
+
version: 9.2.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-07-
|
13
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
220
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.4.
|
221
|
+
rubygems_version: 2.4.5
|
222
222
|
signing_key:
|
223
223
|
specification_version: 4
|
224
224
|
summary: Access controls for project hydra
|