2011-08-04 20:32:01 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
|
|
|
|
var test = require('tap').test;
|
|
|
|
|
|
|
|
var asn1 = require('asn1');
|
|
|
|
|
|
|
|
|
|
|
|
///--- 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);
|
|
|
|
|
|
|
|
var req = new DeleteRequest();
|
|
|
|
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();
|
|
|
|
});
|