Skip to content

Commit 06e8090

Browse files
committed
Stub search results directly h/t @jch
1 parent e63e2af commit 06e8090

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

test/membership_validators/active_directory_test.rb

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,36 @@ def make_validator(groups)
1717
@validator.new(@ldap, groups)
1818
end
1919

20-
# Stub search to return the given results.
21-
def stub_search(result)
22-
@ldap.stub :search, result do
23-
yield
24-
end
25-
end
26-
2720
def test_validates_user_in_group
28-
stub_search [@entry] do
21+
@ldap.stub :search, [@entry] do
2922
validator = make_validator(%w(nested-group1))
3023
assert validator.perform(@entry)
3124
end
3225
end
3326

3427
def test_validates_user_in_child_group
35-
stub_search [@entry] do
28+
@ldap.stub :search, [@entry] do
3629
validator = make_validator(%w(n-depth-nested-group1))
3730
assert validator.perform(@entry)
3831
end
3932
end
4033

4134
def test_validates_user_in_grandchild_group
42-
stub_search [@entry] do
35+
@ldap.stub :search, [@entry] do
4336
validator = make_validator(%w(n-depth-nested-group2))
4437
assert validator.perform(@entry)
4538
end
4639
end
4740

4841
def test_validates_user_in_great_grandchild_group
49-
stub_search [@entry] do
42+
@ldap.stub :search, [@entry] do
5043
validator = make_validator(%w(n-depth-nested-group3))
5144
assert validator.perform(@entry)
5245
end
5346
end
5447

5548
def test_does_not_validate_user_not_in_group
56-
stub_search [] do
49+
@ldap.stub :search, [] do
5750
validator = make_validator(%w(ghe-admins))
5851
refute validator.perform(@entry)
5952
end
@@ -62,14 +55,14 @@ def test_does_not_validate_user_not_in_group
6255
def test_does_not_validate_user_not_in_any_group
6356
entry = @domain.user?('groupless-user1')
6457

65-
stub_search [] do
58+
@ldap.stub :search, [] do
6659
validator = make_validator(%w(all-users))
6760
refute validator.perform(entry)
6861
end
6962
end
7063

7164
def test_validates_user_in_posix_group
72-
stub_search [@entry] do
65+
@ldap.stub :search, [@entry] do
7366
validator = make_validator(%w(posix-group1))
7467
assert validator.perform(@entry)
7568
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy