2019-08-27 21:11:49 +00:00
|
|
|
'use strict'
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
const { test } = require('tap')
|
|
|
|
const { BerReader, BerWriter } = require('asn1')
|
|
|
|
const { DeleteRequest, dn } = require('../../lib')
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('new no args', function (t) {
|
2019-08-27 21:11:49 +00:00
|
|
|
t.ok(new DeleteRequest())
|
|
|
|
t.end()
|
|
|
|
})
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('new with args', function (t) {
|
2019-08-27 18:17:33 +00:00
|
|
|
const req = new DeleteRequest({
|
2011-08-04 20:32:01 +00:00
|
|
|
entry: dn.parse('cn=test')
|
2019-08-27 21:11:49 +00:00
|
|
|
})
|
|
|
|
t.ok(req)
|
|
|
|
t.equal(req.dn.toString(), 'cn=test')
|
|
|
|
t.end()
|
|
|
|
})
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('parse', function (t) {
|
2019-08-27 21:11:49 +00:00
|
|
|
const ber = new BerWriter()
|
|
|
|
ber.writeString('cn=test', 0x4a)
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
const req = new DeleteRequest()
|
|
|
|
const reader = new BerReader(ber.buffer)
|
|
|
|
reader.readSequence(0x4a)
|
|
|
|
t.ok(req.parse(reader, reader.length))
|
|
|
|
t.equal(req.dn.toString(), 'cn=test')
|
|
|
|
t.end()
|
|
|
|
})
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('toBer', function (t) {
|
2019-08-27 18:17:33 +00:00
|
|
|
const req = new DeleteRequest({
|
2011-08-04 20:32:01 +00:00
|
|
|
messageID: 123,
|
|
|
|
entry: dn.parse('cn=test')
|
2019-08-27 21:11:49 +00:00
|
|
|
})
|
|
|
|
t.ok(req)
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
const ber = new BerReader(req.toBer())
|
|
|
|
t.ok(ber)
|
|
|
|
t.equal(ber.readSequence(), 0x30)
|
|
|
|
t.equal(ber.readInt(), 123)
|
|
|
|
t.equal(ber.readString(0x4a), 'cn=test')
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
t.end()
|
|
|
|
})
|