net-snmp 3.19.0 → 3.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/index.js +3 -3
- package/package.json +1 -1
- package/test/object-types.test.js +11 -0
package/README.md
CHANGED
@@ -3465,6 +3465,14 @@ Example programs are included under the module's `example` directory.
|
|
3465
3465
|
|
3466
3466
|
* Remove deprecated isArray call and fix agent string constraints check
|
3467
3467
|
|
3468
|
+
## Version 3.19.1 - 03/03/2025
|
3469
|
+
|
3470
|
+
* Fix integer constraints check
|
3471
|
+
|
3472
|
+
# Version 3.19.2 - 06/03/2025
|
3473
|
+
|
3474
|
+
* Fix integer and string constraints check on cast
|
3475
|
+
|
3468
3476
|
# License
|
3469
3477
|
|
3470
3478
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/index.js
CHANGED
@@ -604,7 +604,7 @@ ObjectTypeUtil.castSetValue = function (type, value, constraints) {
|
|
604
604
|
if ( isNaN(parsedValue) ) {
|
605
605
|
throw new Error("Invalid Integer", value);
|
606
606
|
}
|
607
|
-
if ( constraints && ObjectTypeUtil.doesIntegerMeetConstraints (parsedValue, constraints) ) {
|
607
|
+
if ( constraints && ! ObjectTypeUtil.doesIntegerMeetConstraints (parsedValue, constraints) ) {
|
608
608
|
throw new Error("Integer does not meet constraints", value);
|
609
609
|
}
|
610
610
|
return parsedValue;
|
@@ -614,7 +614,7 @@ ObjectTypeUtil.castSetValue = function (type, value, constraints) {
|
|
614
614
|
if ( ! value instanceof Buffer && typeof value != "string" ) {
|
615
615
|
throw new Error("Invalid OctetString", value);
|
616
616
|
}
|
617
|
-
if ( constraints && ObjectTypeUtil.doesStringMeetConstraints (value, constraints) ) {
|
617
|
+
if ( constraints && ! ObjectTypeUtil.doesStringMeetConstraints (value, constraints) ) {
|
618
618
|
throw new Error("OctetString does not meet constraints", value);
|
619
619
|
}
|
620
620
|
if ( value instanceof Buffer ) {
|
@@ -672,7 +672,7 @@ ObjectTypeUtil.isValid = function (type, value, constraints) {
|
|
672
672
|
if ( isNaN(parsedValue) || ! Number.isInteger(parsedValue) || parsedValue < MIN_SIGNED_INT32 || parsedValue > MAX_SIGNED_INT32 ) {
|
673
673
|
return false;
|
674
674
|
}
|
675
|
-
if ( constraints && ObjectTypeUtil.doesIntegerMeetConstraints (parsedValue, constraints) ) {
|
675
|
+
if ( constraints && ! ObjectTypeUtil.doesIntegerMeetConstraints (parsedValue, constraints) ) {
|
676
676
|
return false;
|
677
677
|
}
|
678
678
|
return true;
|
package/package.json
CHANGED
@@ -72,6 +72,17 @@ describe('Object Types', function() {
|
|
72
72
|
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 2147483648), false);
|
73
73
|
});
|
74
74
|
});
|
75
|
+
// Tests for constraints
|
76
|
+
describe('An integer at the bottom of the valid range is a valid Integer type', function() {
|
77
|
+
it('returns true', function() {
|
78
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 0, { ranges: [{ min: 0, max: 10 }] }), true);
|
79
|
+
});
|
80
|
+
});
|
81
|
+
describe('An integer outside the valid range is not an valid Integer type', function() {
|
82
|
+
it('returns false', function() {
|
83
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 11, { ranges: [{ min: 0, max: 10 }] }), false);
|
84
|
+
});
|
85
|
+
});
|
75
86
|
});
|
76
87
|
|
77
88
|
describe('isValid() - OctetString', function() {
|