hydra-access-controls 12.0.0 → 12.0.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
  SHA256:
3
- metadata.gz: 399d12c5e3bbaf7a4f7f89b834803ba68bfa9f6a28d6e8ee95c0cb3d6a1d745b
4
- data.tar.gz: ed68661ab7b6182930000473102723a6ad0e6f82c9fe671aac7c2f03a3597fd4
3
+ metadata.gz: cb6758e64e46375378c0ab402d42197ac1ed64af8f9ec87bda1ee603c2fa4e4e
4
+ data.tar.gz: 2e7f290acefb3924c5947e5ada34b54cdf0a64f3a127422c72cb5fdef8fe88c6
5
5
  SHA512:
6
- metadata.gz: d0c2cf3c21d32ae7b5cf3aeb72116603cd614340f3409b9b69aaff4d8a09760bf18f01164775cd2ff628d522b53e8e8b530c6ea82159003e53dd107d48bfe109
7
- data.tar.gz: bd228f09270e9a1b08c315db330413f42e530a1e6964e324ef56f86e504758ee7964edfca8a8504e09627e32d32127967e426b9c69699c968f25465d81e12449
6
+ metadata.gz: 80f663ea54a156cf6a5ded46a0aae98a1df9e8953ca0999fa56a8668b266cc855a4db8aa1933dd2989c4c5df9ea989146af1989089059640412a573417901d01
7
+ data.tar.gz: 299fffeb06237d336774894d209313e968173446276210821a42a896522c5a3d17ee0ae67c428c856405cab04a3246a820fc54bd7fce5b613ea328d27c69b6ff
@@ -5,8 +5,8 @@ module Hydra
5
5
  include Hydra::AccessControls::WithAccessRight
6
6
 
7
7
  included do
8
- validates :lease_expiration_date, :'hydra/future_date' => true, if: :enforce_future_date_for_lease?
9
- validates :embargo_release_date, :'hydra/future_date' => true, if: :enforce_future_date_for_embargo?
8
+ validates :lease_expiration_date, :'hydra/future_date' => true, if: :enforce_future_date_for_lease?, on: :create
9
+ validates :embargo_release_date, :'hydra/future_date' => true, if: :enforce_future_date_for_embargo?, on: :create
10
10
 
11
11
  belongs_to :embargo, predicate: Hydra::ACL.hasEmbargo, class_name: 'Hydra::AccessControls::Embargo', autosave: true
12
12
  belongs_to :lease, predicate: Hydra::ACL.hasLease, class_name: 'Hydra::AccessControls::Lease', autosave: true
@@ -41,7 +41,7 @@ module Hydra::AccessControls
41
41
  end
42
42
 
43
43
  def agent_name
44
- URI.decode(parsed_agent.last)
44
+ decode(parsed_agent.last)
45
45
  end
46
46
 
47
47
  def update(*)
@@ -80,7 +80,7 @@ module Hydra::AccessControls
80
80
  end
81
81
 
82
82
  def build_agent_resource(prefix, name)
83
- [Agent.new(::RDF::URI.new("#{prefix}##{URI.encode(name)}"))]
83
+ [Agent.new(::RDF::URI.new("#{prefix}##{encode(name)}"))]
84
84
  end
85
85
 
86
86
  def build_access(access)
@@ -96,5 +96,15 @@ module Hydra::AccessControls
96
96
  raise ArgumentError, "Unknown access #{access.inspect}"
97
97
  end
98
98
  end
99
+
100
+ private
101
+
102
+ def encode(str)
103
+ URI::RFC2396_Parser.new.escape(str)
104
+ end
105
+
106
+ def decode(str)
107
+ URI::RFC2396_Parser.new.unescape(str)
108
+ end
99
109
  end
100
110
  end
@@ -83,9 +83,9 @@ describe Hydra::AccessControls::Embargoable do
83
83
  end
84
84
 
85
85
  describe 'validations' do
