getControl not handling null values correctly
This commit is contained in:
parent
4a106d1acf
commit
16a1018a3b
|
@ -34,7 +34,7 @@ function Control(options) {
|
||||||
|
|
||||||
this.type = options.type || '';
|
this.type = options.type || '';
|
||||||
this.criticality = options.critical || options.criticality || false;
|
this.criticality = options.critical || options.criticality || false;
|
||||||
this.value = options.value || undefined;
|
this.value = options.value || null;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.__defineGetter__('json', function() {
|
this.__defineGetter__('json', function() {
|
||||||
|
|
|
@ -54,7 +54,7 @@ module.exports = {
|
||||||
control = new Control({
|
control = new Control({
|
||||||
type: type,
|
type: type,
|
||||||
critical: critical,
|
critical: critical,
|
||||||
value: value.toString('utf8')
|
value: value ? value.toString('utf8') : null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,3 +58,19 @@ test('parse', function(t) {
|
||||||
t.equal(c.value, 'foo');
|
t.equal(c.value, 'foo');
|
||||||
t.end();
|
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();
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue