net-snmp 3.17.0 → 3.18.1
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/.vscode/launch.json +111 -156
- package/README.md +19 -2
- package/index.js +145 -84
- package/package.json +1 -1
- package/test/TEST-MIB.mib +210 -0
- package/test/mib.test.js +129 -0
- package/test/object-types.test.js +242 -0
- package/test/varbinds.test.js +53 -0
- package/test/objects.js +0 -238
- package/test/varbinds.js +0 -49
package/test/mib.test.js
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
const assert = require('assert');
|
2
|
+
const snmp = require('..');
|
3
|
+
|
4
|
+
let mibProviders;
|
5
|
+
let mib;
|
6
|
+
|
7
|
+
describe('MIB', function () {
|
8
|
+
|
9
|
+
this.beforeAll(function () {
|
10
|
+
const mibDir = './test/';
|
11
|
+
const store = snmp.createModuleStore();
|
12
|
+
store.loadFromFile(mibDir + 'TEST-MIB.mib');
|
13
|
+
mibProviders = store.getProvidersForModule('TEST-MIB');
|
14
|
+
});
|
15
|
+
|
16
|
+
beforeEach(function () {
|
17
|
+
mib = snmp.createMib();
|
18
|
+
mib.registerProviders(mibProviders);
|
19
|
+
});
|
20
|
+
|
21
|
+
describe('setScalarValue()', function () {
|
22
|
+
it('sets a scalar value', function () {
|
23
|
+
mib.setScalarValue('testScalarInteger', 42);
|
24
|
+
assert.equal(mib.getScalarValue('testScalarInteger'), 42);
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
describe('getScalarValue()', function () {
|
29
|
+
it('sets a scalar value', function () {
|
30
|
+
mib.setScalarValue('testScalarInteger', 42);
|
31
|
+
assert.equal(mib.getScalarValue('testScalarInteger'), 42);
|
32
|
+
});
|
33
|
+
});
|
34
|
+
|
35
|
+
describe('addTableRow()', function () {
|
36
|
+
it('adds a row to a table', function () {
|
37
|
+
const row = [1, 'RowValue'];
|
38
|
+
mib.addTableRow('testEntry1', row);
|
39
|
+
const tableData = mib.getTableCells('testEntry1', true, true);
|
40
|
+
assert.deepEqual(tableData, [[ [1], 'RowValue']]);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
|
44
|
+
describe('getTableColumnDefinitions()', function () {
|
45
|
+
it('returns column definitions for a table', function () {
|
46
|
+
const columns = mib.getTableColumnDefinitions('testEntry1');
|
47
|
+
assert.equal(columns.length, 2);
|
48
|
+
assert.equal(columns[0].name, 'testTable1Index');
|
49
|
+
assert.equal(columns[1].name, 'testTable1Value');
|
50
|
+
});
|
51
|
+
});
|
52
|
+
|
53
|
+
describe('getTableCells()', function () {
|
54
|
+
it('retrieves table data by rows', function () {
|
55
|
+
const row = [1, 'RowValue'];
|
56
|
+
mib.addTableRow('testEntry1', row);
|
57
|
+
const data = mib.getTableCells('testEntry1', true, true);
|
58
|
+
assert.deepEqual(data, [[ [1], 'RowValue']]);
|
59
|
+
});
|
60
|
+
|
61
|
+
it('retrieves table data by columns', function () {
|
62
|
+
const row = [1, 'RowValue'];
|
63
|
+
mib.addTableRow('testEntry1', row);
|
64
|
+
const data = mib.getTableCells('testEntry1', false, true);
|
65
|
+
assert.deepEqual(data, [ [[1]], ['RowValue']]);
|
66
|
+
});
|
67
|
+
});
|
68
|
+
|
69
|
+
describe('getTableColumnCells()', function () {
|
70
|
+
it('retrieves a single column of table data', function () {
|
71
|
+
const row = [1, 'RowValue'];
|
72
|
+
mib.addTableRow('testEntry1', row);
|
73
|
+
const columnData = mib.getTableColumnCells('testEntry1', 2);
|
74
|
+
assert.deepEqual(columnData, ['RowValue']);
|
75
|
+
});
|
76
|
+
});
|
77
|
+
|
78
|
+
describe('getTableRowCells()', function () {
|
79
|
+
it('retrieves a single row of table data', function () {
|
80
|
+
const row = [1, 'RowValue'];
|
81
|
+
mib.addTableRow('testEntry1', row);
|
82
|
+
const rowData = mib.getTableRowCells('testEntry1', [1]);
|
83
|
+
assert.deepEqual(rowData, ['RowValue']);
|
84
|
+
});
|
85
|
+
});
|
86
|
+
|
87
|
+
describe('getTableSingleCell()', function () {
|
88
|
+
it('retrieves a single cell value from a table', function () {
|
89
|
+
const row = [1, 'RowValue'];
|
90
|
+
mib.addTableRow('testEntry1', row);
|
91
|
+
const cellValue = mib.getTableSingleCell('testEntry1', 2, [1]);
|
92
|
+
assert.equal(cellValue, 'RowValue');
|
93
|
+
});
|
94
|
+
});
|
95
|
+
|
96
|
+
describe('setTableSingleCell()', function () {
|
97
|
+
it('sets a single cell value in a table', function () {
|
98
|
+
const row = [1, 'RowValue'];
|
99
|
+
mib.addTableRow('testEntry1', row);
|
100
|
+
mib.setTableSingleCell('testEntry1', 2, [1], 'NewValue');
|
101
|
+
const cellValue = mib.getTableSingleCell('testEntry1', 2, [1]);
|
102
|
+
assert.equal(cellValue, 'NewValue');
|
103
|
+
});
|
104
|
+
});
|
105
|
+
|
106
|
+
describe('deleteTableRow()', function () {
|
107
|
+
it('deletes a table row', function () {
|
108
|
+
const row1 = [1, 'CellValue1'];
|
109
|
+
const row2 = [2, 'CellValue2'];
|
110
|
+
mib.addTableRow('testEntry1', row1);
|
111
|
+
mib.addTableRow('testEntry1', row2);
|
112
|
+
mib.deleteTableRow('testEntry1', [1]);
|
113
|
+
const data = mib.getTableCells('testEntry1', true, true);
|
114
|
+
assert.deepEqual(data, [[ [2], 'CellValue2']]);
|
115
|
+
});
|
116
|
+
});
|
117
|
+
|
118
|
+
describe('registerProvider() - scalar defVal', function () {
|
119
|
+
it('adds a scalar value on registration', function () {
|
120
|
+
const options = {
|
121
|
+
addScalarDefaultsOnRegistration: true
|
122
|
+
};
|
123
|
+
mib = snmp.createMib(options);
|
124
|
+
mib.registerProviders(mibProviders);
|
125
|
+
assert.equal(mib.getScalarValue('testScalarIntegerDefval'), 49);
|
126
|
+
});
|
127
|
+
});
|
128
|
+
|
129
|
+
});
|
@@ -0,0 +1,242 @@
|
|
1
|
+
const assert = require('assert');
|
2
|
+
const snmp = require('..');
|
3
|
+
|
4
|
+
describe('Object Types', function() {
|
5
|
+
|
6
|
+
describe('isValid() - Boolean', function() {
|
7
|
+
describe('JS true is a Boolean type', function() {
|
8
|
+
it('returns true', function() {
|
9
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Boolean, true), true);
|
10
|
+
});
|
11
|
+
});
|
12
|
+
describe('JS false is a Boolean type', function() {
|
13
|
+
it('returns true', function() {
|
14
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Boolean, false), true);
|
15
|
+
});
|
16
|
+
});
|
17
|
+
});
|
18
|
+
|
19
|
+
describe('isValid() - Integer', function() {
|
20
|
+
describe('Zero is an Integer type', function() {
|
21
|
+
it('returns true', function() {
|
22
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 0), true);
|
23
|
+
});
|
24
|
+
});
|
25
|
+
describe('An positive integer number is an Integer type', function() {
|
26
|
+
it('returns true', function() {
|
27
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 44), true);
|
28
|
+
});
|
29
|
+
});
|
30
|
+
describe('An positive integer string is an Integer type', function() {
|
31
|
+
it('returns true', function() {
|
32
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "44"), true);
|
33
|
+
});
|
34
|
+
});
|
35
|
+
describe('An negative integer number is an Integer type', function() {
|
36
|
+
it('returns true', function() {
|
37
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -24), true);
|
38
|
+
});
|
39
|
+
});
|
40
|
+
describe('A negative integer string is an Integer type', function() {
|
41
|
+
it('returns true', function() {
|
42
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "-24"), true);
|
43
|
+
});
|
44
|
+
});
|
45
|
+
describe('A non-integer decimal number is not an Integer type', function() {
|
46
|
+
it('returns false', function() {
|
47
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 45.2), false);
|
48
|
+
});
|
49
|
+
});
|
50
|
+
describe('A non-integer decimal string is not an Integer type', function() {
|
51
|
+
it('returns false', function() {
|
52
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "45.2"), false);
|
53
|
+
});
|
54
|
+
});
|
55
|
+
describe('An integer at the bottom of the valid range is an Integer type', function() {
|
56
|
+
it('returns true', function() {
|
57
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -2147483648), true);
|
58
|
+
});
|
59
|
+
});
|
60
|
+
describe('An integer just lower than the valid range is not an Integer type', function() {
|
61
|
+
it('returns false', function() {
|
62
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -2147483649), false);
|
63
|
+
});
|
64
|
+
});
|
65
|
+
describe('An integer at the top of the valid range is an Integer type', function() {
|
66
|
+
it('returns true', function() {
|
67
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 2147483647), true);
|
68
|
+
});
|
69
|
+
});
|
70
|
+
describe('An integer just higher than the valid range is not an Integer type', function() {
|
71
|
+
it('returns false', function() {
|
72
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 2147483648), false);
|
73
|
+
});
|
74
|
+
});
|
75
|
+
});
|
76
|
+
|
77
|
+
describe('isValid() - OctetString', function() {
|
78
|
+
describe('A string is an OctetString type', function() {
|
79
|
+
it('returns true', function() {
|
80
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'Better late than never'), true);
|
81
|
+
});
|
82
|
+
});
|
83
|
+
describe('A buffer is an OctetString type', function() {
|
84
|
+
it('returns true', function() {
|
85
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, Buffer.from('1.3.6.1.2.3.4.5')), true);
|
86
|
+
});
|
87
|
+
});
|
88
|
+
});
|
89
|
+
|
90
|
+
describe('isValid() - OID', function() {
|
91
|
+
describe('A string OID is an OID type', function() {
|
92
|
+
it('returns true', function() {
|
93
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1.2.33.4.5'), true);
|
94
|
+
});
|
95
|
+
});
|
96
|
+
describe('A string non-OID is not an OID type', function() {
|
97
|
+
it('returns true', function() {
|
98
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'dog'), true);
|
99
|
+
});
|
100
|
+
});
|
101
|
+
describe('An OID string with a double-dot is not an OID type', function() {
|
102
|
+
it('returns true', function() {
|
103
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1..2.33.4.5'), true);
|
104
|
+
});
|
105
|
+
});
|
106
|
+
describe('An OID string with a leading dot is not an OID type', function() {
|
107
|
+
it('returns true', function() {
|
108
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '.1.3.6.1..2.33.4.5'), true);
|
109
|
+
});
|
110
|
+
});
|
111
|
+
describe('An OID string with a trailing dot is not an OID type', function() {
|
112
|
+
it('returns true', function() {
|
113
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1.2.33.4.5.'), true);
|
114
|
+
});
|
115
|
+
});
|
116
|
+
});
|
117
|
+
|
118
|
+
describe('isValid() - Counter', function() {
|
119
|
+
describe('Zero is a Counter type', function() {
|
120
|
+
it('returns true', function() {
|
121
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 0), true);
|
122
|
+
});
|
123
|
+
});
|
124
|
+
describe('An positive integer number is a Counter type', function() {
|
125
|
+
it('returns true', function() {
|
126
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 44), true);
|
127
|
+
});
|
128
|
+
});
|
129
|
+
describe('An positive integer string is a Counter type', function() {
|
130
|
+
it('returns true', function() {
|
131
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "44"), true);
|
132
|
+
});
|
133
|
+
});
|
134
|
+
describe('An negative integer number is not a Counter type', function() {
|
135
|
+
it('returns false', function() {
|
136
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, -24), false);
|
137
|
+
});
|
138
|
+
});
|
139
|
+
describe('A negative integer string is not a Counter type', function() {
|
140
|
+
it('returns false', function() {
|
141
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "-24"), false);
|
142
|
+
});
|
143
|
+
});
|
144
|
+
describe('A non-integer decimal number is not a Counter type', function() {
|
145
|
+
it('returns false', function() {
|
146
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 45.2), false);
|
147
|
+
});
|
148
|
+
});
|
149
|
+
describe('A non-integer decimal string is not a Counter type', function() {
|
150
|
+
it('returns false', function() {
|
151
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "45.2"), false);
|
152
|
+
});
|
153
|
+
});
|
154
|
+
describe('An integer at the bottom of the valid range is a Counter type', function() {
|
155
|
+
it('returns true', function() {
|
156
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 0), true);
|
157
|
+
});
|
158
|
+
});
|
159
|
+
describe('An integer just lower than the valid range is not a Counter type', function() {
|
160
|
+
it('returns false', function() {
|
161
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, -1), false);
|
162
|
+
});
|
163
|
+
});
|
164
|
+
describe('An integer at the top of the valid range is a Counter type', function() {
|
165
|
+
it('returns true', function() {
|
166
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 4294967295), true);
|
167
|
+
});
|
168
|
+
});
|
169
|
+
describe('An integer just higher than the valid range is not a Counter type', function() {
|
170
|
+
it('returns false', function() {
|
171
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 4294967296), false);
|
172
|
+
});
|
173
|
+
});
|
174
|
+
});
|
175
|
+
|
176
|
+
describe('isValid() - Counter64', function() {
|
177
|
+
describe('Zero is a Counter64 type', function() {
|
178
|
+
it('returns true', function() {
|
179
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 0), true);
|
180
|
+
});
|
181
|
+
});
|
182
|
+
describe('An positive integer number is a Counter64 type', function() {
|
183
|
+
it('returns true', function() {
|
184
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 44), true);
|
185
|
+
});
|
186
|
+
});
|
187
|
+
describe('An positive integer string is a Counter64 type', function() {
|
188
|
+
it('returns true', function() {
|
189
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "44"), true);
|
190
|
+
});
|
191
|
+
});
|
192
|
+
describe('An negative integer number is not a Counter64 type', function() {
|
193
|
+
it('returns false', function() {
|
194
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, -24), false);
|
195
|
+
});
|
196
|
+
});
|
197
|
+
describe('A negative integer string is not a Counter64 type', function() {
|
198
|
+
it('returns false', function() {
|
199
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "-24"), false);
|
200
|
+
});
|
201
|
+
});
|
202
|
+
describe('A non-integer decimal number is not a Counter64 type', function() {
|
203
|
+
it('returns false', function() {
|
204
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 45.2), false);
|
205
|
+
});
|
206
|
+
});
|
207
|
+
describe('A non-integer decimal string is not a Counter64 type', function() {
|
208
|
+
it('returns false', function() {
|
209
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "45.2"), false);
|
210
|
+
});
|
211
|
+
});
|
212
|
+
describe('An integer at the bottom of the valid range is a Counter64 type', function() {
|
213
|
+
it('returns true', function() {
|
214
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 0), true);
|
215
|
+
});
|
216
|
+
});
|
217
|
+
describe('An integer just lower than the valid range is not a Counter64 type', function() {
|
218
|
+
it('returns false', function() {
|
219
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, -1), false);
|
220
|
+
});
|
221
|
+
});
|
222
|
+
});
|
223
|
+
|
224
|
+
describe('isValid() - IPAddress', function() {
|
225
|
+
describe('Dotted quad of numbers is an IpAddress type', function() {
|
226
|
+
it('returns true', function() {
|
227
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.3.147.4'), true);
|
228
|
+
});
|
229
|
+
});
|
230
|
+
describe('Dotted quin of numbers is not an IpAddress type', function() {
|
231
|
+
it('returns false', function() {
|
232
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.3.147.22.4'), false);
|
233
|
+
});
|
234
|
+
});
|
235
|
+
describe('Dotted quad containing non-numbers is not an IpAddress type', function() {
|
236
|
+
it('returns false', function() {
|
237
|
+
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.word.147.4'), false);
|
238
|
+
});
|
239
|
+
});
|
240
|
+
});
|
241
|
+
|
242
|
+
});
|
@@ -0,0 +1,53 @@
|
|
1
|
+
const assert = require('assert');
|
2
|
+
const ber = require ('asn1-ber').Ber;
|
3
|
+
const snmp = require('..');
|
4
|
+
|
5
|
+
describe('Varbinds', function() {
|
6
|
+
|
7
|
+
describe('parseInt()', function() {
|
8
|
+
describe('given a negative integer', function() {
|
9
|
+
const writer = new ber.Writer();
|
10
|
+
writer.writeInt(-3);
|
11
|
+
const reader = new ber.Reader(writer.buffer);
|
12
|
+
it('returns a negative integer', function() {
|
13
|
+
assert.equal(snmp.ObjectParser.readInt32(reader), -3);
|
14
|
+
});
|
15
|
+
});
|
16
|
+
describe('given a positive integer', function() {
|
17
|
+
const writer = new ber.Writer();
|
18
|
+
writer.writeInt(3245689);
|
19
|
+
const reader = new ber.Reader(writer.buffer);
|
20
|
+
it('returns a positive integer', function() {
|
21
|
+
assert.equal(snmp.ObjectParser.readInt32(reader), 3245689);
|
22
|
+
});
|
23
|
+
});
|
24
|
+
});
|
25
|
+
|
26
|
+
describe('parseUint()', function() {
|
27
|
+
describe('given a positive integer', function() {
|
28
|
+
const writer = new ber.Writer();
|
29
|
+
writer.writeInt(3242425);
|
30
|
+
const reader = new ber.Reader(writer.buffer);
|
31
|
+
it('returns a positive integer', function() {
|
32
|
+
assert.equal(snmp.ObjectParser.readUint32(reader), 3242425);
|
33
|
+
});
|
34
|
+
});
|
35
|
+
describe('given a negative integer', function() {
|
36
|
+
const writer = new ber.Writer();
|
37
|
+
writer.writeInt(-3);
|
38
|
+
const reader = new ber.Reader(writer.buffer);
|
39
|
+
it('returns a positive integer', function() {
|
40
|
+
assert.equal(snmp.ObjectParser.readUint32(reader), 4294967293);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
describe('given a large integer', function() {
|
44
|
+
const writer = new ber.Writer();
|
45
|
+
writer.writeInt(4294967294);
|
46
|
+
const reader = new ber.Reader(writer.buffer);
|
47
|
+
it('returns a positive integer', function() {
|
48
|
+
assert.equal(snmp.ObjectParser.readUint32(reader), 4294967294);
|
49
|
+
});
|
50
|
+
});
|
51
|
+
});
|
52
|
+
|
53
|
+
});
|
package/test/objects.js
DELETED
@@ -1,238 +0,0 @@
|
|
1
|
-
const assert = require('assert');
|
2
|
-
const snmp = require('../');
|
3
|
-
|
4
|
-
describe('isValid() - Boolean', function() {
|
5
|
-
describe('JS true is a Boolean type', function() {
|
6
|
-
it('returns true', function() {
|
7
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Boolean, true), true);
|
8
|
-
});
|
9
|
-
});
|
10
|
-
describe('JS false is a Boolean type', function() {
|
11
|
-
it('returns true', function() {
|
12
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Boolean, false), true);
|
13
|
-
});
|
14
|
-
});
|
15
|
-
});
|
16
|
-
|
17
|
-
describe('isValid() - Integer', function() {
|
18
|
-
describe('Zero is an Integer type', function() {
|
19
|
-
it('returns true', function() {
|
20
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 0), true);
|
21
|
-
});
|
22
|
-
});
|
23
|
-
describe('An positive integer number is an Integer type', function() {
|
24
|
-
it('returns true', function() {
|
25
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 44), true);
|
26
|
-
});
|
27
|
-
});
|
28
|
-
describe('An positive integer string is an Integer type', function() {
|
29
|
-
it('returns true', function() {
|
30
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "44"), true);
|
31
|
-
});
|
32
|
-
});
|
33
|
-
describe('An negative integer number is an Integer type', function() {
|
34
|
-
it('returns true', function() {
|
35
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -24), true);
|
36
|
-
});
|
37
|
-
});
|
38
|
-
describe('A negative integer string is an Integer type', function() {
|
39
|
-
it('returns true', function() {
|
40
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "-24"), true);
|
41
|
-
});
|
42
|
-
});
|
43
|
-
describe('A non-integer decimal number is not an Integer type', function() {
|
44
|
-
it('returns false', function() {
|
45
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 45.2), false);
|
46
|
-
});
|
47
|
-
});
|
48
|
-
describe('A non-integer decimal string is not an Integer type', function() {
|
49
|
-
it('returns false', function() {
|
50
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, "45.2"), false);
|
51
|
-
});
|
52
|
-
});
|
53
|
-
describe('An integer at the bottom of the valid range is an Integer type', function() {
|
54
|
-
it('returns true', function() {
|
55
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -2147483648), true);
|
56
|
-
});
|
57
|
-
});
|
58
|
-
describe('An integer just lower than the valid range is not an Integer type', function() {
|
59
|
-
it('returns false', function() {
|
60
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, -2147483649), false);
|
61
|
-
});
|
62
|
-
});
|
63
|
-
describe('An integer at the top of the valid range is an Integer type', function() {
|
64
|
-
it('returns true', function() {
|
65
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 2147483647), true);
|
66
|
-
});
|
67
|
-
});
|
68
|
-
describe('An integer just higher than the valid range is not an Integer type', function() {
|
69
|
-
it('returns false', function() {
|
70
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 2147483648), false);
|
71
|
-
});
|
72
|
-
});
|
73
|
-
});
|
74
|
-
|
75
|
-
describe('isValid() - OctetString', function() {
|
76
|
-
describe('A string is an OctetString type', function() {
|
77
|
-
it('returns true', function() {
|
78
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'Better late than never'), true);
|
79
|
-
});
|
80
|
-
});
|
81
|
-
describe('A buffer is an OctetString type', function() {
|
82
|
-
it('returns true', function() {
|
83
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, Buffer.from('1.3.6.1.2.3.4.5')), true);
|
84
|
-
});
|
85
|
-
});
|
86
|
-
});
|
87
|
-
|
88
|
-
describe('isValid() - OID', function() {
|
89
|
-
describe('A string OID is an OID type', function() {
|
90
|
-
it('returns true', function() {
|
91
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1.2.33.4.5'), true);
|
92
|
-
});
|
93
|
-
});
|
94
|
-
describe('A string non-OID is not an OID type', function() {
|
95
|
-
it('returns true', function() {
|
96
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'dog'), true);
|
97
|
-
});
|
98
|
-
});
|
99
|
-
describe('An OID string with a double-dot is not an OID type', function() {
|
100
|
-
it('returns true', function() {
|
101
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1..2.33.4.5'), true);
|
102
|
-
});
|
103
|
-
});
|
104
|
-
describe('An OID string with a leading dot is not an OID type', function() {
|
105
|
-
it('returns true', function() {
|
106
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '.1.3.6.1..2.33.4.5'), true);
|
107
|
-
});
|
108
|
-
});
|
109
|
-
describe('An OID string with a trailing dot is not an OID type', function() {
|
110
|
-
it('returns true', function() {
|
111
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, '1.3.6.1.2.33.4.5.'), true);
|
112
|
-
});
|
113
|
-
});
|
114
|
-
});
|
115
|
-
|
116
|
-
describe('isValid() - Counter', function() {
|
117
|
-
describe('Zero is a Counter type', function() {
|
118
|
-
it('returns true', function() {
|
119
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 0), true);
|
120
|
-
});
|
121
|
-
});
|
122
|
-
describe('An positive integer number is a Counter type', function() {
|
123
|
-
it('returns true', function() {
|
124
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 44), true);
|
125
|
-
});
|
126
|
-
});
|
127
|
-
describe('An positive integer string is a Counter type', function() {
|
128
|
-
it('returns true', function() {
|
129
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "44"), true);
|
130
|
-
});
|
131
|
-
});
|
132
|
-
describe('An negative integer number is not a Counter type', function() {
|
133
|
-
it('returns false', function() {
|
134
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, -24), false);
|
135
|
-
});
|
136
|
-
});
|
137
|
-
describe('A negative integer string is not a Counter type', function() {
|
138
|
-
it('returns false', function() {
|
139
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "-24"), false);
|
140
|
-
});
|
141
|
-
});
|
142
|
-
describe('A non-integer decimal number is not a Counter type', function() {
|
143
|
-
it('returns false', function() {
|
144
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 45.2), false);
|
145
|
-
});
|
146
|
-
});
|
147
|
-
describe('A non-integer decimal string is not a Counter type', function() {
|
148
|
-
it('returns false', function() {
|
149
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, "45.2"), false);
|
150
|
-
});
|
151
|
-
});
|
152
|
-
describe('An integer at the bottom of the valid range is a Counter type', function() {
|
153
|
-
it('returns true', function() {
|
154
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 0), true);
|
155
|
-
});
|
156
|
-
});
|
157
|
-
describe('An integer just lower than the valid range is not a Counter type', function() {
|
158
|
-
it('returns false', function() {
|
159
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, -1), false);
|
160
|
-
});
|
161
|
-
});
|
162
|
-
describe('An integer at the top of the valid range is a Counter type', function() {
|
163
|
-
it('returns true', function() {
|
164
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 4294967295), true);
|
165
|
-
});
|
166
|
-
});
|
167
|
-
describe('An integer just higher than the valid range is not a Counter type', function() {
|
168
|
-
it('returns false', function() {
|
169
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter, 4294967296), false);
|
170
|
-
});
|
171
|
-
});
|
172
|
-
});
|
173
|
-
|
174
|
-
describe('isValid() - Counter64', function() {
|
175
|
-
describe('Zero is a Counter64 type', function() {
|
176
|
-
it('returns true', function() {
|
177
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 0), true);
|
178
|
-
});
|
179
|
-
});
|
180
|
-
describe('An positive integer number is a Counter64 type', function() {
|
181
|
-
it('returns true', function() {
|
182
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 44), true);
|
183
|
-
});
|
184
|
-
});
|
185
|
-
describe('An positive integer string is a Counter64 type', function() {
|
186
|
-
it('returns true', function() {
|
187
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "44"), true);
|
188
|
-
});
|
189
|
-
});
|
190
|
-
describe('An negative integer number is not a Counter64 type', function() {
|
191
|
-
it('returns false', function() {
|
192
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, -24), false);
|
193
|
-
});
|
194
|
-
});
|
195
|
-
describe('A negative integer string is not a Counter64 type', function() {
|
196
|
-
it('returns false', function() {
|
197
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "-24"), false);
|
198
|
-
});
|
199
|
-
});
|
200
|
-
describe('A non-integer decimal number is not a Counter64 type', function() {
|
201
|
-
it('returns false', function() {
|
202
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 45.2), false);
|
203
|
-
});
|
204
|
-
});
|
205
|
-
describe('A non-integer decimal string is not a Counter64 type', function() {
|
206
|
-
it('returns false', function() {
|
207
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, "45.2"), false);
|
208
|
-
});
|
209
|
-
});
|
210
|
-
describe('An integer at the bottom of the valid range is a Counter64 type', function() {
|
211
|
-
it('returns true', function() {
|
212
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, 0), true);
|
213
|
-
});
|
214
|
-
});
|
215
|
-
describe('An integer just lower than the valid range is not a Counter64 type', function() {
|
216
|
-
it('returns false', function() {
|
217
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Counter64, -1), false);
|
218
|
-
});
|
219
|
-
});
|
220
|
-
});
|
221
|
-
|
222
|
-
describe('isValid() - IPAddress', function() {
|
223
|
-
describe('Dotted quad of numbers is an IpAddress type', function() {
|
224
|
-
it('returns true', function() {
|
225
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.3.147.4'), true);
|
226
|
-
});
|
227
|
-
});
|
228
|
-
describe('Dotted quin of numbers is not an IpAddress type', function() {
|
229
|
-
it('returns false', function() {
|
230
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.3.147.22.4'), false);
|
231
|
-
});
|
232
|
-
});
|
233
|
-
describe('Dotted quad containing non-numbers is not an IpAddress type', function() {
|
234
|
-
it('returns false', function() {
|
235
|
-
assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.IpAddress, '10.word.147.4'), false);
|
236
|
-
});
|
237
|
-
});
|
238
|
-
});
|