Commit Graph

65 Commits

Author SHA1 Message Date
James Sumners 92341e770a
Refactor MessageTracker into testable module 2019-08-30 10:50:02 -04:00
James Sumners 2e1ef78108
Refactor client RequestQueue into testable module (#548)
* Refactor client RequestQueue into testable module

* Update test/lib/client/request-queue/enqueue.test.js

Co-Authored-By: Tony Brix <tony@brix.ninja>

* Update test/lib/client/request-queue/enqueue.test.js

Co-Authored-By: Tony Brix <tony@brix.ninja>

* Update test/lib/client/request-queue/enqueue.test.js

Co-Authored-By: Tony Brix <tony@brix.ninja>
2019-08-28 19:15:09 -04:00
James Sumners e2c9b12430
Apply standard linting to the code base (#539)
* Apply standard linting to the code base

* Specify files to lint

* Run lint as first stage

* Update travis config
2019-08-27 17:11:49 -04:00
James Sumners 6b514b97df
Refactor tests to be independent of each other 2019-08-27 14:17:33 -04:00
acappella2017 a8b09f3f81 Support Node.js 10 (#497)
* Support node 10

* remove arrow function
2019-08-27 08:10:45 -04:00
Phil Batey 5f21dbf4cd destroy socket if auto-bind fails 2019-08-25 16:58:23 -06:00
James Sumners 2e2a0783bf
Create new instances of the null logger to remove potential side effects 2019-08-24 21:04:23 -04:00
James Sumners e9e8033fda
Remove dependency on Bunyan 2019-08-24 20:51:40 -04:00
Vincent van der Weele bb2d018b2c Emit error object in case of ConnectionError 2016-03-16 17:01:26 +02:00
Patrick Mooney bdbff63bc0 Expose Client as top-level export 2015-10-27 21:53:15 -05:00
Patrick Mooney c10a1a6faf Clean up client handling of end/error for searches 2015-10-15 21:49:34 -05:00
Patrick Mooney 3ca7e6d98f Allow startTLS during client setup 2015-05-24 19:56:16 -05:00
Patrick Mooney 821569c2c4 Implement client-side StartTLS support 2015-05-13 22:26:42 -05:00
Patrick Mooney ec062d370c Improve empty DN handling
- Use more strict comparisons for client input asserts
- Fix baseObject comparison in SearchRequest initialization
- Alter default error for server route fallthrough
2015-04-25 20:53:50 -05:00
Matt Simerson 19f2c16783 Allow simple client bind with empty credentials
Fix mcavage/node-ldapjs#254
2015-04-13 23:40:58 -05:00
Patrick Mooney 408e7c9f99 Support invalid DNs in client/server
Some LDAP implementations (mainly AD and Outlook) accept and/or output
DNs that are not valid.  To support interaction with these invalid DNs a
strictDN flag (default: true) has been added to the client and server
constructors.  Setting this flag to false will allow use of
non-conforming DNs.

When disabling strictDN in the ldapjs client, strings which wouldn't
parse into a DN can then be passed to the ldap operation methods.  It
also means that some methods (such as search) may return results with
string-formatted DNs instead of DN objects.

When disabling strictDN in the ldapjs server, incoming requests that
contain invalid DNs will be routed to the default ('') handler for that
operation type.  It is your responsiblity to differentiate between
string-type and object-type DNs in those handlers.

Fix mcavage/node-ldapjs#222
Fix mcavage/node-ldapjs#146
Fix mcavage/node-ldapjs#113
Fix mcavage/node-ldapjs#104
2014-09-30 18:39:19 -05:00
Patrick Mooney 92362e01f3 Improve parser error handling
- Wrap parser errors with VError
- Catch initial potential sequence errors
- Improve parser test coverage
- Emit parser errors instead of implicitly logging

Fix mcavage/node-ldapjs#221
2014-09-16 15:23:21 -05:00
Patrick Mooney 9ec6184ef5 Fix socket error handling during client unbind
The client now blackholes any socket errors after sending an unbind.
This prevents servers which issue RST from causing unecessary errors for
what was a succesful operation.

Fix mcavage/node-ldapjs#217
2014-08-21 02:01:30 -05:00
Patrick Mooney de16802a16 Fix SearchPager bugs, improve test coverage 2014-07-25 14:16:31 -05:00
Patrick Mooney 8fd16ee255 Add resultError event to client
Detecting certain types of errors in encountered during any operation
(such as BusyError or UnavailableError) can be useful for making
client-wide decisions.
2014-07-25 13:35:15 -05:00
Patrick Mooney b555463a90 Minor cleanup in SearchPager 2014-07-25 13:21:02 -05:00
Patrick Mooney d665378c0e Improve client paged search handling
Search response objects now include more instrumentation and control when
automatically fetching paged results.  See the SearchPager documentation
for more details.

Fix mcavage/node-ldapjs#203
2014-07-24 15:41:24 -05:00
Patrick Mooney abdd4890e5 Move client.connect into public API
In cases where a reconnect-enabled client has been manually disconnected
via unbind, it may be desirable to initiate a reconnect without
incurring other client actions.
2014-07-18 10:29:46 -05:00
Patrick Mooney 59bebe537b Make Attribute detection more strict
The old Attribute.isAttribute would allow objects lacking the toBer
method to be attached to Change objects.  This would result in errors
during serialization.

With the stricter Attribute detection, it's necessary to convert
Attribute-like objects containing type (string) and vals (array)
properties into real Attribute objects.  This precise detection is
necessary to avoid falling back to the object-keys-into-attributes

That other logic which will turn a well structured Attribute-like object
such as this:

  { type: 'valid', vals: ['something'] }

... and turn it into something broken like this:

  [
    { type: 'type', vals: ['valid'] },
    { type: 'vals', vals: ['something'] }
  ]
2014-07-17 13:33:02 -05:00
Patrick Mooney 2939fa1fad Improve client request state tracking
- Handle abandoned requests properly
- Re-enable client abandon test
- Report client idleness correctly (even after abandons)

Fix mcavage/node-ldapjs#211
2014-07-09 13:40:17 -05:00
Patrick Mooney 6607d83b86 Add automatic bind support to client
The pooled client would automatically bind when initializing connections
if bindDN and bindCredentials were passed to during construction.
This convenience should be supported in the plain client too.
2014-07-08 21:44:01 -05:00
Patrick Mooney aed6d2b043 Add optional error arg to client destroy event 2014-06-27 17:28:04 -05:00
Patrick Mooney 4bd454e608 Fix client initiation of multiple reconnect ops
If the client queue was enabled and requests were made during the
reconnect process (but after one unsuccessful connection attempt), they
would spawn concurrent reconnection attempts.
2014-06-27 16:48:13 -05:00
Patrick Mooney c7cd5da208 Improve client reconnect behavior
A client configured to reconnect should do so on socket close unless
unbind was called explicitly.  This covers cases where the connection
undergoes clean but unexpected termination.
2014-06-27 16:15:04 -05:00
Patrick Mooney 3edf9de578 Suppress setup errors after client.destroy
This allows clients to be destroyed during setupError events without
emitting errors from the connect/setup retry loop.
2014-06-26 12:05:34 -05:00
Patrick Mooney 28d3ed86e1 Refine client reconnection logic
- Emit setupError for errors during client setup
- Client accepts more generic options.reconnect
- Fix unbind hang in client.destroy
- Add tests for client reconnect/setup scenarios
2014-06-26 10:11:07 -05:00
Patrick Mooney 9e2bbe1072 Alter client queue parameters and error reporting
- Use 'queueDisable' as option for disabling client RequestQueue
- Throw more meaningful ConnectionError when enqueue fails
2014-06-25 14:38:26 -05:00
Patrick Mooney b49c2efed2 Fix socket close event handling in node.js 0.11.x
Fix mcavage/node-ldapjs#205
2014-06-24 18:41:11 -05:00
Patrick Mooney ea96468602 Use proper Change object detection in client 2014-06-24 17:43:25 -05:00
Patrick Mooney a0fd56d7b3 Fix reconnect abort logic on client.destroy() 2014-06-24 13:25:21 -05:00
Patrick Mooney 41f99c5b1a Merge pfmooney/gh-202
Fix mcavage/node-ldapjs#202
2014-06-24 11:06:09 -05:00
Patrick Mooney acfaa69a07 Fix client RequestQueue
- Reference documented queue parameters
- Add freeze/thaw methods
2014-06-24 11:04:23 -05:00
Patrick Mooney 3b101a7b2f Cease reconnection when client.destroy is called 2014-06-24 05:45:06 -05:00
Patrick Mooney 00956eaae5 Add ducktyping Filter.isFilter method
This should make some headway in avoiding instanceof pitfalls when
dealing with Filter objects.

Fix mcavage/node-ldapjs#123
2014-06-23 18:09:56 -05:00
Patrick Mooney 72bfb9b0f7 Major overhaul of client connection logic
- Remove PooledClient
- Add reconnect functionality to client
- Add 'idle' client event and options
2014-06-23 16:15:52 -05:00
Patrick Mooney f213b3e9a2 Allow configuration of derefAliases client option
Fix mcavage/node-ldapjs#134
2014-06-16 10:07:55 -05:00
Patrick Mooney d20308265a Circumvent lack of 'close' event for tls sockets
It appears that in node.js (at least recent versions), the 'close' event
is not emitted by TLS sockets.  The CleartextStream class specifies that
the 'close' event is optional, so such operation is allowed.  In order
to compensate, the event can be trapped at the raw net.socket instead.

Fix mcavage/node-ldapjs#161
2014-01-23 10:06:40 -06:00
Patrick Mooney 7bacfb676e Merge from pfmooney/client-pool-events
Fix mcavage/node-ldapjs#162
2014-01-17 15:33:11 -06:00
Patrick Mooney 6b7906ce99 Fix error event handling for pooled clients
Do not emit error events if no listeners are present
2014-01-17 10:47:51 -06:00
Gonzalo Huerta-Canepa 737009ee15 Modified client to allow buffer as a value for exop 2014-01-03 12:58:20 +00:00
Patrick Mooney dfbb6031c6 Merge client-pool-events from pfmooney/node-ldapjs
Fix mcavage/node-ldapjs#87
2013-11-28 14:09:28 -06:00
Patrick Mooney f5ba81dc38 Minor update to ClientPool event pass-through
- Allow event pass-through when performing ClientPool.bind
- Rename createPool parameter for better readability
- Fix jsstyle error
2013-11-28 14:08:17 -06:00
Patrick Mooney ebcba1205d Fix unhandled error during client connection
Client actions utilizing an EventEmitter may generate unhandled errors,
especially during initial connection.  Tracking whether the emitter has
been sent via callback is critical for proper routing of such errors.

Fix mcavage/node-ldapjs#144
2013-10-30 18:24:37 -05:00
Mark Cavage aa633dfd20 support extensible matching of caseIgnore and caseIgnoreSubstrings 2013-10-28 21:12:12 +00:00
Patrick Mooney e03d40957e Fix some ClientPool event handling
Emit connectTimeout and error events from ClientPool as Client would.
2013-10-24 21:04:50 -05:00