Skip to content

Commit 7cc195e

Browse files
committed
Add headers with test names to unit test output
1 parent 14b0681 commit 7cc195e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/unit/s3gateway_test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ fakeRequest.log = function(msg) {
4949
}
5050

5151
function testPad() {
52+
printHeader('testPad');
5253
var padSingleDigit = s3gateway._padWithLeadingZeros(3, 2);
5354
var expected = '03';
5455

@@ -60,6 +61,7 @@ function testPad() {
6061
}
6162

6263
function testEightDigitDate() {
64+
printHeader('testEightDigitDate');
6365
var timestamp = new Date('2020-08-03T02:01:09.004Z');
6466
var eightDigitDate = s3gateway._eightDigitDate(timestamp);
6567
var expected = '20200803';
@@ -72,6 +74,7 @@ function testEightDigitDate() {
7274
}
7375

7476
function testAmzDatetime() {
77+
printHeader('testAmzDatetime');
7578
var timestamp = new Date('2020-08-03T02:01:09.004Z');
7679
var eightDigitDate = s3gateway._eightDigitDate(timestamp);
7780
var amzDatetime = s3gateway._amzDatetime(timestamp, eightDigitDate);
@@ -85,6 +88,7 @@ function testAmzDatetime() {
8588
}
8689

8790
function testSplitCachedValues() {
91+
printHeader('testSplitCachedValues');
8892
var eightDigitDate = "20200811"
8993
var kSigningHash = "{\"type\":\"Buffer\",\"data\":[164,135,1,191,232,3,16,62,137,5,31,85,175,34,151,221,118,120,59,188,235,94,180,22,218,183,30,14,173,203,196,246]}"
9094
var cached = eightDigitDate + ":" + kSigningHash;
@@ -110,6 +114,7 @@ function testSplitCachedValues() {
110114
}
111115

112116
function testBuildSigningKeyHashWithReferenceInputs() {
117+
printHeader('testBuildSigningKeyHashWithReferenceInputs');
113118
var kSecret = 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY';
114119
var date = '20150830';
115120
var service = 'iam';
@@ -125,6 +130,7 @@ function testBuildSigningKeyHashWithReferenceInputs() {
125130
}
126131

127132
function testBuildSigningKeyHashWithTestSuiteInputs() {
133+
printHeader('testBuildSigningKeyHashWithTestSuiteInputs');
128134
var kSecret = 'pvgoBEA1z7zZKqN9RoKVksKh31AtNou+pspn+iyb';
129135
var date = '20200811';
130136
var service = 's3';
@@ -162,6 +168,7 @@ function _runSignatureV4(r) {
162168
}
163169

164170
function testSignatureV4() {
171+
printHeader('testSignatureV4');
165172
// Note: since this is a read-only gateway, host, query parameters and all
166173
// client headers will be ignored.
167174
var r = {
@@ -194,6 +201,7 @@ function testSignatureV4() {
194201
}
195202

196203
function testSignatureV4Cache() {
204+
printHeader('testSignatureV4Cache');
197205
// Note: since this is a read-only gateway, host, query parameters and all
198206
// client headers will be ignored.
199207
var r = {
@@ -233,6 +241,7 @@ function testSignatureV4Cache() {
233241
}
234242

235243
function testEditAmzHeaders() {
244+
printHeader('testEditAmzHeaders');
236245
var r = {
237246
"headersOut": {
238247
"Accept-Ranges": "bytes",
@@ -262,6 +271,7 @@ function testEditAmzHeaders() {
262271
}
263272

264273
function testEditAmzHeadersHeadDirectory() {
274+
printHeader('testEditAmzHeadersHeadDirectory');
265275
let r = {
266276
"method": "HEAD",
267277
"headersOut" : {
@@ -289,6 +299,7 @@ function testEditAmzHeadersHeadDirectory() {
289299
}
290300

291301
function testEscapeURIPathPreservesDoubleSlashes() {
302+
printHeader('testEscapeURIPathPreservesDoubleSlashes');
292303
var doubleSlashed = '/testbucketer2/foo3//bar3/somedir/license';
293304
var actual = s3gateway._escapeURIPath(doubleSlashed);
294305
var expected = '/testbucketer2/foo3//bar3/somedir/license';
@@ -299,6 +310,7 @@ function testEscapeURIPathPreservesDoubleSlashes() {
299310
}
300311

301312
function testReadCredentialsWithAccessAndSecretKeySet() {
313+
printHeader('testReadCredentialsWithAccessAndSecretKeySet');
302314
process.env['S3_ACCESS_KEY_ID'] = 'SOME_ACCESS_KEY';
303315
process.env['S3_SECRET_KEY'] = 'SOME_SECRET_KEY';
304316

@@ -324,6 +336,7 @@ function testReadCredentialsWithAccessAndSecretKeySet() {
324336
}
325337

326338
function testReadCredentials() {
339+
printHeader('testReadCredentials');
327340
var originalCredentialPath = process.env['S3_CREDENTIALS_TEMP_FILE'];
328341
var tempDir = (process.env['TMPDIR'] ? process.env['TMPDIR'] : '/tmp');
329342
var uniqId = `${new Date().getTime()}-${Math.floor(Math.random()*101)}`;
@@ -359,6 +372,7 @@ function testReadCredentials() {
359372
}
360373

361374
function testReadCredentialsFromNonexistentPath() {
375+
printHeader('testReadCredentialsFromNonexistentPath');
362376
var originalCredentialPath = process.env['S3_CREDENTIALS_TEMP_FILE'];
363377
var tempDir = (process.env['TMPDIR'] ? process.env['TMPDIR'] : '/tmp');
364378
var uniqId = `${new Date().getTime()}-${Math.floor(Math.random()*101)}`;
@@ -382,6 +396,7 @@ function testReadCredentialsFromNonexistentPath() {
382396
}
383397

384398
async function testEcsCredentialRetrieval() {
399+
printHeader('testEcsCredentialRetrieval');
385400
process.env['S3_ACCESS_KEY_ID'] = undefined;
386401
process.env['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] = '/example';
387402
globalThis.ngx.fetch = function (url) {
@@ -428,6 +443,7 @@ async function testEcsCredentialRetrieval() {
428443
}
429444

430445
async function testEc2CredentialRetrieval() {
446+
printHeader('testEc2CredentialRetrieval');
431447
process.env['S3_ACCESS_KEY_ID'] = undefined;
432448
process.env['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] = undefined;
433449
globalThis.ngx.fetch = function (url, options) {
@@ -498,6 +514,10 @@ async function testEc2CredentialRetrieval() {
498514
}
499515
}
500516

517+
function printHeader(testName) {
518+
console.log(`\n## ${testName}`);
519+
}
520+
501521
async function test() {
502522
testPad();
503523
testEightDigitDate();

0 commit comments

Comments
 (0)