2019-08-27 18:17:33 +00:00
|
|
|
'use strict';
|
2011-12-20 00:52:48 +00:00
|
|
|
|
2019-08-27 18:17:33 +00:00
|
|
|
const { test } = require('tap');
|
|
|
|
const { BerReader, BerWriter } = require('asn1');
|
|
|
|
const { getControl, EntryChangeNotificationControl } = require('../../lib');
|
2011-12-20 00:52:48 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('new no args', function (t) {
|
2011-12-20 00:52:48 +00:00
|
|
|
t.ok(new EntryChangeNotificationControl());
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('new with args', function (t) {
|
2019-08-27 18:17:33 +00:00
|
|
|
const c = new EntryChangeNotificationControl({
|
2011-12-20 00:52:48 +00:00
|
|
|
type: '2.16.840.1.113730.3.4.7',
|
|
|
|
criticality: true,
|
|
|
|
value: {
|
|
|
|
changeType: 8,
|
|
|
|
previousDN: 'cn=foobarbazcar',
|
|
|
|
changeNumber: 123456789
|
|
|
|
}
|
|
|
|
});
|
|
|
|
t.ok(c);
|
|
|
|
t.equal(c.type, '2.16.840.1.113730.3.4.7');
|
|
|
|
t.ok(c.criticality);
|
|
|
|
t.equal(c.value.changeType, 8);
|
|
|
|
t.equal(c.value.previousDN, 'cn=foobarbazcar');
|
|
|
|
t.equal(c.value.changeNumber, 123456789);
|
|
|
|
|
2019-08-27 18:17:33 +00:00
|
|
|
const writer = new BerWriter();
|
2011-12-20 00:52:48 +00:00
|
|
|
c.toBer(writer);
|
2019-08-27 18:17:33 +00:00
|
|
|
const reader = new BerReader(writer.buffer);
|
|
|
|
const psc = getControl(reader);
|
2011-12-20 00:52:48 +00:00
|
|
|
t.ok(psc);
|
|
|
|
t.equal(psc.type, '2.16.840.1.113730.3.4.7');
|
|
|
|
t.ok(psc.criticality);
|
|
|
|
t.equal(psc.value.changeType, 8);
|
|
|
|
t.equal(psc.value.previousDN, 'cn=foobarbazcar');
|
|
|
|
t.equal(psc.value.changeNumber, 123456789);
|
|
|
|
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('tober', function (t) {
|
2019-08-27 18:17:33 +00:00
|
|
|
const psc = new EntryChangeNotificationControl({
|
2011-12-20 00:52:48 +00:00
|
|
|
type: '2.16.840.1.113730.3.4.7',
|
|
|
|
criticality: true,
|
|
|
|
value: {
|
|
|
|
changeType: 8,
|
|
|
|
previousDN: 'cn=foobarbazcar',
|
|
|
|
changeNumber: 123456789
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-27 18:17:33 +00:00
|
|
|
const ber = new BerWriter();
|
2011-12-20 00:52:48 +00:00
|
|
|
psc.toBer(ber);
|
|
|
|
|
2019-08-27 18:17:33 +00:00
|
|
|
const c = getControl(new BerReader(ber.buffer));
|
2011-12-20 00:52:48 +00:00
|
|
|
t.ok(c);
|
|
|
|
t.equal(c.type, '2.16.840.1.113730.3.4.7');
|
|
|
|
t.ok(c.criticality);
|
|
|
|
t.equal(c.value.changeType, 8);
|
|
|
|
t.equal(c.value.previousDN, 'cn=foobarbazcar');
|
|
|
|
t.equal(c.value.changeNumber, 123456789);
|
|
|
|
|
|
|
|
t.end();
|
|
|
|
});
|