2011-08-04 20:32:01 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
var asn1 = require('asn1');
|
2012-02-18 19:47:58 +00:00
|
|
|
var Logger = require('bunyan');
|
2014-07-08 19:31:57 +00:00
|
|
|
var test = require('tape').test;
|
2011-08-04 20:32:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
///--- Globals
|
|
|
|
|
|
|
|
var BerReader = asn1.BerReader;
|
|
|
|
var BerWriter = asn1.BerWriter;
|
|
|
|
var DeleteRequest;
|
|
|
|
var dn;
|
|
|
|
|
|
|
|
|
|
|
|
///--- Tests
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('load library', function (t) {
|
2011-08-04 20:32:01 +00:00
|
|
|
DeleteRequest = require('../../lib/index').DeleteRequest;
|
|
|
|
dn = require('../../lib/index').dn;
|
|
|
|
t.ok(DeleteRequest);
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('new no args', function (t) {
|
2011-08-04 20:32:01 +00:00
|
|
|
t.ok(new DeleteRequest());
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('new with args', function (t) {
|
2011-08-04 20:32:01 +00:00
|
|
|
var req = new DeleteRequest({
|
|
|
|
entry: dn.parse('cn=test')
|
|
|
|
});
|
|
|
|
t.ok(req);
|
2011-08-12 23:37:47 +00:00
|
|
|
t.equal(req.dn.toString(), 'cn=test');
|
2011-08-04 20:32:01 +00:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('parse', function (t) {
|
2011-08-04 20:32:01 +00:00
|
|
|
var ber = new BerWriter();
|
|
|
|
ber.writeString('cn=test', 0x4a);
|
|
|
|
|
2012-02-18 19:47:58 +00:00
|
|
|
var req = new DeleteRequest({
|
|
|
|
log: new Logger({name: 'del_request.test.js'})
|
|
|
|
});
|
2011-08-04 20:32:01 +00:00
|
|
|
var reader = new BerReader(ber.buffer);
|
|
|
|
reader.readSequence(0x4a);
|
2011-11-11 18:08:48 +00:00
|
|
|
t.ok(req.parse(reader, reader.length));
|
2011-08-12 23:37:47 +00:00
|
|
|
t.equal(req.dn.toString(), 'cn=test');
|
2011-08-04 20:32:01 +00:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
test('toBer', function (t) {
|
2011-08-04 20:32:01 +00:00
|
|
|
var req = new DeleteRequest({
|
|
|
|
messageID: 123,
|
|
|
|
entry: dn.parse('cn=test')
|
|
|
|
});
|
|
|
|
t.ok(req);
|
|
|
|
|
|
|
|
var 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');
|
|
|
|
|
|
|
|
t.end();
|
|
|
|
});
|