ldap_groups_lookup 0.6.0 → 0.6.1
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 +4 -4
- data/lib/ldap_groups_lookup/behavior.rb +4 -4
- data/lib/ldap_groups_lookup/version.rb +1 -1
- data/spec/lib/ldap_groups_lookup_spec.rb +21 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89497393dbd1cb8187e740a5867c0758a6a47eb79ae4719bf2e09ba0952011ac
|
4
|
+
data.tar.gz: e9e7db4530168f315c7b7463beeb395d94aa49411fc2a7d92cba6152136600ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be721599c153b22b93fc7769377610619d24d74973e3316f7ebd427341a1c5830cc71d45df67cb78671773347c865999b65e18e2cf349759e005d42c84b5b337
|
7
|
+
data.tar.gz: f5f4aa7a0d10008ee984cc495076fb669b6113bf8ac52012f8c6806f7b14cb8c1ac12bd340a98a1585168be8cb2101d29da1aa6aef154d04d8222e6f3e8c9f11
|
@@ -6,14 +6,14 @@ module LDAPGroupsLookup
|
|
6
6
|
|
7
7
|
# @return String object's mail attribute
|
8
8
|
def ldap_mail
|
9
|
-
return '' unless respond_to?
|
9
|
+
return '' unless respond_to?(:ldap_lookup_key) && ldap_lookup_key.to_s.size.positive?
|
10
10
|
LDAPGroupsLookup.lookup_mail(ldap_lookup_key)
|
11
11
|
end
|
12
12
|
|
13
13
|
# Searches object's nested LDAP groups by value of ldap_lookup_key
|
14
14
|
# @return [Array] all of the object's LDAP groups, sorted
|
15
15
|
def ldap_groups
|
16
|
-
return [] unless respond_to?
|
16
|
+
return [] unless respond_to?(:ldap_lookup_key) && ldap_lookup_key.to_s.size.positive?
|
17
17
|
LDAPGroupsLookup.walk_ldap_groups(
|
18
18
|
LDAPGroupsLookup.ldap_member_of(ldap_lookup_key)
|
19
19
|
).sort
|
@@ -23,10 +23,10 @@ module LDAPGroupsLookup
|
|
23
23
|
# @param [Array] groups is a list of group CN strings to search within
|
24
24
|
# @return [Boolean]
|
25
25
|
def member_of_ldap_group?(groups)
|
26
|
-
return false unless respond_to?
|
26
|
+
return false unless respond_to?(:ldap_lookup_key) && ldap_lookup_key.to_s.size.positive?
|
27
27
|
return false if LDAPGroupsLookup.service.nil?
|
28
28
|
groups = [groups] if groups.is_a? String
|
29
|
-
dn = LDAPGroupsLookup.lookup_dn
|
29
|
+
dn = LDAPGroupsLookup.lookup_dn(ldap_lookup_key)
|
30
30
|
return LDAPGroupsLookup.walk_ldap_members(groups, dn)
|
31
31
|
end
|
32
32
|
end
|
@@ -72,12 +72,18 @@ RSpec.describe LDAPGroupsLookup do
|
|
72
72
|
allow_any_instance_of(Net::LDAP).to receive(:search).and_return([entry])
|
73
73
|
allow_any_instance_of(Net::LDAP).to receive(:bind).and_return(true)
|
74
74
|
end
|
75
|
-
context 'when subject does not provide ldap_lookup_key' do
|
75
|
+
context 'when subject does not provide ldap_lookup_key method' do
|
76
76
|
before(:each) { user.class.send(:remove_method, :ldap_lookup_key) }
|
77
77
|
it 'should return ''' do
|
78
78
|
expect(user.ldap_mail).to eq('')
|
79
79
|
end
|
80
80
|
end
|
81
|
+
context 'when subject does not provide ldap_lookup_key value' do
|
82
|
+
before(:each) { allow(user).to receive(:ldap_lookup_key).and_return(nil) }
|
83
|
+
it 'should return ''' do
|
84
|
+
expect(user.ldap_mail).to eq('')
|
85
|
+
end
|
86
|
+
end
|
81
87
|
context 'when subject provides ldap_lookup_key' do
|
82
88
|
context 'when LDAP is not configured' do
|
83
89
|
before(:each) do
|
@@ -103,12 +109,18 @@ RSpec.describe LDAPGroupsLookup do
|
|
103
109
|
allow_any_instance_of(Net::LDAP).to receive(:search).and_return([entry])
|
104
110
|
allow_any_instance_of(Net::LDAP).to receive(:bind).and_return(true)
|
105
111
|
end
|
106
|
-
context 'when subject does not provide ldap_lookup_key' do
|
112
|
+
context 'when subject does not provide ldap_lookup_key method' do
|
107
113
|
before(:each) { user.class.send(:remove_method, :ldap_lookup_key) }
|
108
114
|
it 'should return []' do
|
109
115
|
expect(user.ldap_groups).to eq([])
|
110
116
|
end
|
111
117
|
end
|
118
|
+
context 'when subject does not provide ldap_lookup_key value' do
|
119
|
+
before(:each) { allow(user).to receive(:ldap_lookup_key).and_return(nil) }
|
120
|
+
it 'should return []' do
|
121
|
+
expect(user.ldap_groups).to eq([])
|
122
|
+
end
|
123
|
+
end
|
112
124
|
context 'when subject provides ldap_lookup_key' do
|
113
125
|
context 'when LDAP is not configured' do
|
114
126
|
before(:each) do
|
@@ -127,12 +139,18 @@ RSpec.describe LDAPGroupsLookup do
|
|
127
139
|
end
|
128
140
|
|
129
141
|
describe '#member_of_ldap_group?' do
|
130
|
-
context 'when subject does not provide ldap_lookup_key' do
|
142
|
+
context 'when subject does not provide ldap_lookup_key method' do
|
131
143
|
before(:each) { user.class.send(:remove_method, :ldap_lookup_key) }
|
132
144
|
it 'should return false' do
|
133
145
|
expect(user.member_of_ldap_group?('Test-Group')).to eq(false)
|
134
146
|
end
|
135
147
|
end
|
148
|
+
context 'when subject does not provide ldap_lookup_key value' do
|
149
|
+
before(:each) { allow(user).to receive(:ldap_lookup_key).and_return(nil) }
|
150
|
+
it 'should return false' do
|
151
|
+
expect(user.member_of_ldap_group?('Test-Group')).to eq(false)
|
152
|
+
end
|
153
|
+
end
|
136
154
|
context 'when subject provides ldap_lookup_key' do
|
137
155
|
context 'when LDAP is not configured' do
|
138
156
|
before(:each) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ldap_groups_lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Ploshay
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: net-ldap
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.7.6
|
115
|
+
rubygems_version: 2.7.6.2
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Provides easy access to the list of LDAP groups a username is a member of.
|