Skip to content

Commit 5b8b5ab

Browse files
committed
Fixed UT test failing in git pipeline
1 parent e4cfe0c commit 5b8b5ab

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

internal/file/external_file_operator_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -286,31 +286,31 @@ func TestFileManagerService_IsDomainAllowed(t *testing.T) {
286286

287287
tests := []testCase{
288288
{
289-
name: "Invalid URL (Percent)",
289+
name: "Test 1: Invalid URL (Percent)",
290290
url: "http://%",
291291
allowedDomains: []string{"example.com"},
292292
expected: false,
293293
},
294294
{
295-
name: "Invalid URL (Empty Host)",
295+
name: "Test 2: Invalid URL (Empty Host)",
296296
url: "http://",
297297
allowedDomains: []string{"example.com"},
298298
expected: false,
299299
},
300300
{
301-
name: "Empty Allowed List",
301+
name: "Test 3: Empty Allowed List",
302302
url: "http://example.com/path",
303303
allowedDomains: []string{""},
304304
expected: false,
305305
},
306306
{
307-
name: "Basic Match",
307+
name: "Test 4: Basic Match",
308308
url: "http://example.com/path",
309309
allowedDomains: []string{"example.com"},
310310
expected: true,
311311
},
312312
{
313-
name: "Wildcard Subdomain Match",
313+
name: "Test 5: Wildcard Subdomain Match",
314314
url: "http://sub.example.com/path",
315315
allowedDomains: []string{"*.example.com"},
316316
expected: true,
@@ -337,31 +337,31 @@ func TestFileManagerService_IsMatchesWildcardDomain(t *testing.T) {
337337

338338
tests := []testCase{
339339
{
340-
name: "True Match - Subdomain",
340+
name: "Test 1: True Match - Subdomain",
341341
hostname: "sub.example.com",
342342
pattern: "*.example.com",
343343
expected: true,
344344
},
345345
{
346-
name: "True Match - Exact Base Domain",
346+
name: "Test 2: True Match - Exact Base Domain",
347347
hostname: "example.com",
348348
pattern: "*.example.com",
349349
expected: true,
350350
},
351351
{
352-
name: "False Match - Bad Domain Suffix",
352+
name: "Test 3: False Match - Bad Domain Suffix",
353353
hostname: "badexample.com",
354354
pattern: "*.example.com",
355355
expected: false,
356356
},
357357
{
358-
name: "False Match - No Wildcard Prefix",
358+
name: "Test 4: False Match - No Wildcard Prefix",
359359
hostname: "test.com",
360360
pattern: "google.com",
361361
expected: false,
362362
},
363363
{
364-
name: "False Match - Different Suffix",
364+
name: "Test 5: False Match - Different Suffix",
365365
hostname: "sub.anotherexample.com",
366366
pattern: "*.example.com",
367367
expected: false,
@@ -392,32 +392,33 @@ func TestExternalFileOperator_validateDownloadedFile(t *testing.T) {
392392
expectErr bool
393393
}{
394394
{
395-
name: "Accept when extension matches detected MIME (text)",
395+
name: "Test 1: Accept when extension matches detected MIME (text)",
396396
content: textBytes,
397397
fileName: "/tmp/file.txt",
398398
expectErr: false,
399399
},
400400
{
401-
name: "Reject when extension maps to different MIME (html implies text/html but content is png)",
401+
name: "Test 2: Reject when extension maps to different MIME " +
402+
"(html implies text/html but content is png)",
402403
content: pngBytes,
403404
fileName: "/tmp/file.html",
404405
expectErr: true,
405406
errContains: "implies MIME",
406407
},
407408
{
408-
name: "Allow when extension unknown but detected MIME is in allowed list",
409+
name: "Test 3: Allow when extension unknown but detected MIME is in allowed list",
409410
content: pngBytes,
410411
fileName: "/tmp/file.unknownext",
411412
allowedList: []string{"image/png"},
412413
expectErr: false,
413414
},
414415
{
415-
name: "Reject when detected MIME not in allowed list and extension has no known mapping",
416+
name: "Test 4: Reject when detected MIME not in allowed list and extension has no known mapping",
416417
content: pngBytes,
417-
fileName: "/tmp/file.bin",
418+
fileName: "/tmp/file.definitelyunknown",
418419
allowedList: []string{".conf"},
419420
expectErr: true,
420-
errContains: "implies MIME",
421+
errContains: "is not allowed",
421422
},
422423
}
423424

0 commit comments

Comments
 (0)