ddr-models 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6d273e1b012bea164a89a6ce3029bae9568c2b1
4
- data.tar.gz: 942b1b7201d4426c1df684417d657df550604490
3
+ metadata.gz: ac3fde76afdd04c188208ae9f82e637fbf7a6c05
4
+ data.tar.gz: 7bd9cf7895be31f83557505d02256d0f10ab5b7e
5
5
  SHA512:
6
- metadata.gz: 76c5fdc47393e01d2e3746747f85565c1d17accb24f371e737bb5143abb73364d607315a7f7974bb0c1d95893a2133a9abf78426488209451ad4f1e912e16dff
7
- data.tar.gz: 177b2529645a27c5a4c216817b3ab727b6cce26941199f42207668ef0761ab87f9f756e6bd2d98879f7bac4cceb55c57c53d7bea32b713b5bae12547b7415d8c
6
+ metadata.gz: a498acd13aa0be7b1f7f99db275d1278dda26140960c450fbc27e6c93574f24cb42ce14edcd202b8c78024f5d2ed97a613fe4e25832ad8f2d29eb00794d37930
7
+ data.tar.gz: 272e6699ccb404fa3c8976ad7ce444c159bc16ff9bbd55aeefd9b27e819f3f187fd1a187b910d16d5e79bc6e5438fe384e1c9c2b9fdd50479315d8cb307b6dfc
@@ -30,7 +30,7 @@ module Ddr::Auth
30
30
  # Return the user agent for this context.
31
31
  # @return [String] or nil, if auth context is anonymous/
32
32
  def agent
33
- anonymous? ? nil : user.agent
33
+ user.agent if authenticated?
34
34
  end
35
35
 
36
36
  # Is the authenticated agent a Duke identity?
@@ -11,12 +11,12 @@ module Ddr::Auth
11
11
 
12
12
  # @return [Array<String>]
13
13
  def affiliation
14
- split_env("affiliation").map { |a| a.sub(/@duke\.edu\z/, "") }
14
+ anonymous? ? super : split_env("affiliation").map { |a| a.sub(/@duke\.edu\z/, "") }
15
15
  end
16
16
 
17
17
  # @return [Array<String>]
18
18
  def ismemberof
19
- split_env("ismemberof")
19
+ anonymous? ? super : split_env("ismemberof")
20
20
  end
21
21
 
22
22
  private
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "3.0.1"
3
+ VERSION = "3.0.2"
4
4
  end
5
5
  end
@@ -3,7 +3,6 @@ module Ddr::Auth
3
3
 
4
4
  subject { described_class.new(user, env) }
5
5
 
6
- let(:user) { FactoryGirl.build(:user) }
7
6
  let(:mock_ip_middleware) { double(calculate_ip: "8.8.8.8") }
8
7
 
9
8
  let(:env) do
@@ -13,18 +12,38 @@ module Ddr::Auth
13
12
  }
14
13
  end
15
14
 
16
- it_behaves_like "an auth context"
15
+ shared_examples "a web auth context" do
16
+ it_behaves_like "an auth context"
17
+ its(:ip_address) { should eq("8.8.8.8") }
18
+ end
19
+
20
+ describe "authenticated" do
21
+ let(:user) { FactoryGirl.build(:user) }
17
22
 
18
- its(:affiliation) { should contain_exactly("staff", "student") }
19
- its(:ismemberof) { should contain_exactly("group1", "group2", "group3") }
20
- its(:ip_address) { should eq("8.8.8.8") }
23
+ it_behaves_like "a web auth context"
24
+ its(:affiliation) { should contain_exactly("staff", "student") }
25
+ its(:ismemberof) { should contain_exactly("group1", "group2", "group3") }
26
+
27
+ describe "when env vars are not present" do
28
+ let(:env) { {} }
29
+ its(:affiliation) { should be_empty }
30
+ its(:ismemberof) { should be_empty }
31
+ its(:ip_address) { should be_nil }
32
+ end
33
+ end
21
34
 
22
- describe "when env vars are not present" do
23
- let(:env) { {} }
35
+ describe "anonymous" do
36
+ let(:user) { nil }
37
+
38
+ it_behaves_like "a web auth context"
24
39
  its(:affiliation) { should be_empty }
25
40
  its(:ismemberof) { should be_empty }
26
- its(:ip_address) { should be_nil }
41
+
42
+ describe "when env vars are not present" do
43
+ let(:env) { {} }
44
+ its(:ip_address) { should be_nil }
45
+ end
27
46
  end
28
-
47
+
29
48
  end
30
49
  end
@@ -40,7 +40,9 @@ module Ddr::Auth
40
40
 
41
41
  describe "#agents" do
42
42
  before { allow(subject).to receive(:groups) { [ Groups::PUBLIC, Groups::REGISTERED, Group.new("foo") ] } }
43
- its(:agents) { should contain_exactly(subject.agent, Groups::PUBLIC.agent, Groups::REGISTERED.agent, "foo") }
43
+ its(:agents) {
44
+ are_expected.to match_array([subject.agent, Groups::PUBLIC.agent, Groups::REGISTERED.agent, "foo"].compact)
45
+ }
44
46
  end
45
47
 
46
48
  describe "#member_of?" do
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: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-13 00:00:00.000000000 Z
12
+ date: 2016-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails