SalesLoft / tcr

VCR for TCP
MIT License
59 stars 31 forks source link

Doesn't work with net-ldap gem #25

Closed rlue closed 6 years ago

rlue commented 6 years ago

When trying to record an LDAP connection with the ruby-net-ldap gem, TCR raises the following exception:

Exceptions::UnprocessableEntity: Can't connect to 'localhost' on port '389', undefined method `read_ber' for #<TCR::RecordableTCPSocket:0x000055d461a080f8>

TCR is trying to mock out the object returned by the #socket method in the fourth line below — but it looks like the method called on it is not implemented by the mock object:

def read(syntax = Net::LDAP::AsnSyntax)
  ber_object =
    instrument "read.net_ldap_connection", :syntax => syntax do |payload|
      socket.read_ber(syntax) do |id, content_length|
        payload[:object_type_id] = id
        payload[:content_length] = content_length
      end
    end

  return unless ber_object

  instrument "parse_pdu.net_ldap_connection" do |payload|
    pdu = payload[:pdu]  = Net::LDAP::PDU.new(ber_object)

    payload[:message_id] = pdu.message_id
    payload[:app_tag]    = pdu.app_tag

    pdu
  end
end

Sorry I can't offer more clarity; I'm still not too familiar with what TCR is doing under the hood. Happy to help continue debugging this issue with your guidance, though!

robforman commented 6 years ago

Interesting. Is there a public LDAP service we can test against?

robforman commented 6 years ago

nvm- found it over in #26

pjmartorell commented 3 years ago

This issue should be re-opened since cassettes are not being recorded when using Net::LDAP with an LDAPS connection, it only creates cassettes with an empty JSON array. LDAP tests are too vague and only test that using LDAP does not raise an error, but it does not test that a cassette is actually being recorded 🤷‍♂️