getControl not handling null values correctly

This commit is contained in:
Mark Cavage 2012-01-06 08:51:54 -08:00
parent 4a106d1acf
commit 16a1018a3b
3 changed files with 18 additions and 2 deletions

View File

@ -34,7 +34,7 @@ function Control(options) {
this.type = options.type || '';
this.criticality = options.critical || options.criticality || false;
this.value = options.value || undefined;
this.value = options.value || null;
var self = this;
this.__defineGetter__('json', function() {

View File

@ -54,7 +54,7 @@ module.exports = {
control = new Control({
type: type,
critical: critical,
value: value.toString('utf8')
value: value ? value.toString('utf8') : null
});
}

View File

@ -58,3 +58,19 @@ test('parse', function(t) {
t.equal(c.value, 'foo');
t.end();
});
test('parse no value', function(t) {
var ber = new BerWriter();
ber.startSequence();
ber.writeString('2.16.840.1.113730.3.4.2');
ber.endSequence();
var c = getControl(new BerReader(ber.buffer));
t.ok(c);
t.equal(c.type, '2.16.840.1.113730.3.4.2');
t.equal(c.criticality, false);
t.notOk(c.value, null);
t.end();
});