86
- context "with dates" do
86
+ context "with past dates" do
87
87
  subject { ModsAsset.new(lease_expiration_date: past_date, embargo_release_date: past_date) }
88
- it "validates embargo_release_date and lease_expiration_date" do
88
+ it "validates embargo_release_date and lease_expiration_date on create" do
89
89
  expect(subject).to_not be_valid
90
90
  expect(subject.errors[:lease_expiration_date]).to eq ['Must be a future date']
91
91
  expect(subject.errors[:embargo_release_date]).to eq ['Must be a future date']
@@ -47,17 +47,29 @@ describe Hydra::AccessControls::Permission do
47
47
  end
48
48
 
49
49
  describe "URI escaping" do
50
- let(:permission) { described_class.new(type: 'person', name: 'john doe', access: 'read') }
51
- let(:permission2) { described_class.new(type: 'group', name: 'hydra devs', access: 'read') }
50
+ let(:user_permission) { described_class.new(type: 'person', name: 'john doe', access: 'read') }
51
+ let(:user_permission2) { described_class.new(type: 'person', name: 'john%20doe', access: 'read') }
52
+ let(:user_permission3) { described_class.new(type: 'person', name: 'john+doe', access: 'read') }
53
+ let(:group_permission) { described_class.new(type: 'group', name: 'hydra devs', access: 'read') }
54
+ let(:group_permission2) { described_class.new(type: 'group', name: 'hydra%20devs', access: 'read') }
55
+ let(:group_permission3) { described_class.new(type: 'group', name: 'hydra+devs', access: 'read') }
52
56
 
53
57
  it "should escape agent when building" do
54
- expect(permission.agent.first.rdf_subject.to_s).to eq 'http://projecthydra.org/ns/auth/person#john%20doe'
55
- expect(permission2.agent.first.rdf_subject.to_s).to eq 'http://projecthydra.org/ns/auth/group#hydra%20devs'
58
+ expect(user_permission.agent.first.rdf_subject.to_s).to eq 'http://projecthydra.org/ns/auth/person#john%20doe'
59
+ expect(user_permission2.agent.first.rdf_subject.to_s).to eq 'http://projecthydra.org/ns/auth/person#john%2520doe'
60
+ expect(user_permission3.agent.first.rdf_subject.to_s).to eq 'http://projecthydra.org/ns/auth/person#john+doe'
61
+ expect(group_permission.agent.first.rdf_subject.to_s).to eq 'http://projecthydra.org/ns/auth/group#hydra%20devs'
62
+ expect(group_permission2.agent.first.rdf_subject.to_s).to eq 'http://projecthydra.org/ns/auth/group#hydra%2520devs'
63
+ expect(group_permission3.agent.first.rdf_subject.to_s).to eq 'http://projecthydra.org/ns/auth/group#hydra+devs'
56
64
  end
57
65
 
58
66
  it "should unescape agent when parsing" do
59
- expect(permission.agent_name).to eq 'john doe'
60
- expect(permission2.agent_name).to eq 'hydra devs'
67
+ expect(user_permission.agent_name).to eq 'john doe'
68
+ expect(user_permission2.agent_name).to eq 'john%20doe'
69
+ expect(user_permission3.agent_name).to eq 'john+doe'
70
+ expect(group_permission.agent_name).to eq 'hydra devs'
71
+ expect(group_permission2.agent_name).to eq 'hydra%20devs'
72
+ expect(group_permission3.agent_name).to eq 'hydra+devs'
61
73
  end
62
74
 
63
75
  context 'with a User instance passed as :name argument' do
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: 12.0.0
4
+ version: 12.0.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: 2020-11-18 00:00:00.000000000 Z
13
+ date: 2021-05-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  requirements: []
226
- rubygems_version: 3.1.2
226
+ rubygems_version: 3.1.4
227
227
  signing_key:
228
228
  specification_version: 4
229
229
  summary: Access controls for project hydra