hydra-access-controls 9.4.0 → 9.4.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: 2936e5b807433daa6ecd2c103eb663255afa6815
|
4
|
+
data.tar.gz: 0bcbd88134dea8542bf81852bb9ff15d39c35317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e3a0171c9cb88cbc161b86295a628f2c4d5b0a1f45a22a4322d2c562ed167d49455c6c064ef4d8a9909fdc44df951584c8332d8bf4c09e0276a551a766f32bd
|
7
|
+
data.tar.gz: a15532976668837b47d10e1f93511abe7f109486a21a1b832bc1e7117ffd7063c3e2750e4130e02a62df0975e464a15cc371d7d057f97ad4643d47d592a74672
|
@@ -1,57 +1,65 @@
|
|
1
|
-
module Hydra
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
raise ArgumentError, "Invalid visibility: #{value.inspect}"
|
18
|
-
end
|
1
|
+
module Hydra::AccessControls
|
2
|
+
module Visibility
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def visibility=(value)
|
6
|
+
return if value.nil?
|
7
|
+
# only set explicit permissions
|
8
|
+
case value
|
9
|
+
when AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
10
|
+
public_visibility!
|
11
|
+
when AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
12
|
+
registered_visibility!
|
13
|
+
when AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
14
|
+
private_visibility!
|
15
|
+
else
|
16
|
+
raise ArgumentError, "Invalid visibility: #{value.inspect}"
|
19
17
|
end
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
20
|
+
def visibility
|
21
|
+
if read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_PUBLIC
|
22
|
+
AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
23
|
+
elsif read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED
|
24
|
+
AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
25
|
+
else
|
26
|
+
AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
29
27
|
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def visibility_changed?
|
31
|
+
!!@visibility_will_change
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
30
35
|
|
31
|
-
|
32
|
-
|
36
|
+
# Override represented_visibility if you want to add another visibility that is
|
37
|
+
# represented as a read group (e.g. on-campus)
|
38
|
+
# @return [Array] a list of visibility types that are represented as read groups
|
39
|
+
def represented_visibility
|
40
|
+
[AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED,
|
41
|
+
AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
|
33
42
|
end
|
34
43
|
|
35
|
-
private
|
36
44
|
def visibility_will_change!
|
37
45
|
@visibility_will_change = true
|
38
46
|
end
|
39
47
|
|
40
48
|
def public_visibility!
|
41
|
-
visibility_will_change! unless visibility ==
|
42
|
-
|
49
|
+
visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
50
|
+
remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
|
51
|
+
set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_PUBLIC], remove_groups)
|
43
52
|
end
|
44
53
|
|
45
54
|
def registered_visibility!
|
46
|
-
visibility_will_change! unless visibility ==
|
47
|
-
|
55
|
+
visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
56
|
+
remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED]
|
57
|
+
set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED], remove_groups)
|
48
58
|
end
|
49
59
|
|
50
60
|
def private_visibility!
|
51
|
-
visibility_will_change! unless visibility ==
|
52
|
-
set_read_groups([],
|
61
|
+
visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
62
|
+
set_read_groups([], represented_visibility)
|
53
63
|
end
|
54
|
-
|
55
|
-
end
|
56
64
|
end
|
57
65
|
end
|
@@ -3,7 +3,7 @@ module Hydra
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
included do
|
5
5
|
# Rights
|
6
|
-
property :rights, predicate: ::RDF::DC.rights do |index|
|
6
|
+
property :rights, predicate: ::RDF::Vocab::DC.rights do |index|
|
7
7
|
index.as :facetable
|
8
8
|
end
|
9
9
|
property :rightsHolder, predicate: ::RDF::URI('http://opaquenamespace.org/rights/rightsHolder') do |index|
|
data/lib/hydra/admin_policy.rb
CHANGED
@@ -4,10 +4,10 @@ module Hydra
|
|
4
4
|
include Hydra::AdminPolicyBehavior
|
5
5
|
include Hydra::AccessControls::Permissions
|
6
6
|
|
7
|
-
property :title, predicate: ::RDF::DC.title do |index|
|
7
|
+
property :title, predicate: ::RDF::Vocab::DC.title do |index|
|
8
8
|
index.as :stored_searchable
|
9
9
|
end
|
10
|
-
property :description, predicate: ::RDF::DC.description do |index|
|
10
|
+
property :description, predicate: ::RDF::Vocab::DC.description do |index|
|
11
11
|
index.as :searchable
|
12
12
|
end
|
13
13
|
|
@@ -1,16 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hydra::AccessControls::Visibility do
|
4
|
-
module VisibilityOverride
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
include Hydra::AccessControls::Permissions
|
7
|
-
def visibility; super; end
|
8
|
-
def visibility=(value); super(value); end
|
9
|
-
end
|
10
|
-
class MockParent < ActiveFedora::Base
|
11
|
-
include VisibilityOverride
|
12
|
-
end
|
13
|
-
|
14
4
|
describe "setting visibility" do
|
15
5
|
before do
|
16
6
|
class Foo < ActiveFedora::Base
|
@@ -67,14 +57,47 @@ describe Hydra::AccessControls::Visibility do
|
|
67
57
|
end
|
68
58
|
end
|
69
59
|
end
|
60
|
+
end
|
61
|
+
end
|
70
62
|
|
63
|
+
describe "overiding visibility" do
|
64
|
+
module VisibilityOverride
|
65
|
+
extend ActiveSupport::Concern
|
66
|
+
include Hydra::AccessControls::Permissions
|
67
|
+
def visibility; super; end
|
68
|
+
def visibility=(value); super(value); end
|
69
|
+
end
|
70
|
+
class MockParent < ActiveFedora::Base
|
71
|
+
include VisibilityOverride
|
71
72
|
end
|
72
73
|
|
74
|
+
it 'allows for overrides of visibility' do
|
75
|
+
expect {
|
76
|
+
MockParent.new(visibility: Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE)
|
77
|
+
}.to_not raise_error
|
78
|
+
end
|
73
79
|
end
|
74
80
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
context "when represented_visibility is overridden" do
|
82
|
+
let(:model) { MockObject.new }
|
83
|
+
before do
|
84
|
+
class MockObject < ActiveFedora::Base
|
85
|
+
include Hydra::AccessControls::Permissions
|
86
|
+
def represented_visibility
|
87
|
+
['one']
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
model.read_groups = ['one', 'another']
|
92
|
+
end
|
93
|
+
|
94
|
+
after do
|
95
|
+
Object.send(:remove_const, :MockObject)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "replaces the represented visibility" do
|
99
|
+
model.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
100
|
+
expect(model.read_groups).to contain_exactly 'public', 'another'
|
101
|
+
end
|
79
102
|
end
|
80
103
|
end
|
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.4.
|
4
|
+
version: 9.4.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-11-
|
13
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|