Refuse an empty list for a repeatable TLV
Mirror / push (push) Successful in 6s
Test / lint (pull_request) Successful in 19s
Test / test (18) (pull_request) Successful in 30s
Test / test (20) (pull_request) Successful in 28s
Test / test (22) (pull_request) Successful in 30s
Test / test (24) (pull_request) Successful in 28s
Test / test (26) (pull_request) Successful in 30s
Mirror / push (push) Successful in 6s
Test / lint (pull_request) Successful in 19s
Test / test (18) (pull_request) Successful in 30s
Test / test (20) (pull_request) Successful in 28s
Test / test (22) (pull_request) Successful in 30s
Test / test (24) (pull_request) Successful in 28s
Test / test (26) (pull_request) Successful in 30s
This commit is contained in:
+2
-1
@@ -39,7 +39,8 @@
|
|||||||
other limits. `server({ maxOctets: 0 })` used to start and then refuse every multipart message.
|
other limits. `server({ maxOctets: 0 })` used to start and then refuse every multipart message.
|
||||||
- `callback_num`, `callback_num_atag`, `callback_num_pres_ind`, `broadcast_area_identifier` and
|
- `callback_num`, `callback_num_atag`, `callback_num_pres_ind`, `broadcast_area_identifier` and
|
||||||
`broadcast_error_status` read as a list of every copy the peer sent, where only the last was kept,
|
`broadcast_error_status` read as a list of every copy the peer sent, where only the last was kept,
|
||||||
and are written from a list. A single value for one of them, or a list for any other tag, is
|
and are written from a list. A single value or an empty list for one of them, or a list for any
|
||||||
|
other tag, is
|
||||||
refused.
|
refused.
|
||||||
- `tlvMap` is gone from the `broadcast_sm_resp` command definition. Nothing read it.
|
- `tlvMap` is gone from the `broadcast_sm_resp` command definition. Nothing read it.
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -135,7 +135,11 @@ export function tagIdOf(name: string, input: TlvInput): Result<{ tagId: number }
|
|||||||
function copiesOf(name: string, definition: TlvDefinition | undefined, value: TlvValue): Result<{ copies: TlvScalar[] }> {
|
function copiesOf(name: string, definition: TlvDefinition | undefined, value: TlvValue): Result<{ copies: TlvScalar[] }> {
|
||||||
const multiple = definition?.multiple === true;
|
const multiple = definition?.multiple === true;
|
||||||
|
|
||||||
if (Array.isArray(value) && multiple) return { copies: value };
|
if (Array.isArray(value) && multiple) {
|
||||||
|
return value.length > 0
|
||||||
|
? { copies: value }
|
||||||
|
: { err: new Error(`TLV "${name}": give at least one value, or leave the tag out`) };
|
||||||
|
}
|
||||||
|
|
||||||
if (!Array.isArray(value) && !multiple) return { copies: [value] };
|
if (!Array.isArray(value) && !multiple) return { copies: [value] };
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -432,16 +432,18 @@ describe('TLVs', () => {
|
|||||||
assert.deepEqual(pduObj.tlvs.callback_num_pres_ind?.tagValue, [1]);
|
assert.deepEqual(pduObj.tlvs.callback_num_pres_ind?.tagValue, [1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('refuses a single value for a tag SMPP lets repeat, and a list for one it does not', () => {
|
test('refuses a single value or an empty list for a tag SMPP lets repeat, and a list for one it does not', () => {
|
||||||
const params = { destination_addr: '46709771337', short_message: 'hi', source_addr: '46701113311' };
|
const params = { destination_addr: '46709771337', short_message: 'hi', source_addr: '46701113311' };
|
||||||
const single = objToPdu({
|
const single = objToPdu({
|
||||||
cmdName: 'submit_sm',
|
cmdName: 'submit_sm',
|
||||||
params,
|
params,
|
||||||
tlvs: { callback_num: { tagValue: Buffer.from('46701113311', 'latin1') } },
|
tlvs: { callback_num: { tagValue: Buffer.from('46701113311', 'latin1') } },
|
||||||
});
|
});
|
||||||
|
const empty = objToPdu({ cmdName: 'submit_sm', params, tlvs: { callback_num: { tagValue: [] } } });
|
||||||
const list = objToPdu({ cmdName: 'submit_sm', params, tlvs: { source_port: { tagValue: [1234] } } });
|
const list = objToPdu({ cmdName: 'submit_sm', params, tlvs: { source_port: { tagValue: [1234] } } });
|
||||||
|
|
||||||
assert.match(single.err?.message ?? '', /TLV "callback_num": .*list/);
|
assert.match(single.err?.message ?? '', /TLV "callback_num": .*list/);
|
||||||
|
assert.match(empty.err?.message ?? '', /TLV "callback_num": .*leave the tag out/);
|
||||||
assert.match(list.err?.message ?? '', /TLV "source_port": .*list/);
|
assert.match(list.err?.message ?? '', /TLV "source_port": .*list/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user