Resolve issue #336

This commit is contained in:
James Sumners 2019-08-27 19:01:47 -04:00
parent b62e303fc4
commit 9a8f60767b
No known key found for this signature in database
GPG Key ID: DD9AAE30F864776B
3 changed files with 22 additions and 4 deletions

View File

@ -289,7 +289,7 @@ with ldapjs.
var entry = req.toObject().attributes;
if (entry.objectclass.indexOf('unixUser') === -1)
return next(new ldap.ConstraintViolation('entry must be a unixUser'));
return next(new ldap.ConstraintViolationError('entry must be a unixUser'));
var opts = ['-m'];
if (entry.description) {

View File

@ -409,7 +409,7 @@ the following code in as another handler (you'll need a
var entry = req.toObject().attributes;
if (entry.objectclass.indexOf('unixUser') === -1)
return next(new ldap.ConstraintViolation('entry must be a unixUser'));
return next(new ldap.ConstraintViolationError('entry must be a unixUser'));
var opts = ['-m'];
if (entry.description) {
@ -496,7 +496,7 @@ As before, here's a breakdown of the code:
var entry = req.toObject().attributes;
if (entry.objectclass.indexOf('unixUser') === -1)
return next(new ldap.ConstraintViolation('entry must be a unixUser'));
return next(new ldap.ConstraintViolationError('entry must be a unixUser'));
A few new things:

View File

@ -1,7 +1,14 @@
'use strict'
const { test } = require('tap')
const { LDAPError, ConnectionError, AbandonedError, TimeoutError, LDAP_OTHER } = require('../lib')
const {
LDAPError,
ConnectionError,
AbandonedError,
TimeoutError,
ConstraintViolationError,
LDAP_OTHER
} = require('../lib')
test('basic error', function (t) {
const msg = 'mymsg'
@ -14,6 +21,17 @@ test('basic error', function (t) {
t.end()
})
test('exports ConstraintViolationError', function (t) {
const msg = 'mymsg'
const err = new ConstraintViolationError(msg, null, null)
t.ok(err)
t.equal(err.name, 'ConstraintViolationError')
t.equal(err.code, 19)
t.equal(err.dn, '')
t.equal(err.message, msg)
t.end()
})
test('"custom" errors', function (t) {
const errors = [
{ name: 'ConnectionError', Func: ConnectionError },