ddr-models 1.11.6 → 1.11.7

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: 3efb0abc090200e8bbf81d43c217595f1c9697c7
4
- data.tar.gz: e68ed383bfd5d79052c0381424bdb47ad536b471
3
+ metadata.gz: 629034fc61b1462f5458cd9bcd4bf53208adfb75
4
+ data.tar.gz: 2202b8145c9340b1fd8daf341435d09c60a62ab6
5
5
  SHA512:
6
- metadata.gz: dfc022a0397d4b62fe27685208d1ba9d67b744b7aa8642956aee4aaf4e97faeb175efc500a58d140b4edcf120e760fa43bce9664e0e9bedc35a383073213f0bf
7
- data.tar.gz: 7dff6a4a6ca4045f61d325b0d46db338ff3d263f0cfadcb49540b17e362e608b2c5cb3ccecffec7d6ba4d2c77499757a2d4b5ae4ecbd7928666ae651d98c63b7
6
+ metadata.gz: 686be30cb8c22f36a995c7ec453844a8fc79e89b2f3f0c9323aefc6a426b0f56e4b791b707f86ee9d052ac7462b1507fd5423aa7c6da6651bf78cad093acefba
7
+ data.tar.gz: 7792c1ddfc02aeab76c1e6e31a097e79aac31ddb1c73e19f77c3087b33ae9810d951c676bdf6970128d03bd2f862693153abeb57737fc4991a401727c429436a
@@ -2,5 +2,12 @@ en:
2
2
  groups:
3
3
  public: Public
4
4
  registered: Duke Community
5
+ duke:
6
+ staff: Duke Staff
7
+ faculty: Duke Faculty
8
+ student: Duke Students
9
+ affiliate: Duke Affiliates
10
+ alumni: Duke Alumni
11
+ emeritus: Duke Emeritus Faculty
5
12
  # Grouper group example:
6
13
  # "duke:library:repository:ddr:archivists": Archivists
@@ -2,6 +2,10 @@ module Ddr
2
2
  module Auth
3
3
  class RemoteGroupService < GroupService
4
4
 
5
+ AFFILIATIONS = %w( faculty student staff affiliate alumni emeritus )
6
+ AFFILIATION_GROUP_MAP = AFFILIATIONS.map { |a| [a, "duke.#{a}"] }.to_h
7
+ AFFILIATION_RE = Regexp.new('(%{a})(?=@duke\.edu)' % {a: AFFILIATIONS.join("|")})
8
+
5
9
  attr_reader :env
6
10
 
7
11
  def initialize(env = nil)
@@ -9,12 +13,12 @@ module Ddr
9
13
  end
10
14
 
11
15
  def append_groups
12
- GrouperService.repository_group_names
16
+ GrouperService.repository_group_names + AFFILIATION_GROUP_MAP.values
13
17
  end
14
18
 
15
19
  def append_user_groups(user)
16
20
  if env && env.key?(Ddr::Auth.remote_groups_env_key)
17
- remote_groups
21
+ remote_groups + affiliation_groups
18
22
  else
19
23
  GrouperService.user_group_names(user)
20
24
  end
@@ -30,6 +34,11 @@ module Ddr
30
34
  groups
31
35
  end
32
36
 
37
+ def affiliation_groups
38
+ affiliations = env["affiliation"] ? env["affiliation"].scan(AFFILIATION_RE).flatten : []
39
+ affiliations.map { |affiliation| AFFILIATION_GROUP_MAP[affiliation] }.compact
40
+ end
41
+
33
42
  end
34
43
  end
35
44
  end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "1.11.6"
3
+ VERSION = "1.11.7"
4
4
  end
5
5
  end
@@ -0,0 +1,16 @@
1
+ module Ddr
2
+ module Auth
3
+ RSpec.describe RemoteGroupService do
4
+
5
+ subject { described_class.new(env) }
6
+
7
+ describe "affiliation_groups" do
8
+ let(:env) { {"affiliation" => "faculty@duke.edu;staff@duke.edu"} }
9
+ it "should return the groups for the affiliations" do
10
+ expect(subject.affiliation_groups).to match_array(["duke.faculty", "duke.staff"])
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.6
4
+ version: 1.11.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -452,6 +452,7 @@ files:
452
452
  - spec/models/user_spec.rb
453
453
  - spec/routing/user_routing_spec.rb
454
454
  - spec/services/group_service_spec.rb
455
+ - spec/services/remote_group_service_spec.rb
455
456
  - spec/spec_helper.rb
456
457
  - spec/support/shared_examples_for_access_controllables.rb
457
458
  - spec/support/shared_examples_for_associations.rb
@@ -565,6 +566,7 @@ test_files:
565
566
  - spec/models/user_spec.rb
566
567
  - spec/routing/user_routing_spec.rb
567
568
  - spec/services/group_service_spec.rb
569
+ - spec/services/remote_group_service_spec.rb
568
570
  - spec/spec_helper.rb
569
571
  - spec/support/shared_examples_for_access_controllables.rb
570
572
  - spec/support/shared_examples_for_associations.rb