hydra-access-controls 10.3.2 → 10.3.3

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: 41551b5b4c585cf81dcf873b800b5699dc6c1b22
4
- data.tar.gz: a81738e509b739baf6d816ad0ec58f68a1b880f9
3
+ metadata.gz: 7d9f4e9a294e4eb06926d2cda789c8b1feb24609
4
+ data.tar.gz: 84ea038cc5f00777a46865971fab5ef1fc363bd3
5
5
  SHA512:
6
- metadata.gz: a4979abd13373922171646bd2bf6cbf79c8c016e3c45b145be961cf778a4818d71151345ed0bfa8defa41ab3f32cfbe7de2a1a0a5d3280d600c2377d4811575b
7
- data.tar.gz: 25049f1bb1d157fa2512c045644543851c88020c60f8875ee2c4b993f5619a0f57394a01d5e84b56ff5f15d69ff35cb34f17987f0b4e8d5f0ded3e5dfcce2051
6
+ metadata.gz: c061f202f781cd99fdfae4ffc0910bd66e9d49d50052cd87ea77a5b8f7ec44a21271769b22f66ee0a34d37c5277c28f776730013510b91a4d4be3492bc052045
7
+ data.tar.gz: 21c4e5e27a1b6b1b516bc50906d76821eb8388892a114b9aea06ab34d77ea965cf7576a3fc51c7f7a6862f0e1cb739a92009e5eee5169c45e3761b3f5bdae5b0
@@ -37,7 +37,7 @@ module Hydra::AccessControls
37
37
  end
38
38
 
39
39
  def agent_name
40
- parsed_agent.last
40
+ URI.decode(parsed_agent.last)
41
41
  end
42
42
 
43
43
  def access
@@ -58,14 +58,18 @@ module Hydra::AccessControls
58
58
  raise "Can't build agent #{inspect}" unless name && type
59
59
  self.agent = case type
60
60
  when 'group'
61
- Agent.new(::RDF::URI.new("#{GROUP_AGENT_URL_PREFIX}##{name}"))
61
+ build_agent_resource(GROUP_AGENT_URL_PREFIX, name)
62
62
  when 'person'
63
- Agent.new(::RDF::URI.new("#{PERSON_AGENT_URL_PREFIX}##{name}"))
63
+ build_agent_resource(PERSON_AGENT_URL_PREFIX, name)
64
64
  else
65
65
  raise ArgumentError, "Unknown agent type #{type.inspect}"
66
66
  end
67
67
  end
68
68
 
69
+ def build_agent_resource(prefix, name)
70
+ Agent.new(::RDF::URI.new("#{prefix}##{URI.encode(name)}"))
71
+ end
72
+
69
73
  def build_access(access)
70
74
  raise "Can't build access #{inspect}" unless access
71
75
  self.mode = case access
@@ -45,4 +45,19 @@ describe Hydra::AccessControls::Permission do
45
45
  expect(perm2).to_not eq perm3
46
46
  end
47
47
  end
48
+
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') }
52
+
53
+ 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'
56
+ end
57
+
58
+ 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'
61
+ end
62
+ end
48
63
  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: 10.3.2
4
+ version: 10.3.3
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: 2016-10-28 00:00:00.000000000 Z
13
+ date: 2016-11-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  version: '0'
237
237
  requirements: []
238
238
  rubyforge_project:
239
- rubygems_version: 2.6.4
239
+ rubygems_version: 2.5.1
240
240
  signing_key:
241
241
  specification_version: 4
242
242
  summary: Access controls for project hydra