-
Notifications
You must be signed in to change notification settings - Fork 252
[CI] Add integration tests for Net::LDAP#open behavior #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
74fe070
Test Net::LDAP#open behavior
mtodd f16a4ff
Add failing test for Net::LDAP#open with nested queries
mtodd 49fd5c9
Merge branch 'master' into open-integration-tests
mtodd 70cb1f9
Accept message_id as param to write
mtodd 8f4745d
Pull queued messages first, queue messages unless ID matches
mtodd 91618d6
Include message ID in event payload
mtodd 9c4b45b
Fix message_id in test
mtodd acd676e
Extract queued_read(message_id) method
mtodd 6cbb814
Extract message_queue accessor, documentation, cleanup
mtodd 1e59169
Clear search's message queue, instrument unread messages
mtodd bd4f3fd
Merge pull request #138 from ruby-ldap/read-queue-by-message_id
mtodd 77e5899
Merge branch 'master' into open-integration-tests
mtodd 0536b42
Add explanatory comment
mtodd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require_relative '../test_helper' | ||
|
||
class TestBindIntegration < LDAPIntegrationTestCase | ||
def test_binds_without_open | ||
events = @service.subscribe "bind.net_ldap_connection" | ||
|
||
@ldap.search(filter: "uid=user1", base: "ou=People,dc=rubyldap,dc=com", ignore_server_caps: true) | ||
@ldap.search(filter: "uid=user1", base: "ou=People,dc=rubyldap,dc=com", ignore_server_caps: true) | ||
|
||
assert_equal 2, events.size | ||
end | ||
|
||
def test_binds_with_open | ||
events = @service.subscribe "bind.net_ldap_connection" | ||
|
||
@ldap.open do | ||
@ldap.search(filter: "uid=user1", base: "ou=People,dc=rubyldap,dc=com", ignore_server_caps: true) | ||
@ldap.search(filter: "uid=user1", base: "ou=People,dc=rubyldap,dc=com", ignore_server_caps: true) | ||
end | ||
|
||
assert_equal 1, events.size | ||
end | ||
|
||
def test_nested_search_without_open | ||
entries = [] | ||
nested_entry = nil | ||
|
||
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=rubyldap,dc=com") do |entry| | ||
entries << entry.uid.first | ||
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=rubyldap,dc=com").first | ||
end | ||
|
||
assert_equal "user3", nested_entry.uid.first | ||
assert_equal %w(user1 user2), entries | ||
end | ||
|
||
def test_nested_search_with_open | ||
entries = [] | ||
nested_entry = nil | ||
|
||
@ldap.open do | ||
@ldap.search(filter: "(|(uid=user1)(uid=user2))", base: "ou=People,dc=rubyldap,dc=com") do |entry| | ||
entries << entry.uid.first | ||
nested_entry ||= @ldap.search(filter: "uid=user3", base: "ou=People,dc=rubyldap,dc=com").first | ||
end | ||
end | ||
|
||
assert_equal "user3", nested_entry.uid.first | ||
assert_equal %w(user1 user2), entries | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To double check I understand this. This clears PDU's we've
queue_read
from the socket for this particular search keyed bymessage_id
that weren't consumed. I think this is good cleanup, but when do we hit this scenario? Is this an exceptional case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, you understand it perfectly. It shouldn't happen, it would be an exceptional case. Didn't feel right to blow up, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A contrived failure would be if we didn't follow spec and reused a message_id before that request was finished. Maybe some additional comments indicating this case shouldn't be reached?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jch added a brief comment.