Resolve issue #336
This commit is contained in:
parent
b62e303fc4
commit
9a8f60767b
|
@ -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) {
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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 },
|
||||
|
|
Loading…
Reference in New Issue