add test for excess padding

This commit is contained in:
Kevin Gibbons 2024-03-11 22:51:35 -07:00 committed by Jordan Harband
parent 070d7ee87e
commit 44803f799c
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
2 changed files with 38 additions and 2 deletions

View File

@ -37,7 +37,7 @@ assert.throws(SyntaxError, function() {
Uint8Array.fromBase64('ZXhhZh', { lastChunkHandling: 'strict' });
});
// malformed padding
// partial padding
assert.throws(SyntaxError, function() {
Uint8Array.fromBase64('ZXhhZg=');
});
@ -48,3 +48,17 @@ assert.compareArray(Uint8Array.fromBase64('ZXhhZg=', { lastChunkHandling: 'stop-
assert.throws(SyntaxError, function() {
Uint8Array.fromBase64('ZXhhZg=', { lastChunkHandling: 'strict' });
});
// excess padding
assert.throws(SyntaxError, function() {
Uint8Array.fromBase64('ZXhhZg===');
});
assert.throws(SyntaxError, function() {
Uint8Array.fromBase64('ZXhhZg===', { lastChunkHandling: 'loose' });
});
assert.throws(SyntaxError, function() {
Uint8Array.fromBase64('ZXhhZg===', { lastChunkHandling: 'stop-before-partial' });
});
assert.throws(SyntaxError, function() {
Uint8Array.fromBase64('ZXhhZg===', { lastChunkHandling: 'strict' });
});

View File

@ -108,7 +108,7 @@ assert.throws(SyntaxError, function() {
});
// malformed padding
// partial padding
assert.throws(SyntaxError, function() {
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
target.setFromBase64('ZXhhZg=');
@ -129,3 +129,25 @@ assert.throws(SyntaxError, function() {
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
target.setFromBase64('ZXhhZg=', { lastChunkHandling: 'strict' });
});
// excess padding
assert.throws(SyntaxError, function() {
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
target.setFromBase64('ZXhhZg===');
});
assert.throws(SyntaxError, function() {
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
target.setFromBase64('ZXhhZg===', { lastChunkHandling: 'loose' });
});
assert.throws(SyntaxError, function() {
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
target.setFromBase64('ZXhhZg===', { lastChunkHandling: 'stop-before-partial' });
});
assert.throws(SyntaxError, function() {
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
target.setFromBase64('ZXhhZg===', { lastChunkHandling: 'strict' });
});