-
Notifications
You must be signed in to change notification settings - Fork 252
Add private Net::LDAP::Connection#write_request #116
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
Conversation
allows us to mock out the actual connection for testing
higher level abstraction to make testing easier and to DRY up existing socket IO
with #write_request
@jch do you think it might make sense to bake the |
@@ -10,7 +10,7 @@ def initialize(server) | |||
@instrumentation_service = server[:instrumentation_service] | |||
|
|||
begin | |||
@conn = TCPSocket.new(server[:host], server[:port]) | |||
@conn = server[:socket] || TCPSocket.new(server[:host], server[:port]) |
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.
👌
No problems with using |
Works for me. I started with |
not adding another method call. Since it's a private method, not giving any deprecation warning.
@jch 👍 diff looks good. Wishing we had integration tests right now. Would like to verify this against a directory service (AD or OpenLDAP) to be safe. Can do this later this week if you don't get a chance. |
👍 I'll hold off merging until we have some basic integration tests then. |
Assigned myself since you're blocked on integration testing to move forward on this. |
…quest Conflicts: test/common.rb
since we're not moving away from flexmock just yet, I updated my tests to use flexmock to be consistent. cc @mtodd
@mtodd what integrations tests do you have in mind? Seeing how |
end | ||
|
||
def test_write_increments_msgid | ||
mock = Minitest::Mock.new |
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 looks like this mock was missed.
@jch technically, all operations go through |
@mtodd gotcha. 👍 for adding more integration tests for all the public methods on Net::LDAP, but agree that we can do that in a separate PR. I'll fix up the CI issue and get this merged. |
Add private Net::LDAP::Connection#write_request
Add private Net::LDAP::Connection#write_request
This new method accomplishes two things:
#write
While working on #115, I noticed it was difficult to make assertions about what was being written out on the socket because those values were already BER encoded. By adding
#write_request
, it allows us to write assertions like the following:It's possible to go even more general, but this refactoring is small and does what I want. I also introduced
Minitest::Mock
here. I saw that the project also has flexmock as a dependency, but proposed it with minitest in case that's the direction we want to move towards. If it's preferred, I can also figure out how to achieve the same mocking with flexmock.cc @mtodd @schaary